A large model retrieval enhancement generation method and system

By segmenting the corpus into paragraphs and calculating the relationship between keywords, the problems of limited input and missing context in large-model question and answering are solved, achieving more accurate knowledge recall and question and answering effects.

CN119294516BActive Publication Date: 2025-09-26SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411348766.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-09-26
Estimated Expiration
2044-09-26

AI Technical Summary

Technical Problem

Large models have problems in the question-answering process, such as limited input, missing contextual information, and difficulty matching long and short texts, which leads to inaccurate answers and low knowledge recall.

Method used

By segmenting the corpus knowledge into paragraphs, extracting entities and keywords, calculating the connection relationship between paragraphs, and using word and sentence granularity retrieval methods to perform knowledge recall question and answer, context information is supplemented.

Benefits of technology

The accuracy of answers generated by large models and the knowledge recall rate are improved, and the precision of question and answer is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119294516B_ABST
    Figure CN119294516B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of artificial intelligence technology, and specifically to a large-model retrieval enhancement generation method and system, comprising the following steps: segmenting corpus knowledge according to paragraphs, extracting entities and keywords as information nodes of the paragraphs; extracting adjacent nodes between information nodes as extended information of the current node; calculating the connectivity between nodes in different paragraphs, and using the extended information of the nodes to supplement the context information of the paragraph to form a word-granularity description of the paragraph; using word and sentence granularity retrieval methods to perform knowledge retrieval and knowledge recall question-answering. The beneficial effect is that the large-model retrieval enhancement generation method and system proposed in the present invention supplement the context information of knowledge fragments through the connectivity between key information between paragraphs, and cooperate with a multi-scale retrieval algorithm with word and sentence granularity to increase the accuracy of knowledge recall and improve the large-model generation effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a large model retrieval enhancement generation method and system. Background Art

[0002] Intelligent question answering in specialized fields has long been a research hotspot in the natural language field. With the development of large models, this field has made significant progress. However, domain-specific knowledge is highly specialized, and general large models lack targeted fine-tuning during the training phase. Direct question answering is prone to "hallucinations," and the industry is currently pursuing ways to make answers more accurate. Currently, methods for reducing model hallucinations include model fine-tuning and retrieval enhancement techniques. The latter, which eliminates model training and relies solely on knowledge retrieval, provides the model with a concise and accurate knowledge background, assisting the large model in generating high-quality answers.

[0003] In practical applications, retrieval-enhanced question-answer generation is also extremely challenging. The main reasons are as follows:

[0004] Large models have limited input: Large models have input text length restrictions and cannot support unlimited background knowledge input. This means that the retrieved background knowledge must be concise and tailored, and should not be too long. Large pieces of background knowledge may introduce redundant noise, affecting the accuracy of the model's responses, especially in open-source large models that have limited support for context length and semantic understanding.

[0005] Lack of contextual information: Knowledge vectors are stored in slices, and the size of the slices affects the retrieval effect. If the slices are too short, user questions may be distributed across different segments, potentially losing contextual information. If they are too long, redundant noise information will be introduced.

[0006] Matching long and short text: User questions are often short and abstract, while knowledge vectors are relatively long. When calculating the vector distance between the two, key knowledge information can easily be lost in irrelevant information, resulting in the inability to retrieve relevant text, low knowledge recall, and the inability to answer questions. Summary of the Invention

[0007] The purpose of the present invention is to provide a large model retrieval enhancement generation method and system to solve the problems raised in the above background technology.

[0008] To achieve the above object, the present invention provides the following technical solution: a large model retrieval enhancement generation method, the method comprising the following steps:

[0009] Step 1: Segment the corpus knowledge into paragraphs, extract entities and keywords as information nodes of the paragraphs;

[0010] Step 2: Extract the adjacent nodes between information nodes as the extended information of the current node;

[0011] Step 3: Calculate the connection relationship between nodes in different paragraphs, and use the extended information of the nodes to supplement the context information of the paragraph to form a word-granular description of the paragraph;

[0012] Step 4: Use word and sentence granularity retrieval methods to perform knowledge retrieval and knowledge recall question and answer.

[0013] Preferably, step 1 specifically includes:

[0014] (1) Traverse all documents in the knowledge base;

[0015] (2) Document preprocessing: using a structure recognition model to identify the organizational structure of the article, retaining only the article title and text content location information, and removing irrelevant information such as pictures, headers, and footers;

[0016] (3) Traverse the text content under each title, slice the knowledge according to paragraphs, and form a knowledge slice structure organized by title, which is as follows:

[0017] content={title1:[para1,…,para n ],…,title n :[para1,…,para n ]}

