{"id":60986,"date":"2025-01-31T23:49:24","date_gmt":"2025-01-31T23:49:24","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/building-a-rqa-system-with-deepseek-r1-and-streamlit\/"},"modified":"2025-01-31T23:49:24","modified_gmt":"2025-01-31T23:49:24","slug":"building-a-rqa-system-with-deepseek-r1-and-streamlit","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=60986","title":{"rendered":"Building a RQA System with DeepSeek R1 and Streamlit"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div id=\"article-start\">\n<p>DeepSeek R1 is here, and it\u2019s proving to be incredibly helpful for building AI applications. Its advanced architecture, combining reinforcement learning with a <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2024\/12\/mixture-of-experts-models\/#:~:text=A%20Mixture%20of%20Experts%20(MoE,based%20on%20the%20input%20data.\" target=\"_blank\" rel=\"noreferrer noopener\">Mixture of Experts (MoE) <\/a>framework, ensures high efficiency and accuracy. In this article, I\u2019m going to build a Retrieval-based Question Answering (RQA) system using DeepSeek R1, LangChain and Streamlit. This step-by-step guide will show you how to integrate DeepSeek R1 into a practical application, demonstrating its capabilities in handling real-world reasoning tasks.\u00a0<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-learning-objectives\">Learning Objectives<\/h3>\n<ul class=\"wp-block-list\">\n<li>Understand how the RQA System with DeepSeek R1 enhances reasoning and problem-solving.<\/li>\n<li>Explore the architecture and key features of DeepSeek R1 for AI-driven Q&amp;A.<\/li>\n<li>Learn how to integrate DeepSeek R1 into retrieval-based question-answering systems.<\/li>\n<li>Discover how <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2021\/02\/introduction-to-reinforcement-learning-for-beginners\/\" target=\"_blank\" rel=\"noreferrer noopener\">reinforcement learning<\/a> improves the accuracy of DeepSeek R1 responses.<\/li>\n<li>Analyze real-world applications of DeepSeek R1 in coding, math, and logical reasoning.<\/li>\n<\/ul>\n<p><em><strong>This article was published as a part of the\u00a0<\/strong><\/em><a href=\"https:\/\/www.analyticsvidhya.com\/datahack\/blogathon\" target=\"_blank\" rel=\"noreferrer noopener\"><em><strong>Data Science Blogathon.<\/strong><\/em><\/a><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-what-is-deepseek-r1\">What is DeepSeek-R1? <\/h2>\n<p>\u00a0Open-source foundation models have become a game-changer in the rapidly evolving field of <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2021\/09\/introduction-to-artificial-intelligence-for-beginners\/\" target=\"_blank\" rel=\"noreferrer noopener\">Artificial Intelligence<\/a>, enabling enterprises to develop and fine-tune AI applications. The AI community fosters based on these open-source models as they are advantageous to developers and end users. And this is the advantage of <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2025\/01\/deepseek-r1\/\" target=\"_blank\" rel=\"noreferrer noopener\">DeepSeek-R1<\/a>.<\/p>\n<p>DeepSeek-R1 is an open-source, reasoning model released by DeepSeek, a Chinese AI company. It\u2019s purpose is to solve tasks that require logical reasoning, solving mathematical problems, and make real-time decisions. The DeepSeek-R1 models provide excellent performance and efficiency while handling a wide range of activities, from general reasoning to code creation.\u00a0<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-training-process-of-deepseek-r1-zero-and-deepseek-r1\">Training Process of DeepSeek-R1-Zero and DeepSeek-R1<\/h2>\n<p>Usually, <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2023\/03\/an-introduction-to-large-language-models-llms\/\" target=\"_blank\" rel=\"noreferrer noopener\">Large language models<\/a> (LLMs) undergo a three-stage training process. Firstly, during pre-training, they are exposed to vast amounts of text and code to learn general-purpose knowledge, enabling them to predict the next word in a sequence. Although proficient at this, they initially struggle to follow human instructions. Supervised fine-tuning is the next step, where the model is trained on a dataset of instruction-response pairs, significantly improving its ability to follow directions. Lastly, reinforcement learning further refines the model using feedback. This can be done through Reinforcement Learning from Human Feedback (RLHF), where human input guides the training, or Reinforcement Learning from AI Feedback (RLAIF), where another AI model provides feedback.<\/p>\n<p>DeepSeek-R1-Zero model uses a pre-trained DeepSeek-V3-Base model which has 671 billion parameters. But it omits this supervised finetuning stage. use a large scale reinforcement learning technique called\u00a0Group Relative Policy Optimization (GRPO).\u00a0<\/p>\n<figure class=\"wp-block-image size-full is-resized figure mt-2 mb-2 d-table mx-auto\"><img fetchpriority=\"high\" decoding=\"async\" width=\"664\" height=\"409\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/grpo.webp\" alt=\"GRPO\" class=\"wp-image-218789\" style=\"width:561px;height:auto\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/grpo.webp 664w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/grpo-300x185.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/grpo-150x92.webp 150w\" sizes=\"(max-width: 664px) 100vw, 664px\"\/><\/figure>\n<p>Group Relative Policy Optimization (GRPO) is based upon the Proximal Policy Optimization (PPO) framework but discards the need for a value function model, thus simplifying the training process and reducing memory consumption. It basically generates multiple outputs for each input question and each output is given a score using a reward model. Then, the average of these rewards serves as the baseline to calculate the advantages and a KL Divergence term. But it struggles with readability issues as it\u2019s output is difficult to understand and it often mixes up the languages. Thus, DeepSeek-R1 was created to address these issues.\u00a0<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-four-stages-of-deepseek-r1\">Four Stages of DeepSeek-R1<\/h2>\n<p>DeepSeek-R1 builds upon DeepSeek-R1-Zero and fixes it\u2019s issues. It\u2019s trained in four stages, described as follows:<\/p>\n<ul class=\"wp-block-list\">\n<li><b>Stage 1 (Cold Start):<\/b> it starts with the pre-trained DeepSeek-V3-Base model and is fine-tuned on a small, high-quality dataset from DeepSeek-R1-Zero to improve readability.<\/li>\n<li><b>Stage 2 (Reasoning Reinforcement Learning):<\/b> enhances reasoning abilities through large-scale reinforcement learning, focusing on tasks like coding, math, science, and logic.<\/li>\n<li><b>Stage 3 (Rejection Sampling and Supervised Fine-Tuning):<\/b> the model generates multiple samples, retains only the correct and readable ones using rejection sampling. Then it is further fine-tuned with a generative reward model. This phase incorporates data beyond reasoning questions, broadening the model\u2019s capabilities.<\/li>\n<li><b>Stage 4 (Diverse Reinforcement Learning): <\/b>applies rule-based rewards for tasks like math and uses feedback from a language model to align the model with human preferences.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"h-features-of-deepseek-r1\">Features of DeepSeek-R1<\/h2>\n<p>Open Source: It is distributed under an MIT license, allowing free inspection, modification, and integration into various projects. DeepSeek-R1 is available on platforms like GitHub and Azure AI Foundry, offering accessibility to developers and researchers.<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Performance:<\/strong> DeepSeek-R1 performs comparably to OpenAI\u2019s GPT-4 on various benchmarks, including tasks related to math, code generation, and complex reasoning.\u00a0<\/li>\n<li><strong>Mixture of Experts (MoE) Architecture: <\/strong>The model is built on a Mixture of Experts framework, containing 671 billion parameters, but activates only 37 billion during each forward pass.\u00a0<\/li>\n<\/ul>\n<p>Distilled Models: DeepSeek-R1 provides many distilled models, including DeepSeek-R1-Distill-Qwen-32B and smaller variants like Qwen-1.5B, 7B, and 14B. Distilled models are smaller models created after transferring knowledge from larger ones.\u00a0This will allow developers to build and deploy AI-powered applications that run efficiently on-device.\u00a0<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-how-to-use-deepseek-r1-locally\">How to use DeepSeek-R1 Locally?<\/h2>\n<p>It\u2019s quite simple!\u00a0<\/p>\n<ul class=\"wp-block-list\">\n<li>Install\u00a0<a href=\"https:\/\/ollama.com\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Ollama<\/a>\u00a0for your local system.<\/li>\n<li>Run the following command in your terminal. (DeepSeek-R1 ranges from 1.5B to 671B parameters)<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># Enter the command in terminal \nollama run deepseek-r1   # To use the default 7B model\n\n# To use a specific model\nollama run deepseek-r1:1.5b <\/code><\/pre>\n<p><b>Output:\u00a0<\/b><\/p>\n<figure class=\"wp-block-image size-full figure mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"1700\" height=\"440\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/To-install-default-7b-model-OR-its-1.5b-variant.webp\" alt=\"To install default 7b model OR it's 1.5b variant\" class=\"wp-image-218790\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/To-install-default-7b-model-OR-its-1.5b-variant.webp 1700w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/To-install-default-7b-model-OR-its-1.5b-variant-300x78.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/To-install-default-7b-model-OR-its-1.5b-variant-768x199.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/To-install-default-7b-model-OR-its-1.5b-variant-1536x398.webp 1536w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/To-install-default-7b-model-OR-its-1.5b-variant-150x39.webp 150w\" sizes=\"auto, (max-width: 1700px) 100vw, 1700px\"\/><\/figure>\n<h2 class=\"wp-block-heading\" id=\"h-steps-to-build-a-rqa-system-with-deepseek-r1\">Steps to Build a RQA System with DeepSeek R1<\/h2>\n<p>Let\u2019s build a Retrieval Question Answering System with LangChain, powered by DeepSeek-R1 for reasoning!\u00a0<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-1-import-necessary-libraries\">Step 1: Import Necessary Libraries<\/h3>\n<p>Import necessary libraries, including streamlit, langchain_community.<\/p>\n<pre class=\"wp-block-code\"><code>import streamlit as st\nfrom langchain_community.document_loaders.csv_loader import CSVLoader\nfrom langchain_community.embeddings import HuggingFaceEmbeddings\nfrom langchain_community.vectorstores import FAISS\nfrom langchain_community.llms import Ollama\nfrom langchain.prompts import PromptTemplate\nfrom langchain.chains import LLMChain\nfrom langchain.chains.combine_documents.stuff import create_stuff_documents_chain\nfrom langchain.chains import RetrievalQA<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-step-2-streamlit-file-uploader\">Step 2: Streamlit File Uploader<\/h3>\n<p>Create a streamlit file uploader to allow CSV files to be uploaded.<\/p>\n<pre class=\"wp-block-code\"><code># Streamlit file uploader for CSV files\nuploaded_file = st.file_uploader(\"Upload a CSV file\", type=\"csv\")\n\nif uploaded_file:\n    # Save CSV temporarily\n    temp_file_path = \"temp.csv\"\n    with open(temp_file_path, \"wb\") as f:\n        f.write(uploaded_file.getvalue())<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-step-3-load-csv-and-create-embeddings\">Step 3: Load CSV and Create Embeddings<\/h3>\n<p>Once CSV files are uploaded, load them to create embeddings. Embeddings are created using HuggingFaceEmbeddings to convert the CSV data into vector representations.<\/p>\n<pre class=\"wp-block-code\"><code>loader = CSVLoader(file_path=temp_file_path)\ndocs = loader.load()\nembeddings = HuggingFaceEmbeddings()<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-step-4-create-vector-store\">Step 4: Create Vector Store<\/h3>\n<p>Create a FAISS vector store from the documents and embeddings to enable efficient similarity search.<\/p>\n<pre class=\"wp-block-code\"><code>vector_store = FAISS.from_documents(docs, embeddings)<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-step-5-connect-a-retriever\">Step 5: Connect a Retriever<\/h3>\n<p>Initialize a retriever with the vector store, and specify the number of top documents to fetch (I have set it as 3).<\/p>\n<pre class=\"wp-block-code\"><code>retriever = vector_store.as_retriever(search_kwargs={\"k\": 3})<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-step-6-define-the-llm\">Step 6: Define the LLM<\/h3>\n<p>By using Ollama, we can define the LLM. Mention the DeepSeek-R1 version as the parameter.<\/p>\n<pre class=\"wp-block-code\"><code>llm = Ollama(model=\"deepseek-r1:1.5b\")  # Our 1.5B parameter model<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-step-7-create-a-prompt-template\">Step 7: Create a Prompt Template<\/h3>\n<p>Here I am using a default, basic template but you can modify it according to your needs.<\/p>\n<pre class=\"wp-block-code\"><code>prompt = \"\"\"\n    1. Use ONLY the context below.\n    2. If unsure, say \"I don\u2019t know\".\n    3. Keep answers under 4 sentences.\n\n    Context: {context}\n\n    Question: {question}\n\n    Answer:\n    \"\"\"\n    QA_CHAIN_PROMPT = PromptTemplate.from_template(prompt)<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-step-8-define-the-qa-chain\">Step 8: Define the QA Chain<\/h3>\n<p>Use the StuffDocumentsChain to combine the LLM and the prompt template into a single chain for document-based question answering.<\/p>\n<pre class=\"wp-block-code\"><code>llm_chain = LLMChain(llm=llm, prompt=QA_CHAIN_PROMPT)\n    \n    # Combine document chunks\n    document_chain = create_stuff_documents_chain(\n        llm=llm,\n        prompt=QA_CHAIN_PROMPT\n    )<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-step-9-create-the-retrievalqa-chain\">Step 9: Create the RetrievalQA Chain<\/h3>\n<p>Initialize the RetrievalQA chain, which integrates the retriever and the LLM to answer user queries based on relevant document chunks.<\/p>\n<pre class=\"wp-block-code\"><code> qa = RetrievalQA.from_chain_type(\n        llm=llm,\n        retriever=retriever,\n        chain_type=\"stuff\", \n    )<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-step-10-create-streamlit-ui-for-the-application\">Step 10: Create Streamlit UI for the application<\/h3>\n<p>Set up a Streamlit text input field where users can enter queries, process the input using the RetrievalQA chain, and display the generated response.<\/p>\n<pre class=\"wp-block-code\"><code>user_input = st.text_input(\"Ask your CSV a question:\")\n\n    if user_input:\n        with st.spinner(\"Thinking...\"):\n            try:\n                response = qa.run(user_input)  \n                st.write(response)\n            except Exception as e:\n                st.error(f\"Error: {str(e)}\")<\/code><\/pre>\n<p>Save the python file (.py) and run it locally using the following command\u00a0to view the UI.<\/p>\n<pre class=\"wp-block-code\"><code>#In terminal\nstreamlit run filename.py<\/code><\/pre>\n<p><strong>Note: <\/strong>Ensure the necessary libraries are installed in your system. You can do so by the following command.\u00a0<\/p>\n<pre class=\"wp-block-code\"><code>pip install streamlit langchain_community transformers faiss-cpu langchain\n<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-output\">Output<\/h4>\n<p>Here I have uploaded an Automobile dataset and asked it a question related to my csv file.\u00a0<\/p>\n<figure class=\"wp-block-image size-full is-resized figure mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"987\" height=\"793\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image_q3XUXED.webp\" alt=\"output: RQA System with DeepSeek R1\" class=\"wp-image-218792\" style=\"width:593px;height:auto\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image_q3XUXED.webp 987w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image_q3XUXED-300x241.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image_q3XUXED-768x617.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/01\/image_q3XUXED-150x121.webp 150w\" sizes=\"auto, (max-width: 987px) 100vw, 987px\"\/><\/figure>\n<p><b>Advantage:\u00a0<\/b>Here\u2019s what I liked about DeepSeek-R1\u2019s reasoning \u2013 you can follow it\u2019s logic! It displays it\u2019s thinking process and why it has come to a conclusion. Thus, DeepSeek-R1 improves the explainability of LLMs!<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n<p>DeepSeek-R1 shows the way forward for high-quality AI models with sophisticated reasoning and nuanced understanding. Combining powerful reinforcement learning techniques with an efficient Mixture of Experts architecture, DeepSeek-R1 provides solution for a variety of complex tasks, from code generation to deep reasoning challenges. Its open-source nature and accessibility further empower developers and researchers. With the continuous development of AI, open-source models such as DeepSeek-R1 are opening up the prospects of more intelligent and resource-efficient systems across various domains. With great performance, its unparalleled architecture, and impressive results, DeepSeek-R1 is poised for prominent future innovations in AI.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-key-takeaways\">Key Takeaways<\/h3>\n<ul class=\"wp-block-list\">\n<li>DeepSeek-R1 is an advanced open-source reasoning model designed for logical problem-solving, math, and real-time decision-making.<\/li>\n<li>The RQA System with DeepSeek R1 enables efficient document-based question-answering by leveraging retrieval-augmented generation techniques.<\/li>\n<li>DeepSeek-R1\u2019s training process includes reinforcement learning, rejection sampling, and fine-tuning, making it highly optimized for reasoning tasks.<\/li>\n<li>The RQA System with DeepSeek R1 enhances AI explainability by displaying its step-by-step thought process in responses.<\/li>\n<li>DeepSeek-R1\u2019s Mixture of Experts (MoE) architecture activates only relevant parameters per task, improving efficiency while handling complex queries.<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-references\">References<\/h3>\n<h2 class=\"wp-block-heading\" id=\"h-frequently-asked-questions\">Frequently Asked Questions<\/h2>\n<div class=\"schema-faq wp-block-yoast-faq-block\">\n<div class=\"schema-faq-section\" id=\"faq-question-1738309000031\"><strong class=\"schema-faq-question\"><b>Q1. What is Mixtures-of-Experts architecture?<\/b><\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. It is a smart neural network design that uses multiple specialized sub-models (experts). A gating system selects the most relevant experts for each input, ensuring only a few are active at a time. This makes the model more efficient than traditional dense models, which use all parameters.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1738309014073\"><strong class=\"schema-faq-question\"><b>Q2. What are the other ways to access DeepSeek-R1?<\/b><\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. DeepSeek\u2019s chatbot is available on company\u2019s website and is available for download on the Apple App Store and Google Play Store. It is also available on\u00a0<a href=\"https:\/\/huggingface.co\/deepseek-ai\/DeepSeek-R1\" target=\"_blank\" rel=\"nofollow noopener\">Hugging Face<\/a>\u00a0and\u00a0<a href=\"https:\/\/chat.deepseek.com\/503\/\" target=\"_blank\" rel=\"nofollow noopener\">DeepSeek\u2019s API<\/a>.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1738309025575\"><strong class=\"schema-faq-question\"><b>Q3. What is a Retrieval-based Question Answering (RQA) system?<\/b><\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. A Retrieval-based QA system fetches information from a dataset or documents and generates answers based on the retrieved content, rather than just depending upon pre-trained knowledge.\u00a0<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1738309039701\"><strong class=\"schema-faq-question\"><b>Q4. What is FAISS and why is it used? <\/b><\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. FAISS stands for Facebook AI Similarity Search. It enables fast and efficient similarity searches, allowing the system to retrieve the most relevant chunks of information from the CSV data.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1738309052289\"><strong class=\"schema-faq-question\"><b>Q5.\u00a0What are the system requirements for running DeepSeek-R1? <\/b><\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. The requirements vary based on the model size. For example, the 7B model needs at least 8GB of RAM, while the 33B model requires a minimum of 32GB of RAM.\u00a0<\/p>\n<\/p><\/div>\n<\/p><\/div>\n<p><strong>The media shown in this article is not owned by Analytics Vidhya and is used at the Author\u2019s discretion.<\/strong><\/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\/aditi3807991\/\" 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_7zsRRR3.webp\" width=\"48\" height=\"48\" alt=\"Aditi V\" loading=\"lazy\" class=\"rounded-circle\"\/><\/p>\n<p>                                <\/a>\n                                <\/div>\n<\/p><\/div>\n<p>      Hello data enthusiasts! I am V Aditi, a rising and dedicated data science and artificial intelligence student embarking on a journey of exploration and learning in the world of data and machines. Join me as I navigate through the fascinating world of data science and artificial intelligence, unraveling mysteries and sharing insights along the way! \ud83d\udcca\u2728      <\/p>\n<\/p><\/div>\n<\/p><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>DeepSeek R1 is here, and it\u2019s proving to be incredibly helpful for building AI applications. Its advanced architecture, combining reinforcement learning with a Mixture of Experts (MoE) framework, ensures high efficiency and accuracy. In this article, I\u2019m going to build a Retrieval-based Question Answering (RQA) system using DeepSeek R1, LangChain and Streamlit. This step-by-step guide [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":60987,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[5815,2539,29466,33829,33830,2345],"dealstore":[],"offerexpiration":[],"class_list":["post-60986","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-blogathon","tag-building","tag-deepseek","tag-rqa","tag-streamlit","tag-system"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Building a RQA System with DeepSeek R1 and Streamlit - 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=60986\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building a RQA System with DeepSeek R1 and Streamlit - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"DeepSeek R1 is here, and it\u2019s proving to be incredibly helpful for building AI applications. Its advanced architecture, combining reinforcement learning with a Mixture of Experts (MoE) framework, ensures high efficiency and accuracy. In this article, I\u2019m going to build a Retrieval-based Question Answering (RQA) system using DeepSeek R1, LangChain and Streamlit. This step-by-step guide [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=60986\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-31T23:49:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Step-by-Step-Guide-to-Building-a-RQA-System-with-DeepSeek-R1-LangChain.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=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=60986#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=60986\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"Building a RQA System with DeepSeek R1 and Streamlit\",\"datePublished\":\"2025-01-31T23:49:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=60986\"},\"wordCount\":1621,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=60986#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Step-by-Step-Guide-to-Building-a-RQA-System-with-DeepSeek-R1-LangChain.webp.webp\",\"keywords\":[\"Blogathon\",\"Building\",\"DeepSeek\",\"RQA\",\"Streamlit\",\"SYSTEM\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=60986#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=60986\",\"url\":\"https:\/\/fivemor.com\/?p=60986\",\"name\":\"Building a RQA System with DeepSeek R1 and Streamlit - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=60986#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=60986#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Step-by-Step-Guide-to-Building-a-RQA-System-with-DeepSeek-R1-LangChain.webp.webp\",\"datePublished\":\"2025-01-31T23:49:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=60986#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=60986\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=60986#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Step-by-Step-Guide-to-Building-a-RQA-System-with-DeepSeek-R1-LangChain.webp.webp\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Step-by-Step-Guide-to-Building-a-RQA-System-with-DeepSeek-R1-LangChain.webp.webp\",\"width\":872,\"height\":473},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=60986#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building a RQA System with DeepSeek R1 and Streamlit\"}]},{\"@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":"Building a RQA System with DeepSeek R1 and Streamlit - 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=60986","og_locale":"en_US","og_type":"article","og_title":"Building a RQA System with DeepSeek R1 and Streamlit - Som2ny Network","og_description":"DeepSeek R1 is here, and it\u2019s proving to be incredibly helpful for building AI applications. Its advanced architecture, combining reinforcement learning with a Mixture of Experts (MoE) framework, ensures high efficiency and accuracy. In this article, I\u2019m going to build a Retrieval-based Question Answering (RQA) system using DeepSeek R1, LangChain and Streamlit. This step-by-step guide [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=60986","og_site_name":"Som2ny Network","article_published_time":"2025-01-31T23:49:24+00:00","og_image":[{"width":872,"height":473,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Step-by-Step-Guide-to-Building-a-RQA-System-with-DeepSeek-R1-LangChain.webp.webp","type":"image\/webp"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=60986#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=60986"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"Building a RQA System with DeepSeek R1 and Streamlit","datePublished":"2025-01-31T23:49:24+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=60986"},"wordCount":1621,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=60986#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Step-by-Step-Guide-to-Building-a-RQA-System-with-DeepSeek-R1-LangChain.webp.webp","keywords":["Blogathon","Building","DeepSeek","RQA","Streamlit","SYSTEM"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=60986#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=60986","url":"https:\/\/fivemor.com\/?p=60986","name":"Building a RQA System with DeepSeek R1 and Streamlit - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=60986#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=60986#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Step-by-Step-Guide-to-Building-a-RQA-System-with-DeepSeek-R1-LangChain.webp.webp","datePublished":"2025-01-31T23:49:24+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=60986#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=60986"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=60986#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Step-by-Step-Guide-to-Building-a-RQA-System-with-DeepSeek-R1-LangChain.webp.webp","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/01\/Step-by-Step-Guide-to-Building-a-RQA-System-with-DeepSeek-R1-LangChain.webp.webp","width":872,"height":473},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=60986#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"Building a RQA System with DeepSeek R1 and Streamlit"}]},{"@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\/60986","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=60986"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/60986\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/60987"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=60986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=60986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=60986"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=60986"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=60986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}