A knowledge retrieval enhancement method and system based on post-block adaptive re-search
By adopting the post-block adaptive re-retrieval method, the problems of unreasonable text block segmentation and lack of information interpretability in knowledge retrieval are solved, achieving efficient and accurate information retrieval and generation, and improving the system's adaptability and robustness.
Patent Information
- Application Number
- CN202510030059.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-08
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2045-01-08
AI Technical Summary
Existing technologies in knowledge retrieval suffer from several problems, including unreasonable text block segmentation leading to loss of contextual information, insufficient mastery of professional domain knowledge, lack of interpretability and traceability of generated information, privacy and security issues, and limitations in the efficiency and accuracy of traditional retrieval strategies.
The post-block adaptive re-retrieval method is adopted. By setting a confidence threshold of a predefined large model, adaptive re-retrieval is performed on words with a value below the threshold. The knowledge document is divided into text blocks using the Colbert embedding model, and the retrieval results are optimized by weighted calculation through keyword masking and an improved Colbert similarity algorithm.
It improves the accuracy and reliability of information retrieval, simplifies the data structure, enhances processing efficiency, and strengthens the system's adaptability and robustness, thus meeting users' flexible query needs.
Smart Images

Figure CN119961402B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of retrieval enhancement generation, and mainly to a knowledge retrieval enhancement method and system based on post-block adaptive re-retrieval. Background Technology
[0002] Knowledge retrieval enhancement technology has emerged in response to the rapid development of artificial intelligence and natural language processing technologies. It aims to address challenges such as rapid knowledge updates, long-tail data processing, answer verification and tracing, and the need for domain-specific knowledge. This technology combines advanced achievements in deep learning, natural language processing, and information retrieval. Through strategies such as knowledge parameterization, multimodal retrieval, and intelligent guidance and extended retrieval, it provides users with more accurate, richer, and context-relevant information generation and retrieval solutions.
[0003] However, existing technologies, by clustering sentences with similar semantic vectors into text blocks, often result in unreasonable segmentation during text block formation. This leads to the loss of contextual information in the text blocks, making it impossible for the embedded vectors to fully represent the semantic information contained in the text blocks, thus affecting the accuracy of retrieval. Furthermore, they lack in-depth knowledge of professional fields and have limited reasoning capabilities, making it difficult to meet the needs of accurate question answering. The generated information lacks interpretability and traceability, reducing user trust. Privacy and security issues become prominent when handling sensitive data. In addition, traditional retrieval strategies may not be able to accurately capture user intent, and their efficiency and accuracy are limited when faced with massive amounts of data and complex queries.
[0004] For example, Chinese invention patent publication number "CN117573815A" discloses a "Retrieval Enhancement Generation Method Based on Vector Similarity Matching Optimization," which specifically discloses "determining the feature vector of the text to be processed, obtaining the similarity between the candidate vector and the feature vector of the text to be processed based on the candidate vector in the specified vector database, the feature vector of the text to be processed, and a similarity prediction model, determining the reference text associated with the text to be processed based on the similarity, and inputting the prompt text determined by the text to be processed and the reference text into a pre-trained natural language model to obtain the target text." However, this method relies on the similarity between the candidate vector in the vector database and the feature vector of the text to be processed to determine the reference text. This method does not consider the problem of insufficient confidence that may occur during the generation of the target text, resulting in deviations in some key information or expressions of the generated text, affecting the overall quality and usability of the text. In addition, this method cannot make full use of the semantic information in the text. After generating the target text, it does not provide further feedback and iteration mechanisms to optimize the results, resulting in insufficient correlation between the retrieved reference text and the text to be processed. Summary of the Invention
[0005] To address the aforementioned problems in existing technologies, this application provides a knowledge retrieval enhancement method and system based on post-block adaptive re-retrieval.
[0006] The technical solution of this application is as follows:
[0007] On the one hand, this invention proposes a knowledge retrieval enhancement method based on post-block adaptive re-retrieval, the method comprising:
[0008] Acquire user data and set a confidence threshold for a predefined large model; the user data includes knowledge documents and query statements; preprocess the knowledge documents, input the preprocessed knowledge documents into the Colbert embedding model using a post-blocking strategy to obtain word vector groups based on sentences, and divide the preprocessed knowledge documents into text blocks based on semantics; store the word vector groups and text blocks in a vector database;
[0009] The query statement is input into the Colbert embedding model to obtain the query vector; the group containing the word vector corresponding to the query vector is matched in the vector database, and the text block corresponding to the group containing the matched word vector is used as the recall document;
[0010] The preset prompts and the recalled documents are concatenated as input data for a pre-defined large-scale model, and the output is the answer result. The confidence score of each word in the pre-defined large-scale model is calculated. If the word with the highest confidence score is lower than the confidence score threshold, the word is marked as a keyword, and adaptive re-retrieval is performed, specifically as follows:
[0011] The keywords are subjected to keyword masking to obtain keyword masked word segments. An improved Colbert similarity algorithm is used to weight and calculate the similarity between the keyword masked word segments and the unmasked word segments to obtain the total similarity. Specifically, the keyword masked word segment similarity is the similarity between the keyword masked word segments and the query vector; the unmasked word segment similarity is the similarity between the unmasked word segments in the answer results and the query vector.
[0012] Similarity retrieval is performed on a sentence-by-sentence basis in the recalled documents. Different retrieval methods are adopted according to user needs to obtain corresponding re-retrieval results. The re-retrieval results are then input into a predetermined large model to regenerate the answer results. The final answer results are obtained until the confidence scores of all word segments in the answer results are higher than the preset confidence score threshold.
[0013] Preferably, the preprocessing of the knowledge document includes document format normalization, document cleaning, and word segmentation; the method of inputting the preprocessed knowledge document into the embedding model using a post-blocking strategy to obtain sentence vectors is specifically as follows:
[0014] The preprocessing includes document format normalization, document cleaning, and word segmentation; the document cleaning specifically involves removing irrelevant characters from the document, including punctuation marks, numbers, and special symbols.
[0015] The text content in the preprocessed knowledge document is identified, and the text content is segmented using jieba word segmentation technology to obtain a segmented document. ,in Represents a word-segmented document; Indicates the first One document sentence; Indicates the number of sentences; Indicates the first The index value of a sentence in a document; Indicates the first Each word segmentation; Indicates the number of word segmentations; Indicates the first The index value of each word segment;
[0016] The segmented document is input into the Colbert embedding model for vectorization, generating word vectors. ,in Represents a document vector; Indicates the first Word vectors; This indicates the number of word vectors, which is equal to the number of word segments.
[0017] The word vectors belonging to the same sentence in the preprocessed knowledge document will be categorized to obtain word vector groups. ,in Indicates the first Grouping word vectors; Indicates the first The index value of each word vector group; This indicates the number of word vector groups.
[0018] Preferably, the method for dividing the preprocessed knowledge document into text blocks based on semantics specifically includes:
[0019] Perform similarity comparison on document sentences and calculate document sentence similarity. and The similarity between them, of which Indicates the first A document sentence. Indicates the first The index value of a sentence in a document;
[0020] If the similarity is greater than the preset similarity threshold, then and Merge, update The similarity comparison process is repeated until the similarity is less than a preset similarity threshold, at which point the loop stops and the results are updated. ,in Indicates the first A text block;
[0021] from The similarity comparison is repeated until the preprocessed knowledge document is completely segmented, resulting in a set of text blocks. ,in Indicates the number of text blocks.
[0022] Preferably, the specific step of matching the group of word vectors corresponding to the query vector in the vector database involves calculating the similarity between the query vector and the word vector group, using the following formula:
[0023] ;
[0024] In the formula, This indicates the similarity between the query vector and the word vector group; Indicates the first One query vector; Indicates the first The index value of each query vector; Indicates the transpose operation; Represents the maximum value function; Indicates the modulo symbol;
[0025] Groups of word vectors with similarity exceeding a preset threshold are marked, and the text blocks containing these word vector groups are used as the recalled documents.
[0026] Preferably, the confidence level of the response is calculated using the following formula:
[0027] ;
[0028] ;
[0029] In the formula, Indicates the first result in the answer. The original preference logits of each word segment; This indicates the preset weight value; Indicates the preset bias; Indicates the first result in the answer. Confidence of each word segment; Indicates the number of word segments in the answer result; Indicates the first result in the answer. The index value of each word segment;
[0030] Select the word segment with the highest confidence from all the word segments that generate the answer results. If the highest confidence is less than the confidence threshold, mark the word segment as a keyword.
[0031] Preferably, the keywords are subjected to keyword masking to obtain keyword masked word segmentation, specifically as follows:
[0032] The keyword masking process specifically involves replacing keywords with a mask symbol in the answer results. To represent the uncertainty of keywords in the response results, keyword mask segmentation is obtained; the keyword mask segmentation is input into the embedding model to generate a new segmentation vector; specifically, the new segmentation vector is obtained by changing the marker [CLS] of the query vector to the marker [Q], and changing the marker [CLS] of the word vector grouping in the recalled document to the marker [D], resulting in a new query vector and a recalled document vector, represented as follows:
[0033] ;
[0034] ;
[0035] in, Indicates the new query vector; This represents the document vector to be recalled. Represents mask symbol ; This represents the value of the new query vector; This represents the value of the recalled document vector; express Model; Represents a convolutional neural network; Represents the normalization function; This represents the document vector corresponding to the filtered punctuation marks.
[0036] The improved Colbert similarity algorithm is used to perform a weighted calculation of the similarity between word segments corresponding to keyword masks and those corresponding to word segments without keyword masking, expressed by the following formula:
[0037] ;
[0038] ;
[0039] ;
[0040] In the formula, Indicates the overall similarity; Indicates the similarity of keyword mask word segmentation; This indicates the word segmentation similarity without keyword masking. Indicates the first The values of the new query vector, where ; Indicates the first The value of the recalled document vector; Indicates the first The values of the new query vector, where ; This indicates the number of keywords in the new query vector; This indicates the number of tokens in all new query vectors; Indicates the first The index value of each keyword; Indicates the first The index value of a word segment that has not undergone keyword masking; Indicates the first The index value of the recalled document vector; Represents the set of all keywords; This indicates the preset weight.
[0041] Preferably, similarity retrieval is performed on a sentence-by-sentence basis in the recalled documents, and different retrieval methods are adopted according to user needs, including:
[0042] If the user prioritizes accuracy, the word vector group with the highest similarity value is selected as the re-search result; if the user prioritizes completeness, all word vector groups with similarity values greater than the confidence threshold are selected as the re-search result. The re-search result is then input into a predefined large model to regenerate the answer result. The final answer result is obtained when the confidence of all word segments in the answer result is higher than the preset confidence threshold.
[0043] On the other hand, a knowledge retrieval enhancement generation system based on adaptive re-retrieval includes a data acquisition module, a recall information generation module, a confidence judgment module, and an answer output module, wherein:
[0044] The data acquisition module is used to acquire user data and set a confidence threshold for a predefined large model; the user data includes knowledge documents and query statements; the knowledge documents are preprocessed, and the preprocessed knowledge documents are input into the Colbert embedding model using a post-blocking strategy to obtain word vector groups based on sentences, and the preprocessed knowledge documents are divided into text blocks based on semantics; the word vector groups and text blocks are stored in a vector database;
[0045] The recall information generation module is used to input the query statement into the Colbert embedding model to obtain the query vector; match the word vector corresponding to the query vector in the vector database, and take the text block corresponding to the matched word vector group as the recall document; and transmit the answer result to the confidence judgment module.
[0046] The confidence judgment module is used to concatenate preset prompt words with the recalled document as input data for a pre-defined large model and output the answer result; calculate the confidence score of each word when the pre-defined large model generates the answer result; if the word with the highest confidence score is lower than the confidence score threshold, the word is marked as a keyword, and adaptive re-retrieval is performed, specifically by performing keyword masking on the keyword to obtain keyword masked word segmentation; and use an improved Colbert similarity algorithm to perform weighted calculation on the similarity corresponding to the keyword masked word segmentation and the similarity corresponding to the word segmentation without keyword masking to obtain the total similarity. The similarity is defined as follows: the similarity between keyword-masked word segmentation and the query vector; the similarity between word segmentation without keyword masking is defined as the similarity between word segmentation without keyword masking in the answer result and the query vector; similarity retrieval is performed on a sentence-by-sentence basis in the recalled document, and different retrieval methods are adopted according to user needs to obtain corresponding re-retrieval results. The re-retrieval results are input into a predetermined large model to regenerate the answer result; until the confidence of all word segmentation in the answer result is higher than the preset confidence threshold, the final answer result is obtained.
[0047] The answer output module is used to output the final answer result.
[0048] In another aspect, the present invention also proposes an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements a knowledge retrieval enhancement method based on post-block adaptive re-retrieval as described in any embodiment of the present invention.
[0049] In another aspect, the present invention also proposes a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements a knowledge retrieval enhancement method based on post-block adaptive re-retrieval as described in any embodiment of the present invention.
[0050] Compared with the prior art, the beneficial effects of the present invention are:
[0051] 1) This invention provides a knowledge retrieval enhancement method and system based on post-block adaptive re-retrieval. By setting a confidence threshold for a predetermined large model and performing adaptive re-retrieval on words below the threshold, the retrieval results are continuously iterated and optimized, thereby improving the accuracy of information retrieval and enhancing the reliability and relevance of information.
[0052] 2) This invention provides a knowledge retrieval enhancement method and system based on post-block adaptive re-retrieval. By utilizing the post-block strategy and Colbert embedding model, the preprocessed knowledge document is efficiently divided into text blocks, and word vectors are stored in groups by sentence, which simplifies the data structure, speeds up the matching speed of query vectors in the vector database, and improves the processing efficiency of the entire system.
[0053] 3) This invention provides a knowledge retrieval enhancement method and system based on post-block adaptive re-retrieval. By introducing an adaptive re-retrieval mechanism, keyword masking is performed on word segments with insufficient confidence in the answer results, and weighted calculation is performed using an improved Colbert similarity algorithm, which enhances the adaptability and robustness of the system and improves the flexibility to meet query requirements. Attached Figure Description
[0054] Figure 1 This is a flowchart of a method according to an embodiment of the present invention;
[0055] Figure 2 This is a flowchart of the post-blocking strategy in an embodiment of the present invention. Detailed Implementation
[0056] The specific embodiments of the present invention are described below to enable those skilled in the art to understand the present invention. However, it should be understood that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the present invention as defined and determined by the appended claims. All inventions utilizing the concept of the present invention are protected.
[0057] This invention provides the following technical solution: a knowledge retrieval enhancement method and system based on post-block adaptive re-retrieval.
[0058] Example 1
[0059] See details Figure 1 This embodiment provides a knowledge retrieval enhancement method based on post-block adaptive re-retrieval, the specific steps of which include:
[0060] S1. Obtain user data and set a confidence threshold for a predefined large model; the user data includes knowledge documents and query statements; preprocess the knowledge documents; the preprocessing includes document format normalization, document cleaning, and word segmentation; the document cleaning specifically involves removing irrelevant characters from the document, including punctuation marks, numbers, and special symbols;
[0061] S2, please refer to Figure 2 The preprocessed knowledge documents are input into the Colbert embedding model using a post-blocking strategy to obtain word vector groups based on sentences.
[0062] The preprocessing includes document format normalization, document cleaning, and word segmentation; the document cleaning specifically involves removing irrelevant characters from the document, including punctuation marks, numbers, and special symbols.
[0063] The text content in the preprocessed knowledge document is identified, and the text content is segmented using jieba word segmentation technology to obtain a segmented document. ,in Represents a word-segmented document; Indicates the first One document sentence; Indicates the number of sentences; Indicates the first The index value of a sentence in a document; Indicates the first Each word segmentation; Indicates the number of word segmentations; Indicates the first The index value of each word segment;
[0064] The segmented document is input into the Colbert embedding model for vectorization, generating word vectors. ,in Represents a document vector; Indicates the first Word vectors; This indicates the number of word vectors, which is equal to the number of word segments.
[0065] The word vectors belonging to the same sentence in the preprocessed knowledge document will be categorized to obtain word vector groups. ,in Indicates the first Grouping word vectors; Indicates the first The index value of each word vector group; Indicates the number of word vector groups;
[0066] S3. Based on semantics, the preprocessed knowledge document is divided into text blocks; the word vector groups and text blocks are stored in the vector database;
[0067] Perform similarity comparison on document sentences and calculate document sentence similarity. and The similarity between them, of which Indicates the first A document sentence. Indicates the first The index value of a sentence in a document;
[0068] If the similarity is greater than the preset similarity threshold, then and Merge, update The similarity comparison process is repeated until the similarity is less than a preset similarity threshold, at which point the loop stops and the results are updated. ,in Indicates the first A text block;
[0069] from The similarity comparison is repeated until the preprocessed knowledge document is completely segmented, resulting in a set of text blocks. ,in Indicates the number of text blocks;
[0070] S4. Input the query statement into the Colbert embedding model to obtain the query vector; match the group of word vectors corresponding to the query vector in the vector database, and use the text block corresponding to the group of word vectors matched as the recall document;
[0071] The specific steps for matching the word vector group corresponding to the query vector in the vector database are as follows: Calculate the similarity between the query vector and the word vector group. The similarity calculation formula is:
[0072] ;
[0073] In the formula, This indicates the similarity between the query vector and the word vector group; Indicates the first One query vector; Indicates the first The index value of each query vector; Indicates the transpose operation; Represents the maximum value function; Indicates the modulo symbol;
[0074] Tag word vector groups whose similarity exceeds a preset threshold, and use the text blocks corresponding to the word vector groups as recalled documents;
[0075] S5. Concatenate the preset prompts and the recalled documents as input data for the pre-defined large model, and output the answer results; calculate the confidence level of each word when the pre-defined large model generates the answer results. If the word with the highest confidence level is lower than the confidence level threshold, mark the word as a keyword, and perform adaptive re-retrieval, specifically:
[0076] S51. Calculate the confidence level of the response, expressed by the formula:
[0077] ;
[0078] ;
[0079] In the formula, Indicates the first result in the answer. The original preference logits of each word segment; This indicates the preset weight value; Indicates the preset bias; Indicates the first result in the answer. Confidence of each word segment; Indicates the number of word segments in the answer result; Indicates the first result in the answer. The index value of each word segment;
[0080] Select the word segment with the highest confidence from all the word segments that generate the answer results. If the highest confidence is less than the confidence threshold, mark the word segment as a keyword.
[0081] S52. Perform keyword masking on the keywords to obtain keyword masked word segmentation;
[0082] The keyword masking process specifically involves replacing keywords with a mask symbol in the answer results. To represent the uncertainty of keywords in the response results, keyword mask segmentation is obtained; the keyword mask segmentation is input into the embedding model to generate a new segmentation vector; specifically, the new segmentation vector is obtained by changing the marker [CLS] of the query vector to the marker [Q], and changing the marker [CLS] of the word vector grouping in the recalled document to the marker [D], resulting in a new query vector and a recalled document vector, represented as follows:
[0083] ;
[0084] ;
[0085] in, Indicates the new query vector; This represents the document vector to be recalled. Represents mask symbol ; This represents the value of the new query vector; This represents the value of the recalled document vector; express Model; Represents a convolutional neural network; Represents the normalization function; This represents the document vector corresponding to the filtered punctuation marks.
[0086] S53. The improved Colbert similarity algorithm is used to perform a weighted calculation on the similarity between the word segmentation corresponding to the keyword mask and the word segmentation corresponding to the unmasked segment to obtain the total similarity. Specifically, the similarity between the word segmentation corresponding to the keyword mask is the similarity between the word segmentation corresponding to the keyword mask and the query vector; the similarity between the word segmentation corresponding to the unmasked segment in the answer result is the similarity between the word segmentation corresponding to the unmasked segment in the answer result and the query vector.
[0087] The total similarity is expressed by the formula:
[0088] ;
[0089] ;
[0090] ;
[0091] In the formula, Indicates the overall similarity; Indicates the similarity of keyword mask word segmentation; This indicates the word segmentation similarity without keyword masking. Indicates the first The values of the new query vector, where ; Indicates the first The value of the recalled document vector; Indicates the first The values of the new query vector, where ; This indicates the number of keywords in the new query vector; This indicates the number of tokens in all new query vectors; Indicates the first The index value of each keyword; Indicates the first The index value of a word segment that has not undergone keyword masking; Indicates the first The index value of the recalled document vector; Represents the set of all keywords; Indicates the preset weight;
[0092] S6. Perform similarity retrieval on a sentence-by-sentence basis in the recalled documents. Adopt different retrieval methods according to user needs. If the user needs accuracy first, select the word vector group with the highest similarity value as the re-retrieval result. If the user needs completeness first, select all word vector groups with similarity values greater than the confidence threshold as the re-retrieval result. Input the re-retrieval result into the large model to regenerate the answer result. Continue until the confidence of all word segments in the answer result is higher than the preset confidence threshold to obtain the final answer result.
[0093] Example 2
[0094] This embodiment provides a knowledge retrieval enhancement system based on post-block adaptive re-retrieval. The system includes a data acquisition module, a recall information generation module, a confidence judgment module, and an answer output module, wherein:
[0095] The data acquisition module is used to acquire user data and set a confidence threshold for a predefined large model; the user data includes knowledge documents and query statements; the knowledge documents are preprocessed, and the preprocessed knowledge documents are input into the Colbert embedding model using a post-blocking strategy to obtain word vector groups based on sentences, and the preprocessed knowledge documents are divided into text blocks based on semantics; the word vector groups and text blocks are stored in a vector database;
[0096] The recall information generation module is used to input the query statement into the Colbert embedding model to obtain the query vector; match the word vector corresponding to the query vector in the vector database, and take the text block corresponding to the matched word vector group as the recall document; and transmit the answer result to the confidence judgment module.
[0097] The confidence judgment module is used to concatenate preset prompt words with the recalled document as input data for a predefined large model and output the answer result; calculate the confidence score of each word when the predefined large model generates the answer result; if the word with the highest confidence score is lower than the confidence score threshold, the word is marked as a keyword, and adaptive re-retrieval is performed, specifically by performing keyword masking on the keyword to obtain keyword masked word segmentation; and use an improved Colbert similarity algorithm to perform weighted calculation on the similarity corresponding to the keyword masked word segmentation and the similarity corresponding to the word segmentation without keyword masking to obtain the total similarity. Similarity is defined as follows: the similarity corresponding to keyword masking segmentation is specifically the similarity between keyword masking segmentation and query vector; the similarity corresponding to segmentation without keyword masking is specifically the similarity between segmentation without keyword masking in the answer result and query vector; similarity retrieval is performed on a sentence-by-sentence basis in the recalled document, and different retrieval methods are adopted according to user needs to obtain corresponding re-retrieval results. The re-retrieval results are input into the large model to regenerate the answer result; until the confidence of all segmentation in the answer result is higher than the preset confidence threshold, the final answer result is obtained.
[0098] The answer output module is used to output the final answer result.
[0099] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
[0100] Example 3
[0101] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements a knowledge retrieval enhancement method based on post-block adaptive re-retrieval as described in any embodiment of the present invention.
[0102] Example 4
[0103] This embodiment provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a knowledge retrieval enhancement method based on post-block adaptive re-retrieval as described in any embodiment of the present invention.
Claims
1. A knowledge retrieval enhancement method based on post-block adaptive re-retrieval, characterized in that, The method includes: Acquire user data and set a confidence threshold for a predefined large model; the user data includes knowledge documents and query statements; preprocess the knowledge documents, input the preprocessed knowledge documents into the Colbert embedding model using a post-blocking strategy to obtain word vector groups based on sentences, and divide the preprocessed knowledge documents into text blocks based on semantics; store the word vector groups and text blocks in a vector database; The query statement is input into the Colbert embedding model to obtain the query vector; the group containing the word vector corresponding to the query vector is matched in the vector database, and the text block corresponding to the group containing the matched word vector is used as the recall document; The preset prompts and the recalled documents are concatenated as input data for a pre-defined large-scale model, and the output is the answer result. The confidence score of each word in the pre-defined large-scale model is calculated. If the word with the highest confidence score is lower than the confidence score threshold, the word is marked as a keyword, and adaptive re-retrieval is performed, specifically as follows: The keywords are subjected to keyword masking to obtain keyword masked word segments. An improved Colbert similarity algorithm is used to weight and calculate the similarity between the keyword masked word segments and the unmasked word segments to obtain the total similarity. Specifically, the keyword masked word segment similarity is the similarity between the keyword masked word segments and the query vector; the unmasked word segment similarity is the similarity between the unmasked word segments in the answer results and the query vector. Similarity retrieval is performed on a sentence-by-sentence basis in the recalled documents. Different retrieval methods are adopted according to user needs to obtain corresponding re-retrieval results. The re-retrieval results are then input into a predetermined large model to regenerate the answer results. The final answer results are obtained until the confidence scores of all word segments in the answer results are higher than the preset confidence score threshold.
2. The knowledge retrieval enhancement method based on post-block adaptive re-retrieval according to claim 1, characterized in that, The preprocessing of the knowledge document includes document format normalization, document cleaning, and word segmentation; the method of inputting the preprocessed knowledge document into the embedding model using a post-blocking strategy to obtain sentence vectors is as follows: The preprocessing includes document format normalization, document cleaning, and word segmentation; the document cleaning specifically involves removing irrelevant characters from the document, including punctuation marks, numbers, and special symbols. The text content in the preprocessed knowledge document is identified, and the text content is segmented using jieba word segmentation technology to obtain a segmented document. ,in Represents a word-segmented document; Indicates the first One document sentence; Indicates the number of sentences; Indicates the first The index value of a sentence in a document; Indicates the first Each word segmentation; Indicates the number of word segmentations; Indicates the first The index value of each word segment; The segmented document is input into the Colbert embedding model for vectorization, generating word vectors. ,in Represents a document vector; Indicates the first Word vectors; This indicates the number of word vectors, which is equal to the number of word segments. The word vectors belonging to the same sentence in the preprocessed knowledge document will be categorized to obtain word vector groups. ,in Indicates the first Grouping word vectors; Indicates the first The index value of each word vector group; This indicates the number of word vector groups.
3. The knowledge retrieval enhancement method based on post-block adaptive re-retrieval according to claim 1, characterized in that, The method for dividing the preprocessed knowledge document into text blocks based on semantics is as follows: Perform similarity comparison on document sentences and calculate document sentence similarity. and The similarity between them, of which Indicates the first A document sentence. Indicates the first The index value of a sentence in a document; If the similarity is greater than the preset similarity threshold, then and Merge, update The similarity comparison process is repeated until the similarity is less than a preset similarity threshold, at which point the loop stops and the results are updated. ,in Indicates the first A text block; from The similarity comparison is repeated until the preprocessed knowledge document is completely segmented, resulting in a set of text blocks. ,in Indicates the number of text blocks.
4. The knowledge retrieval enhancement method based on post-block adaptive re-retrieval according to claim 1, characterized in that, The specific steps for matching the word vector group corresponding to the query vector in the vector database are as follows: Calculate the similarity between the query vector and the word vector group. The similarity calculation formula is: ; In the formula, This indicates the similarity between the query vector and the word vector group; Indicates the first One query vector; Indicates the first The index value of each query vector; Indicates the transpose operation; Represents the maximum value function; Indicates the modulo symbol; Groups of word vectors with a similarity exceeding a preset threshold are labeled, and the text blocks corresponding to the word vector groups are used as recalled documents.
5. The knowledge retrieval enhancement method based on post-block adaptive re-retrieval according to claim 1, characterized in that, The confidence level of the response is calculated using the following formula: ; ; In the formula, Indicates the first result in the answer. The original preference logits of each word segment; This indicates the preset weight value; Indicates the preset bias; Indicates the first result in the answer. Confidence of each word segment; Indicates the number of word segments in the answer result; Indicates the first result in the answer. The index value of each word segment; Select the word segment with the highest confidence from all the word segments that generate the answer results. If the highest confidence is less than the confidence threshold, mark the word segment as a keyword.
6. The knowledge retrieval enhancement method based on post-block adaptive re-retrieval according to claim 5, characterized in that, The keywords are subjected to keyword masking to obtain keyword masked word segmentation, specifically as follows: The keyword masking process specifically involves replacing keywords with a mask symbol in the answer results. To represent the uncertainty of keywords in the response results, keyword mask segmentation is obtained; the keyword mask segmentation is input into the embedding model to generate a new segmentation vector; specifically, the new segmentation vector is obtained by changing the marker [CLS] of the query vector to the marker [Q], and changing the marker [CLS] of the word vector grouping in the recalled document to the marker [D], resulting in a new query vector and a recalled document vector, represented as follows: ; ; in, Indicates the new query vector; Represents the document vector for recall; Represents mask symbol ; This represents the value of the new query vector; This represents the value of the recalled document vector; express Model; Represents a convolutional neural network; Represents the normalization function; This represents the document vector corresponding to the filtered punctuation marks. The improved Colbert similarity algorithm is used to weight the similarity of word segments without keyword masking, and the similarity of word segments without keyword masking is calculated. The formula is as follows: ; ; ; In the formula, Indicates the overall similarity; Indicates the similarity of keyword mask word segmentation; This indicates the word segmentation similarity without keyword masking. Indicates the first The values of the new query vector, where ; Indicates the first The value of the recalled document vector; Indicates the first The values of the new query vector, where ; This indicates the number of keywords in the new query vector; This indicates the number of tokens in all new query vectors; Indicates the first The index value of each keyword; Indicates the first The index value of a segmented word that has not undergone keyword masking; Indicates the first The index value of the recalled document vector; Represents the set of all keywords; This indicates the preset weight.
7. The knowledge retrieval enhancement method based on post-block adaptive re-retrieval according to claim 1, characterized in that, Similarity retrieval is performed on a sentence-by-sentence basis in the recalled documents. Different retrieval methods are adopted according to user needs, including: If the user prioritizes accuracy, the word vector group with the highest similarity value is selected as the re-search result; if the user prioritizes completeness, all word vector groups with similarity values greater than the confidence threshold are selected as the re-search result. The re-search result is then input into a predefined large model to regenerate the answer result. The final answer result is obtained when the confidence of all word segments in the answer result is higher than the preset confidence threshold.
8. A knowledge retrieval enhancement system based on post-block adaptive re-retrieval, characterized in that, The system includes a data acquisition module, a recall information generation module, a confidence level judgment module, and an answer output module, wherein: The data acquisition module is used to acquire user data and set a confidence threshold for a predefined large model; the user data includes knowledge documents and query statements; the knowledge documents are preprocessed, and the preprocessed knowledge documents are input into the embedding model using a post-blocking strategy to obtain word vector groups based on sentences, and the preprocessed knowledge documents are divided into text blocks based on semantics; the word vector groups based on sentences and the text blocks are stored in a vector database; The recall information generation module is used to input the query statement into the embedded model to obtain a query vector; match the word vector group corresponding to the query vector in the vector database, calculate the similarity between the query vector and the word vector group, and use the text block where the word vector group is located as the recall document; concatenate the preset prompt words with the recall document as input data for a predetermined large model, and output the answer result; and transmit the answer result to the confidence judgment module. The confidence judgment module is used to concatenate preset prompt words with the recalled document as input data for a predetermined large model and output the answer result; calculate the confidence score of each word when the predetermined large model generates the answer result; if the word with the highest confidence score is lower than the confidence score threshold, the word is marked as a keyword, and adaptive re-retrieval is performed, specifically by performing keyword masking on the keyword to obtain keyword masked word segmentation; and using an improved Colbert similarity algorithm to perform weighted calculation on the similarity scores corresponding to keyword masked word segmentation and the similarity scores corresponding to word segmentation without keyword masking to obtain the total similarity score. In this process, the keyword masking segmentation similarity is specifically the similarity between the keyword masked segmentation and the query vector; the segmentation in the answer result that has not undergone keyword masking is specifically the similarity between the segmentation in the answer result that has not undergone keyword masking and the query vector; similarity retrieval is performed on a sentence-by-sentence basis in the recalled document, and different retrieval methods are adopted according to user needs to obtain corresponding re-retrieval results. The re-retrieval results are then input into a predetermined large model to regenerate the answer results; until the confidence of all segmentation in the answer results is higher than the preset confidence threshold, the final answer result is obtained. The answer output module is used to output the final answer result.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements a knowledge retrieval enhancement method based on post-block adaptive re-retrieval as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements a knowledge retrieval enhancement method based on post-block adaptive re-retrieval as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Retrieval enhancement generation method based on vector similarity matching optimization
CN117573815A
Text Retrieval Method Based on Confidence-Correlation Coefficient Framework Mining Rule Predecessor
CN109299278A
Text multi-hop reasoning question and answer method using two-stage retrieval
CN116383347A