[0018] Among them: content represents a single knowledge document, title n Indicates the nth title in the document, para n Indicates the nth paragraph under the current heading;

[0019] (4) For each paragraph para in step (3) n Extract key information at word granularity. The key information here includes but is not limited to entity-class words and keywords. Entity-class words rely on various entity extraction models. Keyword extraction is based on the PageRank algorithm and is performed on the full text. The extracted result is recorded as p keyword , each paragraph n Have corresponding keyword information;

[0020] (5) For each title in step (3) n , because it often contains summary information and is naturally aligned with the user's question information, all its information is retained, and only the title is segmented and stop words are removed as the key information of the title, recorded as t keyword ;

[0021] (6) Each paragraph maintains a keyword set para wordAs a semantic description of word granularity, each keyword set includes the key information and the title information of the current paragraph, and its form is as follows:

[0022] para word =[p keyword 1,…,p keywordn, t keyword 1,…,t keywordn ]

[0023] Each keyword serves as an information node for the current paragraph, making it easier to calculate correlations between different paragraphs.

[0024] Preferably, the specific operations of step 2 include:

[0025] (1) Split the paragraph into sentences to obtain clauses. Each paragraph can be expressed as:

[0026] para n =[sent1,…,sent n ]

[0027] Among them, para n Indicates the current paragraph, sent n Indicates the nth clause of the current paragraph;

[0028] (2) Traverse each clause sent n The paragraph keywords that appear in keyword If there are multiple sentences, they are considered adjacent and an adjacent set is constructed. So far, each sentence maintains an adjacent set, which is recorded as sent connect :

[0029] sent connect =[p keyword 1,…,p keywordt ]

[0030] The adjacency set records the key information and its coexistence relationship in the current context window. The key information can be used as the initial word-granularity semantic description of the paragraph. The coexistence information is subsequently used as supplementary information for the same node in the neighboring paragraphs, effectively expanding the context of the paragraph. Since the expansion range is constrained to the sentence level, it effectively eliminates redundant text compared to the method of expanding the fixed-length context.

[0031] Preferably, the specific operations of step 3 include:

[0032] (1) Enter the current paragraph;

[0033] (2) Selecting candidate expansion nodes: First, determine whether the keyword of the current paragraph appears in other paragraphs. If so, consider the node (keyword) as a candidate expansion node;

[0034] (3) Calculate the connectivity threshold of candidate expansion nodes and screen candidate nodes. The calculation method of the connectivity threshold is shown in Formula 1. The calculation of the node connectivity threshold is measured by two parts: the proximity distance between the paragraphs to which the node belongs and the similarity distance of all clauses of the node. The proximity distance of paragraphs is expressed as the number of paragraphs between two paragraphs. For example, the distance between the first and second paragraphs of an article is 1, and the distance between the first and third paragraphs of an article is 2, which is recorded as: dis para ; The similarity of the clauses is calculated using the Jaccard similarity of the keyword set of the sentence to which the node belongs, denoted as similar sent ;

[0035]

[0036] Among them: λ represents the attenuation coefficient. The larger its value is, the farther the distance is, and the stronger the attenuation of the node connection relationship is. connect Indicates the connectivity score of two nodes in different paragraphs;

[0037] (4) If the connection score is greater than the threshold, it is considered as a paragraph connection between nodes, and the keyword information of the clause to which the connected node belongs is added to the keyword set of the current paragraph. word , complete the context of the paragraph;

[0038] (5) Vectorize the paragraph based on the embedding model to obtain the sentence-level semantic description of the paragraph;

[0039] At this point, the semantic information extraction of each paragraph is completed. This information includes word-level description (keyword combination) and sentence-level description (embedding vector), and expands the context information, which is cross-paragraph.

[0040] Preferably, the specific operations of step 4 include:

[0041] (1) Input the user question and segment the user question to obtain a segmentation set;

[0042] (2) Perform word-granular knowledge recall, calculate the hit ratio of the keyword set after the expanded context in the knowledge slice and the user question word set, and recall the knowledge slices that are greater than the threshold;

[0043] (3) The user question is vectorized through the embedding model, and the inner product similarity is calculated with the vectorized matrix of the knowledge slice. The knowledge slices with a value greater than the threshold are recalled;

[0044] (4) De-duplicate the knowledge slices, remove duplicate knowledge slices, and re-rank them using the rerank model;

[0045] (5) The first n knowledge fragments are selected as the knowledge background and spliced ​​into the prompt for knowledge question and answer.

[0046] A large model retrieval enhancement generation system, the system comprising:

[0047] The entity extraction module divides the corpus knowledge into paragraphs and extracts entities and keywords as information nodes of the paragraphs;

