Retrieval enhancement generation method and system based on multivariate fusion

By structuring the knowledge base document into a knowledge graph and combining multiple search methods to generate semantic complete text blocks, the problems of correlation and hallucination in the search-enhanced generation technology are solved, and a more accurate knowledge base question and answer is achieved.

CN120296147APending Publication Date: 2025-07-11BEIJING ZHITONG YUNLIAN TECH CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202510455206.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-11
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

The existing search enhancement generation technology has problems with retrieval content relevance and hallucinations that may result from the generation of content, and cannot effectively capture the semantic information and domain knowledge of the query.

Method used

By structuring the knowledge base document into a knowledge graph, combining vector search, Elasticsearch search and graph search, multiple search methods are integrated to generate semantic complete text blocks, and the final answer is performed using a large language model.

Benefits of technology

It improves the relevance and accuracy of the searched content, reduces the illusion of the generated content, and improves the accuracy and answer quality of the knowledge base question and answer.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120296147A_ABST
    Figure CN120296147A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a retrieval enhancement generation method and system based on multivariate fusion, and the method comprises the steps: firstly structuring a knowledge base document, generating a knowledge graph, and importing an ES to establish an index; inputting question sentences, carrying out word segmentation and other processing, querying instance nodes from the map, and outputting meeting conditions according to answer sentence patterns; if not, fragmenting and blocking the document according to a title level, obtaining candidate results through vector, ES and atlas retrieval, normalizing scores, merging and optimizing the scores of the candidate retrieval results according to a retrieval source, calculating comprehensive scores, and outputting the comprehensive scores in a descending order; and finally, carrying out semantic integrity aggregation on the combined candidate results, and inputting into a large language model to obtain a final answer. According to the method, the relevance of the retrieved content is greatly improved, the semantic integrity of the retrieved content is improved, the model magic view problem is reduced, and the question and answer accuracy and the answer quality of a knowledge base are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This document relates to the field of artificial intelligence technology, and particularly to a retrieval enhanced generation method and system based on multi-source fusion. Background Art

[0002] Retrieval-Augmented Generation (RAG) is an artificial intelligence technology that combines information retrieval technology with large language generation models. By retrieving relevant information from an external knowledge base and using it as prompts for input to a large language model, it enhances the model's ability to handle knowledge-intensive tasks. Retrieval-Augmented Generation technology performs well in multiple scenarios such as knowledge base question answering and intelligent assistants, but it still has some deficiencies, mainly reflected in the following aspects: Relevance issues of retrieved content: Existing retrieval modules may not guarantee that all retrieved content is relevant to the query; Hallucination issues in large models: When the retrieved content is not completely relevant, the generation model may generate content based on inaccurate or incomplete context, resulting in the "hallucination" problem, that is, the generated content seems reasonable but is actually incorrect.

[0003] To address the problems existing in traditional retrieval-enhanced generation technology, it is necessary to fuse multiple retrieval methods to comprehensively capture the semantic information and domain knowledge of the query, and improve the relevance and accuracy of retrieved content. Summary of the Invention

[0004] One or more embodiments of this specification provide a retrieval enhanced generation method based on multi-source fusion, including:

[0005] S1. Structurally process the knowledge base documents to generate a knowledge graph containing nodes and relationships of documents, chapters, knowledge points, knowledge entries, objects, activities, and attributes, and import the generated knowledge graph data into ES to establish an index;

[0006] S2. Through word segmentation, synonym replacement, and intent template matching of the input question sentence, query instance nodes in the knowledge graph that completely cover the keywords of the question sentence. If the instance nodes meet the coverage condition, output the result in combination with the answer sentence pattern of the intent template; otherwise, execute S3;

[0007] S3. Fragment and block the knowledge base documents based on the title hierarchy to generate semantically complete text blocks. Perform vector retrieval, ES retrieval, and graph retrieval on the text blocks respectively to obtain candidate retrieval results, and perform score normalization processing on each candidate retrieval result;

[0008] S4. Merge and optimize the scores of the candidate retrieval results according to the retrieval sources, calculate the comprehensive score of the retrieval results according to the preset calculation rules, and sort each retrieval result in descending order of the comprehensive score and output;

