Skip to content

marcominerva/OpenAIEmbeddingSample

Repository files navigation

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 configurations in the Program.cs file
  • Import some documents into the memory (search for await kernelMemory.ImportDocumentAsync in the Program.cs file

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

If you want to see a manual (explicit) approach to embedding and Vector Search using SQL Server, refer to the manual-approach branch.

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.

Topics

Resources

License

Stars

Watchers

Forks

Languages