An enhanced question answering method integrating context awareness

By performing vector representation and knowledge block screening on user queries, the defects of the existing RAG methods in correlation evaluation and information utilization are solved, and more accurate and coherent Q&A results are achieved, and system performance and user experience are improved.

CN119760082APending Publication Date: 2025-04-04CHINA TELECOM SHANGHAI IDEAL INFORMATION IND GRP
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411875518.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-19
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

The existing RAG method has significant flaws in the evaluation of document-query relevance, resulting in inaccurate or misleading responses. The traditional method fails to effectively utilize context information when processing retrieved documents, which increases the computational burden of the model and reduces the accuracy and system performance of the answers.

Method used

An enhanced question-and-answer method is adopted to integrate context perception, and the relevant knowledge blocks are retrieved by vector representation of the received query information, and the knowledge blocks used for answer generation are filtered based on the correlation and position information of the knowledge blocks to generate the response result.

Benefits of technology

Improve the coherence, relevance and accuracy of the answers, reduce the risk of generating "illusions", and improve the performance and user experience of the Q&A system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119760082A_ABST
    Figure CN119760082A_ABST
Patent Text Reader

Abstract

This application proposes an enhanced question-answering method that integrates context awareness and proposes an innovative solution. In the process of building a knowledge base, a context-preserving strategy is adopted to retain key semantic information, ensure semantic coherence, and prevent context loss. In the question-answering process, the user's query intent is first identified and refined to generate more precise query statements, and keywords are extracted from them to improve the accuracy and relevance of semantic and full-text retrieval; and multiple embedding models are used to search the knowledge base to identify text fragments that are highly consistent with the user's query intent, and the relevance and continuity processing of the initially identified text fragments are performed to provide continuous and relevant information retrieval and answers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of natural language processing technology, and in particular, the present application provides an enhanced question-answering method integrating context awareness. Background Art

[0002] In the field of natural language processing (NLP), large language models (LLMs) such as GPT-4 and GLM-4 are widely used. However, the effectiveness of RAG systems depends largely on the relevance of the retrieved documents. If the retrieval process is biased or inaccurate, even if the LLM is highly expressive, the generated answers may be affected, leading to inaccurate or misleading results.

[0003] Existing RAG methods have significant deficiencies in assessing the relevance of documents to queries. Specifically, these systems often fail to effectively identify and filter the document content that is most relevant to the user's query, but instead pass all retrieved documents indiscriminately as input to the generation model. This approach introduces a large amount of irrelevant information, dilutes the concentration of key information, and may cause the model to "hallucinate" when generating answers. In addition, when processing retrieved documents, traditional RAG methods often use the entire document content as input, without considering that only part of the content is actually relevant to generating answers. This information redundancy approach increases the model's computational burden, affects the effective extraction and utilization of key information, and reduces answer accuracy and system performance. Summary of the invention

[0004] In view of the above-mentioned problems in the prior art, the purpose of this application is to provide an enhanced question-answering method integrating context awareness, which can improve the coherence, relevance and accuracy of answers.

[0005] In order to solve the above technical problems, the specific technical solutions of this application are as follows:

[0006] On the one hand, the present application provides an enhanced question-answering method that integrates context awareness, characterized in that the method includes: performing vector representation on the received query information to obtain a query vector; retrieving the knowledge block corresponding to the query vector from a knowledge base to obtain an initial knowledge block set; wherein the knowledge base stores knowledge blocks and index information of the knowledge blocks, the index information includes an identifier of the knowledge block and position information of the knowledge block in the document, and the position information is used to characterize the semantic order of the text block in the document; evaluating the relevance of the knowledge blocks in the initial knowledge block set to the query information; based on the relevance and position information of each knowledge block in the initial knowledge block set, screening out the knowledge blocks used for answer generation from the initial knowledge block set to obtain an associated knowledge block set; and generating a response result to the query information based on the associated knowledge block set.

[0007] In some embodiments, the vector representation of the received query information includes: extracting query intent from the query information to obtain a rewritten query statement; using m embedding models to respectively vectorize the query information and the rewritten query statement to obtain n query vectors, where n and m are integers greater than or equal to 1.

[0008] In some embodiments, retrieving the knowledge block corresponding to the query vector from the knowledge base includes: searching the query vector in the knowledge base to obtain a first search result corresponding to the query vector, the first search result including the knowledge block retrieved based on the query vector and the search score of the knowledge block; extracting query keywords from the rewritten query statement, searching the query keywords in the knowledge block using the BM25 algorithm, and obtaining a second search result, the second search result including the knowledge block retrieved based on the BM25 algorithm and the search score of the knowledge block; for any retrieved knowledge block, fusing the search scores for the knowledge block in n first search results and the second search results to obtain a fusion score of the knowledge block; and preliminarily screening the retrieved knowledge blocks based on the fusion score to obtain an initial set of knowledge blocks.

[0009] In some embodiments, the step of fusing the first search results and the second search results corresponding to the n query vectors includes:

[0010]

[0011] Where d represents the knowledge block, n is the number of query vectors, and λ i is the weight of the embedding model corresponding to the i-th query vector, λ bm25 is the weight of the BM25 algorithm, score i (d) is the retrieval score of the i-th query vector for knowledge block d, score bm25 (d) is the retrieval score of the BM25 algorithm for knowledge block d, and Score(d) is the fusion score of knowledge block d.

[0012] In some embodiments, the information in the knowledge base is generated in the following manner: performing layout analysis and text recognition on the document to obtain text blocks and document structure information of the text blocks; extracting the position information of the text blocks in the document; and reorganizing the text blocks according to the document structure information and position information of the text blocks to obtain knowledge blocks and position information of the knowledge blocks.

[0013] In some embodiments, the document structure information includes the structure type of the text block, and the structure type includes a title block and a non-title block; the text block is reorganized according to the document structure information and position information of the text block to obtain the knowledge block and the position information of the knowledge block, including: storing the text block in a text block list in semantic order based on the position information of the text block; taking out the text blocks from the text block list in sequence, if the text block currently being processed is a title block, checking whether the temporary list already contains the non-title block, if it contains the non-title block, adding all the text blocks in the temporary list as a knowledge unit to the final list, and clearing the temporary list, adding the text block currently being processed to the cleared temporary list; if the text block currently being processed is a text block, adding it to the temporary list; wherein the temporary list is used to store text blocks, and the final list is used to store knowledge units; after the text block list is traversed, checking whether the temporary list is empty, if not empty, adding the content in the temporary list as a knowledge unit to the final list; based on the knowledge units in the final list and the position information of each text block corresponding to the knowledge unit, generate the knowledge blocks in the knowledge base and the position information of the knowledge blocks.