[0009] S5. Aggregate the semantic integrity of the content of the merged candidate retrieval results, and input the large language model to generate the final answer.

[0010] Further, the intention template matching includes:

[0011] Identify comparison type questions through regular expressions, and split the question sentence into single type sub-questions according to the instance node type;

[0012] Expand the query scope according to the node hierarchy relationship, match the target type and generate the corresponding answer sentence template.

[0013] Further, the specific method of vector retrieval is:

[0014] Convert the text block into a vector, find the 30 most similar contents from the vector library through cosine similarity, and return the corresponding index ID and matching score;

[0015] Query the index table according to the index ID to obtain the atomic content ID;

[0016] Extract the specific content from the content table through the atomic content ID, and return the first 30 original results;

[0017] Sort the scores corresponding to the original results after deviation normalization, and output the retrieval results.

[0018] Further, the specific method of ES retrieval is:

[0019] Search the knowledge base in Elasticsearch according to the text block, find the most relevant paragraphs, and return the corresponding index ID and score;

[0020] Query the index table through the index ID to obtain the corresponding atomic content ID;

[0021] Extract the specific content from the content table according to the atomic content ID, and return the first 30 original results;

[0022] Sort the scores corresponding to the original results after deviation normalization, and output the retrieval results.

[0023] Further, the specific method of graph retrieval is:

[0024] Input the question sentence for word segmentation to obtain all the keywords of the sentence;

[0025] Locate the best document through the keywords, and query the atomic content nodes that are connected to all related word nodes;

[0026] Sum the path lengths between the atomic content node and each related word node, select the atomic content with a shorter total path length, and calculate the average distance;

[0027] Calculate scores based on the length of the average distance, normalize the scores by deviation, sort them, and output the retrieval results.

[0028] Furthermore, the scores of the candidate retrieval results are merged and optimized according to the retrieval source, and the specific method for calculating the comprehensive score of the retrieval results according to the preset calculation rules is as follows:

[0029] For the results that come from both vector retrieval and ES retrieval, the score is adjusted to the average score plus 0.05;

[0030] For the results that come from both vector retrieval and graph retrieval, the score is adjusted to the average score plus 0.1;

[0031] For the results that come from both ES retrieval and graph retrieval, the score is adjusted to the average score plus 0.1;

[0032] For the results that come from all three types of retrieval, the score is adjusted to the average score plus 0.15.

[0033] Furthermore, the content of the merged candidate retrieval results is semantically integrated, and the input large language model is used to generate the final answer, which specifically includes:

[0034] Reorganize the retrieved atomic content according to the title hierarchy structure to ensure context coherence;

[0035] Polish the aggregated content through the large language model to generate the final answer.

[0036] One or more embodiments of this specification provide a retrieval enhanced generation system based on multi-source integration, which is characterized by including:

[0037] Data processing module: used to structurally process the knowledge base documents, generate a knowledge graph containing nodes and relationships of documents, chapters, knowledge points, knowledge items, objects, activities, and attributes, and import the generated knowledge graph data into ES to establish an index;

[0038] Intent matching module: used to tokenize, replace synonyms, and match the input question sentence with the intent template, query the instance nodes in the knowledge graph that completely cover the keywords of the question sentence, and if the instance nodes meet the coverage condition, output the result in combination with the answer sentence pattern of the intent template; otherwise, execute the retrieval module;

[0039] Retrieval module: used to fragment and chunk the knowledge base documents based on the title hierarchy, generate semantically complete text chunks, perform vector retrieval, ES retrieval, and graph retrieval on the text chunks respectively to obtain candidate retrieval results, and perform score normalization processing on each candidate retrieval result;

[0040] Retrieval result output module: used to merge and optimize the scores of the candidate retrieval results according to the retrieval sources, calculate the comprehensive score of the retrieval results according to the preset calculation rules, and sort each retrieval result in descending order of the comprehensive score for output;

[0041] Retrieval result processing module: used to perform semantic integrity aggregation on the content of the merged candidate retrieval results, and input into a large language model to generate the final answer.

[0042] One or more embodiments of this specification provide an electronic device, including:

[0043] A processor; and,

[0044] A memory arranged to store computer-executable instructions, which when executed cause the processor to implement the steps of the above-mentioned retrieval enhanced generation method based on multi-source fusion.

