Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 2.23 KB

README.md

File metadata and controls

43 lines (27 loc) · 2.23 KB

RAG Sample using .NET AI Fundamentals

This sample shows how to apply vanilla / simple RAG pattern using .NET fundamentals in the AI ecosystem such as:

Given a list of movies, this sample implements semantic search, a building block for RAG patterns.

The project structure is as follows:

  • Domain.cs - Contains the data models used by ML.NET and the vector store
  • MLNETONNXEmbeddingGenerator - Implementation of IEmbeddingGenerator Microsoft.Extensions.AI interface. The implementation creates an ML.NET pipeline which uses the BertTokenizer from Microsoft.ML.Tokenizers and an the e5-small-v2 ONNX embedding model to generate embeddings.
  • Program.cs - Uses an InMemoryVectorStore Semantic Kernel to store and query movie data containg embeddings generated by the MLNETONNXEmbeddingGenerator.

Prerequisites

Quick Start

  1. Open in GitHub Codespaces

    Open in GitHub Codespaces

  2. Download the e5-small-v2 model and save it to the assets directory. If you rename the file, make sure to update the model path used by the generator in Program.cs.

Setup

  1. Download the e5-small-v2 model and save it to the assets directory. If you rename the file, make sure to update the model path used by the generator in Program.cs.

Run the application

  1. Open the terminal and run the following command.
dotnet run