[0014] In some embodiments, the knowledge units in the final list and the position information of the text blocks corresponding to the knowledge units are used to generate the knowledge blocks and the position information of the knowledge blocks in the knowledge base, including: when the text length of the knowledge unit does not exceed the preset text length threshold, the knowledge unit is used as a knowledge block, and the position information of the knowledge block is generated based on the position information of the text blocks corresponding to the knowledge unit; when the text length of the knowledge unit exceeds the preset text length threshold, the text segmentation points of the knowledge unit are extracted, the text of the knowledge unit is segmented using the text segmentation points to obtain knowledge sub-units, and the knowledge unit is processed using summary generation technology to generate summary information of the knowledge unit, and the summary information is associated with the knowledge sub-unit to obtain the knowledge block corresponding to the knowledge sub-unit; and the position information of the knowledge block corresponding to the knowledge sub-unit is generated based on the position information of the text blocks corresponding to the knowledge sub-unit.

[0015] In some embodiments, extracting the position information of the text block in the document includes: extracting the vertical coordinates of the text block in the document, the vertical coordinates are used to represent the order of the text blocks in the vertical direction in the document; constructing a gap tree according to the horizontal coordinates of the text blocks based on the extracted vertical coordinates of the text blocks, wherein the gap tree is used to represent the horizontal intervals between the text blocks; sorting the text blocks in the same row according to the horizontal intervals and adjusting the coherence so that the text blocks are arranged in order from left to right;

[0016] The sequence information of the text blocks is used as the position information of the text blocks.

[0017] In some embodiments, based on the relevance and position information of each knowledge block in the initial knowledge block set, the knowledge blocks for answer generation are screened out from the initial knowledge block set, including: screening out knowledge blocks whose relevance meets a first relevance requirement as first associated knowledge blocks from the initial knowledge block set, and screening out knowledge blocks whose relevance meets a second relevance requirement as candidate knowledge blocks; wherein the first relevance requirement includes a relevance greater than a first relevance threshold or the first X relevances sorted from large to small, the second relevance requirement includes a relevance greater than a second relevance threshold or the first Y relevances sorted from large to small, the first relevance threshold is greater than the second relevance threshold, X and Y are positive integers, and X is less than Y; extracting a candidate knowledge block whose position is continuous with the first associated knowledge block as a second associated knowledge block, and extracting a candidate knowledge block whose position is continuous with the second associated knowledge block as a third associated knowledge block; storing the first associated knowledge block, the second associated knowledge block and the third associated knowledge block in the associated knowledge block set to generate a response result of the query information based on the associated knowledge block set.

[0018] In some embodiments, the LLM model fine-tuned by LoRA technology is used to extract query intent from the query information; and / or, the relevance of the knowledge blocks in the initial knowledge block set to the query information is evaluated by using a fine-tuned BERT model.

[0019] This application proposes an innovative solution, which effectively solves the problems of insufficient relevance evaluation and information redundancy by integrating context-aware mechanisms and enhanced retrieval strategies, improves question-answering performance and user experience, and improves the coherence, relevance and accuracy of answers by accurately evaluating the retrieved knowledge, thereby reducing the risk of generating "hallucinations".

[0020] In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the following specifically cites preferred embodiments and describes them in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0022] Figure 1 A question-and-answer flow chart of an embodiment of the present application is shown;

[0023] Figure 2 The knowledge processing flow chart of the embodiment of the present application is shown;

[0024] Figure 3 A schematic diagram of the internal structure of a computer device according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0027] In order to solve the above problems, the embodiments of the present application provide an enhanced question-answering method that integrates context awareness. This specification provides method operation steps as described in the embodiments or flowcharts, but more or fewer operation steps may be included based on conventional or non-creative labor. The order of steps listed in the embodiments is only one way of executing the steps among many orders, and does not represent the only order of execution. When the actual system or device product is executed, it can be executed in the order of the methods shown in the embodiments or the drawings or in parallel. Specifically, Figure 1 As shown, the method may include:

[0028] S20: Perform vector representation on the received query information to obtain a query vector.

[0029] After receiving the query information input by the user, the original query information can be parsed and optimized to generate a more accurate query expression, reduce the number of parameters, and improve query accuracy and efficiency. The method of vectorizing the received query information is not limited here. For example, the query information can be processed using an LLM model to obtain a query vector.

[0030] In some embodiments, the vector representation of the received query information may include: extracting query intent from the query information to obtain a rewritten query statement; using m embedding models to respectively vectorize the query information and the rewritten query statement to obtain n query vectors, where n and m are integers greater than or equal to 1.

[0031] For example, the LLM model fine-tuned by LoRA technology can be used to extract query intent from the query information. The pre-trained LLM is fine-tuned using LoRA technology to adapt to specific user intent recognition tasks. LoRA reduces the number of trainable parameters for downstream tasks by injecting a trainable low-rank decomposition matrix into each layer of the Transformer architecture, thereby improving the efficiency and effectiveness of fine-tuning. During the fine-tuning process, only the LoRA parameters are updated, while the original LLM parameters remain unchanged, so that the original knowledge of the model can be maintained while quickly adapting to new task requirements.

[0032] The fine-tuned LLM model is used to identify the user's query intent and generate a rewritten query statement to improve the accuracy and efficiency of retrieval. The rewritten query statement will be used in subsequent semantic retrieval to ensure that the retrieved documents are highly relevant to the user's query intent.

[0033] Keywords can also be extracted from the rewritten query statement, which will be used for subsequent BM25 contextual keyword retrieval.

[0034] Therefore, we can use advanced natural language processing technology to accurately capture and understand the user's query intention, and then generate more precise and complete query statements and extracted keywords to improve the accuracy and relevance of retrieval, and significantly enhance the performance of the question-answering system and user experience.

[0035] Embedding models such as BGE and BCE can be selected to keep consistent with knowledge block embedding. The vectors generated by each model can be used to represent different semantic features of the query statement. The user's original query and its rewritten query are represented by vectors through multiple embedding models, and multiple vector representations from different angles are generated. The query vector representations of multiple embedding models can be used to retrieve the most relevant knowledge blocks from different semantic spaces to ensure the comprehensiveness and accuracy of the retrieval.

[0036] Multiple embedding models are used to vectorize the user's original query and its rewritten query, achieving multi-angle semantic matching. This strategy allows the system to retrieve the most relevant knowledge blocks from different semantic spaces, significantly improving the comprehensiveness and accuracy of the retrieval.