[0045] One or more embodiments of this specification provide a storage medium for storing computer-executable instructions, which when executed implement the steps of the above-mentioned retrieval enhanced generation method based on multi-source fusion.

[0046] Adopting the embodiments of the present invention, for the relevance problem of retrieval content, using the RAG technology that divides document fragmentation differences into document chunks and fuses three retrieval methods of vector - es - graph, greatly improves the relevance of retrieval content. By aggregating and outputting the retrieval content, the semantic integrity of the retrieval content is improved; for the "hallucination" problem of the traditional RAG model, a direct graph query is newly added to the fusion RAG route of vector - es - graph. Through technologies such as knowledge graph combined with intent recognition, the type of the input question is identified, and the answer sentence pattern of the desired question is matched, so that the retrieval content is the answer to the question, reducing the "hallucination problem" of the model and improving the accuracy and quality of knowledge base question answering.

[0047] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable, the specific embodiments of the present invention are given below. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in one or more embodiments of this specification or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments recorded in this specification. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0049] Figure 1 A flowchart of a retrieval-enhanced generation method based on multi-source fusion provided for one or more embodiments of this specification;

[0050] Figure 2 A vector retrieval flowchart of a retrieval-enhanced generation method based on multi-source fusion provided for one or more embodiments of this specification;

[0051] Figure 3 An ES retrieval flowchart of a retrieval-enhanced generation method based on multi-source fusion provided for one or more embodiments of this specification;

[0052] Figure 4 A vector-ES-graph fusion RAG retrieval flowchart of a retrieval-enhanced generation method based on multi-source fusion provided for one or more embodiments of this specification;

[0053] Figure 5 A schematic diagram of the retrieval aggregation logic of a retrieval-enhanced generation method based on multi-source fusion provided for one or more embodiments of this specification;

[0054] Figure 6 A schematic diagram of the composition of a retrieval-enhanced generation system based on multi-source fusion provided for one or more embodiments of this specification;

[0055] Figure 7 A schematic diagram of the structure of an electronic device provided for one or more embodiments of this specification. Detailed implementation manners

[0056] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the following will clearly and completely describe the technical solutions in one or more embodiments of this specification in conjunction with the accompanying drawings in one or more embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this document.

[0057] Method embodiments

[0058] According to an embodiment of the present invention, a retrieval-enhanced generation method based on multi-source fusion is provided. Figure 1 A flowchart of a retrieval-enhanced generation method based on multi-source fusion provided for one or more embodiments of this specification, as Figure 1 shown. The retrieval-enhanced generation method based on multi-source fusion according to an embodiment of the present invention specifically includes:

[0059] S1. Structurally process the knowledge base documents to generate a knowledge graph containing nodes and relationships of documents, chapters, knowledge points, knowledge entries, objects, activities, and attributes, and import the generated knowledge graph data into ES to create an index.

[0060] Construct a knowledge graph corresponding to the knowledge base documents with entities as nodes and relationships between entities as edges. The graph contains nodes such as documents, chapters, knowledge points, knowledge entries, objects, activities, attributes, and the relationships between the nodes. Among them, the document refers to the entire knowledge base document, the chapter is a component of the document content divided according to a certain logical structure, the knowledge point is a further subdivided knowledge unit under the chapter; the knowledge entry is more refined content of the knowledge point; the object is the specific object involved in the knowledge entry; the activity is the action or behavior related to the object; the attribute is the characteristic or property of the object.

[0061] Import this data into the es index to construct the es index of the graph data. Specifically, according to the data characteristics of the knowledge graph, create a suitable index structure in Elasticsearch, define the fields, data types, mapping relationships, etc. of the index to ensure that the node and relationship data of the knowledge graph can be correctly stored and retrieved. For example, define the relevant fields and their data types of the document nodes, define the storage method of the relationships between the nodes, etc., so as to construct an Elasticsearch index suitable for the knowledge graph data.

[0062] S2. Through word segmentation, synonym replacement, and intention template matching of the input question sentence, query the instance nodes in the knowledge graph that completely cover the keywords of the question sentence. If the instance nodes meet the coverage conditions, output the result in combination with the answer sentence pattern of the intention template; otherwise, execute S3.

