AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Serialized11/27/2023 ![]() For more information, see the BinaryFormatter security guide. WCF also includes a companion serializer, the NetDataContractSerializer. It also supports the XmlDictionaryReader and XmlDictionaryWriter classes to enable it to produce optimized XML in some cases, such as when using the WCF binary XML format. When deserializing XML, the serializer uses the XmlReader and XmlWriter classes. For an introduction to data contracts, see Using Data Contracts. For a full list of supported types, see Types Supported by the Data Contract Serializer. NET Framework objects, the serializer understands a variety of serialization programming models, including the new data contract model. This topic explains how the serializer works. NET Framework objects and XML, in both directions. ![]() The DataContractSerializer translates between. Gets the data repository in write modeįor (session in DroidconSessionData.Windows Communication Foundation (WCF) includes a new serialization engine, the DataContractSerializer. The second half of the snippet adds the database customization – first the vector (which is an array of Double values) gets serialized, and then it is inserted into the database using the dbHelper class that has been added to the function: In Figure 2, you can see the first half of the code snippet has not changed – it still loops through the conference schedule and generates an embedding for each session via the web API. The updated code leverages this existing loop to also insert each vector into the local database.Īs mentioned above, there are no special vector-handling features in the existing version of Sqlite, so the code will treat the vector as a string for data storage and retrieval. There is already an initVectorCache function in the DroidconEmbeddingsWrapper.kt file which generates all the vectors in a loop over the droidconSessions collection and stores the vectors in-memory in the vectorCache variable. The DroidconDbHelper then takes care of creating the table (don’t forget to update the DATABASE_VERSION whenever you make schema changes). Private const val SQL_CREATE_EMBEDDING_ENTRIES = The schema and create/delete scripts for an embeddings table are defined in the data/DroidconDatabase.kt file:Ĭonst val COLUMN_NAME_SESSIONID = "session_id" The database setup uses the same pattern that we used for the favorites feature. Don’t forget to choose the droidcon-chat from the top-left menu to test out these features.įigure 1: Embeddings with similarity comparisons enable retrieval augmented generation (RAG) chat interactions Configure the database The sample code is available at /conceptdev/droidcon-sf-23. The demo app we’re working on is the JetchatAI sample that allows you to query the conference schedule for the droidcon SF 2023 event. Embedding vector similarity comparisons will continue to be done with the dot function defined in DroidconEmbeddingsWrapper.kt. Note that the version of Sqlite we’ll use on Android does not have any special “vector database” features – instead, the embedding vectors will just be serialized/deserialized and stored in a TEXT column. Now that we’ve added Sqlite to the solution to support memory and querying, we can use that infrastructure to also cache the embedding vectors. ![]() Earlier this year I tried to create a hardcoded cache of embedding vectors, only to be thwarted by the limitations of Kotlin (the combined size of the arrays of numbers exceeded Kotlin’s maximum function size). ![]()
0 Comments
Read More
Leave a Reply. |