Deepseek-R1 dialogue question answering method based on RAG
Through the Deepseek-R1 dialogue question and answer method based on RAG, the existing system's insufficient knowledge coverage, unreliable answers and insufficient understanding of complex contexts are solved, and efficient and accurate dialogue question and answer services are realized, adapting to multilingual and different application scenarios.
Patent Information
- Application Number
- CN202510249601.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-08-29
AI Technical Summary
The existing dialogue Q&A system has defects in insufficient knowledge coverage, unreliable answer generation, insufficient complex context understanding, and insufficient system scalability and flexibility, making it difficult to provide accurate, natural and highly adaptable dialogue Q&A services.
The Deepseek-R1 dialogue question and answer method based on RAG is adopted, and efficient and accurate dialogue question and answer is achieved through knowledge base preprocessing, vectorized storage, problem understanding and rewriting, vectorized encoding search and reordering model optimization, combined with RESTful API and message queues.
It improves the accuracy and verifiability of answers, enhances the ability to understand complex contexts, improves knowledge coverage and update efficiency, enhances the flexibility and scalability of the system, and adapts to multilingual and different application scenarios.
Abstract
Description
Technical Field
[0001] The present invention is applied to the field of artificial intelligence, and specifically is a Deepseek-R1 dialogue question-answering method based on RAG. Background Art
[0002] This invention relates to the fields of natural language processing (NLP) and artificial intelligence (AI), and more specifically to a Deepseek-R1 conversational question-answering system based on RAG (Retrieval-Augmented Generation). This system combines the technical advantages of information retrieval and generative models to provide users with efficient, accurate, and natural conversational question-answering services. It is applicable to a variety of fields, including intelligent customer service, intelligent writing, education, healthcare, law, and government services.
[0003] In the existing dialogue question-answering systems, there are two main technical routes: retrieval-based question-answering systems and generation-based question-answering systems.
[0004] Retrieval-based question answering systems:
[0005] This type of system answers questions by retrieving relevant information from predefined knowledge bases or documents. Typical representatives are traditional search engines and keyword-matching-based question-answering systems.
[0006] Advantages: Able to provide accurate and verifiable answers, with clear sources.
[0007] Disadvantages: For complex questions or questions that require contextual understanding, retrieval systems often cannot provide fluent and natural answers and rely on the coverage and quality of the knowledge base.
[0008] Generation-based question answering systems:
[0009] Such systems use generative models (such as the GPT series of models) to directly generate answers without relying on external knowledge bases.
[0010] Advantages: It can generate fluent and natural answers and is suitable for open-domain question answering.
[0011] Disadvantages: The generated answers may lack factual basis, have "hallucination" phenomenon (i.e., generate content that seems reasonable but has no factual basis), and the source of the answers cannot be traced.
[0012] RAG (Retrieval-Augmented Generation) technology:
[0013] RAG technology combines the advantages of retrieval and generation, and enhances the answer accuracy of the generation model by retrieving external knowledge bases.
[0014] Advantages: It can generate fluent responses while ensuring the accuracy and verifiability of the answers.
[0015] Disadvantages: Existing RAG systems still have certain limitations when handling complex contexts and multi-round dialogues. In particular, when the knowledge base is not updated in a timely manner or the knowledge coverage is insufficient, the generated answers may not be accurate enough.
[0016] Although existing conversational question answering systems perform well in some scenarios, they still have the following major problems:
[0017] Insufficient knowledge coverage: Retrieval-based systems rely on a predefined knowledge base. If the knowledge base is not updated in a timely manner or has limited coverage, the system cannot answer new or complex questions.
[0018] Unreliability of generated answers: Although generation-based systems can generate fluent answers, they suffer from the phenomenon of "hallucination". The generated answers may lack factual basis and cannot be traced back to the source.
[0019] Insufficient understanding of complex contexts: Existing RAG systems often fail to deeply understand the context when dealing with complex contexts and multi-round dialogues, resulting in the generated answers being inaccurate or unnatural.
[0020] Insufficient system scalability and flexibility: Existing conversational question-answering systems are generally difficult to quickly adapt to new application scenarios or fields, and lack flexible architectural design and multilingual support capabilities. Summary of the Invention
[0021] The technical problem to be solved by the present invention is to provide a Deepseek-R1 dialogue question-answering method based on RAG in view of the deficiencies in the prior art.
[0022] To solve the above technical problems, the present invention provides a Deepseek-R1 dialogue question-answering method based on RAG, comprising the following steps:
[0023] Perform knowledge base preprocessing, collect information from data sources, convert it into a unified format, perform text parsing, segmentation, information extraction and annotation, vectorize text data and store it in a vector database;
[0024] Use a distributed vector database to store pre-processed text data and its vectorized representation;
[0025] Receive user input questions, understand and rewrite the questions, use vectorized coding and similarity calculation to search from the knowledge base, and optimize the search results through the re-ranking model;
[0026] Based on the retrieved background knowledge, the Deepseek-R1 model is used to generate natural language answers, which are then optimized and adjusted before being output to the user.
[0027] As a possible implementation method, it further includes: at least supporting integration with external systems through RESTful API and message queue, and adapting to different technology stacks and application scenarios.
[0028] As a possible implementation, further, the knowledge base preprocessing includes:
[0029] Data collection and integration: Collect information from various data sources such as text files, databases, web pages, and convert the data into JSON or XML format;
[0030] Text parsing and segmentation: Parse text data, identify structured information, and segment it into logical blocks;
[0031] Information extraction and annotation: Use natural language processing technology to extract key entity information and annotate key concepts and topics in the text;
[0032] Data vectorization: Use a pre-trained language model to convert text blocks into vector representations and store them in a vector database;
[0033] Data quality assessment and optimization: Perform quality assessment on the preprocessed knowledge base data and optimize the data based on the assessment results.
[0034] As a possible implementation, further, the step of using a distributed vector database to store the pre-processed text data and its vectorized representation includes:
[0035] Raw text storage: The pre-processed raw text is stored in a structured form in a vector database. Each record contains metadata information such as text content, source, subject classification, creation time, and update time.
[0036] Vectorized data storage: The high-dimensional vectors of the text vectorized are stored in a vector database and associated with the original text records;
[0037] Data addition, deletion, modification and query: Supports addition, deletion, modification and query operations on knowledge base data, and achieves efficient data management by defining indexes and data structures.
[0038] As a possible implementation, the steps of receiving a question input by a user, understanding and rewriting the question, searching from a knowledge base using vectorized coding and similarity calculation, and optimizing the search results using a reranking model further include:
[0039] Question understanding and rephrasing: Analyze user-entered questions and generate multiple semantically similar question variants to improve the comprehensiveness and accuracy of retrieval;
[0040] Vectorized encoding: User questions and rephrased questions are converted into vector representations using a pre-trained vector model;
[0041] Similarity calculation and retrieval: Calculate the similarity between the question vector and all document vectors in the knowledge base, and retrieve the most relevant documents or text fragments;
[0042] Hybrid search: Combining vector search and traditional keyword search methods to improve the comprehensiveness and accuracy of search results;
[0043] Result Reranking: Use the reranking model to rerank the retrieved candidate documents to ensure that the most relevant and valuable documents are ranked first.
[0044] As a possible implementation, further, the steps of generating a natural language answer based on the retrieved background knowledge using the Deepseek-R1 model, optimizing and adjusting the answer, and outputting the answer to the user include:
[0045] Receiving user input: receiving dialogue question and answer requests input by the user through the user interface;
[0046] Question understanding and preprocessing: Perform natural language processing on user input questions to determine the intent, key entities, and concepts of the question;
[0047] Background knowledge retrieval: Convert the processed question into a vector representation and use vector retrieval technology to find relevant background knowledge in the knowledge base;
[0048] Background knowledge integration and understanding: Further process the retrieved background knowledge text to extract key information and knowledge points, and integrate them with user questions;
[0049] Generate answers: Generate natural language answers based on understanding the question and background knowledge;
[0050] Answer optimization and adjustment: Optimize and adjust the generated answer text to improve the quality and readability of the answer;
[0051] Output answer: Return the final optimized answer text to the user.
[0052] As a possible implementation, further, the steps of at least supporting integration with external systems via RESTful API and message queues and adapting to different technology stacks and application scenarios include:
[0053] RESTful API access: Supports integration with external systems via RESTful API. External systems send user questions via HTTP requests, and the system returns answers in JSON format.
[0054] Message queue access: supports integration with external systems through message queues, suitable for scenarios with high requirements for real-time data processing and large data traffic;
[0055] Programming language adaptation: Supports technology stacks for different programming languages such as Python and Java, and provides corresponding SDKs or client libraries;
[0056] Application scenario adaptation: supports customized configuration for different application scenarios such as intelligent customer service, intelligent writing, education, games, and government services.
[0057] A Deepseek-R1 conversational question answering system based on RAG, comprising:
[0058] Knowledge base preprocessing module: used to collect information from various data sources, convert the data into a unified format, perform text parsing, segmentation, information extraction and annotation, and finally vectorize the text data and store it in a vector database;
[0059] Data storage module: uses a distributed vector database to store pre-processed text data and its vectorized representation, supporting data addition, deletion, modification, and query operations;
[0060] Knowledge retrieval module: Receives user input questions, understands and rephrases them using natural language processing technology, retrieves relevant documents from the knowledge base using vectorized coding and similarity calculation, and optimizes the retrieval results using a re-ranking model;
[0061] Conversational Q&A module: Based on the retrieved background knowledge, it uses the Deepseek-R1 model to generate natural language answers, optimizes and adjusts the answers, and outputs them to the user;
[0062] System access and adaptation module: supports integration with external systems through RESTful API, message queues, etc., and adapts to different technology stacks and application scenarios.
[0063] The present invention adopts the above technical solution and has the following beneficial effects:
[0064] 1. Improve the accuracy and verifiability of answers
[0065] By using RAG technology to retrieve relevant information from a large-scale knowledge base, the generated answers are ensured to have factual basis, avoiding the "hallucination" phenomenon common in generative models (i.e. generating content that seems reasonable but has no factual basis).
[0066] All generated answers can be traced back to the original document source, increasing the credibility and verifiability of the answers.
[0067] 2. Enhance the ability to understand complex contexts
[0068] The Deepseek-R1 model can deeply understand complex contexts and multi-round conversations, generate more natural and context-appropriate answers, and enhance the user-system interaction experience.
[0069] The system can handle complex questions involving multi-domain knowledge and provide comprehensive and accurate answers.
[0070] 3. Improve knowledge coverage and updating efficiency
[0071] The system can dynamically collect and update the knowledge base from a variety of data sources (such as text files, databases, web page content, etc.) to ensure the coverage and timeliness of knowledge.
[0072] Through real-time updates of the knowledge base, the system can answer the latest and complex questions and adapt to changing business needs.
[0073] 4. Improve system flexibility and scalability
[0074] The system adopts a modular design, supports multi-language processing tasks, and can quickly adapt to different application scenarios and field requirements.
[0075] It integrates with external systems through RESTful APIs, message queues, etc., and supports multiple technology stacks (such as Python, Java) and application scenarios (such as intelligent customer service, intelligent writing, education, games, government services, etc.). DETAILED DESCRIPTION
[0076] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below.
[0077] Example 1
[0078] A Deepseek-R1 conversational question answering method based on RAG, comprising:
[0079] The system preprocesses the knowledge base, collecting information from data sources and converting it into a unified format. It then performs text parsing, segmentation, information extraction, and annotation, vectorizing the text data and storing it in a vector database. A distributed vector database is used to store the preprocessed text data and its vectorized representation. The system receives user-entered questions, understands and rephrases them, searches the knowledge base using vectorized encoding and similarity calculations, and optimizes the search results using a re-ranking model. Based on the retrieved background knowledge, the Deepseek-R1 model is used to generate natural language answers, which are then optimized and adjusted and output to the user. It supports integration with external systems via, at a minimum, RESTful APIs and message queues, adapting to different technology stacks and application scenarios.
[0080] Among them, knowledge base preprocessing includes:
[0081] Data collection and integration: Collect information from various data sources such as text files, databases, web pages, and convert the data into JSON or XML format;
[0082] Text parsing and segmentation: Parse text data, identify structured information, and segment it into logical blocks;
[0083] Information extraction and annotation: Use natural language processing technology to extract key entity information and annotate key concepts and topics in the text;
[0084] Data vectorization: Use a pre-trained language model to convert text blocks into vector representations and store them in a vector database;
[0085] Data quality assessment and optimization: Perform quality assessment on the preprocessed knowledge base data and optimize the data based on the assessment results.
[0086] The steps of using a distributed vector database to store pre-processed text data and its vectorized representation include:
[0087] Raw text storage: The pre-processed raw text is stored in a structured form in a vector database. Each record contains metadata information such as text content, source, subject classification, creation time, and update time.
[0088] Vectorized data storage: The high-dimensional vectors of the text vectorized are stored in a vector database and associated with the original text records;
[0089] Data addition, deletion, modification and query: Supports addition, deletion, modification and query operations on knowledge base data, and achieves efficient data management by defining indexes and data structures.
[0090] The steps of receiving user input questions, understanding and rewriting the questions, searching from the knowledge base using vectorized coding and similarity calculation, and optimizing the search results using a reranking model include:
[0091] Question understanding and rephrasing: Analyze user-entered questions and generate multiple semantically similar question variants to improve the comprehensiveness and accuracy of retrieval;
[0092] Vectorized encoding: User questions and rephrased questions are converted into vector representations using a pre-trained vector model;
[0093] Similarity calculation and retrieval: Calculate the similarity between the question vector and all document vectors in the knowledge base, and retrieve the most relevant documents or text fragments;
[0094] Hybrid search: Combining vector search and traditional keyword search methods to improve the comprehensiveness and accuracy of search results;
[0095] Result Reranking: Use the reranking model to rerank the retrieved candidate documents to ensure that the most relevant and valuable documents are ranked first.
[0096] Based on the retrieved background knowledge, the Deepseek-R1 model is used to generate natural language answers. After optimization and adjustment, the answers are output to the user. The steps include:
[0097] Receiving user input: receiving dialogue question and answer requests input by the user through the user interface;
[0098] Question understanding and preprocessing: Perform natural language processing on user input questions to determine the intent, key entities, and concepts of the question;
[0099] Background knowledge retrieval: Convert the processed question into a vector representation and use vector retrieval technology to find relevant background knowledge in the knowledge base;
[0100] Background knowledge integration and understanding: Further process the retrieved background knowledge text to extract key information and knowledge points, and integrate them with user questions;
[0101] Generate answers: Generate natural language answers based on understanding the question and background knowledge;
[0102] Answer optimization and adjustment: Optimize and adjust the generated answer text to improve the quality and readability of the answer;
[0103] Output answer: Return the final optimized answer text to the user.
[0104] At least support integration with external systems through RESTful APIs and message queues. Steps for adapting to different technology stacks and application scenarios include:
[0105] RESTful API access: Supports integration with external systems via RESTful API. External systems send user questions via HTTP requests, and the system returns answers in JSON format.
[0106] Message queue access: supports integration with external systems through message queues, suitable for scenarios with high requirements for real-time data processing and large data traffic;
[0107] Programming language adaptation: Supports technology stacks for different programming languages such as Python and Java, and provides corresponding SDKs or client libraries;
[0108] Application scenario adaptation: supports customized configuration for different application scenarios such as intelligent customer service, intelligent writing, education, games, and government services.
[0109] A Deepseek-R1 conversational question answering system based on RAG, comprising:
[0110] Knowledge base preprocessing module: used to collect information from various data sources, convert the data into a unified format, perform text parsing, segmentation, information extraction and annotation, and finally vectorize the text data and store it in a vector database;
[0111] Data storage module: uses a distributed vector database to store pre-processed text data and its vectorized representation, supporting data addition, deletion, modification, and query operations;
[0112] Knowledge retrieval module: Receives user input questions, understands and rephrases them using natural language processing technology, retrieves relevant documents from the knowledge base using vectorized coding and similarity calculation, and optimizes the retrieval results using a re-ranking model;
[0113] Conversational Q&A module: Based on the retrieved background knowledge, it uses the Deepseek-R1 model to generate natural language answers, optimizes and adjusts the answers, and outputs them to the user;
[0114] System access and adaptation module: supports integration with external systems through RESTful API, message queues, etc., and adapts to different technology stacks and application scenarios.
[0115] Example 2
[0116] A Deepseek-R1 dialogue question answering system based on RAG mainly includes the following steps: knowledge base preprocessing, data storage, knowledge retrieval, and large model answering based on background knowledge.
[0117] 1.1 Knowledge Base Preprocessing
[0118] The following is a detailed description of the knowledge base preprocessing steps:
[0119] 1.1.1 Data Collection and Integration
[0120] 1. Collect information from a variety of data sources, including but not limited to text files (such as PDFs and Word documents), databases, and web pages. These data sources cover a wide range of domain knowledge related to the system's question-answering topic. For example, if the question-answering system is about medical knowledge, the data sources may include medical textbooks, clinical research papers, and medical databases.
[0121] 2. Use data import tools to convert the collected data into a unified format, such as JSON or XML, for subsequent processing. During this process, perform preliminary data cleaning to remove obvious format errors, duplicate data, and irrelevant content.
[0122] 1.1.2 Text parsing and segmentation
[0123] 1. Parse the collected text data to identify structured information in the text, such as titles, paragraphs, lists, etc. For example, for an academic paper containing multiple chapters, the parsing process can identify the title of each chapter and the corresponding text content.
[0124] 2. Divide the parsed text into logical blocks. The size of the blocks can be determined based on actual needs and the characteristics of the knowledge. For long technical documents, blocks can be divided into paragraphs or topic sections. For question-and-answer content, each question and its corresponding answer can be considered a block. This allows for more efficient information processing and matching during subsequent knowledge retrieval.
[0125] 1.1.3 Information Extraction and Annotation
[0126] Natural language processing techniques, such as named entity recognition (NER), are used to extract key entity information from text blocks, including people, places, organizations, dates, etc. For example, when processing a text about a historical event, entities such as the time and place of the event, the main people and organizations involved, etc. can be extracted.
[0127] Annotate key concepts and themes within a text. You can use predefined ontologies or classification systems to annotate the categories to which a text belongs. For example, in a scientific knowledge base, you can annotate whether a text is about topics such as artificial intelligence, biotechnology, or new energy. You can also annotate important viewpoints and conclusions within a text, making it easier to quickly locate relevant information during the question-and-answer process.
[0128] 1.1.4 Data Vectorization (for Retrieval)
[0129] To achieve efficient knowledge retrieval, text blocks or knowledge units are converted into vector representations. A pre-trained language model can be used to encode the text, generating fixed-dimensional vectors. These vectors capture the semantic information of the text, placing similar text close together in the vector space. The generated vectors are stored in the Milvus vector database. This allows rapid retrieval of relevant knowledge content during question-answering by calculating the similarity between the question text vector and the vectors in the knowledge base.
[0130] 1.1.5 Data Quality Assessment and Optimization
[0131] Perform a quality assessment on the preprocessed knowledge base data. Evaluation metrics can include data completeness, accuracy, and consistency. For example, check whether there is missing key information in the knowledge base, whether the annotations are correct, and whether the entity relationships are reasonable.
[0132] Based on the evaluation results, data is optimized. This may include supplementing missing data, correcting incorrect annotations, and adjusting relationships in the knowledge graph. Furthermore, pre-processing steps such as data segmentation and vectorization methods can be adjusted based on actual Q&A needs and feedback to improve the quality of the knowledge base and the performance of the Q&A system.
[0133] 1.2 Data Storage
[0134] This knowledge base uses the Milvus database as its data storage solution, which efficiently stores and manages large amounts of vectorized data. Milvus supports a variety of data types, including vector data and associated metadata, meeting the storage needs of both raw text and vectorized data. It also offers powerful retrieval capabilities, providing strong support for subsequent knowledge retrieval and question-and-answer generation. The Milvus database's distributed architecture enables horizontal data scalability. As the knowledge base grows in size, storage and retrieval performance can be easily improved by adding nodes, ensuring system stability and efficiency.
[0135] 1.2.1 Original text storage:
[0136] The preprocessed raw text is stored in a structured format in the Milvus database. Each text block or knowledge unit corresponds to a record containing metadata such as text content, source, subject classification, creation time, and update time. This metadata helps manage and organize knowledge base content and facilitates subsequent query and update operations.
[0137] 1.2.2 Vectorized Data Storage
[0138] After using a pre-trained language model to convert raw text into high-dimensional vectors, these vectors are stored in the Milvus database. Each vector is associated with the corresponding raw text record. By creating an index in Milvus, vector similarity searches can be performed quickly, enabling efficient knowledge retrieval.
[0139] For example, for a user's question vector, Milvus can quickly retrieve the most similar vector in the knowledge base, and then find the corresponding text record to provide background knowledge support for question and answer generation.
[0140] 1.2.3 Implementation of data addition, deletion, modification and query functions
[0141] In the Milvus database, by defining appropriate indexes and data structures, you can easily implement operations such as adding, deleting, modifying, and querying knowledge base data. When adding new data, the original text and its vector are directly inserted into the database; when deleting data, the corresponding record is deleted based on the corresponding unique identifier (such as the primary key ID); when modifying data, you can update the original text content or the corresponding vector information; when querying data, you can query by text content, metadata, or vector similarity in a variety of ways to meet the needs of different scenarios.
[0142] For example, through Milvus's query interface, you can query several knowledge records with the highest similarity based on the user's question vector, providing the question-answering system with accurate answer basis; you can also query knowledge in specific fields based on text topic classification, making it easier for users to obtain professional information.
[0143] 1.3 Knowledge Retrieval
[0144] The specific process of knowledge retrieval is as follows:
[0145] 1.3.1 Question Understanding and Rewriting
[0146] Question analysis: The system first analyzes the question input by the user to understand its semantics and intent. This may involve natural language processing technologies such as lexical analysis, syntactic analysis, and semantic role labeling to determine the key entities, concepts, and relationships in the question. Question rewriting: In order to improve the comprehensiveness and accuracy of the retrieval, the system will generate multiple question variants that are semantically similar to the original question but with different expressions based on its understanding of the question. For example, if a user asks "What is the development history of artificial intelligence?", the system may rewrite it as "How did artificial intelligence develop?" "What are the development stages of artificial intelligence?" etc. These rewritten questions can cover knowledge related to the original question from different angles, increasing the possibility of retrieving useful information.
[0147] 1.3.2 Knowledge Base Search
[0148] Vectorized encoding: The user's original question and the rephrased question are converted into vector representations using a pre-trained vector model. At the same time, documents or text snippets in the knowledge base are also pre-encoded into vectors and stored in the vector database Milvus.
[0149] Similarity calculation and retrieval: Calculate the similarity between the question vector and all document vectors in the knowledge base. Based on the similarity scores, retrieve a certain number of documents or text snippets that are most relevant to the question from the knowledge base as candidate answers. For example, you can retrieve the top 10 document snippets with the highest similarity to the question.
[0150] Hybrid search: In complex scenarios, vector search and traditional keyword search methods may be combined to leverage the strengths of both. Vector search captures semantic similarity, while keyword search can quickly locate documents containing specific vocabulary, improving the comprehensiveness and accuracy of search results.
[0151] 1.3.3 Results Rearrangement
[0152] Relevance Assessment: This involves evaluating the relevance of retrieved candidate documents or text snippets, analyzing their match with the user's question in greater detail. This may involve more complex semantic matching algorithms that consider factors such as semantic consistency and information coverage between the question and document.
[0153] Reranking Model: This model reranks candidate documents. Based on the semantic match between the user question and the candidate documents, the reranking model calculates a relevance score for each document and sorts the documents from high to low based on the relevance score. This ensures that the most relevant and valuable documents are ranked first, thereby improving the quality of search results and providing more accurate background knowledge for subsequent answer generation.
[0154] 1.4 Large Model Conducts Conversational Questions and Answers Based on Background Knowledge
[0155] The following is a detailed description of the steps for the large model Deepseek-R1 to conduct conversational question answering based on background knowledge:
[0156] 1.4.1 Receiving User Input
[0157] The system receives a dialogue question-and-answer request input by the user through a user interface (such as a web page, application, etc.). The request is usually presented in the form of natural language text, for example, the user asks "Please explain the basic principles of relativity."
[0158] Problem understanding and preprocessing
[0159] Natural language processing (NLP) is performed on user-entered questions, including lexical analysis, syntactic analysis, and semantic understanding, to determine the question's intent, key entities, and concepts. For example, analysis can identify "relativity" as the core topic of the question and "basic principles" as the specific content the user wants to understand.
[0160] Questions may be standardized, such as expanding abbreviations and correcting spelling errors, to improve the accuracy of subsequent searches and answers.
[0161] 1.4.2 Background Knowledge Retrieval
[0162] The processed questions are converted into vector representations, and vector retrieval technology is used to search for background knowledge related to the questions in the knowledge base. The knowledge base stores a large amount of pre-processed and vectorized text data, including knowledge and information in various fields.
[0163] The similarity between the question vector and the vector of each document or text fragment in the knowledge base is calculated. Based on the similarity score, a certain number of the most relevant background knowledge texts are filtered out. For example, for questions related to relativity, texts containing basic relativity concepts, formula derivations, and experimental verifications may be retrieved.
[0164] 1.4.3 Background Knowledge Integration and Understanding
[0165] Further processing and understanding of the retrieved background knowledge text is performed to extract key information and key knowledge points. This may involve techniques such as text summarization and information extraction to ensure that the model accurately grasps the core content of the background knowledge. Integrating background knowledge with user questions allows the model to better understand the context and background of the question, laying the foundation for generating accurate responses. For example, combining the basic principles of relativity with the user's question can clarify the content and key points that need to be explained.
[0166] 1.4.4 Generating Answers
[0167] Based on its understanding of the question and background knowledge, the Deepseek-R1 model begins generating response text. Leveraging its powerful language generation capabilities, the model follows the grammatical rules and semantic logic of natural language to organize language and answer the user's question.
[0168] When generating responses, the model references key information and key points in the background knowledge to ensure accuracy and reliability. For example, when answering questions about the basic principles of relativity, the model cites core concepts and formulas from the theory and provides detailed explanations and illustrations.
[0169] 1.4.5 Answer optimization and adjustment
[0170] Optimize and adjust the generated answer text to improve its quality and readability. This may include optimizing the answer's language style, expression, logical structure, and other aspects to better suit the user's reading habits and comprehension abilities. Further adjustments and improvements may be made to the answer based on user feedback or the system's evaluation mechanisms. For example, if a user expresses doubt or dissatisfaction with a certain part of the answer, the system can regenerate or provide additional explanation for that part.
[0171] 1.4.6 Output Answer
[0172] The final optimized answer text is returned to the user through the user interface, completing the conversational question-and-answer process. The user can obtain the required information based on the answer content and continue to ask questions or raise new questions as needed. The system will repeat the above process to answer.
[0173] Example 3
[0174] The following is a specific implementation example of Deepseek conversational question answering based on RAG based on internal enterprise knowledge:
[0175] Scenario description: During project development, an employee of a company encounters a problem regarding the use of the company's internal development framework and needs to acquire relevant knowledge to solve the current problem.
[0176] User input: "How can we achieve efficient communication between modules in our company's internal development framework?"
[0177] System processing flow:
[0178] a. Question understanding and rephrasing
[0179] The system analyzes the user's input question and identifies key information such as "company internal development framework" and "efficient communication between modules." It then generates multiple rewritten questions, such as "What are the communication methods for modules within the company's internal development framework?" and "How to optimize the efficiency of module communication within the company's internal development framework?"
[0180] b. Knowledge base retrieval
[0181] The original question and the rewritten question are converted into vector representations using a vectorization model. A search is performed within the company's internal knowledge base (stored in the Milvus database), and the similarity between the question vector and the document vectors in the knowledge base is calculated. Retrieved documents related to the question include "Guidelines for Internal Development Framework Module Communication" and "Practical Case Studies for Optimizing Internal Development Framework Module Communication."
[0182] c. Rearrange the results
[0183] The retrieved documents are evaluated for relevance, taking into account factors such as semantic consistency between the document and the question, information coverage, etc. The documents are re-ranked using a re-ranking model, with the most relevant documents at the top.
[0184] d. Background knowledge integration and understanding
[0185] Extract key information from the sorted documents, such as module communication interface definitions, communication protocols, optimization strategies, etc. This key information is integrated with user questions to enable the Deepseek-R1 model to understand the background knowledge for efficient communication between modules.
[0186] e. Generate answers
[0187] Based on the integrated background knowledge, the Deepseek-R1 model generates answer text, introducing the methods for achieving efficient communication between modules in the company's internal development framework, including recommended communication interfaces, communication protocols to be followed, and some optimization techniques.
[0188] f. Finally generate the reply
[0189] In our internal development framework, efficient inter-module communication can be achieved through the following methods: First, use the standard communication interfaces provided by the framework, such as [Interface Name], which are optimized to ensure fast data transmission. Second, adhere to our established communication protocols, such as [Protocol Name], which specify data formats and transmission rules, helping to reduce communication errors and improve efficiency. Additionally, consider adopting asynchronous communication mechanisms, which, where appropriate, can avoid inter-module blocking and further improve communication performance. In practical applications, we have some optimization cases, such as [Case Name], which you can refer to to optimize your module communication.
[0190] Example 4
[0191] The following is an example of a graph query based on RAG-based Deepseek conversational question answering based on internal enterprise knowledge:
[0192] Scenario description: An employee in the company's marketing department needs to understand the company's sales data for each quarter of the past year in order to prepare a market analysis report. He wants to quickly obtain relevant chart information through a conversational question-and-answer system.
[0193] User input: "Please show me a chart of the company's sales data for each quarter last year."
[0194] System processing flow:
[0195] a. Question understanding and rephrasing
[0196] The system analyzes the user input and identifies the key information, such as "Company's sales data chart for each quarter last year." It then generates rephrased questions, such as "Query the company's quarterly sales data chart for last year" or "Get a visualization chart of the company's sales data for each quarter last year."
[0197] b. Knowledge base retrieval
[0198] Vectorize the original and rewritten questions. Search the company's internal knowledge base, which contains various documents and data reports, including chart files related to sales data. Retrieve documents related to the question, such as "Last Year's Quarterly Sales Report" and "Collection of Sales Data Visualization Charts." These documents may contain the required charts.
[0199] c. Rearrange the results
[0200] Retrieved documents are evaluated for relevance, taking into account factors such as how well the document matches the question, the clarity and accuracy of the diagrams, etc. A re-ranking model is used to rank the documents, placing those most likely to contain accurate and clear diagrams at the top.
[0201] d. Background knowledge integration and understanding
[0202] Extract information containing sales data charts from the sorted documents and understand the data content, time range, data indicators, etc. By integrating this chart information with the user's question, the Deepseek-R1 model can clearly understand that the user needs sales data charts for each quarter of last year.
[0203] e. Generate answers
[0204] Based on the integrated background knowledge, the Deepseek-R1 model generates a response text, informing the user that a relevant chart has been found and describing the chart's general characteristics, such as chart type (bar chart, line chart, etc.) and data trends. Furthermore, the system can interact with the user interface to directly display the chart or provide a link to the chart file for easy viewing and use.
[0205] f. Finally, generate a response: "Hello, I've found a chart showing the company's sales data for each quarter of last year. This is a bar chart that clearly shows the changes in sales data for the four quarters of last year. As you can see, sales in the first quarter were [X1] million yuan, increased to [X2] million yuan in the second quarter, declined slightly to [X3] million yuan in the third quarter, and rebounded to [X4] million yuan in the fourth quarter. You can view the chart at the following link: [chart link], and I hope it will be helpful in preparing your market analysis report."
[0206] Deepseek's RAG-based conversational question answering has the following technical advantages:
[0207] a. Knowledge Richness: The system can retrieve relevant information from large-scale knowledge bases, ensuring that the generated answers have high knowledge coverage. It can also access private domain knowledge bases, enabling it to generate accurate answers even when addressing specialized domain questions.
[0208] b. Improved accuracy: By providing relevant context, it effectively reduces the phenomenon of model "hallucination", that is, generating content that seems reasonable but has no factual basis.
[0209] c. Flexibility and scalability: The generation module can dynamically generate answers based on the retrieved information, adapting to different questions and scenarios. It can be flexibly applied to different fields and tasks, and can adapt to new application scenarios by simply replacing or expanding the search library.
[0210] d. Verifiability: All answers can be traced back to the original document source, increasing the credibility of the answers.
[0211] e. Cost-effectiveness: There is no need to continuously retrain the model, reducing time and resource costs.
[0212] f. Domain adaptability: By updating the document library, the RAG system can quickly adapt to the needs of new fields, demonstrating strong domain adaptability.
[0213] g. Efficient retrieval algorithm: DeepSeek uses a retrieval algorithm based on deep learning, which can quickly and accurately retrieve relevant information from large-scale knowledge bases.
[0214] h. Powerful generative model: DeepSeek integrates an advanced generative model that can generate fluent and accurate answers.
[0215] i. Flexible architecture design: DeepSeek's modular design makes the system easy to expand and customize, and can adapt to different application scenarios.
[0216] Multi-language support: The DeepSeek-R1 model has multi-language support capabilities and demonstrates strong capabilities in multiple language processing tasks, providing a strong guarantee for building a multi-language RAG system.
[0217] The above are embodiments of the present invention. For ordinary technicians in this field, based on the teachings of the present invention, all equivalent changes, modifications, substitutions and variations made within the scope of the patent application of the present invention without departing from the principles and spirit of the present invention should be covered by the scope of the present invention.
Claims
1. A Deepseek-R1 dialogue question answering method based on RAG, characterized in that: The following steps are involved: Perform knowledge base preprocessing, collect information from data sources, convert it into a unified format, perform text parsing, segmentation, information extraction and annotation, vectorize text data and store it in a vector database; Use a distributed vector database to store pre-processed text data and its vectorized representation; Receive user input questions, understand and rewrite the questions, use vectorized coding and similarity calculation to search from the knowledge base, and optimize the search results through the re-ranking model; Based on the retrieved background knowledge, the Deepseek-R1 model is used to generate natural language answers, which are then optimized and adjusted before being output to the user.
2. A RAG-based Deepseek-R1 dialogue question-answering method according to claim 1, characterized in that: Also includes: At least support integration with external systems through RESTful API and message queue, and adapt to different technology stacks and application scenarios.
3. A RAG-based Deepseek-R1 dialogue question-answering method according to claim 1, characterized in that: The knowledge base preprocessing includes: Data collection and integration: Collect information from various data sources such as text files, databases, web pages, and convert the data into JSON or XML format; Text parsing and segmentation: Parse text data, identify structured information, and segment it into logical blocks; Information extraction and annotation: Use natural language processing technology to extract key entity information and annotate key concepts and topics in the text; Data vectorization: Use a pre-trained language model to convert text blocks into vector representations and store them in a vector database; Data quality assessment and optimization: Perform quality assessment on the preprocessed knowledge base data and optimize the data based on the assessment results.
4. A Deepseek-R1 dialogue question-answering method based on RAG according to claim 1, characterized in that: The steps of using a distributed vector database to store pre-processed text data and its vectorized representation include: Raw text storage: The pre-processed raw text is stored in a structured form in a vector database. Each record contains metadata information such as text content, source, subject classification, creation time, and update time. Vectorized data storage: The high-dimensional vectors of the text vectorized are stored in a vector database and associated with the original text records; Data addition, deletion, modification and query: Supports addition, deletion, modification and query operations on knowledge base data, and achieves efficient data management by defining indexes and data structures.
5. A RAG-based Deepseek-R1 dialogue question-answering method according to claim 1, characterized in that: The steps of receiving a question input by a user, understanding and rewriting the question, searching from a knowledge base using vectorized coding and similarity calculation, and optimizing the search results using a reranking model include: Question understanding and rephrasing: Analyze user-entered questions and generate multiple semantically similar question variants to improve the comprehensiveness and accuracy of retrieval; Vectorized encoding: User questions and rephrased questions are converted into vector representations using a pre-trained vector model; Similarity calculation and retrieval: Calculate the similarity between the question vector and all document vectors in the knowledge base, and retrieve the most relevant documents or text fragments; Hybrid search: Combining vector search and traditional keyword search methods to improve the comprehensiveness and accuracy of search results; Result Reranking: Use the reranking model to rerank the retrieved candidate documents to ensure that the most relevant and valuable documents are ranked first.
6. A RAG-based Deepseek-R1 dialogue question-answering method according to claim 1, characterized in that: The steps of generating a natural language answer based on the retrieved background knowledge using the Deepseek-R1 model and outputting it to the user after optimization and adjustment include: Receiving user input: receiving dialogue question and answer requests input by the user through the user interface; Question understanding and preprocessing: Perform natural language processing on user input questions to determine the intent, key entities, and concepts of the question; Background knowledge retrieval: Convert the processed question into a vector representation and use vector retrieval technology to find relevant background knowledge in the knowledge base; Background knowledge integration and understanding: Further process the retrieved background knowledge text to extract key information and knowledge points, and integrate them with user questions; Generate answers: Generate natural language answers based on understanding the question and background knowledge; Answer optimization and adjustment: Optimize and adjust the generated answer text to improve the quality and readability of the answer; Output answer: Return the final optimized answer text to the user.
7. The RAG-based Deepseek-R1 dialogue question-answering method according to claim 2, wherein: The steps for supporting integration with external systems through at least RESTful APIs and message queues, and adapting to different technology stacks and application scenarios include: RESTful API access: Supports integration with external systems through RESTful API. External systems send user questions through HTTP requests, and the system returns answers in JSON format. Message queue access: supports integration with external systems through message queues, suitable for scenarios with high requirements for real-time data processing and large data traffic; Programming language adaptation: Supports technology stacks for different programming languages such as Python and Java, and provides corresponding SDKs or client libraries; Application scenario adaptation: supports customized configuration for different application scenarios such as intelligent customer service, intelligent writing, education, games, and government services.
8. A Deepseek-R1 dialogue question answering system based on RAG, characterized in that: include: Knowledge base preprocessing module: used to collect information from various data sources, convert the data into a unified format, perform text parsing, segmentation, information extraction and annotation, and finally vectorize the text data and store it in a vector database; Data storage module: uses a distributed vector database to store pre-processed text data and its vectorized representation, supporting data addition, deletion, modification, and query operations; Knowledge retrieval module: Receives user input questions, understands and rephrases them using natural language processing technology, retrieves relevant documents from the knowledge base using vectorized coding and similarity calculation, and optimizes the retrieval results using a re-ranking model; Conversational Q&A module: Based on the retrieved background knowledge, it uses the Deepseek-R1 model to generate natural language answers, optimizes and adjusts the answers, and outputs them to the user; System access and adaptation module: supports integration with external systems through RESTful API, message queues, etc., and adapts to different technology stacks and application scenarios.
Citation Information
Cited By
Data set management platform
CN121478853A
Information query method and device based on large model and terminal equipment
CN121561053A
Information query method and device based on large model and terminal equipment
CN121561053B
Knowledge base correction method, electronic equipment and computer readable storage medium
CN121614062A