[0063] First, perform an es-graph query: The input question sentence will first be tokenized by the ES tokenizer to obtain the keywords in it. According to the principle of long words first and after stop word filtering, the keywords in the input question sentence are obtained; the keywords in the tokenized input question sentence are replaced with synonyms and all replaced with standard words; the token types in the question sentence are replaced with tokens, and the matching words in the intention template are matched. If a successful match is obtained, the intention of the question is obtained.

[0064] Perform instance recognition according to the intention matching result: The keywords separated from the question sentence will retrieve the graph data through es. If the intention is matched in the previous step, the es retrieval will only query the type nodes in the target, otherwise all nodes will be queried. The query rule is that the query content contains at least one keyword; after obtaining the es-graph query data, the keywords of the query data are obtained according to the same ES tokenizer as the question sentence, the keywords are replaced with synonyms and all replaced with standard words, and the keyword scores of the query data are calculated. The score calculation method is as follows:

[0065] score = same_tokens / query_tokens;

[0066] Among them, same_tokens is the number of keywords in the query data that are the same as those in the question sentence, and query_tokens is the total number of keywords in the query data. If the instance recognition result does not contain an instance with a score equal to 1, that is, the instance cannot cover the question sentence, then jump out.

[0067] When splitting the input question sentence, identify comparison-type questions through regular expressions, and split the question sentence into single-type sub-questions according to the instance node type; expand the query scope according to the node hierarchical relationship, match the target type, and generate the corresponding answer sentence template.

[0068] Design regular matching for comparison-type questions. If the match is successful, classify the results that meet the instance covering the question sentence in the instance recognition by type, including document, chapter, knowledge point, object, activity, or attribute, count the quantity of each type, and split them in the order of document > chapter > knowledge point > object, activity, attribute:

[0069] If the number of document types = 2, split the original question sentence into two single-type questions according to the document;

[0070] If the number of chapter types = 2, split the original question sentence into two single-type questions according to the chapter;

[0071] If the number of knowledge point types = 2, split the original question sentence into single-type questions according to the knowledge point;

[0072] If the number of object nodes >= 2, split the original question sentence into single-type questions according to the object;

[0073] If the number of activity nodes >= 2, split the original question sentence into single-type questions according to the activity;

[0074] If the number of attribute nodes = 2, split the original question sentence into single-type questions according to the attribute node;

[0075] If the match is unsuccessful, the original question sentence will not be split. For example:

[0076] Question sentence: Do both the training manual and the installation and configuration instructions of the Shuanghu geological mapping system exist? It will be split into:

[0077] Sub-question 1: Does the training manual of the Shuanghu geological mapping system exist?

[0078] Sub-question 2: Do the installation and configuration instructions of the Shuanghu geological mapping system exist?

[0079] Intention recognition & answer output

[0080] Determine whether the instance can cover the question. If it cannot cover the question, expand it by combining instances. If it successfully matches and obtains the intention of the question, and the known question classification and target are available, expand the knowledge graph according to the target relationship. If it does not match, expand it according to the following relationships:

[0081] Expansion of document type instances: Attribute relationship;

[0082] Expansion of chapter type instances: Expand upward to the document according to the part-whole relationship; Attribute relationship;

[0083] Expansion of knowledge point type instances: Expand upward to the document according to the part-whole relationship; Attribute relationship;

[0084] Expansion of object and activity instances: Attribute relationship;

[0085] If the expanded instance cannot cover the question, jump out. If the instance can cover the question, it means:

[0086] The node is highly relevant to the question, and the correct answer can be obtained after judging the intention through the intention template.

[0087] If there is a document in the combination result, the target is the document;

[0088] Otherwise, if there is a chapter in the combination result, the target is the chapter;

[0089] Otherwise, if there is a knowledge point in the combination result, the target is the knowledge point;

[0090] Otherwise, the target is the activity, object, and attribute.

[0091] Intention = question type + target.

[0092] Match the corresponding answer sentence pattern template according to the input question sentence pattern:

[0093] The target is the document: Obtain the document attributes + first-level headings;

[0094] The target is the chapter: Obtain the chapter content;

[0095] The target is the knowledge point: Obtain all the content of the knowledge point;