[0037] S22: Retrieve the knowledge block corresponding to the query vector from the knowledge base to obtain an initial set of knowledge blocks; wherein the knowledge base stores knowledge blocks and index information of the knowledge blocks, the index information includes the identifier of the knowledge block and the position information of the knowledge block in the document, and the position information is used to characterize the semantic order of the text block in the document.

[0038] The knowledge base may store knowledge blocks and index information of the knowledge blocks, wherein the index information includes the identifier of the knowledge block and the position information of the knowledge block in the document, and the position information is used to characterize the semantic order of the text block in the document. A unique storage ID is generated for each knowledge block, and an index table is constructed to record the ID of each knowledge block and its corresponding position information. During the retrieval process, the index table can be used to quickly locate and recall relevant knowledge blocks based on the similarity query results, thereby ensuring the contextual semantic continuity of the knowledge block and improving the logical coherence and accuracy of the retrieved information.

[0039] In some embodiments, the document can be subjected to layout analysis and text recognition to obtain text blocks and document structure information of the text blocks; the position information of the text blocks in the document can be extracted; the text blocks can be reorganized according to the document structure information and position information of the text blocks to obtain knowledge blocks and position information of the knowledge blocks.

[0040] (1) Layout analysis: Use layout analysis techniques (such as layout analysis and block segmentation) to conduct preliminary analysis of the document and identify different text blocks and non-text areas. Layout analysis techniques can help the system understand the structure of the document, including structural information such as titles, paragraphs, tables, and images.

[0041] (2) Text recognition: Use OCR technology to perform character recognition on the identified text blocks and extract the content and coordinate information of each text block. OCR technology can convert text in an image into editable text data.

[0042] In some embodiments, the vertical coordinates of the text blocks in the document may be extracted, and the vertical coordinates are used to represent the vertical order of the text blocks in the document; based on the vertical coordinates of the text blocks extracted, a gap tree is constructed according to the horizontal coordinates of the text blocks, wherein the gap tree is used to represent the horizontal intervals between the text blocks; the text blocks in the same row are sorted and the coherence is adjusted according to the horizontal intervals, so that the text blocks are arranged in order from left to right; and the order information of the text blocks is used as the position information of the text blocks. For example,

[0043] (3) Initial sorting: The text in the document is arranged vertically and horizontally, with the text on the top first, the text on the bottom last, the text on the left first, and the text on the right last. A preliminary sorting can be performed based on the vertical coordinates (y coordinates) of the text blocks to ensure that the text blocks are roughly arranged in order from top to bottom. This step ensures the basic order of the text blocks in the vertical direction.

[0044] (4) Horizontal adjustment: Based on the preliminary sorting, the gap tree sorting algorithm is used to adjust the text blocks in the same row to ensure that the text blocks are arranged from left to right. The specific steps are as follows:

[0045] ①Build a gap tree: Build a gap tree based on the horizontal coordinates (x coordinates) of the text blocks. The gap tree is a data structure used to represent the horizontal spacing between text blocks.

[0046] ② Calculate horizontal spacing: Calculate the horizontal spacing between adjacent text blocks to ensure that the spacing value can reflect the actual arrangement of the text blocks.

[0047] ③ Adjust the order: adjust the text blocks in the same row according to the spacing values ​​in the gap tree to ensure that the text blocks are arranged from left to right.

[0048] ④ Handle special cases: For text blocks with small horizontal spacing, consider that they may be part of continuous paragraphs or tables, and perform special processing to maintain their coherence.

[0049] (5) Processing cross-page text blocks: For cross-page text blocks, merge and sort them according to their coordinate information on different pages to ensure the continuity of the cross-page text blocks. This step solves the problem of text block breakage that may occur in multi-page documents.

[0050] (6) Returning the sorted text block list: Returning the sorted text block list to the subsequent processing module to ensure that the subsequent processing module receives the text blocks arranged in the order of the original document.

[0051] The region coordinate information is used to accurately sort the recognized text blocks, ensuring that the text blocks are arranged in the order of the original document, thereby maintaining the fluency and accuracy of the text content.

[0052] In some embodiments, the document structure information includes a structure type of a text block, and the structure type includes a title block and a non-title block; and the text block is reorganized according to the document structure information and position information of the text block to obtain a knowledge block and the position information of the knowledge block, including:

[0053] Based on the position information of the text blocks, the text blocks are stored in a text block list in a semantic order;

[0054] Take out text blocks from the text block list in sequence. If the text block currently being processed is a title block, check whether the temporary list already contains non-title blocks. If it contains non-title blocks, add all text blocks in the temporary list as a knowledge unit to the final list, clear the temporary list, and add the text block currently being processed to the cleared temporary list; if the text block currently being processed is a text block, add it to the temporary list; wherein the temporary list is used to store text blocks, and the final list is used to store knowledge units;

[0055] After the text block list is traversed, check whether the temporary list is empty. If not, add the content in the temporary list as a knowledge unit to the final list;

[0056] Based on the knowledge units in the final list and the position information of the text blocks corresponding to the knowledge units, the knowledge blocks and the position information of the knowledge blocks in the knowledge base are generated.

[0057] (1) Initialization:

[0058] ① Create a temporary list `temp_list` to store text blocks.

[0059] ② Create a final list `final_units` to store knowledge units.

[0060] (2) Traverse the sorted text block list:

[0061] ①Processing title block:

[0062] If the current text block is a title block, add it to `temp_list`:

[0063] Check if `temp_list` already contains a non-header block;

[0064] If it contains a non-title block, it means that the previous knowledge unit has been completed, the information in `temp_list` is added to `final_units`, and `temp_list` is cleared;

[0065] Add the current title block to the empty `temp_list`.

[0066] ②Processing the text block:

[0067] If the current text block is a body block, add it to `temp_list`.

[0068] ③Process the last knowledge unit:

[0069] After the traversal is completed, check whether `temp_list` is empty;

[0070] If it is not empty, add the information in `temp_list` to `final_units`.

[0071] ④Return the reorganized knowledge unit list:

[0072] Returns `final_units` to subsequent processing modules.

[0073] In some embodiments, the generating of the knowledge blocks and the position information of the knowledge blocks in the knowledge base based on the knowledge units in the final list and the position information of the text blocks corresponding to the knowledge units includes:

[0074] When the text length of the knowledge unit does not exceed the preset text length threshold, the knowledge unit is regarded as a knowledge block, and the position information of the knowledge block is generated based on the position information of each text block corresponding to the knowledge unit;

[0075] When the text length of a knowledge unit exceeds a preset text length threshold, the text segmentation points of the knowledge unit are extracted, the text of the knowledge unit is segmented using the text segmentation points to obtain knowledge sub-units, and the knowledge unit is processed using summary generation technology to generate summary information of the knowledge unit, and the summary information is associated with the knowledge sub-unit to obtain the knowledge block corresponding to the knowledge sub-unit; and based on the position information of each text block corresponding to the knowledge sub-unit, the position information of the knowledge block corresponding to the knowledge sub-unit is generated.

