Retrieval enhancement generation method and system, computer equipment and storage medium

By segmenting the initial text and constructing a database, and combining vector and graph recall operations, the problem of inaccurate retrieval in multi-hop logic processing of large language models is solved, and more accurate and complete information generation is achieved.

CN121256017APending Publication Date: 2026-01-02XIAN YANGU TECHNOLOGY CO LTD

Patent Information

Application Number
CN202511458231.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-13
Publication Date
2026-01-02

AI Technical Summary

Technical Problem

Large language models lack domain knowledge and real-time information updates when processing specific domains or tasks, leading to problems such as generating inaccurate or fictitious information. Furthermore, common vector retrieval methods cannot effectively capture the information chain of multi-hop logic, resulting in incomplete or inaccurate retrieval.

Method used

By segmenting the initial text into multiple corpus blocks, constructing a vector database and a graph database, classifying and splitting the problem into sub-problems according to the complexity of the problem, and combining vector and graph recall operations, a large language model is used to handle multi-hop logic and generate accurate answers.

Benefits of technology

It improves the accuracy and completeness of retrieval, reduces the risk of generating illusions, and is able to better capture the contextual information of multi-hop logic, generating results that match the user's question.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121256017A_ABST
    Figure CN121256017A_ABST
Patent Text Reader

Abstract

The invention provides a retrieval enhancement generation method and system, computer equipment and a storage medium, and belongs to the field of retrieval enhancement generation, and the method comprises the following steps: obtaining an initial text block, and carrying out cutting operation on the initial text block to obtain a plurality of corpus blocks; respectively constructing a vector database and a graph database by using the plurality of corpus blocks; classifying the user questions according to complexity to obtain complexity categories of the user questions, selecting hyper-parameters for retrieval according to the complexity categories of the user questions, and splitting the user questions according to the hyper-parameters to obtain a plurality of sub-questions; performing vector recall operation and graph recall operation on the data in the vector database and the graph database respectively to obtain corpus blocks and knowledge triples related to the user question; and inputting the plurality of sub-questions, the corpus blocks related to the user question and the knowledge triple into a large language model to obtain a result matched with the user question.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of retrieval augmented generation, and particularly relates to a retrieval augmented generation method and system, a computer device and a storage medium. BACKGROUND

[0002] Although large language models have made significant achievements in natural language processing, they may have some limitations when dealing with specific domains or tasks, such as lack of domain knowledge, lack of real-time updated information or specialized knowledge, etc., which can easily lead to hallucination phenomenon, i.e., the model generates inaccurate or even fabricated information.

[0003] Using retrieval augmented generation technology can retrieve missing information from structured databases, thus solving the above problems, but since common retrieval augmented generation technologies mostly use vector retrieval methods, which cannot retrieve complete context for multi-hop logic contained in user questions, because multi-hop logic refers to questions that require crossing multiple information sources or relying on multiple reasoning steps to answer. For example, a question may require first obtaining information from one data source, then combining information from another data source for reasoning, or requiring multiple reasoning steps to arrive at the final answer. In this case, simple vector-based retrieval methods may not effectively capture these multi-hop information chains, resulting in incomplete or inaccurate retrieved information. SUMMARY

[0004] In order to overcome the deficiencies of the prior art, the present application provides a retrieval augmented generation method, comprising the following steps: An initial text block is obtained, and a chunking operation is performed on the initial text block to obtain a plurality of corpus blocks; a vector database and a graph database are constructed using the plurality of corpus blocks; The user question is classified according to complexity to obtain a user question complexity category, and the hyperparameters used for retrieval are selected according to the user question complexity category; the user question is split according to the hyperparameters to obtain a plurality of sub-questions; Vector recall operation and graph recall operation are performed on the data in the vector database and the graph database respectively to obtain corpus blocks and knowledge triples related to the user question; the plurality of sub-questions, corpus blocks and knowledge triples related to the user question are input into a large language model to obtain results matched with the user question.

[0005] Preferably, the plurality of corpus blocks are used to construct a vector database and a graph database respectively, specifically: the plurality of corpus blocks are embedded using an embedding model to obtain embedding vectors of each corpus block, and the embedding vectors of each corpus block are stored in a database to obtain a vector database; and the plurality of corpus blocks are subjected to entity recognition, entity relationship extraction and attribute extraction to obtain a knowledge graph corresponding to each corpus, and a graph database is constructed through the knowledge graph corresponding to each corpus.