[0048] Node extraction module extracts adjacent nodes between information nodes as extended information of the current node;

[0049] The calculation module calculates the connection relationship between nodes in different paragraphs and uses the extended information of the nodes to supplement the context information of the paragraph to form a word-granular description of the paragraph;

[0050] The retrieval module uses word and sentence granularity retrieval methods to perform knowledge retrieval and knowledge recall question and answer.

[0051] Preferably, the entity extraction module includes:

[0052] (1) Traverse all documents in the knowledge base;

[0053] (2) Document preprocessing: using a structure recognition model to identify the organizational structure of the article, retaining only the article title and text content location information, and removing irrelevant information such as pictures, headers, and footers;

[0054] (3) Traverse the text content under each title, slice the knowledge according to paragraphs, and form a knowledge slice structure organized by title, which is as follows:

[0055] content={title1:[para1,…,para n ],…,title n :[para1,…,para n ]}

[0056] Among them: content represents a single knowledge document, title n Indicates the nth title in the document, para n Indicates the nth paragraph under the current heading;

[0057] (4) For each paragraph para in step (3) n Extract key information at word granularity. The key information here includes but is not limited to entity-class words and keywords. Entity-class words rely on various entity extraction models. Keyword extraction is based on the PageRank algorithm and is performed on the full text. The extracted result is recorded as p keyword , each paragraph nHave corresponding keyword information;

[0058] (5) For each title in step (3) n , because it often contains summary information and is naturally aligned with the user's question information, all its information is retained, and only the title is segmented and stop words are removed as the key information of the title, recorded as t keyword ;

[0059] (6) Each paragraph maintains a keyword set para word As a semantic description of word granularity, each keyword set includes the key information and the title information of the current paragraph, and its form is as follows:

[0060] para word =[p keyword 1,…,p keywordn, t keyword 1,…,t keywordn ]

[0061] Each keyword serves as an information node for the current paragraph, making it easier to calculate correlations between different paragraphs.

[0062] Preferably, the node extraction module includes:

[0063] (1) Split the paragraph into sentences to obtain clauses. Each paragraph can be expressed as:

[0064] para n =[sent1,…,sent n ]

[0065] Among them, para n Indicates the current paragraph, sent n Indicates the nth clause of the current paragraph;

[0066] (2) Traverse each clause sent n The paragraph keywords that appear in keyword If there are multiple sentences, they are considered adjacent and an adjacent set is constructed. So far, each sentence maintains an adjacent set, which is recorded as sent connect :

[0067] sent connect =[p keyword 1,…,p keywordt ]

[0068] The adjacency set records the key information and its coexistence relationship in the current context window. The key information can be used as the initial word-granularity semantic description of the paragraph. The coexistence information is subsequently used as supplementary information for the same node in the neighboring paragraphs, effectively expanding the context of the paragraph. Since the expansion range is constrained to the sentence level, it effectively eliminates redundant text compared to the method of expanding the fixed-length context.

[0069] Preferably, the calculation module includes:

[0070] (1) Enter the current paragraph;

[0071] (2) Selecting candidate expansion nodes: First, determine whether the keyword of the current paragraph appears in other paragraphs. If so, consider the node (keyword) as a candidate expansion node;

[0072] (3) Calculate the connectivity threshold of candidate expansion nodes and screen candidate nodes. The calculation method of the connectivity threshold is shown in Formula 1. The calculation of the node connectivity threshold is measured by two parts: the proximity distance between the paragraphs to which the node belongs and the similarity distance of all clauses of the node. The proximity distance of paragraphs is expressed as the number of paragraphs between two paragraphs. For example, the distance between the first and second paragraphs of an article is 1, and the distance between the first and third paragraphs of an article is 2, which is recorded as: dis para ; The similarity of the clauses is calculated using the Jaccard similarity of the keyword set of the sentence to which the node belongs, denoted as similar sent ;

[0073]

[0074] Among them: λ represents the attenuation coefficient. The larger its value is, the farther the distance is, and the stronger the attenuation of the node connection relationship is. connect Indicates the connectivity score of two nodes in different paragraphs;

[0075] (4) If the connection score is greater than the threshold, it is considered as a paragraph connection between nodes, and the keyword information of the clause to which the connected node belongs is added to the keyword set of the current paragraph. word , complete the context of the paragraph;

[0076] (5) Vectorize the paragraph based on the embedding model to obtain the sentence-level semantic description of the paragraph;

[0077] At this point, the semantic information extraction of each paragraph is completed. This information includes word-level description (keyword combination) and sentence-level description (embedding vector), and expands the context information, which is cross-paragraph.

[0078] Preferably, the retrieval module includes:

[0079] (1) Input the user question and segment the user question to obtain a segmentation set;

[0080] (2) Perform word-granular knowledge recall, calculate the hit ratio of the keyword set after the expanded context in the knowledge slice and the user question word set, and recall the knowledge slices that are greater than the threshold;

[0081] (3) The user question is vectorized through the embedding model, and the inner product similarity is calculated with the vectorized matrix of the knowledge slice. The knowledge slices with a value greater than the threshold are recalled;

[0082] (4) De-duplicate the knowledge slices, remove duplicate knowledge slices, and re-rank them using the rerank model;

[0083] (5) The first n knowledge fragments are selected as the knowledge background and spliced ​​into the prompt for knowledge question and answer.

[0084] Compared with the prior art, the present invention has the following beneficial effects:

[0085] The large-model retrieval enhancement generation method and system proposed in the present invention supplements the contextual information of knowledge fragments by connecting key information between paragraphs, and cooperates with multi-scale retrieval algorithms at word and sentence granularity to increase the accuracy of recalled knowledge and improve the large-model generation effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0086] Figure 1 Flow chart of the method of the present invention. DETAILED DESCRIPTION

[0087] In order to clearly and completely describe the objectives and technical solutions of the present invention and make the advantages more clearly understood, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are part of the embodiments of the present invention, not all of them, and are only used to explain the embodiments of the present invention, not to limit the embodiments of the present invention. All other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0088] For example 1, please refer to Figure 1 The present invention provides a technical solution: a large model retrieval enhancement generation method, the method comprising the following steps:

[0089] Step 1: Divide the corpus knowledge into paragraphs and extract entities and keywords as information nodes of the paragraphs.

[0090] (1) Traverse all documents in the knowledge base.

[0091] (2) Document preprocessing uses a structure recognition model to identify the organizational structure of the article, retaining only the article title and text content location information, and removing irrelevant information such as pictures, headers, and footers.

[0092] (3) Traverse the text content under each title, slice the knowledge according to paragraphs, and form a knowledge slice structure organized by title, which is as follows:

[0093] content={title1:[para1,…,para n ],…,title n :[para1,…,para n ]}

[0094] Among them: content represents a single knowledge document, title n Indicates the nth title in the document, para n Indicates the nth paragraph under the current heading.

[0095] (4) For each paragraph in step 3 n Extract key information at word granularity. The key information here includes but is not limited to entity-class words and keywords. Entity-class words can rely on various entity extraction models, such as BERT, etc. Keyword extraction can be based on the PageRank algorithm and extracted from the entire text. The extracted result is recorded as p keyword . So far, each paragraph n Have the corresponding keyword information.

[0096] (5) For each title in step 3 n , because it often contains summary information and is naturally aligned with the user's question information, all its information is retained, and only the title is segmented and stop words are removed as the key information of the title, recorded as t keyword .

[0097] (6) Each paragraph maintains a keyword set para word As a semantic description of word granularity, each keyword set includes the key information of the current paragraph and the title information to which it belongs. Its form is as follows:

[0098] para word =[p keyword 1,…,p keywordn, t keyword 1,…,t keywordn ]

[0099] Each keyword serves as an information node for the current paragraph, making it easier to calculate correlations between different paragraphs.

[0100] Step 2: Extract the adjacent nodes between information nodes as the extended information of the current node.

[0101] The definition of adjacent nodes here is: in a clause, multiple information nodes (keywords) appear at the same time, which is considered adjacent, which means that multiple groups of keywords jointly describe the same concept and have a dependent relationship.

[0102] (1) Split the paragraph into sentences to obtain clauses. Each paragraph can be represented as:

[0103] para n =[sent1,…,sent n ]

[0104] Among them, para n Indicates the current paragraph, sent n Indicates the nth clause of the current paragraph.

[0105] (2) Traverse each clause sent n The paragraph keywords that appear in keyword If there are multiple sentences, they are considered adjacent and an adjacent set is constructed. So far, each sentence maintains an adjacent set, which is recorded as sent connect :.

[0106] sent connect =[p keyword 1,…,p keywordt ]

[0107] The adjacency set records the key information and its coexistence relationship in the current context window. The key information can be used as the initial word-granularity semantic description of the paragraph, and the coexistence information can be used as supplementary information for the same node in the neighboring paragraphs, effectively expanding the context of the paragraph. Since the expansion range is constrained to the sentence level, it can effectively eliminate redundant text compared to the method of expanding the fixed-length context.

[0108] Step 3: Calculate the connection relationship between nodes in different paragraphs, and use the extended information of the nodes to supplement the context information of the paragraph to form a word-granular description of the paragraph;