[0076] Text segmentation points: Use natural language processing techniques (such as syntactic analysis, semantic segmentation, etc.) to detect logical segmentation points within a paragraph (such as the end of a sentence). These segmentation points are used to determine the appropriate cutting position to ensure that each segmented part has independent semantic integrity.

[0077] Summary information: Use summary generation technology (such as BART, GPT, etc.) to generate short summaries to retain key semantic information. These summaries help ensure that each segmented part still contains complete semantic information. Associating the summary information with the knowledge sub-unit can make the knowledge block corresponding to the knowledge sub-unit have complete semantic meaning.

[0078] For example, the coordinate information or sorting corresponding to the knowledge block can be determined based on the coordinate information or sorting of each text block corresponding to the knowledge block. It can be seen from the above embodiments that the position information of the text block can represent the arrangement order of the text block in the original document. The position information of the knowledge block determined based on the position information of each text block can also represent the arrangement order of the knowledge block in the original document, thereby ensuring the semantic order of each knowledge block in the document.

[0079] The knowledge blocks that have undergone sequence optimization and semantic integration can be vectorized through multiple pre-trained embedding models to obtain multiple vector representations corresponding to the knowledge blocks, and the multiple vector representations corresponding to the knowledge blocks are stored in the knowledge base and assigned storage IDs. The multiple vector representations corresponding to a knowledge block correspond to one ID; or, the multiple vector representations corresponding to a knowledge block correspond to multiple IDs, but some of the information in the multiple IDs is the same, so that the same part is used to represent the knowledge blocks, thereby representing that the multiple vector representations correspond to the same knowledge block, which is convenient for subsequent index recall.

[0080] In some embodiments, retrieving the knowledge block corresponding to the query vector from the knowledge base includes: searching the query vector in the knowledge base to obtain a first search result corresponding to the query vector, the first search result including the knowledge block retrieved based on the query vector and the search score of the knowledge block; extracting query keywords from the rewritten query statement, searching the query keywords in the knowledge block using the BM25 algorithm, and obtaining a second search result, the second search result including the knowledge block retrieved based on the BM25 algorithm and the search score of the knowledge block; for any retrieved knowledge block, fusing the search scores for the knowledge block in n first search results and the second search results to obtain a fusion score of the knowledge block; and preliminarily screening the retrieved knowledge blocks based on the fusion score to obtain an initial set of knowledge blocks.

[0081] In some embodiments, the step of fusing the first search results and the second search results corresponding to the n query vectors includes:

[0082]

[0083] Where d represents the knowledge block, n is the number of query vectors, and λ i is the weight of the embedding model corresponding to the i-th query vector, λ bm25 is the weight of the BM25 algorithm, score i (d) is the retrieval score of the i-th query vector for knowledge block d, score bm25 (d) is the retrieval score of the BM25 algorithm for knowledge block d, and Score(d) is the fusion score of knowledge block d.

[0084] The semantic importance of each word and sentence can be evaluated through natural language processing techniques (such as term frequency-inverse document frequency TF-IDF, word vector similarity, etc.). According to the evaluation results, the corresponding weight is assigned to the retrieval results of each embedding model. The weight calculation formula can be expressed as:

[0085] w j =f(importancej )

[0086] Among them, w j is the weight of the jth embedding model, importance j is the semantic importance score of the jth embedding model, and f is a mapping function used to convert the importance score into a weight value. In the final sorting process, the retrieval results of each embedding model are weighted according to its weight, thereby highlighting the key semantic information. The weight of the BM25 algorithm can be processed in a similar way.

[0087] S24: Evaluate the relevance between the knowledge blocks in the initial knowledge block set and the query information; based on the relevance and position information of each knowledge block in the initial knowledge block set, filter out the knowledge blocks used for answer generation from the initial knowledge block set to obtain a set of associated knowledge blocks.

[0088] The retrieval relevance evaluator can be used to accurately evaluate the relevance of the retrieved knowledge blocks. This evaluation process aims to effectively screen out knowledge blocks that are highly relevant to the user's query and eliminate low-relevance content to reduce information redundancy, thereby significantly improving the accuracy and response efficiency of the answer generation model in question answering.

[0089] The fine-tuned BERT model can be used to evaluate the relevance between the knowledge blocks in the initial knowledge block set and the query information. The retrieval relevance evaluator fine-tunes the BERT model to generate a model specifically used to determine whether the query statement and the knowledge block are relevant, and uses the fine-tuned BERT model to classify the relevance of the retrieved knowledge blocks to determine whether each knowledge block is relevant to the user query. Of course, other relevance evaluation models can also be used to construct the retrieval relevance evaluator, which is not limited here.

[0090] In some embodiments, based on the relevance and position information of each knowledge block in the initial knowledge block set, the knowledge blocks for answer generation are screened out from the initial knowledge block set, including: screening out knowledge blocks whose relevance meets a first relevance requirement as first associated knowledge blocks, and screening out knowledge blocks whose relevance meets a second relevance requirement as candidate knowledge blocks; wherein the first relevance requirement includes a relevance greater than a first relevance threshold or the first X relevances sorted from large to small, the second relevance requirement includes a relevance greater than a second relevance threshold or the first Y relevances sorted from large to small, the first relevance threshold is greater than the second relevance threshold, X and Y are positive integers, and X is less than Y; extracting a candidate knowledge block whose position is continuous with the first associated knowledge block as a second associated knowledge block, and extracting a candidate knowledge block whose position is continuous with the second associated knowledge block as a third associated knowledge block; storing the first associated knowledge block, the second associated knowledge block and the third associated knowledge block in an associated knowledge block set, processing the associated knowledge block set using an answer generation model, and obtaining a response result of the query information.

[0091] The initial knowledge block set is a preliminary screened out knowledge block that is similar and continuous to the query information. The initial knowledge block set can be further subjected to relevance analysis, and after the relevance analysis, the continuity of the screened knowledge blocks can be further ensured, thereby outputting relevant and continuous knowledge blocks.

[0092] For example, T1 can be set as a set of directly related knowledge points (ie, a set of first associated knowledge blocks), and F can be set as a set of candidate knowledge blocks.

[0093] ① Directly related: If knowledge block k belongs to set T1, it will be retained.

[0094] And perform the following consistency check on the alternative knowledge blocks in F:

[0095] ② Context continuity: If the knowledge block k is contextually continuous with a knowledge block in set T1, it will also be retained and form set T2.

