Large model retrieval enhancement generation method and system
By performing paragraph segmentation and communication relationship calculations on the corpus, combined with word granularity and sentence granularity description, the problem of large-scale models being recalled low in specific domain questions and answers is solved, and the accuracy and context understanding of the answers are improved.
Patent Information
- Application Number
- CN202411348766.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-09-26
AI Technical Summary
Large models are prone to "illusion" in specific domain questions and answers, which leads to inaccurate answers. The main reasons are the limitations in input text length, the lack of context information, and the difficulty in matching long and short texts, resulting in low knowledge recall.
By segmenting the corpus knowledge, extracting entities and keywords, calculating the connection relationship between paragraphs, forming word-grained and sentence-grained descriptions, and using multi-scale search algorithms for knowledge retrieval and recall.
It improves the accuracy of knowledge recall, enhances the effect of large-scale model generation, eliminates redundant information, and retains context information.
Smart Images

Figure CN119294516A_ABST
Abstract
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 professional fields has always been a hot topic in the field of natural language research. With the development of large models, this field has made significant progress. However, knowledge in specific fields is highly professional. General large models lack targeted fine-tuning during the training phase. Direct question-answering is prone to "hallucinations". How to make answers more accurate is the current industry demand. At present, the methods to reduce model hallucinations include: model fine-tuning and retrieval enhancement technology. The latter does not require model training, but only provides a concise and accurate knowledge background for the model through knowledge retrieval, assisting the large model in generating high-quality answers.
[0003] In practical applications, retrieval-enhanced question-answer generation is also extremely challenging for the following reasons:
[0004] Large model input is limited: Large models have input text length restrictions and do not support unlimited length background knowledge input, which means that the retrieved background knowledge must be concise and matched, and should not be too long. Large pieces of background knowledge may introduce redundant noise information, affecting the accuracy of the model's answers, especially in open source large models with weak support for context length and semantic understanding.
[0005] Lack of context information: Knowledge slices are stored during the knowledge vector storage process, and the size of the slices will affect the retrieval effect. If the slice is too short, user questions may be distributed in different segments, and context information may be lost; if it is too long, redundant noise information will be introduced.
[0006] Matching long and short texts: User questions are often short and abstract, while knowledge vectors are relatively long. When calculating the vector distance between the two, the key information of the knowledge can easily be submerged in irrelevant information, resulting in the inability to retrieve relevant texts, 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) Preprocess the document by 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 the 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 the word level. The key information here includes but is not limited to entity-type words and keywords. Entity-type 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 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:
[0022] para word =[p keyword 1,…,p keywordn, t keyword 1,…,t keywordn ]
[0023] Each keyword serves as an information node of the current paragraph, which facilitates the calculation of associations 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, n Indicates the current paragraph, sent n Indicates the nth clause of the current paragraph;
[0028] (2) Traverse and query 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, 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, where the key information can be used 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, compared with the method of expanding the fixed-length context, it effectively eliminates redundant text.
[0031] Preferably, the specific operations of step 3 include:
[0032] (1) Enter the current paragraph;
[0033] (2) Selecting candidate expansion nodes, the method is as follows: first, determining whether the keyword of the current paragraph appears in other paragraphs, if so, considering the node (keyword) as a candidate expansion node;
[0034] (3) Calculate the connectivity threshold of the candidate expansion nodes 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 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: 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 scores of two nodes in different paragraphs;
[0037] (4) If the connection score is greater than the threshold, the nodes are considered to be connected to each other, 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. The information includes word-level description (keyword combination) and sentence-level description (embedding vector), and the context information is expanded, and the context information 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 greater than the threshold are recalled;
[0044] (4) De-duplicate 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 answering.
[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] The node extraction module extracts the adjacent nodes between information nodes as the 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) Preprocess the document by 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 the 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 the word level. The key information here includes but is not limited to entity-type words and keywords. Entity-type 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 of the current paragraph, which facilitates the calculation of associations 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, n Indicates the current paragraph, sent n Indicates the nth clause of the current paragraph;
[0066] (2) Traverse and query 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, 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, where the key information can be used 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, compared with the method of expanding the fixed-length context, it effectively eliminates redundant text.
[0069] Preferably, the calculation module includes:
[0070] (1) Enter the current paragraph;
[0071] (2) Selecting candidate expansion nodes, the method is as follows: first, determining whether the keyword of the current paragraph appears in other paragraphs, if so, considering the node (keyword) as a candidate expansion node;
[0072] (3) Calculate the connectivity threshold of the candidate expansion nodes 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 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: 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 scores of two nodes in different paragraphs;
[0075] (4) If the connection score is greater than the threshold, the nodes are considered to be connected to each other, 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. The information includes word-level description (keyword combination) and sentence-level description (embedding vector), and the context information is expanded, and the context information 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 greater than the threshold are recalled;
[0082] (4) De-duplicate 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 answering.
[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 through the connection relationship of key information between paragraphs, and cooperates with the multi-scale retrieval algorithm of 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 The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION
[0087] In order to make the purpose and technical solution of the present invention clearly and completely described, and the advantages more clearly understood, the embodiments of the present invention are further described in detail 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, rather than all of the embodiments, and are only used to explain the embodiments of the present invention, and are not used to limit the embodiments of the present invention. All other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0088] For example, see 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, extract entities and keywords as information nodes of the paragraphs.
[0090] (1) Traverse all documents in the knowledge base.
[0091] (2) Preprocess the document 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 images, headers, and footers.
[0092] (3) Traverse the text content under each title, slice the knowledge according to the 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 para in step 3 n Extract key information at the word level. The key information here includes but is not limited to entity-type words and keywords. Entity-type 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 and the title information of the current paragraph. 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 of the current paragraph, which facilitates the calculation of associations 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, if multiple information nodes (keywords) appear at the same time, they are 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, n Indicates the current paragraph, sent n Indicates the nth clause of the current paragraph.
[0105] (2) Traverse and query 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, 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, where the key information can be used as the initial word-granularity semantic description of the paragraph, and the coexistence information can be used later 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) A candidate expansion node is selected by first determining 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 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: 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 .
[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 Represents the connectivity score of two nodes in different paragraphs.
[0114] (4) If the connection score is greater than the threshold, the nodes are considered to be connected to each other, 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) Vectorize the paragraph 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. The information includes word granularity description (keyword combination) and sentence granularity description (embedding vector), and the context information is expanded, and the context information 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 that are greater than the threshold are recalled.
[0121] (4) De-duplicate 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 answering.
[0123] Embodiment 2, based on embodiment 1, proposes a large model retrieval enhancement generation system, the system comprising:
[0124] The entity extraction module divides the corpus knowledge into paragraphs, extracts entities and keywords as information nodes of the paragraphs; it includes:
[0125] (1) Traverse all documents in the knowledge base;
[0126] (2) Preprocess the document by 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 the 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 the word level. The key information here includes but is not limited to entity-type words and keywords. Entity-type 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 of the current paragraph, which facilitates the calculation of associations between different paragraphs.
[0135] The node extraction module extracts the adjacent nodes between information nodes as the extended information of the current node; including:
[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, n Indicates the current paragraph, sent n Indicates the nth clause of the current paragraph;
[0139] (2) Traverse and query 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, 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, where the key information can be used 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, compared with the method of expanding the fixed-length context, it effectively eliminates redundant text.
[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 granularity description of the paragraph; including:
[0143] (1) Enter the current paragraph;
[0144] (2) Selecting candidate expansion nodes, the method is as follows: first, determining whether the keyword of the current paragraph appears in other paragraphs, if so, considering the node (keyword) as a candidate expansion node;
[0145] (3) Calculate the connectivity threshold of the candidate expansion nodes 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 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: 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 scores of two nodes in different paragraphs;
[0148] (4) If the connection score is greater than the threshold, the nodes are considered to be connected to each other, 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. The information includes word-level description (keyword combination) and sentence-level description (embedding vector), and the context information is expanded, and the context information is cross-paragraph.
[0151] The retrieval module uses word and sentence granularity to perform knowledge retrieval and knowledge recall question and answer, 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 greater than the threshold are recalled;
[0155] (4) De-duplicate 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 answering.
[0157] Although 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 the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present 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 retrieval methods to perform knowledge retrieval and knowledge recall question and answer.
2. A large model retrieval enhancement generation method according to claim 1, characterized in that: Step 1 specifically includes: (1) Traverse all documents in the knowledge base; (2) Preprocess the document by 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 the 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 the word level. The key information here includes but is not limited to entity-type words and keywords. Entity-type 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 of the current paragraph, which facilitates the calculation of associations between different paragraphs.
3. A large model retrieval enhancement generation method according to claim 2, characterized in that: The specific operations of 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, n Indicates the current paragraph, sent n Indicates the nth clause of the current paragraph; (2) Traverse and query 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, 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, where the key information can be used 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, compared with the method of expanding the fixed-length context, it effectively eliminates redundant text.
4. The large model retrieval enhancement generation method according to claim 1 is characterized in that: The specific operations of step 3 include: (1) Enter the current paragraph; (2) Selecting candidate expansion nodes, the method is as follows: first, determining whether the keyword of the current paragraph appears in other paragraphs, if so, considering the node (keyword) as a candidate expansion node; (3) Calculate the connectivity threshold of the candidate expansion nodes 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 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: 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 scores of two nodes in different paragraphs; (4) If the connection score is greater than the threshold, the nodes are considered to be connected to each other, 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. The information includes word-level description (keyword combination) and sentence-level description (embedding vector), and the context information is expanded, and the context information is cross-paragraph.
5. The large model retrieval enhancement generation method according to claim 1, characterized in that: The specific operations of 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 greater than the threshold are recalled; (4) De-duplicate knowledge slices, remove duplicate knowledge slices, and re-rank them using the rerank model; (5) The first n knowledge fragments are selected as the knowledge background and spliced into the prompt for knowledge question and answering.
6. A large model retrieval enhancement generation system according to the large model retrieval enhancement generation method according to any one of claims 1 to 5, 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. The node extraction module extracts the adjacent nodes between information nodes as the 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 granularity description of the paragraph; The retrieval module uses word and sentence granularity retrieval methods to perform knowledge retrieval and knowledge recall question and answer.
7. A large model retrieval enhancement generation system according to claim 6, characterized in that: The entity extraction module comprises: (1) Traverse all documents in the knowledge base; (2) Preprocess the document by 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 the 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 the word level. The key information here includes but is not limited to entity-type words and keywords. Entity-type 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 of the current paragraph, which facilitates the calculation of associations between different paragraphs.
8. A large model retrieval enhancement generation system according to claim 6, characterized in that: The node extraction module comprises: (1) Split the paragraph into sentences to obtain clauses. Each paragraph can be expressed as: for n =[sent1,…,sent n ] Among them, n Indicates the current paragraph, sent n Indicates the nth clause of the current paragraph; (2) Traverse and query 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, 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, where the key information can be used 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, compared with the method of expanding the fixed-length context, it effectively eliminates redundant text.
9. A large model retrieval enhancement generation system according to claim 6, characterized in that: The calculation module comprises: (1) Enter the current paragraph; (2) Selecting candidate expansion nodes, the method is as follows: first, determining whether the keyword of the current paragraph appears in other paragraphs, if so, considering the node (keyword) as a candidate expansion node; (3) Calculate the connectivity threshold of the candidate expansion nodes 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 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: 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 scores of two nodes in different paragraphs; (4) If the connection score is greater than the threshold, the nodes are considered to be connected to each other, 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. The information includes word-level description (keyword combination) and sentence-level description (embedding vector), and the context information is expanded, and the context information is cross-paragraph.
10. A large model retrieval enhancement generation system according to claim 6, characterized in that: The retrieval module comprises: (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 greater than the threshold are recalled; (4) De-duplicate knowledge slices, remove duplicate knowledge slices, and re-rank them using the rerank model; (5) The first n knowledge fragments are selected as the knowledge background and spliced into the prompt for knowledge question and answering.
Citation Information
Patent Citations
Interactive text processing method and device, electronic equipment and storage medium
CN117473034A
Graph long short term memory for syntactic relationship discovery
US20180189269A1
Automated building of expanded datasets for training of autonomous agents
US20190370604A1
Determining semantic similarity of texts based on sub-sections thereof
US20200302018A1
System and method for question-based content answering
US20210365500A1
Cited By
Scientific and technological novelty search report automatic generation method and system based on database and large model
CN119782507A
Method for improving recall accuracy of article document by using RAG technology
CN120216708A
Semantic splicing method and system, electronic equipment and storage medium
CN120930653A