[0109] (1) Enter the current paragraph.

[0110] (2) The candidate expansion node is selected as follows: first, determine whether the keyword of the current paragraph appears in other paragraphs. If so, the node (keyword) is considered as a candidate expansion node.

[0111] (3) Calculate the connectivity threshold of the candidate expansion node and screen the candidate nodes. The calculation method of the connectivity threshold is shown in Formula 1. The calculation of the node connectivity threshold is measured by two parts: the proximity distance between the paragraphs to which the node belongs and the similarity distance of all clauses of the node. The proximity distance of the paragraph is expressed as the number of paragraphs between the two paragraphs. For example, the distance between the first and second paragraphs of an article is 1, and the distance between the first and third paragraphs of an article is 2, which is recorded as: dis para The similarity of clauses is calculated using the Jaccard similarity of the keyword set of the sentence to which the node belongs, denoted as similar sent .

[0112]

[0113] Among them: λ represents the attenuation coefficient. The larger its value is, the farther the distance is, and the stronger the attenuation of the node connection relationship is. connect Indicates the connectivity score of two nodes in different paragraphs.

[0114] (4) If the connection score is greater than the threshold, it is considered as a paragraph connection between nodes, and the keyword information of the clause to which the connected node belongs is added to the keyword set of the current paragraph. word , complete the context of the paragraph.

[0115] (5) The paragraph is vectorized based on the embedding model to obtain a sentence-level semantic description of the paragraph.

[0116] At this point, the semantic information extraction of each paragraph is completed. This information includes word-level description (keyword combination) and sentence-level description (embedding vector), and expands the context information, which is cross-paragraph.

[0117] Step 4: Use word and sentence granularity retrieval methods to perform knowledge retrieval and knowledge recall question and answer.

[0118] (1) Input the user question and segment the user question to obtain a segmentation set.

[0119] (2) Perform word-granular knowledge recall, calculate the hit ratio of the keyword set after the expanded context in the knowledge slice and the user question word set, and recall the knowledge slices that are greater than the threshold.

[0120] (3) The user question is vectorized through the embedding model, and the inner product similarity is calculated with the vectorized matrix of the knowledge slice. The knowledge slices with a value greater than the threshold are recalled.

[0121] (4) De-duplicate the knowledge slices, remove duplicate knowledge slices, and re-rank them using the rerank model.

[0122] (5) The first n knowledge fragments are selected as the knowledge background and spliced ​​into the prompt for knowledge question and answer.

[0123] Example 2, based on Example 1, proposes a large model retrieval enhancement generation system, the system comprising:

[0124] The entity extraction module segments the corpus knowledge into paragraphs, extracting entities and keywords as information nodes of the paragraphs; it includes:

[0125] (1) Traverse all documents in the knowledge base;

[0126] (2) Document preprocessing: using a structure recognition model to identify the organizational structure of the article, retaining only the article title and text content location information, and removing irrelevant information such as pictures, headers, and footers;

[0127] (3) Traverse the text content under each title, slice the knowledge according to paragraphs, and form a knowledge slice structure organized by title, which is as follows:

[0128] content={title1:[para1,…,para n ],…,title n :[para1,…,para n ]}

[0129] Among them: content represents a single knowledge document, title n Indicates the nth title in the document, para n Indicates the nth paragraph under the current heading;

[0130] (4) For each paragraph para in step (3) n Extract key information at word granularity. The key information here includes but is not limited to entity-class words and keywords. Entity-class words rely on various entity extraction models. Keyword extraction is based on the PageRank algorithm and is performed on the full text. The extracted result is recorded as p keyword , each paragraph n Have corresponding keyword information;

[0131] (5) For each title in step (3) n , because it often contains summary information and is naturally aligned with the user's question information, all its information is retained, and only the title is segmented and stop words are removed as the key information of the title, recorded as t keyword ;

[0132] (6) Each paragraph maintains a keyword set paraword As a semantic description of word granularity, each keyword set includes the key information and the title information of the current paragraph, and its form is as follows:

[0133] para word =[p keyword 1,…,p keywordn, t keyword 1,…,t keywordn ]

[0134] Each keyword serves as an information node for the current paragraph, making it easier to calculate correlations between different paragraphs.

[0135] The node extraction module extracts adjacent nodes between information nodes as extended information of the current node; it includes:

[0136] (1) Split the paragraph into sentences to obtain clauses. Each paragraph can be expressed as:

[0137] para n =[sent1,…,sent n ]

[0138] Among them, para n Indicates the current paragraph, sent n Indicates the nth clause of the current paragraph;

