marcominerva / OpenAIEmbeddingSample

An example that shows how to use Semantic Kernel and Kernel Memory to work with embeddings in a .NET application using SQL Server as Vector Database.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenAI Embeddings Sample

An example that shows how to use Semantic Kernel and Kernel Memory to work with embeddings in a .NET application using SQL Server as Vector Database.

The embeddings are stored in a SQL Server database and the Vector Search is efficiently performed thanks to COLUMNSTORE indexes.

To execute the application:

  • Create a database in SQL Server
  • Open the AppCostants.cs file and set the connection string to the database and the other required parameters. This example assumes you're using Azure OpenAI, but you can easily update it to use OpenAI or whatever LLM you want. Take a look to Kernel and KernelMemoryBuilder initialization in the Program.cs file
  • Import some documents in the memory (search for await kernelMemory.ImportDocumentAsync in the Program.cs file

Refer to the Program.cs file to see how document chunking is performed and how embeddings are calculated, stored and retrieved from the database using Kernel Memory.

About

An example that shows how to use Semantic Kernel and Kernel Memory to work with embeddings in a .NET application using SQL Server as Vector Database.

License:MIT License


Languages

Language:C# 100.0%