Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luisquintanilla/ragdotnetaifundamentals
This sample shows how to apply vanilla / simple RAG pattern using .NET fundamentals in the AI ecosystem
https://github.com/luisquintanilla/ragdotnetaifundamentals
Last synced: about 1 month ago
JSON representation
This sample shows how to apply vanilla / simple RAG pattern using .NET fundamentals in the AI ecosystem
- Host: GitHub
- URL: https://github.com/luisquintanilla/ragdotnetaifundamentals
- Owner: luisquintanilla
- Created: 2024-10-23T19:22:10.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-10-23T20:39:43.000Z (2 months ago)
- Last Synced: 2024-10-24T06:02:12.480Z (2 months ago)
- Language: C#
- Size: 10.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
- [Microsoft.ML.Tokenizers](https://www.nuget.org/packages/Microsoft.ML.Tokenizers/)
- [System.Numerics.Tensors](https://www.nuget.org/packages/System.Numerics.Tensors/)
- [Microsoft.Extensions.AI](https://www.nuget.org/packages/Microsoft.Extensions.AI/)
- [Microsoft.Extensions.VectorData.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.VectorData.Abstractions/)
- [ML.NET](https://www.nuget.org/packages/Microsoft.ML/)
- [ONNX Runtime](https://www.nuget.org/packages/Microsoft.ML.OnnxTransformer/)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
- [.NET 9 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)
- Visual Studio or Visual Studio Code## Quick Start
1. Open in GitHub Codespaces
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/luisquintanilla/RAGDotnetAIFundamentals)
1. Download the [e5-small-v2 model](https://huggingface.co/intfloat/e5-small-v2/resolve/main/model.onnx?download=true) 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](https://huggingface.co/intfloat/e5-small-v2/resolve/main/model.onnx?download=true) 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.
```csharp
dotnet run
```