[0139] (2) Traverse each clause sent n The paragraph keywords that appear in keyword If there are multiple sentences, they are considered adjacent and an adjacent set is constructed. So far, each sentence maintains an adjacent set, which is recorded as sent connect :

[0140] sent connect =[p keyword 1,…,p keywordt ]

[0141] The adjacency set records the key information and its coexistence relationship in the current context window. The key information can be used as the initial word-granularity semantic description of the paragraph. The coexistence information is subsequently used as supplementary information for the same node in the neighboring paragraphs, effectively expanding the context of the paragraph. Since the expansion range is constrained to the sentence level, it effectively eliminates redundant text compared to the method of expanding the fixed-length context.

[0142] The calculation module calculates the connection relationship between nodes in different paragraphs and uses the extended information of the nodes to supplement the context information of the paragraph to form a word-granular description of the paragraph; it includes:

[0143] (1) Enter the current paragraph;

[0144] (2) Selecting candidate expansion nodes: First, determine whether the keyword of the current paragraph appears in other paragraphs. If so, consider the node (keyword) as a candidate expansion node;

[0145] (3) Calculate the connectivity threshold of candidate expansion nodes and screen candidate nodes. The calculation method of the connectivity threshold is shown in Formula 1. The calculation of the node connectivity threshold is measured by two parts: the proximity distance between the paragraphs to which the node belongs and the similarity distance of all clauses of the node. The proximity distance of paragraphs is expressed as the number of paragraphs between two paragraphs. For example, the distance between the first and second paragraphs of an article is 1, and the distance between the first and third paragraphs of an article is 2, which is recorded as: dis para ; The similarity of the clauses is calculated using the Jaccard similarity of the keyword set of the sentence to which the node belongs, denoted as similar sent ;

[0146]

[0147] Among them: λ represents the attenuation coefficient. The larger its value is, the farther the distance is, and the stronger the attenuation of the node connection relationship is. connect Indicates the connectivity score of two nodes in different paragraphs;

[0148] (4) If the connection score is greater than the threshold, it is considered as a paragraph connection between nodes, and the keyword information of the clause to which the connected node belongs is added to the keyword set of the current paragraph. word , complete the context of the paragraph;

[0149] (5) Vectorize the paragraph based on the embedding model to obtain the sentence-level semantic description of the paragraph;

[0150] At this point, the semantic information extraction of each paragraph is completed. This information includes word-level description (keyword combination) and sentence-level description (embedding vector), and expands the context information, which is cross-paragraph.

[0151] The retrieval module uses word and sentence granularity to perform knowledge retrieval and knowledge recall question answering, including:

[0152] (1) Input the user question and segment the user question to obtain a segmentation set;

[0153] (2) Perform word-granular knowledge recall, calculate the hit ratio of the keyword set after the expanded context in the knowledge slice and the user question word set, and recall the knowledge slices that are greater than the threshold;

[0154] (3) The user question is vectorized through the embedding model, and the inner product similarity is calculated with the vectorized matrix of the knowledge slice. The knowledge slices with a value greater than the threshold are recalled;

[0155] (4) De-duplicate the knowledge slices, remove duplicate knowledge slices, and re-rank them using the rerank model;

[0156] (5) The first n knowledge fragments are selected as the knowledge background and spliced ​​into the prompt for knowledge question and answer.

[0157] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.

Claims

