RAG mixed retrieval method and device for improving accuracy of large language model
By combining text retrieval and knowledge graph retrieval strategies and dynamically adjusting weighted fusion, the generation accuracy of large language models is improved, solving the problems of inaccurate information and insufficient flexibility in existing technologies, and is particularly suitable for complex information processing.
Patent Information
- Application Number
- CN202511025702.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-24
- Publication Date
- 2025-10-28
- Estimated Expiration
- Not applicable · inactive patent
Smart Images

Figure CN120849631A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of RAG retrieval, and in particular to a hybrid RAG retrieval method and apparatus for improving the accuracy of large language models. Background Technology
[0002] While large language models have demonstrated excellent performance across various tasks, they still face challenges in practical applications, including inaccurate generation results or discrepancies between the generated output and actual needs. This is particularly true when the input text contains ambiguous, unknown, or incomplete information, which often jeopardizes the model's accuracy. To improve the generation quality and accuracy of large language models, researchers have proposed several enhancement methods based on external knowledge bases, among which Retrieval-Enhanced Generation (RAG) is considered a relatively effective technique.
[0003] Traditional RAG methods are typically enhanced through a single information retrieval model or a fixed retrieval strategy, but they fail to fully integrate multi-source and dynamic retrieval information, resulting in inaccurate retrieval information or a lack of flexibility.
[0004] Therefore, a hybrid RAG retrieval method and apparatus to improve the accuracy of large language models is proposed to solve the above problems. Summary of the Invention
[0005] To overcome the shortcomings of existing technologies, the present invention aims to provide a RAG hybrid retrieval method and apparatus to improve the accuracy of large language models. By adopting a multi-level hybrid retrieval strategy, it organically combines traditional text retrieval with knowledge graph retrieval, and combines it with a model adaptive adjustment mechanism, thereby improving the accuracy and response quality of large language models when processing complex information.
[0006] The above technical objectives of the present invention are achieved through the following technical solutions: A RAG hybrid retrieval method and apparatus for improving the accuracy of large language models includes receiving a natural language query input by a user and receiving query text to be processed. The query text is preprocessed to extract key information and generate a preliminary search request. Based on the preliminary search request, information retrieval is performed using both a text retrieval model and a knowledge graph retrieval model to obtain the first type of search information and the second type of search information, respectively. The text search results and knowledge graph search results are merged, and the final search results are obtained through a weighting strategy. The fused search results are used as input to the generative model, which then generates accurate output text. Post-process the generated text and output the final result.
[0007] Furthermore, the text retrieval model is a traditional retrieval model based on TF-IDF or Word2Vec.
[0008] Furthermore, the knowledge graph retrieval model is an entity relationship graph retrieval model based on graph neural networks.
[0009] Furthermore, the weighting strategy is dynamically adjusted based on the contextual information of the query text.
[0010] Furthermore, the preprocessing steps include natural language segmentation, part-of-speech tagging, named entity recognition, and syntactic analysis.
[0011] Furthermore, the knowledge graph includes a general knowledge graph, a domain knowledge graph, or a user-customized knowledge graph, and the graph supports dynamic expansion.
[0012] According to an embodiment of this application, a retrieval device is provided, including at least one computer device, the computer device being configured with at least one processor and a memory; The computer device is equipped with a preprocessing module, a retrieval module, a fusion module, a generation module, a post-processing module, and an output module; The preprocessing module is used for word segmentation and entity recognition; the fusion module is used for weighted fusion of retrieval results; the generation module is used for generating output text; the postprocessing module is used for format adjustment; and the output module is used to return the generated results. The memory is used to store one or more programs; When the one or more programs are executed by the at least one processor, the RAG hybrid retrieval method for improving the accuracy of large language models is implemented.
[0013] Furthermore, it contains a computer program, which, when executed, implements the RAG hybrid retrieval method to improve the accuracy of large language models.
[0014] In summary, the present invention has the following beneficial effects: 1. By combining different types of information sources through a hybrid retrieval strategy, the accuracy of the model is improved. The dynamic weighted fusion strategy enables different types of retrieval results to be adaptively adjusted according to contextual information, thereby ensuring the accuracy and relevance of the generated results.
[0015] 2. Improved the response quality of large language models when processing complex information and fuzzy inputs, especially suitable for tasks that require the integration of external knowledge. Attached Figure Description
[0016] Figure 1This is a flowchart of a method and apparatus for improving the accuracy of large language models, provided in an embodiment of the present invention. Figure 2 This is a schematic diagram of a RAG hybrid retrieval method and device for improving the accuracy of large language models, provided by an embodiment of the present invention. Detailed Implementation
[0017] The present invention will be further described in detail below with reference to the accompanying drawings.
[0018] Identical parts are indicated by the same reference numerals. It should be noted that the terms "front," "rear," "left," "right," "up," and "down" used in the following description refer to directions in the accompanying drawings, while the terms "bottom surface," "top surface," "inner," and "outer" refer to directions toward or away from the geometric center of a specific part, respectively.
[0019] First embodiment; Reference Figure 1-2 As shown, this is a preferred embodiment of the RAG hybrid retrieval method and apparatus for improving the accuracy of large language models, including receiving a natural language query input by a user and receiving a query text to be processed. The query text is preprocessed to extract key information and generate a preliminary search request. Based on the preliminary search request, information retrieval is performed using both a text retrieval model and a knowledge graph retrieval model to obtain the first type of search information and the second type of search information, respectively. The text search results and knowledge graph search results are merged, and the final search results are obtained through a weighting strategy. The fused search results are used as input to the generative model, which then generates accurate output text. Post-process the generated text and output the final result.
[0020] In this embodiment, a hybrid retrieval strategy combines different types of information sources, improving the accuracy of the model. The dynamic weighted fusion strategy enables different types of retrieval results to be adaptively adjusted according to contextual information, thereby ensuring the accuracy and relevance of the generated results.
[0021] Furthermore, it improves the response quality of large language models when processing complex information and fuzzy inputs, making them particularly suitable for tasks that require the integration of external knowledge. Second embodiment; Reference Figure 1-2 As shown, the text retrieval model is a traditional retrieval model based on TF-IDF or Word2Vec.
[0022] In this embodiment, the text retrieval model includes at least one retrieval method based on TF-IDF, BM25, or DenseRetriever.
[0023] Third embodiment; Reference Figure 1-2 As shown, the knowledge graph retrieval model is an entity relationship graph retrieval model based on graph neural networks.
[0024] In this embodiment, the knowledge graph retrieval model obtains structured knowledge nodes and attribute values related to the query semantics through entity linking, subgraph traversal, or graph neural network (GNN).
[0025] Fourth embodiment; Reference Figure 1-2 As shown, the weighting strategy is dynamically adjusted based on the contextual information of the query text.
[0026] In this embodiment, the dynamic weighting mechanism is based on the attention mechanism in the Transformer structure, semantic similarity score, entity confidence or user-defined domain weight factor.
[0027] Fifth embodiment; Reference Figure 1-2 As shown, the preprocessing steps include natural language segmentation, part-of-speech tagging, named entity recognition, and syntactic analysis.
[0028] In this embodiment, the language generation model is one of the large-scale pre-trained generative models of the T5, GPT, BART, or LLaMA class.
[0029] The preprocessing steps also include postprocessing steps that perform semantic detection and controllable output adjustment on the generated results to correct factual biases and linguistic errors.
[0030] Sixth embodiment; Reference Figure 1-2 As shown, knowledge graphs include general knowledge graphs, domain knowledge graphs, or user-customized knowledge graphs, and the graphs support dynamic expansion.
[0031] In this embodiment, the retrieval module is used to retrieve relevant content from the text corpus.
[0032] Seventh embodiment; Based on the same inventive concept, the present invention also provides at least one computer device, which is configured with at least one processor and memory; The computer equipment is equipped with a preprocessing module, a retrieval module, a fusion module, a generation module, a post-processing module, and an output module; The preprocessing module is used for word segmentation and entity recognition; the fusion module is used for weighted fusion of search results; the generation module is used to generate output text; the postprocessing module is used for format adjustment; and the output module is used to return the generated results. Memory, used to store one or more programs; A hybrid RAG retrieval method is implemented to improve the accuracy of large language models when one or more programs are executed by at least one processor.
[0033] In this embodiment, the computer device is used to receive the query text to be processed; the preprocessing module is used to perform preprocessing operations such as word segmentation, entity recognition, and part-of-speech tagging on the query text; the retrieval module includes a text retrieval model and a knowledge graph retrieval model, which are used to perform information retrieval respectively; the fusion module is used to perform weighted fusion of the two retrieval results; the generation module generates output text based on the retrieval results; the post-processing module is used to adjust the format of the generated text and correct errors; and the output module outputs the generated results to the computer device.
[0034] It should be noted that at least one computer device contains a computer program, which, when executed, implements the RAG hybrid retrieval method to improve the accuracy of large language models.
[0035] Specific implementation process: Step 1: Receive the query text to be processed, preprocess the query text, extract the key information, and generate a preliminary search request based on the key information; The second step is to retrieve information based on the initial search request, using both text retrieval and knowledge graph retrieval models. The text retrieval results and knowledge graph retrieval results are then fused together, and a weighted strategy is used to obtain the final search results. Step 3: Use the fused search results as input to the generative model, use the generative model to generate accurate output text, perform post-processing on the generated text, and output the final result.
[0036] The basic principles, main features, and advantages of the present invention are shown and described above. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are merely illustrative of the principles of the present invention. Various changes and modifications may be made to the present invention without departing from the spirit and scope of the present invention. Such changes and modifications are intended to fall within the scope of the present invention. The scope of protection claimed in the present invention is defined by the appended claims and their equivalents.
Claims
1. A RAG hybrid retrieval method for improving the accuracy of large language models, characterized in that: include: Receive natural language queries input by the user and receive query text to be processed; The query text is preprocessed to extract key information and generate a preliminary search request. Based on the preliminary search request, information retrieval is performed using both a text retrieval model and a knowledge graph retrieval model to obtain the first type of search information and the second type of search information, respectively. The text search results and knowledge graph search results are merged, and the final search results are obtained through a weighting strategy. The fused search results are used as input to the generative model, which then generates accurate output text. Post-process the generated text and output the final result.
2. The RAG hybrid retrieval method for improving the accuracy of large language models according to claim 1, characterized in that: The text retrieval model is a traditional retrieval model based on TF-IDF or Word2Vec.
3. The RAG hybrid retrieval method for improving the accuracy of large language models according to claim 1, characterized in that: The knowledge graph retrieval model is an entity relationship graph retrieval model based on graph neural networks.
4. The RAG hybrid retrieval method for improving the accuracy of large language models according to claim 1, characterized in that: The weighting strategy is dynamically adjusted based on the contextual information of the query text.
5. The RAG hybrid retrieval method for improving the accuracy of large language models according to claim 1, characterized in that: The preprocessing steps include natural language segmentation, part-of-speech tagging, named entity recognition, and syntactic analysis.
6. The RAG hybrid retrieval method for improving the accuracy of large language models according to claim 1 or 3, characterized in that: The knowledge graph includes general knowledge graphs, domain knowledge graphs, or user-customized knowledge graphs, and the graph supports dynamic expansion.
7. A retrieval device, characterized in that: It includes at least one computer device, said computer device being configured with at least one processor and memory; The computer device is equipped with a preprocessing module, a retrieval module, a fusion module, a generation module, a post-processing module, and an output module; The preprocessing module is used for word segmentation and entity recognition; the fusion module is used for weighted fusion of retrieval results; the generation module is used for generating output text; the postprocessing module is used for format adjustment; and the output module is used to return the generated results. The memory is used to store one or more programs; When the one or more programs are executed by the at least one processor, the RAG hybrid retrieval method for improving the accuracy of large language models as described in any one of claims 1 to 6 is implemented.
8. A retrieval device, characterized in that: It contains a computer program, which, when executed, implements the RAG hybrid retrieval method for improving the accuracy of large language models as described in any one of claims 1 to 7.