[0096] Output the answer according to the answer sentence pattern in the intention template.

[0097] If there is no result in this process, execute the following method.

[0098] S3. Perform fragmentation and chunking on the knowledge base documents based on the title hierarchy to generate semantically complete text chunks. Perform vector retrieval, ES retrieval, and knowledge graph retrieval on each text chunk to obtain candidate retrieval results, and perform score normalization processing on each candidate retrieval result.

[0099] The knowledge base documents will be fragmented into paragraphs according to the title hierarchical structure. The fragmented paragraph results will be used as blocks, rather than being segmented by a fixed length, to ensure that each block has complete semantic information. There is no need to worry about the loss of semantic information between blocks due to length segmentation. On this basis, a RAG retrieval scheme for vector-ES graph fusion is carried out, as Figure 4 shown.

[0100] In this embodiment, the BGE-base model is used as the vector embedding model. The above fragmented results will be encoded into fixed-length vectors by the BGE-base model. The specific method is as follows:

[0101] The fragmented text is tokenized and converted into an input format acceptable to the model, such as token IDs and attention masks; the fragmented text passes through the Transformer encoder of BGE-base to generate context-related vectors for each token; a fixed-length dense vector is output for downstream tasks.

[0102] The vector retrieval process is as Figure 2 shown:

[0103] First, the input text input is vectorized and encoded to obtain a vector vector. After converting the text blocks into vectors, the vector table is queried, and the 30 contents in the vector table that are closest, that is, the most similar, to the vector vector are obtained through cosine similarity, and the corresponding index table id and matching score score are returned; through the returned index table id, the index table is queried to obtain the atomic content id; through the returned atomic content id, the atomic content results in the atomic content table that are most relevant to the vector vector are queried, and the 30 atomic contents most relevant to the vector query are returned; after performing deviation normalization calculation on the matching scores of the obtained atomic contents, they are sorted in descending order according to the calculated scores, and the contents that meet the score threshold and the limited output number are output; if the number of output contents is less than 2, two pieces of data most relevant to the vector query are supplemented and output.

[0104] ES retrieval constructs an index from the fragmented results obtained by splitting the documents under this knowledge base and stores them in Elasticsearch. The retrieval process is as Figure 3 shown:

[0105] First, according to the input text, search the knowledge base in Elasticsearch. Query the paragraphs in the knowledge base that are most relevant to the input text through the ES query statement, and return the index table id and the matching score score. The score will be optimized according to the length of the paragraph; b. Through the returned index table id, query the index table to obtain the atomic content id; according to the atomic content id, query the atomic content table, extract the specific content, and obtain the atomic content result that is most relevant to the input text. Return the 30 most relevant atomic contents in the es query; for the atomic content scores obtained in c, use the conversion function: perform deviation normalization calculation as follows:

[0106] x = (x - min) / (max - min);

[0107] Map the scores to the range [0–1], sort them in descending order of scores, and output the contents that meet the score threshold and the limited number of output items; if the number of output items is less than 2, supplement the two most relevant data output by the es query.

[0108] The specific method of graph retrieval is as follows:

[0109] Segment the input question sentence to obtain all the keywords of the sentence; locate the best document through the keywords, and limit the document range: find the best document through the research object. If it is empty, query the best document through the associated word nodes, and output the document id of the nodes connected within one hop of the associated word; query the atomic content nodes that are connected to all the associated word nodes, and the document id of the atomic content nodes is the id queried in the above documents; ensure that the path between the atomic content nodes and each associated word node does not exceed 4 hops; sum the path lengths between the atomic content nodes and each associated word node, and select the atomic content with the shorter total path length; divide the total path length of the atomic content nodes by the number of associated words to calculate the average distance; calculate the score based on the length of the average distance. The shorter the average distance, the higher the score. Sort the scores in descending order after deviation normalization, and output the contents that meet the score threshold and the limited number of output items; if the number of output items is less than 2, supplement the two most relevant data output by the es query.

[0110] S4. Merge and optimize the scores of the candidate retrieval results according to the retrieval source, calculate the comprehensive score of the retrieval results according to the preset calculation rules, and sort and output each retrieval result in descending order of the comprehensive score.

