RAG using DeepSeek R1, Ollama & Semantic Kernel. net
In the rapidly advancing world of software development, DeepSeek AI emerges as a groundbreaking approach for developers working with popular enterprise technology stacks. DeepSeek offers developers new possibilities for creating smarter, more adaptive applications by harnessing pure reinforcement learning rather than traditional supervised learning methods.
Beyond Traditional Supervised Learning
Most AI implementations within enterprise ecosystems have historically relied on supervised learning, where algorithms learn from labelled data to recognise patterns. While effective for many applications, this approach requires extensive data preparation and can be limited by the quality of available training datasets.
DeepSeek AI takes a fundamentally different approach. By leveraging reinforcement learning, the system evolves through rewards and penalties, similar to how developers learn through iterative testing. Correct outcomes are rewarded, while incorrect ones receive penalties, allowing the model to refine its code generation and problem-solving capabilities continuously.
How DeepSeek AI Enhances Development
When integrated into your development environment:
- DeepSeek generates code solutions based on its current understanding
- It evaluates the correctness and efficiency of these solutions
- Through reinforcement learning, it improves code quality and performance
- It adapts to specific application requirements within your C#, .NET, or cloud projects
This process eliminates much of the complex prompt engineering that often complicates implementations of other AI coding assistants in popular IDEs.
Applications in Development
DeepSeek AI shows particular promise for developers in several key areas:
- Application optimization that learns from performance metrics
- Cloud service configurations that refine based on cost and efficiency outcomes
- SQL query generation and tuning that improves with each execution
- Algorithm enhancements that evolve through reinforcement cycles
These applications mirror reinforcement learning’s success in other domains like self-driving systems, where programs must learn to navigate complex, changing environments—much like the ever-evolving technology landscape.
Developer Advantage: Free and Flexible
For developers, DeepSeek AI offers compelling advantages:
- Completely free to implement in development environments
- Host locally or on cloud platforms for seamless integration with existing infrastructure
- Train with proprietary codebases to solve specific development challenges
- Adaptable to different technologies from legacy frameworks to the latest versions
This flexibility makes DeepSeek particularly valuable for development teams that need to maintain control over their code while still leveraging advanced AI capabilities.
Mathematical and Logical Excellence
DeepSeek AI’s outstanding performance in mathematics, logic, and coding provides significant advantages for complex development tasks:
- Creating optimized algorithms for data processing
- Developing complex cloud functions with minimal resource consumption
- Solving intricate dependency injection and architecture problems in enterprise applications
Implementing DeepSeek AI in Your Development Workflow
Adding DeepSeek AI to your existing development toolkit doesn’t require abandoning familiar tools. Its simplified approach to prompt engineering makes integration more straightforward than with other AI coding assistants.
Start by identifying repetitive coding tasks in your development process that would benefit from continuous improvement—these are ideal candidates for reinforcement learning implementation within your development environment.
As software developers continue seeking ways to create more efficient, maintainable code, tools like DeepSeek AI represent the next evolution in development assistance—learning, adapting, and improving without constant developer supervision. By eliminating complex prompt engineering and leveraging the power of reinforcement learning, DeepSeek AI could be the key to dramatically improving productivity in software development.
What is Retrieval-Augmented Generation (RAG)?
Think of Retrieval-Augmented Generation (RAG) as adding a reference library to your development stack. RAG enhances large language models (LLMs) by connecting them to external data sources—your databases, documentation files, or code repositories. Just like importing the right dependencies extends your application’s capabilities, RAG empowers AI tools to generate responses using your specific codebase and technical documentation, not just what they learned during training.
Kernel Memory
Kernel Memory optimises dataset indexing. It can be deployed as a Docker service for handling thousands of documents at scale or embedded directly using the MemoryServerless class for smaller applications. This flexibility adapts to various Microsoft development scenarios, from enterprise to lightweight implementations.
Prerequisites:
1. Ollama
Ollama is an open-source tool that lets you run large language models locally on your hardware, eliminating the need for cloud-based API calls.
Install ollama on Windows https://ollama.com/download
1.1 Pull & run DeepSeek LLM locally on ollama platform
Open terminal and paste ollama run deepseek-r1:1.5b
It will take some time to download the DeepSeek model to the local machine. Once the download is complete, you can verify it by running this command in the terminal.
ollama list
2. Deep Seek Account
To make an API call, you will need a Deep Seek Account. You can create one here https://platform.deepseek.com/. Once your account is created, you need to obtain the API Key, which you will need later.
3. Install Kernel Memory on Docker as a service
You also need to install the Kernel Memory on Docker as a service, which will serve as a dataset indexing platform
docker run -e OPENAI_API_KEY=”YOUR_DEEPSEEK_API_KEY” -p 9001:9001 -it –rm kernelmemory/service
After you have installed the necessary prerequisites, you can clone the demo code repository.
git clone https://github.com/vizsphere/RAG_Deepseek_Semantic_Kernel_ImportWebPage.git
The code below is straightforward; we inject two web page links as a data context indexed inside the Kernel memory.
Run the console app and test with the provided questions.
Questions for the prompt
1) What is Microsoft 365 Education?
2) What is the difference between Office 365 and Microsoft 365 Education?
3) Where can I learn more about Windows 11 Education?
4) Which type of web development services do you offer?
5) How do your .NET backend solutions support my business growth?
6) What languages and technologies do you work with?
using Microsoft.KernelMemory;
var memory = new MemoryWebClient("http://127.0.0.1:9001/");
var documentId1 = "195c4f89508b";
var documentId2 = "36fa9724f348";
await memory.ImportWebPageAsync(
"https://vizsphere.com/faq/",
documentId1);
await memory.ImportWebPageAsync("https://www.microsoft.com/en-us/education/products/frequently-asked-questions",
documentId2);
Console.WriteLine("Waiting for memory ingestion to complete...");
while (!await memory.IsDocumentReadyAsync(documentId1))
{
Console.WriteLine("Ask your questions\n");
await Task.Delay(TimeSpan.FromMilliseconds(1500));
var question = Console.ReadLine();
var answer = await memory.AskAsync(question);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(answer.Result);
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.WriteLine("\n Source:");
foreach (var item in answer.RelevantSources)
{
Console.WriteLine($"{item.SourceName} - {item.SourceUrl} - {item.Link}");
}
Console.ForegroundColor = ConsoleColor.White;
}