[0006] Preferably, the vector recall operation and the graph recall operation are performed on the data in the vector database and the graph database respectively, including the following steps: The embedding model is used to perform embedding operation on the user question to obtain an embedding vector of the user question; The similarity of the embedding vector of the user question and the embedding vector of each corpus block in the vector database is calculated, and the similarity of the embedding vector of the user question and the embedding vector of each node in the graph database is calculated, and the embedding vectors of the top M corpus blocks and the embedding vectors of the nodes with the highest similarity are selected as the corpus blocks and knowledge triples related to the user question.

[0007] Preferably, the plurality of corpus blocks are obtained by performing cutting operation on the initial text block, specifically: a period or a line break is used as a cutting mark, and a maximum block length is set for the cutting operation.

[0008] Preferably, the hyperparameters include the number of question rewriting N and the top K documents or knowledge triples most related to the user question.

[0009] The application also provides a retrieval enhancement generation system, comprising: An initial text block is obtained, and a plurality of corpus blocks are obtained by performing cutting operation on the initial text block; and a vector database and a graph database are constructed using the plurality of corpus blocks respectively. The user question is classified according to complexity to obtain a user question complexity category, hyperparameters used for retrieval are selected according to the user question complexity category, the user question is split according to the hyperparameters to obtain a plurality of sub-questions; A vector recall operation and a graph recall operation are performed on the data in the vector database and the graph database respectively to obtain corpus blocks and knowledge triples related to the user question; the plurality of sub-questions, the corpus blocks and the knowledge triples related to the user question are input into a large language model to obtain a result matched with the user question.

[0010] The application also provides a computer device comprising a memory and a processor; the memory stores a computer program, and the processor is used to run the computer program in the memory to execute the retrieval enhancement generation method.

[0011] The present invention also provides a computer-readable storage medium storing a computer program adapted for loading by a processor to execute the retrieval enhancement generation method.

[0012] The retrieval enhancement generation method provided by this invention has the following beneficial effects: By segmenting the initial text into multiple corpus blocks, we can both vectorize knowledge within a small scope and more precisely construct knowledge triples in the graph database. By categorizing user questions according to complexity, different retrieval strategies can be adopted for different types of questions. If a question involves multiple logical steps (i.e., multi-hop logic), the complex question can be broken down into simpler sub-questions, and each sub-question can be retrieved separately, thus gradually solving complex questions that span multiple information sources. This process makes the retrieval target of each sub-question clearer, reduces errors, and improves retrieval accuracy. By performing vector recall operations on data in a vector database, similar semantic information of the question can be captured from corpus blocks. By performing graph recall operations on data in a vector database, more specific associations can be provided based on knowledge triples. By combining the use of two databases, relevant information can be captured from both the semantic level (vectors) and the relational level (graph structure) simultaneously, helping to better capture complex questions involving multiple facts and more accurately find content related to multiple logics. By inputting multiple sub-questions, corpus blocks related to the user question, and knowledge triples into a large language model, the large language model can better combine context when processing multi-hop logic to obtain results that match the user question.

[0013] This invention effectively solves the retrieval accuracy problem caused by multi-hop logic by breaking down user questions, constructing a database of multiple information sources, and performing step-by-step retrieval and reasoning. Attached Figure Description

[0014] To more clearly illustrate the embodiments and design schemes of the present invention, the accompanying drawings required for this embodiment will be briefly described below. The drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0015] Figure 1 This is a flowchart of the retrieval enhancement generation method according to an embodiment of the present invention. Detailed Implementation

[0016] To enable those skilled in the art to better understand and implement the technical solutions of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and should not be construed as limiting the scope of protection of the present invention.

[0017] Example This invention provides a retrieval enhancement generation method, specifically as follows: Figure 1 As shown, it includes the following steps: Step 1: Obtain the initial text block, perform a block segmentation operation on the initial text block to obtain multiple corpus blocks; use the multiple corpus blocks to construct a vector database and a graph database respectively.

[0018] First, the initial text block is segmented to obtain multiple corpus blocks. Specifically, a period or newline character is used as a segmentation marker, and the maximum block length is set for segmentation.