[0096] ③ Exclude irrelevant ones: For knowledge blocks k outside T2 in F, if knowledge block k cannot form a coherent context with the knowledge blocks in set T2, it will be excluded from set F to form set T3.

[0097] In order to solve the problem of context information disconnection that may occur during the retrieval process, this embodiment innovatively implements a context coherence check mechanism to ensure that the knowledge blocks input into the LLM not only meet high standards in terms of relevance, but also maintain the fluency of the context.

[0098] S26: Generate a response result of the query information based on the associated knowledge block set.

[0099] For example, a large language model (LLM) can be used to construct an answer generation model. Of course, other language models can also be used to construct an answer generation model, which is not limited here. The associated knowledge block set can be input into the answer generation model to obtain a response result of the query information, and then the response result of the LLM can be formatted and returned to the user to complete the question-answering process.

[0100] Based on the scheme of the above embodiment, in the process of knowledge base construction, a context retention strategy is adopted to retain key semantic information, ensure semantic coherence and prevent context loss. In the question-answering process, the user's query intent is first identified and refined, a more accurate query statement is generated, and keywords are extracted from it to improve the accuracy and relevance of semantic and full-text retrieval; and multiple embedding models are used to search the knowledge base to identify text fragments that are highly consistent with the user's query intent, and the relevance and continuity processing of the initially identified text fragments are performed to provide continuous and relevant information retrieval and answers.

[0101] Based on the solution provided by the above embodiment, the present application also provides an enhanced question-answering system integrating context awareness, which can provide users with more accurate and comprehensive information services. The technical processing solution of the present application mainly involves the following modules:

[0102] 1. Sequence optimization and semantic integration module

[0103] This module focuses on solving the problem of disordered order in text parsing and is committed to creating structured and semantically coherent knowledge units. Figure 2 , the execution process of this module is divided into the following three stages:

[0104] 1.1 Coordinate-oriented text block serialization

[0105] Function: Use regional coordinate information to accurately sort the recognized text blocks, ensuring that the text blocks are arranged in the order of the original document, thereby maintaining the fluency and accuracy of the text content.

[0106] Specific implementation:

[0107] Input: text blocks and their coordinate information obtained through OCR or other text recognition technologies.

[0108] Output: A list of text blocks in the order of the original document.

[0109] step:

[0110] (1) Layout analysis: Use layout analysis techniques (such as layout analysis and block segmentation) to perform preliminary analysis on the document and identify different text blocks and non-text areas. Layout analysis techniques can help the system understand the structure of the document, including titles, paragraphs, tables, images, etc.

[0111] (2) Text recognition: Use OCR technology to perform character recognition on the identified text blocks and extract the content and coordinate information of each text block. OCR technology can convert text in an image into editable text data.

[0112] (3) Initial sorting: Perform preliminary sorting based on the vertical coordinates (y coordinates) of the text blocks to ensure that the text blocks are roughly arranged in order from top to bottom. This step ensures the basic order of the text blocks in the vertical direction.

[0113] (4) Horizontal adjustment: Based on the preliminary sorting, the gap tree sorting algorithm is used to adjust the text blocks in the same row to ensure that the text blocks are arranged from left to right. The specific steps are as follows:

[0114] ①Build a gap tree: Build a gap tree based on the horizontal coordinates (x coordinates) of the text blocks. The gap tree is a data structure used to represent the horizontal spacing between text blocks.

[0115] ② Calculate horizontal spacing: Calculate the horizontal spacing between adjacent text blocks to ensure that the spacing value can reflect the actual arrangement of the text blocks.

[0116] ③ Adjust the order: adjust the text blocks in the same row according to the spacing values ​​in the gap tree to ensure that the text blocks are arranged from left to right.

[0117] ④ Handle special cases: For text blocks with small horizontal spacing, consider that they may be part of continuous paragraphs or tables, and perform special processing to maintain their coherence.

[0118] (5) Processing cross-page text blocks: For cross-page text blocks, merge and sort them according to their coordinate information on different pages to ensure the continuity of the cross-page text blocks. This step solves the problem of text block breakage that may occur in multi-page documents.

[0119] (6) Returning the sorted text block list: Returning the sorted text block list to the subsequent processing module to ensure that the subsequent processing module receives the text blocks arranged in the order of the original document.

[0120] 1.2 Feature-driven knowledge unit reorganization

[0121] Function: Analyze the features of sorted text blocks (such as titles, text, etc.) and reorganize the text blocks into knowledge units with clear semantic structures.

[0122] Specific implementation:

[0123] Input: List of coordinate-oriented text block serialization.

[0124] Output: List of reorganized knowledge units.

[0125] step:

[0126] (1) Initialization:

[0127] ① Create a temporary list `temp_list` to store text blocks.

[0128] ② Create a final list `final_units` for knowledge units.

[0129] (2) Traverse the sorted text block list:

[0130] ①Processing title block:

[0131] If the current text block is a title block, add it to `temp_list`;

[0132] Check if `temp_list` already contains a non-header block:

[0133] If it contains a non-title block, it means that the previous knowledge unit has been completed, the information in `temp_list` is added to `final_units`, and `temp_list` is cleared;

[0134] Add the current title block to a new `temp_list`.

[0135] ②Processing the text block:

[0136] If the current text block is a body block, add it to `temp_list`.

[0137] ③Process the last knowledge unit:

[0138] After the traversal is complete, check if `temp_list` is empty:

[0139] If it is not empty, add the information in `temp_list` to `final_units`.

[0140] ④Return the reorganized knowledge unit list:

[0141] Returns `final_units` to subsequent processing modules.

[0142] 1.3 Semantic Integrity Maintenance and Length Adaptive Processing Unit

[0143] (1) Function: When the generated knowledge unit exceeds the preset length, an intelligent method is used to ensure its semantic coherence and completeness.

[0144] Specific implementation:

[0145] Input: List of reorganized knowledge units.

[0146] Output: List of knowledge units after length adaptation.

[0147] step:

[0148] (1) Traverse the reorganized knowledge unit list: For each knowledge unit, check whether its length exceeds the preset maximum length.

[0149] (2) Processing of extra-long knowledge units:

[0150] ① Detect segmentation points: Use natural language processing techniques (such as syntactic analysis, semantic segmentation, etc.) to detect logical segmentation points within a paragraph (such as the end of a sentence). These segmentation points are used to determine the appropriate cutting position to ensure that each segmented part has independent semantic integrity.

[0151] ② Generate summaries: Use summary generation techniques (such as BART, GPT, etc.) to generate short summaries to retain key semantic information. These summaries help ensure that each segmented part still contains complete semantic information.