[0111] Merge the three types of query results and recalculate the scores. The calculation rules in this embodiment are as follows:

[0112] For the results that come from both vector retrieval and ES retrieval at the same time, adjust the score to the average score plus 0.05;

[0113] For the results simultaneously from vector retrieval and graph retrieval, the score is adjusted to the average score plus 0.1;

[0114] For the results simultaneously from ES retrieval and graph retrieval, the score is adjusted to the average score plus 0.1;

[0115] For the results simultaneously from the three types of retrieval, the score is adjusted to the average score plus 0.15;

[0116] Output the adjusted scores in descending order.

[0117] S5. Aggregate the semantic integrity of the content of the merged candidate retrieval results, and input it into the large language model to generate the final answer.

[0118] To fully ensure the semantic integrity of the retrieved content, in this embodiment, the retrieved content is aggregated, and the retrieved atomic content is reorganized according to the title hierarchical structure to ensure context coherence; the large language model is used to polish the aggregated content to generate the final answer. The aggregation logic is as Figure 5 shown:

[0119] For item level: Group the atomic content according to the title, keep the score as the maximum, aggregate the data within the group, and output all the data between the data and expand 2 items upward and 7 items downward;

[0120] For the same-level directory: Group according to the title, keep the score as the maximum, and aggregate and output all the content under the title;

[0121] For the first-level title: Group according to the title, keep the score as the maximum, and aggregate and output the content of the first-level title where the title is located;

[0122] For the whole document: Group according to the title, keep the score as the maximum, and aggregate and output the content under the document.

[0123] The beneficial effects of the present invention are as follows:

[0124] By adopting the embodiment of the present invention, aiming at the relevance problem of the retrieved content, the document is fragmented and differentiated into document blocks, and the RAG technology that integrates three retrieval methods of vector - es - graph is used, which greatly improves the relevance of the retrieved content. By aggregating and outputting the retrieved content, the semantic integrity of the retrieved content is improved; aiming at the "hallucination" problem of the traditional RAG, a direct graph query is added to the fusion RAG route of vector - es - graph. Through technologies such as knowledge graph combined with intent recognition, the type of the input problem is identified, and the answer sentence pattern of the desired problem is matched, so that the retrieved content is the answer to the problem, reducing the "hallucination problem" of the model and improving the accuracy and quality of the knowledge base question - answering.

[0125] System embodiment

[0126] According to an embodiment of the present invention, a retrieval enhanced generation system based on multi-source integration is provided. Figure 6 As shown in the schematic diagram of the composition of a retrieval enhanced generation system based on multi-source integration provided for one or more embodiments of this specification, Figure 6 the retrieval enhanced generation system based on multi-source integration according to an embodiment of the present invention specifically includes:

[0127] A data processing module 60: used to structurally process the knowledge base documents, generate a knowledge graph including nodes and relationships of documents, chapters, knowledge points, knowledge entries, objects, activities, and attributes, and import the generated knowledge graph data into ES to establish an index;

[0128] An intention matching module 62: used to query instance nodes that completely cover the keywords of the input question sentence from the knowledge graph by word segmentation, synonym replacement, and intention template matching. If the instance nodes meet the coverage condition, the result is output in combination with the answer sentence pattern of the intention template; otherwise, the retrieval module is executed;

[0129] A retrieval module 64: used to fragment and block the knowledge base documents based on the title hierarchy, generate semantically complete text blocks, perform vector retrieval, ES retrieval, and graph retrieval on the text blocks respectively to obtain candidate retrieval results, and perform score normalization processing on each candidate retrieval result;

[0130] A retrieval result output module 66: used to merge and optimize the scores of the candidate retrieval results according to the retrieval source, calculate the comprehensive score of the retrieval results according to the preset calculation rules, and sort each retrieval result in descending order of the comprehensive score and output;

[0131] A retrieval result processing module 68: used to perform semantic integrity aggregation on the content of the merged candidate retrieval results and input them into a large language model to generate a final answer.

[0132] The embodiment of the present invention is a system embodiment corresponding to the above method embodiment. The specific operations of each module can be understood with reference to the description of the method embodiment and will not be elaborated here.

[0133] Device Embodiment 1