[0019] Secondly, multiple corpus blocks are used to construct vector databases and graph databases respectively. Specifically, embedding models are used to embed multiple corpus blocks to obtain embedding vectors for each corpus block. The embedding vectors of each corpus block are stored in the database to obtain a vector database. Entity recognition, entity relation extraction, and attribute extraction are performed on multiple corpus blocks to obtain a knowledge graph corresponding to each corpus. A graph database is constructed using the knowledge graphs corresponding to each corpus.

[0020] By constructing a dual structure of vector databases and graph databases, we can combine the advantages of both in processing information. Vector databases are good at capturing semantic similarity, while graph databases can effectively express and query complex structured relationships, such as multi-hop logical associations between entities.

[0021] Step 2: Classify user problems according to their complexity to obtain user problem complexity categories. Select hyperparameters for retrieval based on the user problem complexity categories, and split the user problem into multiple sub-problems according to the hyperparameters. This includes the following steps: (1) Using a well-performing existing large language model, generate several questions for the current corpus, and classify the complexity of these questions (three categories: simple, medium, and difficult). The large language model here can be ChatGLM-6B (Chat Generative Language Model-6B) or Llama3-8B, which have good command understanding and text generation capabilities and are suitable for scenarios that generate and judge the difficulty level based on the corpus.

[0022] (2) The generated questions and their complexity categories are made into a dialogue dataset format for training large language models; (3) Using the prepared dataset, fine-tune any large language model with a small number of parameters to obtain a specialized model for classifying the complexity of user questions.

[0023] The predefined hyperparameters include: the number of question rewrites N and the top K documents or knowledge triples most relevant to the user's question.

[0024] The hyperparameters are defined as follows: Easy class: N=3, K=5; Medium class: N=5, K=7; Hard class: N=7, K=10.

[0025] Step 2 categorizes user questions by complexity and dynamically selects hyperparameters based on the categorization results to split the questions into multiple sub-questions. This allows for more targeted handling of different types of query tasks. Especially for complex questions involving multiple logical arguments, this step can break them down into multiple sub-questions with clearer logic, allowing for separate retrieval and reasoning. This improves the completeness and accuracy of the overall retrieval, effectively alleviating the problems of incomplete information coverage and misunderstanding bias that exist in traditional single retrieval methods when dealing with multi-step reasoning questions. It further reduces the risk of large models generating illusions and improves the accuracy of retrieval.

[0026] Step 3: Perform vector recall and graph recall operations on the data in the vector database and graph database respectively to obtain corpus blocks and knowledge triples related to the user question; input multiple sub-questions, corpus blocks and knowledge triples related to the user question into the large language model to obtain the matching results with the user question.

[0027] The process of performing vector retrieval and graph retrieval operations on data in the vector database and graph database, respectively, includes the following steps: (1) Use the embedding model to perform embedding operations on the user question to obtain the embedding vector of the user question.

[0028] (2) Calculate the similarity between the embedding vector of the user question and the embedding vector of each corpus block in the vector database, and calculate the similarity between the embedding vector of the user question and the embedding vector of each node in the graph database. Select the embedding vectors of the top M corpus blocks with the highest similarity and the embedding vectors of the nodes as corpus blocks and knowledge triples related to the user question.

[0029] (3) Input multiple sub-questions, corpus blocks related to the user's question, and knowledge triples into the large language model, and design appropriate prompt words for retrieval to obtain results that match the user's question. The large language model in this step can be Qwen-Max or GPT-4o, which has strong reasoning and context integration capabilities. By inputting sub-questions and multi-source retrieval results into the model, accurate answers that match the user's question can be generated.

[0030] In this embodiment, the embedding model used is Bge-Large-zh-v1.5, and the vector database is PostgreSQL.

[0031] This invention also provides a search enhancement generation system, comprising: Obtain the initial text block, perform a segmentation operation on the initial text block to obtain multiple corpus blocks; use the multiple corpus blocks to construct a vector database and a graph database respectively.

[0032] User problems are categorized by complexity to obtain user problem complexity categories. Hyperparameters for retrieval are selected based on the user problem complexity categories, and user problems are split into multiple sub-problems according to the hyperparameters.

[0033] Vector recall and graph recall operations are performed on the data in the vector database and graph database respectively to obtain corpus blocks and knowledge triples related to the user question; multiple sub-questions, corpus blocks and knowledge triples related to the user question are input into the large language model to obtain the matching results with the user question.