[0152] 2. Semantic weighted ranking and fusion retrieval module

[0153] This module designs a semantic weighted sorting algorithm, which combines the output of the multi-dimensional embedding model with the traditional BM25 search results, aiming to achieve efficient and accurate sorting of knowledge blocks. The following is a detailed explanation of this module.

[0154] 2.1 Weight Allocation Driven by Semantic Importance

[0155] Function: This module adopts an innovative weight assignment mechanism to assign weights to the retrieval results of each embedding model according to semantic importance, thereby highlighting the priority of key semantic information in the sorting process.

[0156] Specific implementation:

[0157] Semantic importance assessment: The semantic importance of each word and sentence is assessed through natural language processing techniques (such as term frequency-inverse document frequency TF-IDF, word vector similarity, etc.).

[0158] Weight calculation: According to the evaluation results, the corresponding weight is assigned to the retrieval results of each embedding model. The weight calculation formula can be expressed as:

[0159] w j =f(importance j )

[0160] Among them, w j is the weight of the jth embedding model, importance j is the semantic importance score of the jth embedding model, and f is a mapping function used to convert the importance score into a weight value.

[0161] Weight application: In the final ranking process, the retrieval results of each embedding model are weighted according to its weight, thereby highlighting key semantic information.

[0162] 2.2 Multi-model integrated retrieval technology

[0163] Function: This module innovatively designs a multi-model integrated retrieval technology, which cleverly combines the vector retrieval results generated by different embedding models with the BM25 retrieval results, achieving a dual improvement in retrieval accuracy and semantic depth.

[0164] Specific implementation:

[0165] Embedding model selection: Select multiple embedding models (BGE, BCE, etc.). The vectors generated by each model represent different semantic features of the document.

[0166] Vector retrieval: Search the vectors generated by each embedding model to obtain the corresponding retrieval results.

[0167] BM25 retrieval: Use the traditional BM25 algorithm to search for documents and obtain retrieval results based on word frequency statistics.

[0168] Result fusion: The retrieval results of different embedding models are fused with the BM25 retrieval results. The specific fusion formula can be expressed as:

[0169]

[0170] Where d represents the knowledge block, n is the number of query vectors, and λ i is the weight of the embedding model corresponding to the i-th query vector, λ bm25 is the weight of the BM25 algorithm, score i (d) is the retrieval score of the i-th query vector for knowledge block d, score bm25 (d) is the retrieval score of the BM25 algorithm for knowledge block d, and Score(d) is the fusion score of knowledge block d.

[0171] 3. Query intent refinement module

[0172] As one of the key components of this system, the query intent refinement module uses advanced natural language processing technology to accurately capture and understand the user's query intent, and then generates more accurate and complete query statements and extracted keywords, significantly improving the performance of the question-answering system and user experience. Its main functions and implementation methods are:

[0173] Function: By fine-tuning the Large Language Model (LLM), it identifies and refines the user's query intent, generates more precise query statements, and extracts keywords from them to improve the accuracy and relevance of retrieval.

[0174] Specific implementation:

[0175] LoRA technology fine-tuning LLM: Use LoRA technology to fine-tune the pre-trained LLM to adapt to specific user intent recognition tasks. LoRA reduces the number of trainable parameters for downstream tasks by injecting a trainable low-rank decomposition matrix into each layer of the Transformer architecture, thereby improving the efficiency and effectiveness of fine-tuning. During the fine-tuning process, only the LoRA parameters are updated, while the original LLM parameters remain unchanged, so that the original knowledge of the model can be maintained while quickly adapting to new task requirements.

[0176] User intent identification and query rewriting: The fine-tuned LLM model is used to identify the user's query intent and generate a rewritten query statement to improve the accuracy and efficiency of retrieval. The rewritten query statement will be used in subsequent semantic retrieval to ensure that the retrieved documents are highly relevant to the user's query intent.

[0177] Keyword extraction: Extract keywords from the rewritten query statement, which will be used for subsequent BM25 contextual keyword retrieval.

[0178] 4. Multi-path similarity retrieval and knowledge block index recall module

[0179] The core innovation of this module lies in its efficient multi-way similarity retrieval process and unique knowledge block index recall mechanism, which ensures the depth and accuracy of the retrieval.

[0180] 4.1 Multi-way Similarity Retrieval

[0181] Function: The module uses multiple embedding models to vectorize the user's original query and its rewritten query, achieving multi-angle semantic matching. This strategy allows the system to retrieve the most relevant knowledge blocks from different semantic spaces, significantly improving the comprehensiveness and accuracy of the retrieval.

[0182] Specific implementation:

[0183] Embedding model selection: Multiple embedding model selections are consistent with knowledge block embedding. The vectors generated by each model represent different semantic features of the query statement.

[0184] Vector representation: The user's original query and its rewritten query are represented by vectors through multiple embedding models to generate vector representations from multiple different angles.

[0185] Multi-angle matching: Through the query vector representation of multiple embedding models, the most relevant knowledge blocks are retrieved from different semantic spaces to ensure the comprehensiveness and accuracy of the retrieval.

[0186] 4.2 Knowledge Block Index Recall

[0187] Function: The module innovatively implements index recall based on knowledge block storage ID, ensuring the contextual continuity within the retrieved knowledge blocks and improving the integrity and availability of information.

[0188] Specific implementation:

[0189] Index building: Reference Figure 2 , a unique storage ID can be generated for each knowledge block in advance, and an index table can be built to record the ID of each knowledge block and its corresponding location information.

[0190] Index recall: During the retrieval process, the index table is used to quickly locate and recall relevant knowledge blocks based on the similarity query results, ensuring the contextual continuity of the knowledge blocks.

[0191] 5. Context-aware module

[0192] The core innovation of this module lies in its efficient knowledge block relevance assessment mechanism and contextual coherence guarantee mechanism, which ensures that the knowledge blocks input into LLM not only meet high standards in relevance but also maintain contextual fluency.

[0193] 5.1 Knowledge Block Relevance Evaluation Mechanism

[0194] Function: The retrieval relevance evaluator is used to accurately evaluate the relevance of the retrieved knowledge blocks. This evaluation process is designed to effectively screen out knowledge blocks that are highly relevant to the user's query and eliminate low-relevance content to reduce information redundancy, thereby significantly improving the accuracy and response efficiency of the Large Language Model (LLM) in question answering.

[0195] Specific implementation:

[0196] Fine-tuning the BERT model: The retrieval relevance evaluator fine-tunes the BERT model to generate a model specifically used to determine whether the query statement and the knowledge block are relevant.

[0197] Relevance evaluation: Use the fine-tuned BERT model to classify the relevance of the retrieved knowledge blocks and determine whether each knowledge block is relevant to the user query.