[0134] The embodiment of the present invention provides an electronic device, as Figure 7 shown, including: a memory 70, a processor 72, and a computer program stored on the memory 70 and executable on the processor 72. When the computer program is executed by the processor 72, the following method steps are implemented:

[0135] S1. Structure the knowledge base documents to generate a knowledge graph containing nodes and relationships of documents, chapters, knowledge points, knowledge entries, objects, activities, and attributes, and import the generated knowledge graph data into ES to create an index;

[0136] S2. Segment the input question sentence, replace synonyms, and match the intention template to query instance nodes in the knowledge graph that completely cover the keywords in the question sentence. If the instance nodes meet the coverage conditions, output the result in combination with the answer sentence pattern of the intention template; otherwise, execute S3;

[0137] S3. Fragment and chunk the knowledge base documents based on the title hierarchy to generate semantically complete text chunks, perform vector retrieval, ES retrieval, and graph retrieval on the text chunks respectively to obtain candidate retrieval results, and perform score normalization on each candidate retrieval result;

[0138] S4. Merge and optimize the scores of the candidate retrieval results according to the retrieval sources, calculate the comprehensive scores of the retrieval results according to the preset calculation rules, and sort each retrieval result in descending order of the comprehensive scores and output;

[0139] S5. Aggregate the content of the merged candidate retrieval results for semantic integrity, and input it into the large language model to generate the final answer.

[0140] Device Embodiment Two

[0141] An embodiment of the present invention provides a computer-readable storage medium, on which an implementation program for information transmission is stored. When the program is executed by a processor 72, the following method steps are implemented:

[0142] S1. Structure the knowledge base documents to generate a knowledge graph containing nodes and relationships of documents, chapters, knowledge points, knowledge entries, objects, activities, and attributes, and import the generated knowledge graph data into ES to create an index;

[0143] S2. Segment the input question sentence, replace synonyms, and match the intention template to query instance nodes in the knowledge graph that completely cover the keywords in the question sentence. If the instance nodes meet the coverage conditions, output the result in combination with the answer sentence pattern of the intention template; otherwise, execute S3;

[0144] S3. Fragment and chunk the knowledge base documents based on the title hierarchy to generate semantically complete text chunks, perform vector retrieval, ES retrieval, and graph retrieval on the text chunks respectively to obtain candidate retrieval results, and perform score normalization on each candidate retrieval result;

[0145] S4. Merge and optimize the scores of the candidate retrieval results according to the retrieval sources, calculate the comprehensive score of the retrieval results according to the preset calculation rules, and sort each retrieval result in descending order of the comprehensive score and output it;

[0146] S5. Aggregate the semantic integrity of the content of the merged candidate retrieval results, and input the large language model to generate the final answer.

[0147] The computer-readable storage medium described in this embodiment includes, but is not limited to: ROM, RAM, magnetic disk, optical disc, etc.

[0148] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A retrieval enhanced generation method based on multi-source fusion, characterized in that Including: S1. Structurally process the knowledge base documents to generate a knowledge graph containing nodes and relationships of documents, chapters, knowledge points, knowledge entries, objects, activities, and attributes, and import the generated knowledge graph data into ES to create an index; S2. Through word segmentation, synonym replacement, and intent template matching of the input question sentence, query the instance nodes in the knowledge graph that completely cover the keywords of the question sentence. If the instance nodes meet the coverage conditions, output the result in combination with the answer sentence pattern of the intent template; Otherwise, execute S3; S3. Fragment and block the knowledge base documents based on the title hierarchy to generate text blocks with complete semantics. Perform vector retrieval, ES retrieval, and graph retrieval on the text blocks respectively to obtain candidate retrieval results, and perform score normalization on each candidate retrieval result; S4. Merge and optimize the scores of the candidate retrieval results according to the retrieval sources, calculate the comprehensive score of the retrieval results according to the preset calculation rules, and sort each retrieval result in descending order of the comprehensive score for output; S5. Aggregate the semantics of the content of the merged candidate retrieval results, and input them into the large language model to generate the final answer.

2. The method according to claim 1, wherein The intent template matching includes: Identify comparison questions through regular expressions, and split the question sentence into single-category sub-questions according to the instance node type; Expand the query scope according to the node hierarchy relationship, match the target type, and generate the corresponding answer sentence pattern template.