[0034] The present invention also provides a computer device including a memory and a processor; the memory stores a computer program, and the processor is used to run the computer program in the memory to perform a retrieval enhancement generation method.

[0035] The present invention also provides a computer-readable storage medium storing a computer program adapted for loading by a processor to execute a retrieval enhancement generation method.

[0036] The above-described embodiments are merely preferred embodiments of the present invention, and the scope of protection of the present invention is not limited thereto. Any simple changes or equivalent substitutions of the technical solutions that can be obviously obtained by those skilled in the art within the scope of the technology disclosed in the present invention shall fall within the scope of protection of the present invention.

Claims

1. A retrieval enhancement generation method, characterized in that, Includes the following steps: Obtain an initial text block, perform a block segmentation operation on the initial text block to obtain multiple corpus blocks; use the multiple corpus blocks to construct a vector database and a graph database respectively; User problems are categorized by complexity to obtain user problem complexity categories. Hyperparameters for retrieval are selected based on the user problem complexity categories. User problems are then split into multiple sub-problems according to the hyperparameters. Vector recall and graph recall operations are performed on the data in the vector database and graph database respectively to obtain corpus blocks and knowledge triples related to the user question; multiple sub-questions, corpus blocks and knowledge triples related to the user question are input into the large language model to obtain the matching results with the user question.

2. The retrieval enhancement generation method according to claim 1, characterized in that, The method of constructing a vector database and a graph database using multiple corpus blocks is as follows: embedding the multiple corpus blocks using an embedding model to obtain the embedding vector of each corpus block, and storing the embedding vector of each corpus block in the database to obtain the vector database. Entity recognition, entity relation extraction, and attribute extraction are performed on multiple corpus blocks to obtain a knowledge graph corresponding to each corpus. A graph database is then constructed using the knowledge graphs corresponding to each corpus.

3. The retrieval enhancement generation method according to claim 1, characterized in that, The step of performing vector retrieval and graph retrieval operations on the data in the vector database and graph database, respectively, includes the following steps: The embedding model is used to embed the user question to obtain the embedding vector of the user question; Calculate the similarity between the embedding vector of the user question and the embedding vector of each corpus block in the vector database, and calculate the similarity between the embedding vector of the user question and the embedding vector of each node in the graph database. Select the embedding vectors of the top M corpus blocks and the embedding vectors of the nodes with the highest similarity as the corpus blocks and knowledge triples related to the user question.

4. The retrieval enhancement generation method according to claim 1, characterized in that, The process of segmenting the initial text block to obtain multiple corpus blocks involves using periods or newlines as segmentation markers and setting a maximum block length for the segmentation operation.

5. The retrieval enhancement generation method according to claim 1, characterized in that, The hyperparameters include the number of question rewrites N and the top K documents or knowledge triples most relevant to the user's question.

6. A retrieval enhancement generation system, characterized in that, include: Obtain the initial text block, and perform a block segmentation operation on the initial text block to obtain multiple corpus blocks; A vector database and a graph database are constructed using multiple corpus blocks; User problems are categorized by complexity to obtain user problem complexity categories. Hyperparameters for retrieval are selected based on the user problem complexity categories. User problems are then split into multiple sub-problems according to the hyperparameters. Vector recall and graph recall operations are performed on the data in the vector database and graph database respectively to obtain corpus blocks and knowledge triples related to the user question; multiple sub-questions, corpus blocks and knowledge triples related to the user question are input into the large language model to obtain the matching results with the user question.

7. A computer device, characterized in that, It includes a memory and a processor; the memory stores a computer program, and the processor is used to run the computer program in the memory to perform the retrieval enhancement generation method according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted for loading by a processor to execute the retrieval enhancement generation method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Question and answer processing method, device and system, computing equipment and computer storage medium

    CN116860949A

  • Method and system for generating enhanced knowledge questions and answers for mixed retrieval of heterogeneous database

    CN119311831A

  • Private domain-oriented large language model personalized question and answer method and related products

    CN119719287A

  • Wind power fault diagnosis operation and maintenance method based on multi-source data and knowledge retrieval enhancement

    CN120297410A

  • Method for enhancing NPC dialogue ability based on graph retrieval enhancement generation

    CN120745800A

Cited By

  • Retrieval system and method based on retrieval enhancement generation

    CN121935302A