[0198] 5.2 Contextual Coherence Guarantee Mechanism

[0199] Function: To address the problem of contextual information discontinuity that may occur during the retrieval process, this module innovatively implements a contextual coherence check mechanism to ensure that the knowledge blocks input into the LLM not only meet high standards in terms of relevance, but also maintain the fluency of the context.

[0200] Specific implementation:

[0201] Related knowledge point set: Let T be the set of directly related knowledge points, S be the set of contextual knowledge points related to T, and F be the result set selected by S after relevance evaluation.

[0202] Continuity check:

[0203] ① Directly related: If the knowledge block k belongs to the set T, it will be retained.

[0204] ② Context continuity: If the knowledge block k does not belong to the set T, but has contextual continuity with a knowledge block in the set T, it will also be retained.

[0205] ③ Eliminate irrelevant ones: If the knowledge block k neither belongs to the set T nor can form a coherent context with the knowledge blocks selected in ② in the F set, it is excluded from the F set.

[0206] ④ Context maintenance: Through coherence checking, ensure that the knowledge blocks input into LLM are not only relevant in content, but also coherent in context, thereby improving the integrity and usability of information.

[0207] This application innovatively creates an enhanced question-answering system that integrates context-aware technology. The system greatly improves the accuracy and efficiency of question-answering by combining multiple embedding models. The system first uses a highly optimized large language model (LLM) to intelligently parse and reconstruct user queries to achieve the best match with the information source. After that, the knowledge base retrieval module with multi-model embedding is used to efficiently identify text fragments that are highly consistent with the user's query intent. A context recall module is further introduced, which uses multiple embedding models to retrieve contextual information closely related to the target text from the vector repository in real time.

[0208] In addition, the system is equipped with a dedicated relevance evaluation component to ensure the accuracy of the retrieved contextual information; and uses a context continuity filtering mechanism to ensure the semantic coherence and completeness of the context fragments used when generating answers.

[0209] Based on this, the question-answering system of this application is particularly suitable for processing complex queries. It can not only respond quickly, but also provide accurate and easy-to-understand answers, thereby significantly enhancing the user's interactive experience. Through this system, the limitations of existing question-answering systems in processing complex data queries are solved, providing users with more efficient and accurate information retrieval services.

[0210] refer to Figure 1 Based on the above system, this application also provides a specific example as follows:

[0211] Step 1: Data collection and preprocessing

[0212] (1) First, collect a large amount of unstructured data from data sources, such as technical manuals, professional reports, research papers, etc.

[0213] (2) Convert these documents in different formats into PDF format to ensure the uniformity of the document format.

[0214] (3) Use optical character recognition (OCR) technology to parse PDF documents and extract text content. In this process, advanced image preprocessing technology is used to improve the recognition accuracy of OCR, including denoising, tilt correction, layout analysis, etc.

[0215] Step 2: Text sequence optimization and semantic integration

[0216] (1) The text data after OCR parsing is transferred to the sequence optimization and semantic integration module.

[0217] (2) In the coordinate-oriented text block serialization stage, the system sorts the text blocks according to their position coordinates in the original document to ensure the correctness of the text order.

[0218] (3) In the feature-driven knowledge unit reorganization stage, the system reorganizes knowledge units according to the format features of the text block (such as title, subtitle, list, etc.) to form structured knowledge blocks.

[0219] (4) In the semantic integrity maintenance and length adaptive processing unit, the overlong text is intelligently truncated or summarized to ensure the semantic integrity of the knowledge unit.

[0220] Step 3: Knowledge Block Index Construction

[0221] (1) The knowledge blocks that have undergone sequence optimization and semantic integration are vectorized through multiple pre-trained embedding models.

[0222] (2) The vectorized knowledge blocks are stored in the knowledge base and each knowledge block is assigned a unique storage ID to facilitate subsequent index recall.

[0223] Step 4: Query intent refinement

[0224] (1) After the user submits a query, the query intent refinement module uses LoRA technology to parse and optimize the original query.

[0225] (2) By adding a low-rank matrix to the original model, a more accurate query expression Q' is generated, which reduces the number of parameters and improves computational efficiency.

[0226] Step 5: Multi-way similarity retrieval and knowledge block index recall

[0227] (1) The multiple rewritten queries obtained in step 4 are vectorized using multiple embedding models, and similarity retrieval is performed in parallel.

[0228] (2) According to the Top K parameters, the knowledge blocks most relevant to the query are recalled from the knowledge base to ensure the contextual continuity between knowledge blocks.

[0229] Step 6: Context Awareness

[0230] (1) Using the knowledge block relevance evaluation mechanism, the recalled knowledge blocks are evaluated for relevance and high-relevance knowledge blocks are screened out.

[0231] (2) Through the contextual coherence guarantee mechanism, the contextual continuity of the knowledge block is checked to ensure that the knowledge block finally provided to the LLM is both relevant and coherent.

[0232] Step 7: Generate Q&A prompt words

[0233] (1) Integrate the knowledge information screened out in step 6 according to a specific question and answer prompt word template to generate question and answer prompt words.

[0234] (2) Ensure that the prompt words can guide the LLM to generate accurate and comprehensive answers.

[0235] Step 8: Question-Answering System Response

[0236] (1) Input the generated question-answer prompt words into the Large Language Model (LLM) to generate the answer.

[0237] (2) The LLM response result is formatted and returned to the user, completing the question-and-answer process.

[0238] Through context-aware mechanisms and query intent refinement technology, complex queries can be quickly responded to and easy-to-understand answers can be provided. By accurately evaluating the knowledge retrieved and recalled, the risk of generating inaccurate or misleading information and the risk of "hallucination" can be reduced. And through semantic integrity maintenance and length adaptive processing technology, the semantic coherence and integrity of knowledge units can be ensured when the length is limited. Therefore, this application can effectively maintain the semantic integrity of knowledge units when processing ultra-long texts through the context coherence guarantee strategy, and improve the accuracy and response quality of the question-answering system in the process of information transmission.

[0239] This embodiment provides a computer device, whose internal structure diagram can be shown as follows: Figure 3 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection.

[0240] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0241] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0242] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0243] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0244] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0245] It should also be understood that in the embodiments of the present application, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present application generally indicates that the associated objects before and after are in an "or" relationship.

[0246] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0247] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0248] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.

[0249] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present application.

[0250] Specific embodiments are used in this application to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core idea of ​​this application. At the same time, for those skilled in the art, according to the idea of ​​this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on this application.

Claims

