👉 Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/rag/single_turn_rag
Single-Turn RAG Q&A for C# .NET Applications
🎯 Purpose of the Demo
The Single-Turn RAG demo showcases how to use the LM-Kit.NET SDK to build a Retrieval-Augmented Generation (RAG) pipeline that answers questions from indexed documents. Each question is handled independently (single-turn), making this the simplest entry point for understanding how RAG works with LM-Kit.NET.
👥 Industry Target Audience
This sample is particularly beneficial for developers and organizations in the following sectors:
- 🛎️ Customer Support: Enhance customer service by retrieving and providing relevant information from knowledge bases.
- 📚 Education: Develop interactive tutoring systems that can answer questions based on textbooks or other educational materials.
- 🏥 Healthcare: Create virtual assistants that can provide information based on medical literature and guidelines.
- 🛍️ E-commerce: Improve customer engagement by providing detailed product information and recommendations from extensive catalogs.
🚀 Problem Solved
Generating accurate and contextually relevant responses can be challenging, especially when dealing with extensive knowledge bases. This demo addresses the problem by leveraging RAG techniques to retrieve relevant information from data sources before generating responses, ensuring precise and informative answers.
💻 Sample Application Description
The Single-Turn RAG demo is a console application that allows users to ask questions answered from the content of loaded eBooks.
✨ Key Features
- 📦 Model Loading: Loads a chat model and an embedding model with download and loading progress.
- 📚 Data Source Loading: Loads eBooks as data sources that can be queried semantically.
- 🔍 RAG Integration: Uses Retrieval-Augmented Generation to retrieve relevant information from data sources and generate responses.
- 📈 Performance Metrics: Displays time taken to load data sources and other relevant metrics.
- 💾 Persistent Storage: Data sources are saved locally for reuse across sessions.
🧠 Supported Models
- Chat Model: Gemma 3 4B
- Embeddings Model: EmbeddingGemma 300M
📘 Data Sources
The sample loads the following eBooks as data sources:
- Romeo and Juliet by William Shakespeare
- Moby Dick by Herman Melville
- Pride and Prejudice by Jane Austen
🛠️ Getting Started
📋 Prerequisites
- .NET 8.0 or later
📥 Download the Project
▶️ Running the Application
📂 Clone the repository:
git clone https://github.com/LM-Kit/lm-kit-net-samples📁 Navigate to the project directory:
cd lm-kit-net-samples/console_net/rag/single_turn_rag🔨 Build and run the application:
dotnet build dotnet run📜 Follow the on-screen prompts to load models and data sources and start querying.
💡 Example Usage
- 📦 Load Models: The application loads a chat model and an embedding model automatically.
- 📚 Load Data Sources: The application loads eBooks as data sources for querying.
- ❓ Enter Query: Start by entering a query, such as "What are the causes and effects of the feud between the two prominent families" or "What are the names of the two rival families?".
- 💬 Receive Response: The system will retrieve relevant information from the loaded data sources and generate a response.
- 🔄 Continue Interaction: Enter another query or end the program by submitting an empty input.
By following these steps, developers can explore the fundamentals of RAG with LM-Kit.NET, building a foundation for more advanced retrieval pipelines.