{"id":57923,"date":"2025-01-30T14:47:06","date_gmt":"2025-01-30T14:47:06","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/how-to-build-rag-system-using-deepseek-r1\/"},"modified":"2025-01-30T14:47:06","modified_gmt":"2025-01-30T14:47:06","slug":"how-to-build-rag-system-using-deepseek-r1","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=57923","title":{"rendered":"How to Build RAG System Using DeepSeek R1?"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div id=\"article-start\">\n<p>I have been reading a lot about RAG and AI Agents, but with the release of new models like DeepSeek V3 and DeepSeek R1, it seems that the possibility of building efficient RAG systems has significantly improved, offering better retrieval accuracy, enhanced reasoning capabilities, and more scalable architectures for real-world applications. The integration of more sophisticated retrieval mechanisms, enhanced fine-tuning options, and multi-modal capabilities are changing how AI agents interact with data. It raises questions about whether traditional RAG approaches are still the best way forward or if newer architectures can provide more efficient and contextually aware solutions.<\/p>\n<p><a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2023\/09\/retrieval-augmented-generation-rag-in-ai\/\" target=\"_blank\" rel=\"noreferrer noopener\">Retrieval-augmented generation (RAG)<\/a> systems have revolutionized the way AI models interact with data by combining retrieval-based and generative approaches to produce more accurate and context-aware responses. With the advent of <strong>DeepSeek R1<\/strong>, an open-source model known for its efficiency and cost-effectiveness, building an effective RAG system has become more accessible and practical. In this article, we are building an RAG system using DeepSeek R1.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-what-is-deepseek-r1\">What is DeepSeek R1?<\/h2>\n<p><a href=\"https:\/\/github.com\/deepseek-ai\/DeepSeek-R1\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">DeepSeek R1<\/a> is an open-source AI model developed with the goal of providing high-quality reasoning and retrieval capabilities at a fraction of the cost of proprietary models like OpenAI\u2019s offerings. It features an MIT license, making it commercially viable and suitable for a wide range of applications.<\/p>\n<p>Also, this powerful model, lets you see the CoT but the OpenAI o1 and o1-mini don\u2019t show any reasoning token.\u00a0<\/p>\n<p>To know how DeepSeek R1 is challenging the OpenAI o1 model: <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2025\/01\/deepseek-r1-vs-openai-o1\/\">DeepSeek R1 vs OpenAI o1: Which One is Faster, Cheaper and Smarter?<\/a>\u00a0<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-benefits-of-using-deepseek-r1-for-rag-system\">Benefits of Using DeepSeek R1 for RAG System<\/h2>\n<p>Building a Retrieval-Augmented Generation (RAG) system using DeepSeek-R1 offers several notable advantages:<\/p>\n<p><strong>1. Advanced Reasoning Capabilities<\/strong>: DeepSeek-R1 is designed to emulate human-like reasoning by analyzing and processing information step-by-step before reaching conclusions. This approach enhances the system\u2019s ability to handle complex queries, particularly in areas requiring logical inference, mathematical reasoning, and coding tasks.<\/p>\n<p><strong>2. Open-Source Accessibility<\/strong>: Released under the MIT license, DeepSeek-R1 is fully open-source, allowing developers unrestricted access to its model. This openness facilitates customization, fine-tuning, and integration into various applications without the constraints often associated with proprietary models.<\/p>\n<p><strong>3. Competitive Performance<\/strong>: Benchmark tests indicate that DeepSeek-R1 performs on par with, or even surpasses, leading models like OpenAI\u2019s o1 in tasks involving reasoning, mathematics, and coding. This level of performance ensures that an RAG system built with DeepSeek-R1 can deliver high-quality, accurate responses across diverse and challenging queries.<\/p>\n<p><strong>4. Transparency in Thought Process<\/strong>: <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2025\/01\/kimi-k1-5-vs-deepseek-r1\/\" target=\"_blank\" rel=\"noreferrer noopener\">DeepSeek-R1<\/a> employs a \u201cchain-of-thought\u201d methodology, making its reasoning steps visible during inference. This transparency not only aids in debugging and refining the system but also builds user trust by providing clear insights into how conclusions are reached.<\/p>\n<p><strong>5. Cost-Effectiveness<\/strong>: The open-source nature of DeepSeek-R1 eliminates licensing fees, and its efficient architecture reduces computational resource requirements. These factors contribute to a more cost-effective solution for organizations looking to implement sophisticated RAG systems without incurring significant expenses.<\/p>\n<p>Integrating DeepSeek-R1 into an RAG system provides a potent combination of advanced reasoning abilities, transparency, performance, and cost efficiency, making it a compelling choice for developers and organizations aiming to enhance their AI capabilities.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-steps-to-build-a-rag-system-using-deepseek-r1\">Steps to Build a RAG System Using DeepSeek R1<\/h2>\n<p>The script is a Retrieval-Augmented Generation (RAG) pipeline that:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Loads and processes a PDF document<\/strong> by splitting it into pages and extracting text.<\/li>\n<li><strong>Stores vectorized representations<\/strong> of the text in a database (ChromaDB).<\/li>\n<li><strong>Retrieves relevant content<\/strong> using similarity search when a query is asked.<\/li>\n<li><strong>Uses an LLM (DeepSeek model)<\/strong> to generate responses based on the retrieved text.<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-install-prerequisites\">Install Prerequisites<\/h3>\n<pre class=\"wp-block-code\"><code>curl -fsSL https:\/\/ollama.com\/install.sh | sh<\/code><\/pre>\n<p>after this pull the DeepSeek R1:1.5b using:<\/p>\n<pre class=\"wp-block-code\"><code>ollama pull deepseek-r1:1.5b<\/code><\/pre>\n<p>This will take a moment to download:<\/p>\n<pre class=\"wp-block-code\"><code>ollama pull deepseek-r1:1.5b\n\npulling manifest\npulling aabd4debf0c8... 100% \u2595\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258f 1.1 GB                         \npulling 369ca498f347... 100% \u2595\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258f  387 B                         \npulling 6e4c38e1172f... 100% \u2595\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258f 1.1 KB                         \npulling f4d24e9138dd... 100% \u2595\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258f  148 B                         \npulling a85fe2a2e58e... 100% \u2595\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258f  487 B                         \nverifying sha256 digest \nwriting manifest \nsuccess <\/code><\/pre>\n<p>After doing this, open your Jupyter Notebook and start with the coding part:<\/p>\n<h3 class=\"wp-block-heading\">1. Install Dependencies<\/h3>\n<p>Before running, the script installs the required Python libraries:<\/p>\n<ul class=\"wp-block-list\">\n<li><code>langchain<\/code> \u2192 A framework for building applications using Large Language Models (LLMs).<\/li>\n<li><code>langchain-openai<\/code> \u2192 Provides integration with OpenAI services.<\/li>\n<li><code>langchain-community<\/code> \u2192 Adds support for various document loaders and utilities.<\/li>\n<li><code>langchain-chroma<\/code> \u2192 Enables integration with ChromaDB, a vector database.<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\">2. Enter OpenAI API Key<\/h3>\n<p>To access OpenAI\u2019s embedding model, the script prompts the user to <strong>securely enter their API key<\/strong> using <code>getpass()<\/code>. This prevents exposing credentials in plain text.<\/p>\n<h3 class=\"wp-block-heading\">3. Set Up Environment Variables<\/h3>\n<p>The script <strong>stores the API key<\/strong> as an environment variable. This allows other parts of the code to access OpenAI services <strong>without hardcoding credentials<\/strong>, which improves security.<\/p>\n<h3 class=\"wp-block-heading\">4. Initialize OpenAI Embeddings<\/h3>\n<p>The script initializes an OpenAI embedding model called <code>\"text-embedding-3-small\"<\/code>. This model <strong>converts text into vector embeddings<\/strong>, which are high-dimensional numerical representations of the text\u2019s meaning. These embeddings are later used to <strong>compare and retrieve similar content<\/strong>.<\/p>\n<h3 class=\"wp-block-heading\">5. Load and Split a PDF Document<\/h3>\n<p>A PDF file (<code>AgenticAI.pdf<\/code>) is <strong>loaded and split into pages<\/strong>. Each page\u2019s text is extracted, which allows for <strong>smaller and more manageable text chunks<\/strong> instead of processing the entire document as a single unit.<\/p>\n<h3 class=\"wp-block-heading\">6. Create and Store a Vector Database<\/h3>\n<ul class=\"wp-block-list\">\n<li>The extracted text from the PDF is <strong>converted into vector embeddings<\/strong>.<\/li>\n<li>These embeddings are <strong>stored in ChromaDB<\/strong>, a high-performance <strong>vector database<\/strong>.<\/li>\n<li>The database is configured to use <strong>cosine similarity<\/strong>, which ensures that text with a high degree of semantic similarity is retrieved efficiently.<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\">7. Retrieve Similar Texts Using a Similarity Threshold<\/h3>\n<p>A <strong>retriever<\/strong> is created using ChromaDB, which:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Searches for the top 3 most similar<\/strong> documents based on a given query.<\/li>\n<li><strong>Filters results with a similarity threshold of 0.3<\/strong> (i.e., documents must have at least 30% similarity to be considered relevant).<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\">8. Query for Similar Documents<\/h3>\n<p>Two test queries are used:<\/p>\n<ol class=\"wp-block-list\">\n<li><code>\"What is the old capital of India?\"<\/code>\n<ul class=\"wp-block-list\">\n<li><strong>No results were found<\/strong>, which indicates that the stored documents do not contain relevant information.<\/li>\n<\/ul>\n<\/li>\n<li><code>\"What is Agentic AI?\"<\/code>\n<ul class=\"wp-block-list\">\n<li><strong>Successfully retrieves relevant text<\/strong>, demonstrating that the system can fetch meaningful context.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3 class=\"wp-block-heading\">9. Build a RAG (Retrieval-Augmented Generation) Chain<\/h3>\n<p>The script sets up a <strong>RAG pipeline<\/strong>, which ensures that:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Text retrieval<\/strong> happens before generating an answer.<\/li>\n<li>The model\u2019s response is <strong>based strictly on retrieved content<\/strong>, preventing hallucinations.<\/li>\n<li>A <strong>prompt template<\/strong> is used to instruct the model to generate structured responses.<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\">10. Load a Connection to an LLM (DeepSeek Model)<\/h3>\n<p>Instead of OpenAI\u2019s GPT, the script <strong>loads DeepSeek-R1 (1.5B parameters)<\/strong>, a powerful LLM optimized for retrieval-based tasks.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-11-create-a-rag-based-chain\">11. Create a RAG-Based Chain<\/h3>\n<p>LangChain\u2019s <strong>Retrieval<\/strong> module is used to:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Fetch relevant content<\/strong> from the vector database.<\/li>\n<li><strong>Format a structured response<\/strong> using a prompt template.<\/li>\n<li><strong>Generate a concise answer<\/strong> with the DeepSeek model.<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\">12. Test the RAG Chain<\/h3>\n<p>The script runs a test query:<br \/><code>\"Tell the Leaders\u2019 Perspectives on Agentic AI\"<\/code><\/p>\n<p>The <strong>LLM generates a fact-based response<\/strong> strictly using the retrieved context.<\/p>\n<p>The system <strong>retrieves relevant information from the database<\/strong>.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-code-to-build-a-rag-system-using-deepseek-r1\">Code to Build a RAG System Using DeepSeek R1<\/h2>\n<p>Here\u2019s the code:<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-install-openai-and-langchain-dependencies\">Install OpenAI and LangChain dependencies<\/h3>\n<pre class=\"wp-block-code\"><code>!pip install langchain==0.3.11\n!pip install langchain-openai==0.2.12\n!pip install langchain-community==0.3.11\n!pip install langchain-chroma==0.1.4<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-enter-open-ai-api-key\">Enter Open AI API Key<\/h3>\n<pre class=\"wp-block-code\"><code>from getpass import getpass\nOPENAI_KEY = getpass('Enter Open AI API Key: ')<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-setup-environment-variables\">Setup Environment Variables<\/h3>\n<pre class=\"wp-block-code\"><code>import os\nos.environ['OPENAI_API_KEY'] = OPENAI_KEY<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-open-ai-embedding-models\">Open AI Embedding Models<\/h3>\n<pre class=\"wp-block-code\"><code>from langchain_openai import OpenAIEmbeddings\nopenai_embed_model = OpenAIEmbeddings(model=\"text-embedding-3-small\")<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-create-a-vector-db-and-persist-on-the-disk\">Create a Vector DB and persist on the disk<\/h3>\n<pre class=\"wp-block-code\"><code>from langchain_community.document_loaders import PyPDFLoader\nloader = PyPDFLoader('AgenticAI.pdf')\npages = loader.load_and_split()\ntexts = [doc.page_content for doc in pages]\n\nfrom langchain_chroma import Chroma\nchroma_db = Chroma.from_texts(\n\u00a0\u00a0\u00a0\u00a0texts=texts,\n\u00a0\u00a0\u00a0\u00a0collection_name=\"db_docs\",\n\u00a0\u00a0\u00a0\u00a0collection_metadata={\"hnsw:space\": \"cosine\"},\u00a0 # Set distance function to cosine\nembedding=openai_embed_model\n)<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-similarity-with-threshold-retrieval\">Similarity with Threshold Retrieval<\/h3>\n<pre class=\"wp-block-code\"><code>similarity_threshold_retriever = chroma_db.as_retriever(search_type=\"similarity_score_threshold\",search_kwargs={\"k\": 3,\"score_threshold\": 0.3})\n\nquery = \"what is the old capital of India?\"\ntop3_docs = similarity_threshold_retriever.invoke(query)\ntop3_docs<\/code><\/pre>\n<pre class=\"wp-block-preformatted\">[]<\/pre>\n<pre class=\"wp-block-code\"><code>query = \"What is Agentic AI?\"\ntop3_docs = similarity_threshold_retriever.invoke(query)\ntop3_docs<\/code><\/pre>\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1087\" height=\"563\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image-22-2.webp\" alt=\"Output\" class=\"wp-image-218586\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image-22-2.webp 1087w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image-22-2-300x155.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image-22-2-768x398.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image-22-2-150x78.webp 150w\" sizes=\"(max-width: 1087px) 100vw, 1087px\"\/><\/figure>\n<h3 class=\"wp-block-heading\" id=\"h-build-a-rag-chain\">Build a RAG Chain<\/h3>\n<pre class=\"wp-block-code\"><code>from langchain_core.prompts import ChatPromptTemplate\nprompt = \"\"\"You are an assistant for question-answering tasks.\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Use the following pieces of retrieved context to answer the question.\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0If no context is present or if you don't know the answer, just say that you don't know.\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Do not make up the answer unless it is there in the provided context.\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Keep the answer concise and to the point with regard to the question.\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Question:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{question}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Context:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{context}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Answer:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"\"\"\nprompt_template = ChatPromptTemplate.from_template(prompt)<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-load-connection-to-llm\">Load Connection to LLM<\/h3>\n<pre class=\"wp-block-code\"><code>from langchain_community.llms import Ollama\ndeepseek = Ollama(model=\"deepseek-r1:1.5b\")<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-langchain-syntax-for-rag-chain\">LangChain Syntax for RAG Chain<\/h3>\n<pre class=\"wp-block-code\"><code>from langchain.chains import Retrieval\nrag_chain = Retrieval.from_chain_type(llm=deepseek,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0chain_type=\"stuff\",\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0retriever=similarity_threshold_retriever,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0chain_type_kwargs={\"prompt\": prompt_template})\nquery = \"Tell the Leaders\u2019 Perspectives on Agentic AI\"\nrag_chain.invoke(query)\n{'query': 'Tell the Leaders\u2019 Perspectives on Agentic AI',<\/code><\/pre>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1104\" height=\"556\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image-24.webp\" alt=\"output\" class=\"wp-image-218588\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image-24.webp 1104w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image-24-300x151.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image-24-768x387.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image-24-150x76.webp 150w\" sizes=\"auto, (max-width: 1104px) 100vw, 1104px\"\/><\/figure>\n<p>Checkout our detailed articles on DeepSeek working and comparison with similar models:<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n<p>Building a RAG system using <strong>DeepSeek R1<\/strong> provides a cost-effective and powerful way to enhance document retrieval and response generation. With its open-source nature and strong reasoning capabilities, it is a great alternative to proprietary solutions. Businesses and developers can leverage its flexibility to create AI-driven applications tailored to their needs.<\/p>\n<p>Want to build applications using DeepSeek? Checkout our <a href=\"https:\/\/courses.analyticsvidhya.com\/courses\/getting-started-with-deepseek?utm_source=blog_page&amp;utm_medium=blog&amp;utm_campaign=SEO\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Free DeepSeek Course<\/a> today!<\/p>\n<p><em><strong>Stay tuned to\u00a0<a href=\"https:\/\/www.analyticsvidhya.com\/blog\/\" target=\"_blank\" rel=\"noreferrer noopener\">Analytics Vidhya Blog<\/a>\u00a0for more such awesome content!<\/strong><\/em><\/p>\n<div class=\"border-top py-3 author-info my-4\">\n<div class=\"author-card d-flex align-items-center\">\n<div class=\"flex-shrink-0 overflow-hidden\">\n                                    <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/author\/pankaj9786\/\" class=\"text-decoration-none active-avatar\"><br \/>\n                                                                       <img decoding=\"async\" src=\"https:\/\/av-eks-lekhak.s3.amazonaws.com\/media\/lekhak-profile-images\/converted_image_Lb7Lh0T.webp\" width=\"48\" height=\"48\" alt=\"Pankaj Singh\" loading=\"lazy\" class=\"rounded-circle\"\/><\/p>\n<p>                                <\/a>\n                                <\/div>\n<\/p><\/div>\n<p>                Hi, I am Pankaj Singh Negi &#8211; Senior Content Editor | Passionate about storytelling and crafting compelling narratives that transform ideas into impactful content. I love reading about technology revolutionizing our lifestyle.                 <\/p>\n<\/p><\/div>\n<\/p><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>I have been reading a lot about RAG and AI Agents, but with the release of new models like DeepSeek V3 and DeepSeek R1, it seems that the possibility of building efficient RAG systems has significantly improved, offering better retrieval accuracy, enhanced reasoning capabilities, and more scalable architectures for real-world applications. The integration of more [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":57924,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[5293,29466,32726,2345],"dealstore":[],"offerexpiration":[],"class_list":["post-57923","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-build","tag-deepseek","tag-rag","tag-system"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Build RAG System Using DeepSeek R1? - Som2ny Network<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fivemor.com\/?p=57923\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Build RAG System Using DeepSeek R1? - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"I have been reading a lot about RAG and AI Agents, but with the release of new models like DeepSeek V3 and DeepSeek R1, it seems that the possibility of building efficient RAG systems has significantly improved, offering better retrieval accuracy, enhanced reasoning capabilities, and more scalable architectures for real-world applications. The integration of more [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=57923\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-30T14:47:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Creating-a-RAG-System-using-DeepSeek.webp.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"872\" \/>\n\t<meta property=\"og:image:height\" content=\"473\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=57923#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=57923\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"How to Build RAG System Using DeepSeek R1?\",\"datePublished\":\"2025-01-30T14:47:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=57923\"},\"wordCount\":1244,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=57923#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Creating-a-RAG-System-using-DeepSeek.webp.webp\",\"keywords\":[\"Build\",\"DeepSeek\",\"RAG\",\"SYSTEM\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=57923#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=57923\",\"url\":\"https:\/\/fivemor.com\/?p=57923\",\"name\":\"How to Build RAG System Using DeepSeek R1? - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=57923#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=57923#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Creating-a-RAG-System-using-DeepSeek.webp.webp\",\"datePublished\":\"2025-01-30T14:47:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=57923#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=57923\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=57923#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Creating-a-RAG-System-using-DeepSeek.webp.webp\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Creating-a-RAG-System-using-DeepSeek.webp.webp\",\"width\":872,\"height\":473},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=57923#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Build RAG System Using DeepSeek R1?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fivemor.com\/#website\",\"url\":\"https:\/\/fivemor.com\/\",\"name\":\"Som2ny Network\",\"description\":\"Daily Deals\",\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fivemor.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/fivemor.com\/#organization\",\"name\":\"Som2ny Network\",\"url\":\"https:\/\/fivemor.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"width\":300,\"height\":86,\"caption\":\"Som2ny Network\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/fivemor.com\"],\"url\":\"https:\/\/fivemor.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Build RAG System Using DeepSeek R1? - Som2ny Network","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fivemor.com\/?p=57923","og_locale":"en_US","og_type":"article","og_title":"How to Build RAG System Using DeepSeek R1? - Som2ny Network","og_description":"I have been reading a lot about RAG and AI Agents, but with the release of new models like DeepSeek V3 and DeepSeek R1, it seems that the possibility of building efficient RAG systems has significantly improved, offering better retrieval accuracy, enhanced reasoning capabilities, and more scalable architectures for real-world applications. The integration of more [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=57923","og_site_name":"Som2ny Network","article_published_time":"2025-01-30T14:47:06+00:00","og_image":[{"width":872,"height":473,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Creating-a-RAG-System-using-DeepSeek.webp.webp","type":"image\/webp"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=57923#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=57923"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"How to Build RAG System Using DeepSeek R1?","datePublished":"2025-01-30T14:47:06+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=57923"},"wordCount":1244,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=57923#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Creating-a-RAG-System-using-DeepSeek.webp.webp","keywords":["Build","DeepSeek","RAG","SYSTEM"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=57923#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=57923","url":"https:\/\/fivemor.com\/?p=57923","name":"How to Build RAG System Using DeepSeek R1? - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=57923#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=57923#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Creating-a-RAG-System-using-DeepSeek.webp.webp","datePublished":"2025-01-30T14:47:06+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=57923#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=57923"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=57923#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Creating-a-RAG-System-using-DeepSeek.webp.webp","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Creating-a-RAG-System-using-DeepSeek.webp.webp","width":872,"height":473},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=57923#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"How to Build RAG System Using DeepSeek R1?"}]},{"@type":"WebSite","@id":"https:\/\/fivemor.com\/#website","url":"https:\/\/fivemor.com\/","name":"Som2ny Network","description":"Daily Deals","publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fivemor.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fivemor.com\/#organization","name":"Som2ny Network","url":"https:\/\/fivemor.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","width":300,"height":86,"caption":"Som2ny Network"},"image":{"@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","caption":"admin"},"sameAs":["https:\/\/fivemor.com"],"url":"https:\/\/fivemor.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/57923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=57923"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/57923\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/57924"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=57923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=57923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=57923"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=57923"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=57923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}