1. An enhanced question-answering method integrating context awareness, characterized in that: The method comprises: Performing vector representation on the received query information to obtain a query vector; Retrieving the knowledge blocks corresponding to the query vector from the knowledge base to obtain an initial knowledge block set; wherein the knowledge base stores knowledge blocks and index information of the knowledge blocks, the index information includes the identifier of the knowledge block and the position information of the knowledge block in the document, and the position information is used to represent the semantic order of the text block in the document; Evaluate the relevance between the knowledge blocks in the initial knowledge block set and the query information; based on the relevance and position information of each knowledge block in the initial knowledge block set, select the knowledge blocks used for answer generation from the initial knowledge block set to obtain a set of associated knowledge blocks; A response result of the query information is generated based on the associated knowledge block set.

2. The method according to claim 1, characterized in that The vector representation of the received query information includes: Extracting query intent from the query information to obtain a rewritten query statement; The query information and the rewritten query statement are respectively represented by vectors using m embedding models to obtain n query vectors, where n and m are integers greater than or equal to 1.

3. The method according to claim 2, characterized in that The retrieving the knowledge block corresponding to the query vector from the knowledge base includes: Searching the query vector in the knowledge base to obtain a first search result corresponding to the query vector, the first search result including knowledge blocks retrieved based on the query vector and search scores of the knowledge blocks; Extracting query keywords from the rewritten query statement, searching the query keywords in the knowledge block using the BM25 algorithm, and obtaining a second search result, wherein the second search result includes the knowledge block retrieved based on the BM25 algorithm and the search score of the knowledge block; For any retrieved knowledge block, fusion of the retrieval scores for the knowledge block in the n first retrieval results and the second retrieval results to obtain a fusion score for the knowledge block; The retrieved knowledge blocks are preliminarily screened based on the fusion scores to obtain an initial set of knowledge blocks.

4. The method according to claim 3, characterized in that: The fusing the first search results and the second search results corresponding to the n query vectors includes: Where d represents the knowledge block, n is the number of query vectors, and λ i is the weight of the embedding model corresponding to the i-th query vector, λ bm25 is the weight of the BM25 algorithm, score i (d) is the retrieval score of the i-th query vector for knowledge block d, score bm25 (d) is the retrieval score of the BM25 algorithm for knowledge block d, and Score(d) is the fusion score of knowledge block d.

5. The method according to claim 1, characterized in that The information in the knowledge base is generated in the following way: Performing layout analysis and text recognition on the document to obtain text blocks and document structure information of the text blocks; Extracting the position information of the text block in the document; The text blocks are reorganized according to the document structure information and the position information of the text blocks to obtain knowledge blocks and the position information of the knowledge blocks.

6. The method according to claim 5, characterized in that The document structure information includes the structure type of the text block, and the structure type includes a title block and a non-title block; the text block is reorganized according to the document structure information and the position information of the text block to obtain the knowledge block and the position information of the knowledge block, including: Based on the position information of the text blocks, the text blocks are stored in a text block list in a semantic order; Take out text blocks from the text block list in sequence. If the text block currently being processed is a title block, check whether the temporary list already contains non-title blocks. If it contains non-title blocks, add all text blocks in the temporary list as a knowledge unit to the final list, clear the temporary list, and add the text block currently being processed to the cleared temporary list; if the text block currently being processed is a text block, add it to the temporary list; wherein the temporary list is used to store text blocks, and the final list is used to store knowledge units; After the text block list is traversed, check whether the temporary list is empty. If not, add the content in the temporary list as a knowledge unit to the final list; Based on the knowledge units in the final list and the position information of each text block corresponding to the knowledge units, the knowledge blocks in the knowledge base and the position information of the knowledge blocks are generated.

7. The method according to claim 6, characterized in that The step of generating the knowledge blocks and the position information of the knowledge blocks in the knowledge base based on the knowledge units in the final list and the position information of the text blocks corresponding to the knowledge units includes: When the text length of the knowledge unit does not exceed the preset text length threshold, the knowledge unit is regarded as a knowledge block, and the position information of the knowledge block is generated based on the position information of each text block corresponding to the knowledge unit; When the text length of a knowledge unit exceeds a preset text length threshold, the text segmentation points of the knowledge unit are extracted, the text of the knowledge unit is segmented using the text segmentation points to obtain knowledge sub-units, and the knowledge unit is processed using summary generation technology to generate summary information of the knowledge unit, and the summary information is associated with the knowledge sub-unit to obtain the knowledge block corresponding to the knowledge sub-unit; and based on the position information of each text block corresponding to the knowledge sub-unit, the position information of the knowledge block corresponding to the knowledge sub-unit is generated.

8. The method according to any one of claims 5 to 7, characterized in that: The extracting the position information of the text block in the document includes: Extracting the vertical coordinates of the text blocks in the document, where the vertical coordinates are used to represent the order of the text blocks in the vertical direction in the document; On the basis of extracting the vertical coordinates of the text blocks, constructing a gap tree according to the horizontal coordinates of the text blocks, wherein the gap tree is used to represent the horizontal intervals between the text blocks; Sorting and coherence-adjusting the text blocks in the same row according to the horizontal interval so that the text blocks are arranged in order from left to right; The sequence information of the text blocks is used as the position information of the text blocks.

9. The method according to claim 1, characterized in that: The step of selecting knowledge blocks for answer generation from the initial knowledge block set based on the relevance and position information of each knowledge block in the initial knowledge block set includes: Filter out knowledge blocks whose relevance meets a first relevance requirement from the initial knowledge block set as first associated knowledge blocks, and filter out knowledge blocks whose relevance meets a second relevance requirement as candidate knowledge blocks; wherein the first relevance requirement includes a relevance greater than a first relevance threshold or the first X relevances sorted from large to small, the second relevance requirement includes a relevance greater than a second relevance threshold or the first Y relevances sorted from large to small, the first relevance threshold is greater than the second relevance threshold, X and Y are positive integers, and X is less than Y; Extracting a candidate knowledge block that is continuous in position with the first associated knowledge block as a second associated knowledge block, and extracting a candidate knowledge block that is continuous in position with the second associated knowledge block as a third associated knowledge block; The first associated knowledge block, the second associated knowledge block and the third associated knowledge block are stored in an associated knowledge block set, so as to generate a response result of the query information based on the associated knowledge block set.

10. The method according to claim 2, characterized in that The LLM model fine-tuned by LoRA technology is used to extract query intent from the query information; and / or, the relevance of the knowledge blocks in the initial knowledge block set to the query information is evaluated by using the fine-tuned BERT model.

Citation Information

Cited By

  • Text processing method, electronic equipment, storage medium and program product

    CN120179796A

  • Data retrieval method and system, storage medium, electronic equipment and program product

    CN121705333A