Intelligent question answering method and system based on problem index retrieval enhanced generation technology
By segmenting knowledge base documents into fragments and extracting summary question vectors, an index retrieval system is constructed. This solves the problem in existing technologies that cannot effectively improve the retrieval performance of long texts or multi-topic documents, and achieves higher accuracy in generating answers.
Patent Information
- Application Number
- CN202510179300.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2045-02-18
AI Technical Summary
Existing search enhancement generation technologies suffer from limited search performance when dealing with long texts or multi-topic documents, and cannot effectively improve the accuracy of generated answers.
The knowledge base documents are segmented into pieces, and summary questions are extracted as hypothetical question vectors. Answers are generated through index retrieval and a large language model. By using hypothetical questions to cover the core semantics of the documents, semantic gaps are reduced, and an efficient semantic space is constructed for retrieval.
It improves retrieval hit rate and accuracy, reduces semantic gap, and enhances the accuracy of large model-generated answers, especially in the case of long texts or multi-topic documents.
Smart Images

Figure CN120124640B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to an intelligent question-answering method and system based on question index retrieval enhancement generation technology, and relates to the field of natural language processing technology. Background Technology
[0002] In the Retrieval Augmentation (RAG) framework, the performance of the retrieval module is highly dependent on the semantic similarity between the input question and the document or fragment. However, due to the diversity and complexity of natural language expressions, there is often a semantic gap between the input question and the document, limiting retrieval effectiveness. In international research, common optimization techniques include question rewriting and hypothetical document embedding, primarily based on semantic adjustments to user input. These methods focus on optimizing from the query end, with hypothesis generation relying on the model's understanding of the query, but they do not fully consider the mining of potential information from the document. While they perform well in handling semantically complex or ambiguous queries, they may still suffer from insufficient information coverage when dealing with long texts or multi-topic documents, thus limiting the improvement of retrieval performance.
[0003] Therefore, how to effectively improve the retrieval performance of RAG technology to ensure the accuracy of the answers generated by the large model has become a key technical issue of concern to technical personnel. Summary of the Invention
[0004] In view of this, the purpose of this invention is to provide an intelligent question-answering method and system based on question index retrieval enhancement generation technology, which can effectively improve the retrieval performance of RAG technology, thereby ensuring the accuracy of answers generated by large models.
[0005] To achieve the above objectives, this invention provides an intelligent question-answering method based on question index retrieval enhancement generation technology, comprising:
[0006] Step 1: Divide all documents in the knowledge base into multiple document fragments, then extract several summary questions from each document fragment as hypothetical questions for the document fragment, then vectorize each hypothetical question to form an ordered set of hypothetical question vectors for the document fragment, and finally use the ordered set of hypothetical question vectors for each document fragment as an index to build a query database.
[0007] Step 2: Rewrite the user-input question and generate a quantized user question vector. Then, retrieve document fragments related to the user question from the query database through index retrieval. The specific process of index retrieval is as follows: Calculate the similarity between the user question vector and each hypothetical question vector in the ordered set of hypothetical question vectors for each document fragment in the query database. Select all hypothetical question vectors with similarity greater than a threshold. Then, sort the selected hypothetical question vectors in descending order of similarity. Select the top-ranked hypothetical question vectors. Finally, extract the document fragments to which the selected hypothetical question vectors belong to form the user question-related text set.
[0008] Step 3: Combine the user question and related texts to form prompt words, and generate the corresponding answer to the user question using a large language model.
[0009] To achieve the above objectives, the present invention also provides an intelligent question-answering system based on question index retrieval enhancement generation technology, comprising:
[0010] The index generation device is used to divide all documents in the knowledge base into multiple document fragments, extract several summary questions from each document fragment as hypothetical questions for the document fragment, vectorize each hypothetical question to form an ordered set of hypothetical question vectors for the document fragment, and finally use the ordered set of hypothetical question vectors for each document fragment as an index to build a query library.
[0011] The document selection device is used to rewrite the user's input question and generate a quantized user question vector. Then, it retrieves document fragments related to the user question from the query database through index retrieval. The specific process of index retrieval is as follows: calculate the similarity between the user question vector and each hypothetical question vector in the ordered set of hypothetical question vectors for each document fragment in the query database, select all hypothetical question vectors with similarity greater than a threshold, sort the selected hypothetical question vectors in descending order of similarity, select the top-ranked hypothetical question vectors, and finally extract the document fragments to which the selected hypothetical question vectors belong to form a text set related to the user question.
[0012] The answer generation device is used to construct prompt words from the user's question and related text, and then generate the answer corresponding to the user's question through a large language model.
[0013] To achieve the above objectives, the present invention also provides a computing device, comprising:
[0014] Memory and processor;
[0015] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, they implement the steps of the intelligent question-answering method based on question index retrieval enhancement generation technology.
[0016] To achieve the above objectives, the present invention also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the intelligent question-answering method based on question index retrieval enhancement generation technology.
[0017] Compared with existing technologies, the beneficial effects of this invention are as follows: Since the expression of the original question may be inconsistent with the document content, and long documents may suffer semantic loss during vectorization, this invention automatically generates hypothetical questions using a large language model. This supplements diverse semantic perspectives, uncovers potential information, and reduces the semantic gap between questions and answers. Constructed metadata (such as paragraph summaries and hypothetical questions) can provide more semantic anchors for the retrieval module, enabling it to find relevant content within a broader semantic scope. Specifically, this invention uses a large model to generate questions that can be answered in the document, and then calculates the similarity between the original question and the hypothetical question during retrieval to reduce the semantic gap between questions and answers. Simultaneously, it applies semantic coverage and semantic diversity indicators to improve the quality of the ordered set of hypothetical questions, thereby increasing the hit rate and accuracy of the retrieval. This invention effectively compresses the information content of the source document through a summary question extraction method, extracting only the necessary information. Specifically, several core semantic information is generated from the source document, including several key hypothetical questions. The answers to these questions can be derived directly from the document or through reasoning. These key questions constitute a compact and efficient semantic space. Compared to direct retrieval in the original semantic space, the constructed semantic space allows the query questions to be retrieved within a semantic range that is closer to it, thereby greatly reducing the size of the query semantic space. In the process of using an embedding model to map text to a high-dimensional semantic space, this invention uses embedding vectors to represent each text (such as questions or documents). However, since embedding is usually a compressed representation of content (such as sentence vectors or paragraph vectors), information loss may occur when capturing text details. This invention can effectively mitigate the impact of detail loss by extracting short text questions from long texts and embedding them into a high-dimensional semantic space, and ensures that the ordered set of hypothetical questions can fully cover the important semantic units in the document and have semantic differences. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating an exemplary embodiment of the present invention of an intelligent question-answering method based on question index retrieval enhancement generation technology.
[0019] Figure 2This is an exemplary embodiment of the present invention. Figure 1 The flowchart shows the specific steps involved in step one: extracting several summary questions from each document fragment as hypothetical questions for the document fragment.
[0020] Figure 3 This is a schematic diagram illustrating the structure of an intelligent question-answering system based on question index retrieval enhancement generation technology, as shown in an exemplary embodiment of the present invention.
[0021] Figure 4 This is a schematic diagram of the structure of a computer device shown in an exemplary embodiment of the present invention. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings.
[0023] like Figure 1 As shown, the intelligent question-answering method based on question index retrieval enhancement generation technology of the present invention includes:
[0024] Step 1: Divide all documents in the knowledge base into multiple document fragments, then extract several summary questions from each document fragment as hypothetical questions for the document fragment, then vectorize each hypothetical question to form an ordered set of hypothetical question vectors for the document fragment, and finally use the ordered set of hypothetical question vectors for each document fragment as an index to build a query database.
[0025] Step 2: Rewrite the user-input question and generate a quantized user question vector. Then, retrieve document fragments related to the user question from the query database through index retrieval. The specific process of index retrieval is as follows: Calculate the similarity between the user question vector and each hypothetical question vector in the ordered set of hypothetical question vectors for each document fragment in the query database. Select all hypothetical question vectors with similarity greater than a threshold. Then, sort the selected hypothetical question vectors in descending order of similarity. Select the top-ranked hypothetical question vectors. Finally, extract the document fragments to which the selected hypothetical question vectors belong to form the user question-related text set.
[0026] The COT (Cognitive Chain) method can be used to rewrite the questions entered by users;
[0027] Step 3: Combine the user question and related texts to form prompt words, and generate the corresponding answer to the user question using a large language model.
[0028] In step one, content extraction can also be performed on documents in the knowledge base, converting non-text data into text data. When the uploaded document is in HTML, PDF, docx, or other formats, the corresponding extractor is used to extract the document content. If image data exists, the specific processing procedure is as follows:
[0029] First, extract the captions or annotations of the images. Then, perform OCR (Operative Character Recognition) on the images to extract character information. Next, input the captions or annotations and character information of the images into a multimodal large model to generate image description information. Finally, use the captions or annotations, character information, and image description information of the images to replace the image data in the knowledge base.
[0030] In step one, a summary question for each document fragment can be generated using a large language model. Then, based on semantic coverage and diversity, several hypothetical questions are selected from the summary questions. For example... Figure 2 As shown, taking document segment D as an example, Figure 1 In step one, several summary questions are extracted from each document fragment as hypothetical questions for the document fragmentation, which may include:
[0031] Step 11: Generate the summary content and summary question set corresponding to document segment D through the large language model. The summary question set contains n summary questions, where n is the preset number of summary questions, and its value can be set according to actual business needs.
[0032] The large language model can be asked to extract summary questions from multiple perspectives such as "use", "definition", and "facts", and the extracted n summary questions constitute a summary question set;
[0033] Step 12: Construct an ordered set Q of hypothetical questions and initialize it as an empty set. At the same time, initialize the set semantic coverage Cov0 and the set semantic diversity value Div0 to 0.
[0034] Step 13: Select each summarizing problem from the set of summarizing problems one by one, and calculate the information gain value corresponding to each summarizing problem: Info_Gain(q i )=α*(Cov(q i )-Cov0)+(1-α)*(Div(q i )-Div0), q i It is the i-th summarizing problem in the set of summarizing problems, Info_Gain(q i ),Cov(q i Div(q) i ) are respectively q iThe corresponding information gain value, contribution to semantic coverage, and contribution to semantic diversity are defined. α is an importance weight parameter used to adjust coverage and diversity; its value can be set according to actual business needs. Then, the maximum information gain value is selected from all summarizing questions, and the summarizing question corresponding to the maximum value is written into the ordered set of hypothetical questions Q. This summarizing question is then removed from the summarizing question set. Simultaneously, the set semantic coverage Cov0 and the set semantic diversity value Div0 are updated. ’ =Cov0+Cov(q) u ), Div0 ’ =Div0+Div(q) u ), Cov0 ’ Div0 ’ It is the updated set semantic coverage and set semantic diversity value, q u This is a summary problem corresponding to the maximum value;
[0035] Step 14: Determine whether the number of hypothetical questions in the ordered set of hypothetical questions Q is less than the preset threshold m for the number of hypothetical questions. If yes, proceed to step 13; otherwise, vectorize each hypothetical question in the ordered set of hypothetical questions Q to generate an ordered set of hypothetical question vectors. m can be set according to actual business needs.
[0036] In step 13, Cov(q) i The calculation process is as follows:
[0037] First, the document is broken down into multiple semantic units such as paragraphs, sentences, phrases, or keywords, and then an embedding model is used to integrate the q... i Each semantic unit is converted into a vector representation, and then q is calculated one by one. i The cosine similarity between the vector representation of each semantic unit and the vector representation of each semantic unit is calculated, and finally Cov(q) is calculated. i ): Where Total_Units is the number of semantic units in a document fragment, NUM_Units(q i ) is q i The total number of semantic units covered by the summary question is represented by the number of semantic units whose cosine similarity to the vector representations of all semantic units in the document segment is greater than a preset threshold.
[0038] Div(q i The calculation formula for ) is as follows: Where Q_NUM is the number of hypothetical problems in the ordered set Q of hypothetical problems, v qj It is the vector representation of the j-th hypothetical problem in the ordered set of hypothetical problems Q. It is q i vector representation, yes Cosine similarity between them.
[0039] To more clearly explain the technical effects of the method of the present invention, the following is an embodiment of the index retrieval method of the present invention:
[0040] Document fragment D:
[0041] Dujiangyan, one of the most famous ancient water conservancy projects in China, is located on the Minjiang River in Sichuan Province. Built under the supervision of Li Bing and his son, its primary functions are flood control and irrigation. Dujiangyan uses a fish-mouth structure to divide the Minjiang River into the Inner River and the Outer River, effectively reducing the threat of floods to downstream farmland. At the same time, the project significantly improved agricultural productivity in the Minjiang River basin, contributing to the prosperity of the "Land of Abundance."
[0042] The completion of the Dujiangyan Irrigation System was not only a milestone in the development of water conservancy technology in China, but also had a profound impact on the regional socio-economic development. The project promoted the development of agricultural culture and supported population growth and urbanization. Through the expansion of the irrigation network, vast amounts of farmland were utilized efficiently, providing a stable food supply for successive dynasties. …
[0043] The ordered set of hypothetical questions constructed for document fragment D is as follows:
[0044] [1] How does Dujiangyan improve agricultural productivity?
[0045] [2] What are the contributions of Dujiangyan to regional social development?
[0046] [3] How did ancient water conservancy projects help with flood control?
[0047] User question: How did ancient societies use technology to improve production and maintain social stability?
[0048] In the above embodiments, the semantics of user questions are too abstract or generalized, making it impossible to directly match keywords or semantics related to the document. The hypothetical question ordered set in this invention, by extracting the core semantics of the document, can connect user questions with document content, compensating for the shortcomings of direct retrieval. Although the matching degree between user questions and the document itself is not high, it can match content in Q. Experimental verification shows that the index retrieval method in this invention is particularly effective when the document size is large, the user question is ambiguous, or the semantic expression is complex.
[0049] When index retrieval fails to find enough document fragments, this invention can also use hybrid retrieval, where index retrieval and hybrid retrieval can be used complementaryly. Thus, when the number of document fragments in the user question-related text set in step two is less than or equal to 1, hybrid retrieval can still be performed. The specific steps of hybrid retrieval include:
[0050] The BM25 algorithm is used to calculate the keyword scores of the user question and each document fragment in the knowledge base, and the K document fragments with the highest keyword scores are selected. At the same time, the cosine similarity of the embedding vectors is used to calculate the similarity between the user question and each document fragment in the knowledge base, and the K document fragments with the highest similarity are selected. Finally, the K document fragments selected based on keyword scores and similarity are written into the user question-related text set. K can be set according to actual business needs.
[0051] The hybrid search suffers from insufficient relevance between the retrieved content and the question itself: Embedding and BM25 primarily focus on semantic similarity and keyword matching between texts, but cannot ensure that the retrieved content is truly helpful in answering the question, thus impacting system performance. For example:
[0052] User question: What are the main causes of global warming? The search results for the mixed search are as follows:
[0053] Document fragment 1: In recent years, the trend of global warming has become very obvious (semantically relevant but without informational value).
[0054] Document segment 2: Greenhouse gases are the main cause of global warming (directly answer the question).
[0055] In the example above, document fragment 1, although semantically related to the question, does not contain the key information needed to answer the question and may even interfere with the generation process.
[0056] For example:
[0057] User question: What are the impacts of the Amazon rainforest on global climate? The search results for the mixed search are as follows:
[0058] Document Segment 1: The Amazon River is the world's largest river by volume, with a length of approximately 6,400 kilometers. (Noise Information)
[0059] Document segment 2: The Amazon rainforest plays a key role in the global carbon cycle and climate regulation by absorbing carbon dioxide and releasing oxygen.
[0060] In the example above, although the retrieved document fragments are related to "Amazon", they completely deviate from the core requirement of the problem (the climate impact of the rainforest) and may even mislead the large language model into discussing the Amazon River instead of the Amazon rainforest.
[0061] To improve the effectiveness and accuracy of document retrieval, this invention can also evaluate and filter the retrieval performance of hybrid retrieval through an evaluation model, and also includes:
[0062] The system extracts document fragments from each hybrid retrieval from the text set related to user questions. Then, an evaluation model is used to calculate the relevance score between the extracted document fragments and the user questions. This relevance score characterizes whether a document fragment is useful for answering the question. Dynamic labels are then generated based on the relevance scores to identify the relationship between the user questions and document fragments, and these labels are used for filtering to avoid interference from useless information. The evaluation model can be implemented using GPT-4, the MonoT5 language model, etc. For example, when using GPT-4, a method based on instruction fine-tuning can be used to score relevance. When using MonoT5, a relevance scoring method can be used, employing an end-to-end generative scoring approach to directly determine whether a document is relevant or irrelevant. Dynamic tags can include: Relevant (highly relevant), meaning the document segment directly answers the question and the information is complete; Partially Relevant (partially relevant), meaning the document segment may contain some relevant information, but it is not direct or comprehensive enough; and Irrrevant (irrelevant), meaning the document segment is irrelevant to the question or contains useless information. If the relevance score range is [0,1], the corresponding interval for Relevant can be set to [0.7,1], the corresponding interval for Partially Relevant can be set to (0.4,0.7), and the corresponding interval for Irrrevant can be set to [0,0.4]. In this way, when the calculated relevance score falls within the Irrrevant interval, the document segment is deleted from the user's question-related text set.
[0063] The ordered set of hypothetical questions is generated to improve retrieval efficiency and quality, but its semantic scope may not precisely match real user questions, potentially leading to retrieval bias. Therefore, this invention also designs a dynamic update mechanism for the ordered set of hypothetical questions. When a document fragment retrieved through mixed retrieval is determined by the evaluation model to be highly relevant (i.e., relevant) to a real user question, this user question can replace some of the hypothetical questions, thereby optimizing index retrieval. It also includes:
[0064] Step A1: Extract the first document fragment from the set of text related to user questions;
[0065] Step A2: Determine whether the dynamic tag that identifies the relationship between the user's question and the extracted document fragments is relevant. If it is, continue to step A3; otherwise, proceed to step A7.
[0066] Step A3: Determine whether the retrieval method for the extracted document fragments is a mixed retrieval. If yes, continue to step A4; otherwise, proceed to step A6.
[0067] Step A4: Calculate the similarity between the user question and the extracted document fragments, and the BM25 keyword scores between the user question and the extracted document fragments. Determine whether the similarity is less than the preset similarity threshold and whether the BM25 keyword scores are less than the preset keyword score threshold. If yes, continue to step A5; otherwise, proceed to step A7.
[0068] Step A5: Determine whether the number of hypothetical questions in the ordered set of hypothetical questions for the extracted document fragment is less than m. If yes, add the user question to the end of the ordered set of hypothetical questions for the extracted document fragment, i.e., the user question is the last hypothetical question in the ordered set of hypothetical questions for the extracted document fragment, and then proceed to step A7; if no, delete the last hypothetical question in the ordered set of hypothetical questions for the extracted document fragment, and add the user question to the beginning of the ordered set of hypothetical questions for the extracted document fragment, i.e., the user question is the first hypothetical question in the ordered set of hypothetical questions for the extracted document fragment, and then proceed to step A7.
[0069] Step A6: Determine whether the retrieval method of the extracted document fragments is index retrieval. If so, obtain the hypothetical question with the highest similarity to the user's question from the ordered set of hypothetical questions of the extracted document fragments, and then move the obtained hypothetical question to the first position of the ordered set of hypothetical questions of the extracted document fragments, and then continue to step A7; if not, continue to step A7.
[0070] Step A7: Determine whether all document fragments in the user question-related text set have been extracted. If yes, this process ends; if no, continue extracting the next document fragment in the user question-related text set and proceed to step A2.
[0071] like Figure 3 As shown, the intelligent question-answering system based on question index retrieval enhancement generation technology of the present invention includes:
[0072] The index generation device is used to divide all documents in the knowledge base into multiple document fragments, extract several summary questions from each document fragment as hypothetical questions for the document fragment, vectorize each hypothetical question to form an ordered set of hypothetical question vectors for the document fragment, and finally use the ordered set of hypothetical question vectors for each document fragment as an index to build a query library.
[0073] The document selection device is used to rewrite the user's input question and generate a quantized user question vector. Then, it retrieves document fragments related to the user question from the query database through index retrieval. The specific process of index retrieval is as follows: calculate the similarity between the user question vector and each hypothetical question vector in the ordered set of hypothetical question vectors for each document fragment in the query database, select all hypothetical question vectors with similarity greater than a threshold, sort the selected hypothetical question vectors in descending order of similarity, select the top-ranked hypothetical question vectors, and finally extract the document fragments to which the selected hypothetical question vectors belong to form a text set related to the user question.
[0074] The answer generation device is used to construct prompt words from the user's question and related text, and then generate the answer corresponding to the user's question through a large language model.
[0075] See Figure 4 , Figure 4 This is a structural block diagram of a computing device 400 illustrated in an exemplary embodiment of this specification. The components of the computing device 400 include, but are not limited to, a memory 410 and a processor 420. The processor 420 is connected to the memory 410 via a bus 430, and a database 450 is used to store data.
[0076] The computing device 400 also includes an access device 440, which enables the computing device 400 to communicate via one or more networks 460. Examples of these networks include a Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 440 may include one or more of any type of wired or wireless network interface (e.g., a network interface card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0077] In one embodiment of this specification, the aforementioned components of the computing device 400 and Figure 4 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 4 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0078] The computing device 400 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 400 can also be a mobile or stationary server or cloud server, etc.
[0079] The processor 420 is configured to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the intelligent question-answering method based on the question index retrieval enhancement generation technology described above.
[0080] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the intelligent question answering method based on question index retrieval enhancement generation technology described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the intelligent question answering method based on question index retrieval enhancement generation technology described above.
[0081] An embodiment of this specification also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the intelligent question-answering method based on question index retrieval enhancement generation technology described above.
[0082] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium belongs to the same concept as the intelligent question-answering method based on question index retrieval enhancement generation technology described above. Details not described in detail in the technical solution of the storage medium can be found in the description of the technical solution of the intelligent question-answering method or system based on question index retrieval enhancement generation technology described above.
[0083] An embodiment of this specification also provides a computer program, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the intelligent question-answering method based on the question index retrieval enhancement generation technology described above.
[0084] The above is an illustrative example of a computer program in this embodiment. It should be noted that the technical solution of this computer program belongs to the same concept as the technical solution of the intelligent question-answering method based on question index retrieval enhancement generation technology described above. Details not described in detail in the computer program's technical solution can be found in the description of the technical solution of the intelligent question-answering method or system based on question index retrieval enhancement generation technology described above.
[0085] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0086] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0087] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments in this specification are not limited to the described order of actions, because according to the embodiments in this specification, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments in this specification.
[0088] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. An intelligent question answering method based on problem index retrieval enhanced generation technology, characterized in that, Comprise: Step one, all documents in the knowledge base are divided into multiple document shards, and then several summary questions are extracted from each document shard as the hypothetical questions of the document shard, and then each hypothetical question is vectorized to form an ordered set of hypothetical question vectors of the document shard, and finally the ordered set of hypothetical question vectors of each document shard is used as an index to build a query library; Step two, rewrite the user input question and vectorize it to generate a user question vector, then retrieve the document shards related to the user question from the query library through index retrieval, the specific process of index retrieval is as follows: calculate the similarity between the user question vector and each hypothetical question vector in the ordered set of hypothetical question vectors of each document shard in the query library, and select all hypothetical question vectors with similarity greater than the threshold value, then sort the selected hypothetical question vectors in descending order of similarity, select multiple hypothetical question vectors in the front, and finally extract the document shards to which the selected hypothetical question vectors belong to form a user question related text set; Step three, the user question and the user question related text set form a prompt word, and a large language model is used to generate an answer corresponding to the user question, In step one, several summary questions are extracted from each document shard as the hypothetical questions of the document shard, comprising: Step 11, generate the summary content and summary question set corresponding to the document shard D through the large language model, and the summary question set contains n summary questions, and n is the preset number of summary questions; Step 12, build an ordered set of hypothetical questions Q and initialize it as an empty set, and initialize the set semantic coverage Cov0 and the set semantic diversity value Div0 to 0; Step 13, select each summary question from the summary question set one by one, and calculate the information gain value corresponding to each summary question: Info Gain(q i ) = a * (Cov(q i ) - Cov0) + (1 - a) * (Div(q i ) - Div0), q i is the i-th summary question in the summary question set, Info Gain(q i ), Cov(q i ), Div(q i ) are the information gain value, the contribution value to semantic coverage and the contribution value to semantic diversity corresponding to q i , a is the importance weight parameter for adjusting the importance of coverage and diversity, then select the maximum value from the information gain values corresponding to all summary questions, write the summary question corresponding to the maximum value into the ordered set of hypothetical questions Q, and delete the summary question from the summary question set, at the same time, update the set semantic coverage Cov0 and the set semantic diversity value Div0: Cov0 ’ = Cov0 + Cov(q u ), Div0 ’ = Div0 + Div(q u ), Cov0 ’ , Div0 ’ are the updated set semantic coverage and set semantic diversity value, q u is the summary question corresponding to the maximum value; Step 14, determine whether the number of hypothetical questions in the ordered set of hypothetical questions Q is less than the preset number of hypothetical questions threshold m, if yes, go to step 13; if not, vectorize each hypothetical question in the ordered set of hypothetical questions Q to generate an ordered set of hypothetical question vectors.
2. The method of claim 1, wherein, In step one, the content of the document in the knowledge base is also extracted, and the non-text data is converted into text data, if there is picture data, the specific processing process is as follows: First, extract the caption or annotation of the picture, then perform OCR recognition on the picture to extract character information, then input the caption or annotation of the picture and the character information into a multi-modal large model to generate picture description information, and finally use the caption or annotation of the picture, the character information, and the picture description information to replace the picture data in the knowledge base.
3. The method of claim 1, wherein, In step 13, Cov(q i ) is calculated as follows: The document fragment is first divided into multiple semantic units, and q i and each semantic unit is converted into a vector representation, and then the cosine similarity between q i and the vector representation of each semantic unit is calculated one by one, and finally Cov(q i ) is calculated: where Total_Units is the number of semantic units of the document fragment, NUM_Units(q i ) is the total number of cosine similarities between q i and the vector representation of all semantic units in the document fragment that are greater than a preset threshold, Div(q i ) is calculated as follows: where Q_NUM is the number of hypothetical questions in the ordered set of hypothetical questions Q, is the vector representation of the jth hypothetical question in the ordered set of hypothetical questions Q, is the vector representation of q i , is the cosine similarity between .
4. The method of claim 1, wherein, When the number of document shards in the user question related text set in step two is less than or equal to 1, hybrid retrieval is also performed, and the specific steps of hybrid retrieval include: The BM25 algorithm is used to calculate the keyword scores of the user question and each document fragment in the knowledge base, and the K document fragments with the highest keyword scores are selected. Meanwhile, the similarity between the user question and each document fragment in the knowledge base is calculated by calculating the cosine similarity of the embedding vectors, and the K document fragments with the highest similarity are selected. Finally, the K document fragments selected according to the keyword scores and the similarity are written into the user question related text set.
5. The method of claim 4, wherein, Further comprising: Each document fragment obtained through mixed retrieval is extracted from the user question related text set one by one, and then an evaluation model is used to calculate the relevance score of the extracted document fragment and the user question, which is used to represent whether the document fragment is useful for answering the question. A dynamic label identifying the relationship between the user question and the document fragment is generated according to the relevance score, and the dynamic label includes Relevant, Partially Relevant, and Irrelevant.
6. The method of claim 5, wherein, Further comprising: Step A1, extracting a first document fragment from the user question related text set; Step A2, judging whether the dynamic label identifying the relationship between the user question and the extracted document fragment is Relevant. If yes, proceed to step A3; if no, go to step A7; Step A3, judging whether the retrieval method of the extracted document fragment is mixed retrieval. If yes, proceed to step A4; if no, go to step A6; Step A4, calculating the similarity between the user question and the extracted document fragment, and the BM25 keyword score of the user question and the extracted document fragment, and judging whether the similarity is less than a preset similarity threshold and the BM25 keyword score is less than a preset keyword score threshold. If yes, proceed to step A5; if no, go to step A7; Step A5, judging whether the number of hypothetical questions in the ordered set of hypothetical questions of the extracted document fragment is less than m. If yes, add the user question to the end of the ordered set of hypothetical questions of the extracted document fragment, i.e., the user question is the last hypothetical question in the ordered set of hypothetical questions of the extracted document fragment, and then go to step A7; if no, delete the last hypothetical question in the ordered set of hypothetical questions of the extracted document fragment, and add the user question to the first position of the ordered set of hypothetical questions of the extracted document fragment, i.e., the user question is the first hypothetical question in the ordered set of hypothetical questions of the extracted document fragment, and then go to step A7; Step A6, judging whether the retrieval method of the extracted document fragment is index retrieval. If yes, obtain the hypothetical question with the highest similarity to the user question from the ordered set of hypothetical questions of the extracted document fragment, and then move the obtained hypothetical question to the first position of the ordered set of hypothetical questions of the extracted document fragment, and proceed to step A7; if no, proceed to step A7; Step A7, judging whether the dynamic label identifying the relationship between the user question and the extracted document fragment is Relevant. If yes, proceed to step A8; if no, go to step A9; Step A8, judging whether the retrieval method of the extracted document fragment is mixed retrieval. If yes, proceed to step A9; if no, go to step A10; Step A9, calculating the similarity between the user question and the extracted document fragment, and the BM25 keyword score of the user question and the extracted document fragment, and judging whether the similarity is less than a preset similarity threshold and the BM25 keyword score is less than a preset keyword score threshold. If yes, proceed to step A10; if no, go to step A11; Step A10, judging whether the number of hypothetical questions in the ordered set of hypothetical questions of the extracted document fragment is less than m. If yes, add the user question to the end of the ordered set of hypothetical questions of the extracted document fragment, i.e., the user question is the last hypothetical question in the ordered set of hypothetical questions of the extracted document fragment, and then go to step A11; if no, delete the last hypothetical question in the ordered set of hypothetical questions of the extracted document fragment, and add the user question to the first position of the ordered set of hypothetical questions of the extracted document fragment, i.e., the user question is the first hypothetical question in the ordered set of hypothetical questions of the extracted document fragment, and then go to step A11; Step A11, judging whether the retrieval method of the extracted document fragment is index retrieval. If yes, obtain the hypothetical question with the highest similarity to the user question from the ordered set of hypothetical questions of the extracted document fragment, and then move the obtained hypothetical question to the first position of the ordered set of hypothetical questions of the extracted document fragment, and proceed to step A12; if no, proceed to step A12; Step A12, judging whether the dynamic label identifying the relationship between the user question and the extracted document fragment is Relevant. If yes, proceed to step A13; if no, go to step A14; Step A13, judging whether the retrieval method of the extracted document fragment is mixed retrieval. If yes, proceed to step A14; if no, go to step A15; Step A14, calculating the similarity between the user question and the extracted document fragment, and the BM25 keyword score of the user question and the extracted document fragment, and judging whether the similarity is less than a preset similarity threshold and the BM25 keyword score is less than a preset keyword score threshold. If yes, proceed to step A15; if no, go to step A16; Step A15, judging whether the number of hypothetical questions in the ordered set of hypothetical questions of the extracted document fragment is less than m. If yes, add the user question to the end of the ordered set of hypothetical questions of the extracted document fragment, i.e., the user question is the last hypothetical question in the ordered set of hypothetical questions of the extracted document fragment, and then go to step A16; if no, delete the last hypothetical question in the ordered set of hypothetical questions of the extracted document fragment, and add the user question to the first position of the ordered set of hypothetical questions of the extracted document fragment, i.e., the user question is the first hypothetical question in the ordered set of hypothetical questions of the extracted document fragment, and then go to step A16; Step A16, judging whether the retrieval method of the extracted document fragment is index retrieval. If yes, obtain the hypothetical question with the highest similarity to the user question from the ordered set of hypothetical questions of the extracted document fragment, and then move the obtained hypothetical question to the first position of the ordered set of hypothetical questions of the extracted document fragment, and proceed to step A17; if no, proceed to step A17; Step A17, judging whether the dynamic label identifying the relationship between the user question and the extracted document fragment is Relevant. If yes, proceed to step A18; if no, go to step A19; Step A18, judging whether the retrieval method of the extracted document fragment is mixed retrieval. If yes, proceed to step A19; if no, go to step A20; Step A19, calculating the similarity between the user question and the extracted document fragment, and the BM25 keyword score of the user question and the extracted document fragment, and judging whether the similarity is less than a preset similarity threshold and the BM25 keyword score is less than a preset keyword score threshold. If yes, proceed to step A20; if no, go to step A21; Step A20, judging whether the number of hypothetical questions in the ordered set of hypothetical questions of the extracted document fragment is less than m. If yes, add the user question to the end of the ordered set of hypothetical questions of the extracted document fragment, i.e., the user question is the last hypothetical question in the ordered set of hypothetical questions of the extracted document fragment, and then go to step A21; if no, delete the last hypothetical question in the ordered set of hypothetical questions of the extracted document fragment, and add the user question to the first position of the ordered set of hypothetical questions of the extracted document fragment, i.e., the user question is the first hypothetical question in the ordered set of hypothetical questions of the extracted document fragment, and then go to step A21; Step A21, judging whether the retrieval method of the extracted document fragment is index retrieval. If yes, obtain the hypothetical question with the highest similarity to the user question from the ordered set of hypothetical questions of the extracted document fragment, and then move the obtained hypothetical question to the first position of the ordered set of hypothetical questions of the extracted document fragment, and proceed to step A22; if no, proceed to step A22; Step A22, judging whether the dynamic label identifying the relationship between the user question and the extracted document fragment is Relevant. If yes, proceed to step A23; if no, go to step A24; Step A23, judging whether the retrieval method of the extracted document fragment is mixed retrieval. If yes, proceed to step A24; if no, go to step A25; Step A24, calculating the similarity between the user question and the extracted document fragment, and the BM25 keyword score of the user question and the extracted document fragment, and judging whether the similarity is less than a preset similarity threshold and the BM25 keyword score is less than a preset keyword score threshold. If yes, proceed to step A25; if no, go to step A26; Step A25, judging whether the number of hypothetical questions in the ordered set of hypothetical questions of the extracted document fragment is less than m. If yes, add the user question to the end of the ordered set of hypothetical questions of the extracted document fragment, i.e., the user question is the last hypothetical question in the ordered set of hypothetical questions of the extracted Step A7, determine whether all document segments in the user question related text set have been extracted, if yes, the process ends; if not, continue to extract the next document segment in the user question related text set, go to step A2.
7. An intelligent question answering system based on problem index retrieval enhanced generation technology, characterized by, The system is used to execute the intelligent question answering method based on the problem index retrieval enhanced generation technology of claim 1, and the system comprises: An index generation device is configured to split all documents in a knowledge base into a plurality of document segments, extract a plurality of summary questions from each document segment as hypothetical questions of the document segment, vectorize each hypothetical question to form an ordered set of hypothetical question vectors of the document segment, and finally construct a query library by taking the ordered set of hypothetical question vectors of each document segment as an index; A document selection device is configured to rewrite a user input question, vectorize the question to generate a user question vector, and obtain document segments related to the user question from the query library through index retrieval. The specific process of index retrieval is as follows: calculate the similarity between the user question vector and each hypothetical question vector of the ordered set of hypothetical question vectors of each document segment in the query library, select all hypothetical question vectors with a similarity greater than a threshold value, sort the selected hypothetical question vectors in descending order of similarity, and finally select a plurality of document segments in the front to form a user question related text set; An answer generation device is configured to form a prompt word by taking the user question and the user question related text set, and generate an answer corresponding to the user question by using a large language model.
8. A computing device, comprising: Comprise: A memory and a processor; The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions, which realize the steps of the intelligent question answering method based on the problem index retrieval enhanced generation technology of any one of claims 1-6 when executed by the processor.
9. A computer-readable storage medium, characterized in that, It stores computer executable instructions, which realize the steps of the intelligent question answering method based on the problem index retrieval enhanced generation technology of any one of claims 1-6 when executed by the processor.
Citation Information
Patent Citations
Large model RAG method based on hierarchical indexing and hybrid retrieval
CN118779437A