1. A large model retrieval enhancement generation method, characterized by: The method comprises the following steps: Step 1: Segment the corpus knowledge into paragraphs, extract entities and keywords as information nodes of the paragraphs; Step 2: Extract the adjacent nodes between information nodes as the extended information of the current node; Step 3: Calculate the connection relationship between nodes in different paragraphs, and use the extended information of the nodes to supplement the context information of the paragraph to form a word-granular description of the paragraph; Step 4: Use word and sentence granularity to perform knowledge retrieval and knowledge recall question answering; Step 1 specifically includes: (1) Traverse all documents in the knowledge base; (2) Document preprocessing: using a structure recognition model to identify the organizational structure of the article, retaining only the article title and text content location information, and removing irrelevant information such as pictures, headers, and footers; (3) Traverse the text content under each title, slice the knowledge according to paragraphs, and form a knowledge slice structure organized by title, which is as follows: content={title1:[para1,…,para n ],…,title n :[for1,…,for n ]} Among them: content represents a single knowledge document, title n Indicates the nth title in the document, para n Indicates the nth paragraph under the current heading; (4) For each paragraph para in step (3) n Extract key information at word granularity. The key information here includes but is not limited to entity-class words and keywords. Entity-class words rely on various entity extraction models. Keyword extraction is based on the PageRank algorithm and is performed on the full text. The extracted result is recorded as p keyword , each paragraph n Have corresponding keyword information; (5) For each title in step (3) n , because it often contains summary information and is naturally aligned with the user's question information, all its information is retained, and only the title is segmented and stop words are removed as the key information of the title, recorded as t keyword ; (6) Each paragraph maintains a keyword set para word As a semantic description of word granularity, each keyword set includes the key information and the title information of the current paragraph, and its form is as follows: para word =[p keyword1 ,…,p keywordn, t keyword1 ,…,t keywordn ] Each keyword serves as an information node for the current paragraph, making it easier to calculate correlations between different paragraphs. The specific operations in step 2 include: (1) Split the paragraph into sentences to obtain clauses. Each paragraph can be expressed as: for n =[sent1,…,sent n ] Among them, para n Indicates the current paragraph, sent n Indicates the nth clause of the current paragraph; (2) Traverse each clause sent n The paragraph keywords that appear in keyword If there are multiple sentences, they are considered adjacent and an adjacent set is constructed. So far, each sentence maintains an adjacent set, which is recorded as sent connect : sent connect =[p keyword1 ,…,p keywordt ] The adjacency set records the key information and its coexistence relationship in the current context window. The key information serves as the initial word-granularity semantic description of the paragraph, and the coexistence information is subsequently used as supplementary information for the same node in the neighboring paragraphs, effectively expanding the context of the paragraph. Since the expansion range is constrained to the sentence level, it effectively eliminates redundant text compared to the method of expanding the fixed-length context.

2. A large model retrieval enhancement generation method according to claim 1, characterized in that: The specific operations in step 3 include: (1) Enter the current paragraph; (2) Selecting candidate expansion nodes: First, determine whether the keyword of the current paragraph appears in other paragraphs. If so, consider the node (keyword) as a candidate expansion node; (3) Calculate the connectivity threshold of candidate expansion nodes and screen candidate nodes. The calculation method of the connectivity threshold is shown in Formula 1. The calculation of the node connectivity threshold is measured by two parts: the proximity distance between the paragraphs to which the node belongs and the similarity distance of all clauses of the node. The proximity distance of paragraphs is expressed as the number of paragraphs between two paragraphs. The distance between the first and second paragraphs of an article is 1, and the distance between the first and third paragraphs of an article is 2, which is recorded as: dis para ; The similarity of the clauses is calculated using the Jaccard similarity of the keyword set of the sentence to which the node belongs, denoted as similar sent ; Among them: λ represents the attenuation coefficient. The larger its value is, the farther the distance is, and the stronger the attenuation of the node connection relationship is. connect Indicates the connectivity score of two nodes in different paragraphs; (4) If the connection score is greater than the threshold, it is considered as a paragraph connection between nodes, and the keyword information of the clause to which the connected node belongs is added to the keyword set of the current paragraph. word , complete the context of the paragraph; (5) Vectorize the paragraph based on the embedding model to obtain the sentence-level semantic description of the paragraph; At this point, the semantic information extraction of each paragraph is completed. This information includes word-level description (keyword combination) and sentence-level description (embedding vector), and expands the context information, which is cross-paragraph.

3. The large model retrieval enhancement generation method according to claim 1, characterized in that: The specific operations in step 4 include: (1) Input the user question and segment the user question to obtain a segmentation set; (2) Perform word-granular knowledge recall, calculate the hit ratio of the keyword set after the expanded context in the knowledge slice and the user question word set, and recall the knowledge slices that are greater than the threshold; (3) The user question is vectorized through the embedding model, and the inner product similarity is calculated with the vectorized matrix of the knowledge slice. The knowledge slices with a value greater than the threshold are recalled; (4) De-duplicate the knowledge slices, remove duplicate knowledge slices, and re-rank them using the rerank model; (5) Select the first n knowledge fragments in the reordering as the knowledge background and splice them into the prompt for knowledge question and answer.

