👉 Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/rag-and-knowledge/query-expansion/query_strategies_lab
RAG Query Strategies Lab for C# .NET RAG Pipelines
🎯 Purpose of the Demo
An interactive console app that compares three retrieval strategies on the same RAG index: Original (one-shot embedding), MultiQuery (LLM rewrites the query into N variants), and HypotheticalAnswer (HyDE: LLM drafts a fake answer, then embeds it). Bring your own passages or use the built-in 7-passage seed.
All processing runs on-device.
👥 Industry Target Audience
- RAG / search engineers evaluating recall lift on real corpora.
- Knowledge base teams: pick the cheapest strategy that recovers your hardest queries.
- eDiscovery / legal: when "the same idea phrased differently" still has to match.
- Internal search: handle paraphrased questions in support chatbots.
🚀 Problem Solved
Naive RAG drops recall the moment a user phrases the question differently from the corpus. MultiQuery and HyDE are the two cheapest, well-known recall fixes. The lab puts them side-by-side so the impact is visible immediately on your own data, with all retrieved partitions printed per strategy for inspection.
💻 Application Overview
Interactive menu (no command-line arguments) with four modes:
| Mode | What it does |
|---|---|
| Compare | Type a question, see the retrieved partitions and answer under all three strategies. |
| Import | Paste passages to add to the index. |
| ImportFile | Load passages from a UTF-8 text file (one per line). |
| Reset | Wipe the index and reseed the default 7-passage corpus. |
| Quit | Exit. |
Both the embedding and chat models load once at startup. The default corpus is preloaded.
✨ Key Features
RagChat.QueryGenerationMode:Original,MultiQuery,HypotheticalAnswer.MultiQueryOptions.QueryVariantCount: number of LLM-rewritten variants.HydeOptions.MaxCompletionTokens: size of the synthetic answer.RagQueryResult.RetrievedPartitions: full per-strategy retrieval inspection.
🧠 Models
qwen3-embedding:0.6bfor the bi-encoder.qwen3.5:4bfor query rewriting and HyDE drafting.
🛠️ Getting Started
📋 Prerequisites
- .NET 8.0 or later
▶️ Running the Application
git clone https://github.com/LM-Kit/lm-kit-net-samples
cd lm-kit-net-samples/console_net/rag-and-knowledge/query-expansion/query_strategies_lab
dotnet run
Pick a mode from the menu.