3. The method according to claim 1, wherein The specific method of the vector retrieval is: Convert the text block into a vector, find the 30 most similar contents from the vector library through cosine similarity, and return the corresponding index ID and matching score; Query the index table according to the index ID to obtain the atomic content ID; Extract the specific content from the content table through the atomic content ID, and return the first 30 original results; Sort the scores corresponding to the original results after deviation standardization, and output the retrieval results.

4. The method according to claim 1, wherein The specific method of the ES retrieval is: According to the text block, search the knowledge base in Elasticsearch to find the most relevant paragraphs, and return the corresponding index ID and score; Query the index table through the index ID to obtain the corresponding atomic content ID; Extract the specific content from the content table according to the atomic content ID, and return the first 30 original results; Sort the scores corresponding to the original results after deviation standardization, and output the retrieval results.

5. The method according to claim 1, characterized in that, The specific method of the graph retrieval is: Perform word segmentation on the input question sentence to obtain all the keywords of the sentence; Locate the best document through the keywords, and query the atomic content nodes that are connected to all related keyword nodes; Sum the path lengths between the atomic content nodes and each related keyword node, select the atomic content with a shorter total path length, and calculate the average distance; Calculate the score based on the length of the average distance, and sort the scores after deviation standardization, and output the retrieval results.

6. The method according to claim 1, wherein The method of merging and optimizing the scores of the candidate retrieval results according to the retrieval sources and calculating the comprehensive score of the retrieval results according to the preset calculation rules is specifically: For the results that come from both vector retrieval and ES retrieval at the same time, adjust the score to the average score plus 0.05; For the results simultaneously from vector retrieval and graph retrieval, the score is adjusted to the average score plus 0.1; For the results simultaneously from ES retrieval and graph retrieval, the score is adjusted to the average score plus 0.1; For the results simultaneously from the three types of retrieval, the score is adjusted to the average score plus 0.

15.

7. The method according to claim 1, characterized in that, The semantic integrity aggregation of the content of the merged candidate retrieval results and inputting into the large language model to generate the final answer specifically includes: Reorganize the retrieved atomic content according to the title hierarchy to ensure context coherence; Polish the aggregated content through the large language model to generate the final answer.

8. A retrieval enhanced generation system based on multi - element integration, characterized in that, Including: Data processing module: used to structurally process the knowledge base documents, generate a knowledge graph containing nodes and relationships of documents, chapters, knowledge points, knowledge items, objects, activities and attributes, and import the generated knowledge graph data into ES to establish an index; Intention matching module: used to query instance nodes that completely cover the question keywords from the knowledge graph by segmenting the input question sentence, replacing with synonyms and matching with intention templates. If the instance nodes meet the coverage conditions, output the results in combination with the answer sentence pattern of the intention template; Otherwise, execute the retrieval module; Retrieval module: used to fragment and chunk the knowledge base documents based on the title hierarchy to generate semantically complete text chunks, perform vector retrieval, ES retrieval and graph retrieval on the text chunks respectively to obtain candidate retrieval results, and perform score normalization processing on each candidate retrieval result; Retrieval result output module: used to merge and optimize the scores of the candidate retrieval results according to the retrieval sources, calculate the comprehensive scores of the retrieval results according to the preset calculation rules, and sort and output each retrieval result in descending order of the comprehensive scores; Retrieval result processing module: used to perform semantic integrity aggregation on the content of the merged candidate retrieval results and input into the large language model to generate the final answer.

9. An electronic device, characterized in that, Including: Processor; And, A memory arranged to store computer-executable instructions that, when executed, cause the processor to implement the steps of the multi-source fusion-based retrieval enhancement generation method according to any one of claims 1 to 7.

10. A storage medium, characterized in that, Used to store computer-executable instructions that, when executed, implement the steps of the multi-source fusion-based retrieval enhancement generation method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Low-altitude intelligent question and answer construction method and system based on dynamic parameters

    CN120632055A

  • Multi-strategy fusion large model retrieval enhancement generation method

    CN121166867A

  • Joint retrieval method and system based on knowledge enhancement, medium and terminal

    CN121166936A

  • Knowledge enhancement based federated search method, system, medium and terminal

    CN121166936B