4. A large model retrieval enhancement generation system according to the large model retrieval enhancement generation method according to any one of claims 1 to 3, characterized in that: The system comprises: The entity extraction module divides the corpus knowledge into paragraphs and extracts entities and keywords as information nodes of the paragraphs; Node extraction module extracts adjacent nodes between information nodes as extended information of the current node; The calculation module calculates the connection relationship between nodes in different paragraphs and uses the extended information of the nodes to supplement the context information of the paragraph to form a word-granular description of the paragraph; The retrieval module uses word and sentence granularity to perform knowledge retrieval and knowledge recall question answering; The entity extraction module includes: (1) Traverse all documents in the knowledge base; (2) Document preprocessing: using a structure recognition model to identify the organizational structure of the article, retaining only the article title and text content location information, and removing irrelevant information such as pictures, headers, and footers; (3) Traverse the text content under each title, slice the knowledge according to paragraphs, and form a knowledge slice structure organized by title, which is as follows: content={title1:[para1,…,para n ],…,title n :[for1,…,for n ]} Among them: content represents a single knowledge document, title n Indicates the nth title in the document, para n Indicates the nth paragraph under the current heading; (4) For each paragraph para in step (3) n Extract key information at word granularity. The key information here includes but is not limited to entity-class words and keywords. Entity-class words rely on various entity extraction models. Keyword extraction is based on the PageRank algorithm and is performed on the full text. The extracted result is recorded as p keyword , each paragraph n Have corresponding keyword information; (5) For each title in step (3) n , because it often contains summary information and is naturally aligned with the user's question information, all its information is retained, and only the title is segmented and stop words are removed as the key information of the title, recorded as t keyword ; (6) Each paragraph maintains a keyword set para word As a semantic description of word granularity, each keyword set includes the key information and the title information of the current paragraph, and its form is as follows: para word =[p keyword1 ,…,p keywordn, t keyword1 ,…,t keywordn ] Each keyword serves as an information node for the current paragraph, making it easier to calculate correlations between different paragraphs. The node extraction module includes: (1) Split the paragraph into sentences to obtain clauses. Each paragraph is represented as: for n =[sent1,…,sent n ] Among them, para n Indicates the current paragraph, sent n Indicates the nth clause of the current paragraph; (2) Traverse each clause sent n The paragraph keywords that appear in keyword If there are multiple sentences, they are considered adjacent and an adjacent set is constructed. So far, each sentence maintains an adjacent set, which is recorded as sent connect : sent connect =[p keyword1 ,…,p keywordt ] The adjacency set records the key information and its coexistence relationship in the current context window. The key information can be used as the initial word-granularity semantic description of the paragraph. The coexistence information is subsequently used as supplementary information for the same node in the neighboring paragraphs, effectively expanding the context of the paragraph. Since the expansion range is constrained to the sentence level, it effectively eliminates redundant text compared to the method of expanding the fixed-length context.

5. A large model retrieval enhancement generation system according to claim 4, characterized in that: The calculation module includes: (1) Enter the current paragraph; (2) Selecting candidate expansion nodes: First, determine whether the keyword of the current paragraph appears in other paragraphs. If so, consider the node (keyword) as a candidate expansion node; (3) Calculate the connectivity threshold of candidate expansion nodes and screen candidate nodes. The calculation method of the connectivity threshold is shown in Formula 1. The calculation of the node connectivity threshold is measured by two parts: the proximity distance between the paragraphs to which the node belongs and the similarity distance of all clauses of the node. The proximity distance of paragraphs is expressed as the number of paragraphs between two paragraphs. The distance between the first and second paragraphs of an article is 1, and the distance between the first and third paragraphs of an article is 2, which is recorded as: dis para ; The similarity of the clauses is calculated using the Jaccard similarity of the keyword set of the sentence to which the node belongs, denoted as similar sent ; Among them: λ represents the attenuation coefficient. The larger its value is, the farther the distance is, and the stronger the attenuation of the node connection relationship is. connect Indicates the connectivity score of two nodes in different paragraphs; (4) If the connection score is greater than the threshold, it is considered as a paragraph connection between nodes, and the keyword information of the clause to which the connected node belongs is added to the keyword set of the current paragraph. word , complete the context of the paragraph; (5) Vectorize the paragraph based on the embedding model to obtain the sentence-level semantic description of the paragraph; At this point, the semantic information extraction of each paragraph is completed. This information includes word-level description (keyword combination) and sentence-level description (embedding vector), and expands the context information, which is cross-paragraph.

6. A large model retrieval enhancement generation system according to claim 4, characterized in that: The retrieval module includes: (1) Input the user question and segment the user question to obtain a segmentation set; (2) Perform word-granular knowledge recall, calculate the hit ratio of the keyword set after the expanded context in the knowledge slice and the user question word set, and recall the knowledge slices that are greater than the threshold; (3) The user question is vectorized through the embedding model, and the inner product similarity is calculated with the vectorized matrix of the knowledge slice. The knowledge slices with a value greater than the threshold are recalled; (4) De-duplicate the knowledge slices, remove duplicate knowledge slices, and re-rank them using the rerank model; (5) Select the first n knowledge fragments in the reordering as the knowledge background and splice them into the prompt for knowledge question and answer.

Citation Information

Patent Citations

  • Interactive text processing method and device, electronic equipment and storage medium

    CN117473034A

  • Feedback data graph generation method and refrigerator

    WO2023246849A1