Are you curious about how to combine your own data with AI so it can answer questions instantly? In this guide, I’ll show you how to build a simple RAG (Retrieval-Augmented Generation) application using DeepSeek R1, OLLAMA, and Microsoft Semantic Kernel.
We’ll create a basic Expense Manager scenario where you can ask questions like:
- “How much did I spend on coffee?”
- “What is my total expense amount?”
- “Which day did I spend the most?”
With RAG, your AI model will not just generate answers — it will pull information from your documents and give accurate, context-aware responses. Let’s dive in 🚀.
Step 1: Prerequisites
Before we start, make sure you have:
- Ollama Running on your machine.
- DeepSeek R1 model installed (e.g., 1.5B parameters).
- Semantic Kernel packages installed in your .NET project.
Verify your model with:
|
|
Confirm that DeepSeek R1 is available and running on port 11434
.
Step 2: Create a Console Project
We’ll use a .NET Console Application for this demo.
Install the required NuGet packages:
|
|
These packages let you embed documents, manage memory, and query with Semantic Kernel.
Step 3: Configure Models
In your program, set up the configuration for text generation and embeddings:
|
|
This ensures both text generation and embeddings are handled by DeepSeek R1.
Step 4: Create Memory and Add Documents
We’ll embed a document containing our expense data into Semantic Kernel memory.
Example snippet:
|
|
Your budget.txt
file might look like this:
|
|
Step 5: Ask Questions
Now we can query our memory interactively:
|
|
Example queries:
-
Q: How much did I spend on coffee?
A: You spent a total of 8.25 on coffee. -
Q: Which day did I spend the most?
A: February 14, 2025 — Rent $800. -
Q: Which day did I spend the least?
A: February 16, 2025 — Groceries $40.
Step 6: Add More Documents (PDFs, etc.)
You can also embed PDFs or multiple files:
|
|
Now your model can answer from both your expense file and MicroPython docs, and even show the exact source file in its response.
Conclusion
By combining DeepSeek R1, AMA, and Semantic Kernel, we built a working RAG application that can:
- Ingest personal or project documents.
- Answer natural-language questions with context.
- Cite sources for reliable results.
This workflow is powerful because you’re not just chatting with an LLM — you’re giving it your own knowledge base.
💡 Want the complete project code? I’ve uploaded it (along with the text and PDF files) on my Buy Me a Coffee .
Semantic Kernel Prompts: Complete Guide to All Types with Examples for .NET AI Apps