Diversity-enhanced text retrieval-augmented generation method and system
By building a local knowledge base and rewriting user questions using a large language model, expanding the search scope, and calculating similarity, the problem of excessively high similarity in search results was solved, resulting in richer and more accurate search results.
Patent Information
- Application Number
- PCT/CN2024/104727
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-05-29
- Filing Date
- 2024-07-10
- Publication Date
- 2025-12-04
AI Technical Summary
Traditional search enhancement generation methods face problems such as excessively high similarity of search results and limited material when processing massive amounts of text data, resulting in a lack of rich user experience and insufficient accuracy.
By building a local knowledge base, rewriting user questions using a large language model, expanding the search scope, increasing the number of search results from top-k to top-2k, and performing the search using a vectorized model, calculating the similarity of search results, retaining the most similar results, and finally generating answers through an intelligent question-answering module.
It provides richer and more informative search results, improving the richness and accuracy of the generated content.
Smart Images

Figure CN2024104727_04122025_PF_FP_ABST
Abstract
Description
A diversity-enhanced text retrieval enhancement generation method and system TECHNICAL FIELD
[0001] The present application belongs to the technical field of artificial intelligence, and particularly relates to a diversity-enhanced text retrieval enhancement generation method and system. BACKGROUND
[0002] Retrieval enhancement generation technology combines information retrieval and generation models to enhance the efficiency of retrieval systems by improving the understanding of context by text generation models. This technology can retrieve relevant information from a large amount of data and use generation models to produce results with more context consistency and semantic richness. In search engines and question and answer systems, retrieval enhancement generation technology provides more accurate and comprehensive answers to optimize user experience.
[0003] When dealing with massive amounts of text data, traditional retrieval enhancement generation methods may retrieve similar documents through vector retrieval. When writing reports or organizing contexts, users need more diverse and comprehensive materials to support the richness and accuracy of their content. Therefore, traditional retrieval enhancement generation methods often face the problem of excessive similarity and single material. In the diversity-enhanced text retrieval enhancement generation method, the user's question is rewritten, and the retrieval range is expanded. By retrieving the user's question and the rewritten question, and filtering the retrieval results for diversity, more rich and informative retrieval results can be provided to the user to improve the richness and accuracy of the generated content.
[0004] SUMMARY
[0005] The present application provides a diversity-enhanced text retrieval enhancement generation method and system to solve the problems in the prior art. By enhancing the diversity in the retrieval process, more rich and informative retrieval results can be provided to the user to improve the richness and accuracy of the generated content.
[0006] To achieve the above purpose, the technical solution adopted by the present application is as follows:
[0007] In a first aspect, the present application provides a diversity-enhanced text retrieval enhancement generation method, comprising:
[0008] Constructing a local knowledge base using knowledge data;
[0009] Obtaining the user's question and the desired number of retrieval results; in the retrieval stage, rewriting the user's question using a large language model to obtain a rewritten question, then expanding the retrieval range, expanding the number of retrieval results, and performing vector retrieval on the user's question and the rewritten question in the knowledge base to obtain retrieval results;
[0010] The similarity between the retrieval results is calculated, and based on the similarity calculation result, the diverse retrieval results are screened out;
[0011] The screened retrieval results and the user question are integrated through a prompt engineering, input into a large language model, and the model generation result is returned to the user as an answer.
[0012] Further, the number of the retrieval results is expanded from top-k to top-2k.
[0013] The second aspect of the present application provides a text retrieval enhancement generation system with diversity enhancement, comprising:
[0014] The knowledge base construction module is configured to construct a local knowledge base by using knowledge data;
[0015] The retrieval module is configured to obtain a user question and a desired number of retrieval results, rewrite the user question by using a large language model in a retrieval stage to obtain a rewritten question, then expand the retrieval range, expand the number of retrieval results, and perform vector retrieval on the user question and the rewritten question in the knowledge base to obtain retrieval results.
[0016] The diversity filtering module is configured to calculate the similarity between the retrieval results, and based on the similarity calculation result, the diverse retrieval results are screened out.
[0017] The intelligent question and answer module is configured to integrate the screened retrieval results and the user question through a prompt engineering, input into a large language model, and the model generation result is returned to the user as an answer.
[0018] The third aspect of the present application provides a computer readable storage medium, which comprises a stored program, wherein when the program is running, the computer readable storage medium controls the device where the computer readable storage medium is located to execute the text retrieval enhancement generation method with diversity enhancement of the first aspect.
[0019] The fourth aspect of the present application provides an electronic device comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the electronic device is triggered to execute the text retrieval enhancement generation method with diversity enhancement of the first aspect.
[0020] Compared with the prior art, the present application has the advantages and positive effects that:
[0021] The text retrieval enhancement generation method and system with diversity enhancement provided by the present application can provide users with more abundant and informative retrieval results by expanding the retrieval results and then filtering the diversity, and improve the richness and accuracy of the generated content. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 is a flowchart of the overall architecture of the text retrieval enhancement generation method with enhanced diversity of the present invention;
[0024] Figure 2 is a schematic diagram of the retrieval module of the present invention;
[0025] Figure 3 is a schematic diagram of the knowledge base construction module of the present invention. Detailed Implementation
[0026] To better understand the above-mentioned objectives, features, and advantages of the present invention, the present invention will be further described below in conjunction with the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.
[0027] Numerous specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways than those described herein, and therefore the invention is not limited to the specific embodiments disclosed in the following specification.
[0028] Example 1, as shown in Figures 1-3, provides a diversity-enhanced text retrieval generation method. The knowledge base construction module uses knowledge data to build a local knowledge base and continuously updates domain knowledge to ensure its timeliness. The rewriting module rewrites the user's question using a large language model, thus increasing the diversity of retrieval queries. The retrieval module expands the retrieval scope, increasing the number of search results from top-k to top-2k. It then uses a vectorization model to convert the user's question into vectors, and obtains the search results through vector retrieval. The diversity filtering module calculates the similarity between search results and filters similar results (only retaining the one with the highest similarity to the user's question and the rewritten question), keeping the top-k results. The intelligent question answering module receives the user's input question, integrates the user's question and the diversity search results through a prompting process, inputs it into the large language model, and returns the model's answer to the user.
[0029] The specific steps are as follows:
[0030] The knowledge base construction module utilizes knowledge data to construct a local knowledge base and continuously updates domain knowledge to ensure the timeliness of the knowledge. The local knowledge base construction method is as follows:
[0031] The knowledge data (text) is cleaned, sliced, and filtered, and then converted into a vector through a vectorization model (such as the open-source model bge-m3);
[0032] The vector is stored in the open-source Milvus database (https: / / milvus.io / ).
[0033] The rewriting module rewrites the user's question through a large language model to obtain a rewritten question, thereby increasing the diversity of the search query. The rewritten question is another way of expressing the user's question. For example, the user's question is "What are the effective methods to protect the environment?", and the search result shows eight methods to protect the environment. The rewritten question is "How to reduce environmental pollution in daily life?", and the result obtained through the rewritten question gives the "Citizen Environmental Protection Behavior Specification" released by the Yulin Ecological Environment Bureau, which contains 50 environmental protection suggestions, greatly enriching the richness of information related to the user's question. The purpose of rewriting is to retrieve more content related to the user's question. Because different expression methods yield different vector search results, the user's question needs to be rewritten.
[0034] A large language model refers to a deep learning model that can process and generate natural language text. There are many types of large language models, but they all have the same function, which is to use natural language dialogue to generate user-specified output content. Some examples of large language models include GPT-4, Chatglm3, and baichuan.
[0035] Prompt engineering refers to designing and constructing effective prompts or input texts when using large language models (such as the GPT series) to guide the model to generate the desired specific output. Prompt engineering is an important technical means that can help regulate the behavior of the model, making it better suited to specific tasks or scenarios, and improving the quality and accuracy of generated text.
[0036] The implementation of the rewriting module is to construct the prompt "Please describe the user's question in a different way: {question}" as input to the large language model. After receiving such input, the large language model will rewrite the user's question.
[0037] The retrieval module expands the search scope, increasing the number of search results from top-k to top-2k. Then, it uses a vectorization model to transform user questions into vectors, and finally obtains search results through vector retrieval. The specific methods and steps of vector retrieval are as follows:
[0038] Building a knowledge base: After cleaning the collected knowledge (removing punctuation, stop words, deduplication, etc.), it is divided into blocks. The original text data after block division is converted into vectors through a word embedding model (here, the cutting-edge bge-m3 model with good performance is used) and stored in the Milvus database.
[0039] The user's question is transformed into a vector using a word embedding model (bge-m3 model). The cosine similarity between the user's question vector and all vectors in the vector library is calculated (the cosine of the angle between two vectors is calculated, and the larger the value, the more similar the vectors are).
[0040] The formula for calculating cosine similarity is as follows:
[0041] in:
[0042] A·B represents the inner product of vectors A and B, which is the result of multiplying corresponding elements and then adding them together.
[0043] ||A|| represents the modulus (length) of vector A, which can be obtained by summing the squares of each element in vector A and then taking the square root.
[0044] ||B|| represents the magnitude (length) of vector B, and is calculated in the same way as vector A.
[0045] Based on similarity scores, sort and return the top-k most relevant documents or data items to the user.
[0046] Vectorization is a technique that represents text or questions as vectors, enabling computers to better understand and process textual data. In the process of rewriting text using large language models, generating question-to-vector transformations is a crucial step. It converts the original text's question into vector form so the model can process and generate results. Originally, the user's question (A) corresponds to only one vector (a). Using this vector to search the vector database retrieves results related to 'a'. After rewriting, the user's question becomes the rewritten question (B), corresponding to vector (b). Using both 'a' and 'b' to search the vector database retrieves results related to both 'a' and 'b', enriching the diversity of search results.
[0047] The specific technical details of vectorization are that the Transformer model (such as BERT, BCE, etc.) encodes the text sequence to obtain the hidden state or attention weight of each position. Then, these hidden states or attention weights are summarized or combined to generate a vector representation of the entire text.
[0048] The diversity filtering module calculates the similarity between the retrieval results, filters similar retrieval results based on the similarity calculation results (only the one with the highest similarity to the user question and the rewritten question is retained among the similar retrieval results), and retains the top-k retrieval results. An appropriate similarity measurement method is used to measure the similarity between the retrieval results. Common similarity measurements include cosine similarity, Jaccard similarity, edit distance, etc.
[0049] Filtering is done by screening results with a similarity lower than a set threshold. For example, the similarity of two texts is 0.3, and the similarity threshold is set to 0.9. The similarity is lower than the threshold, so the two texts are considered not similar, and the retrieval result is discarded.
[0050] The intelligent question and answer module accepts the user input question, integrates the user question and the diversity retrieval result through a prompt engineering, inputs the large language model, and returns the model answer to the user.
[0051] The method is characterized in that the user question is first rewritten to obtain a rewritten question, then the user-specified number of retrieval results (top-k) is first expanded (top-2k), then the user question and the rewritten question are vector-retrieved in the knowledge base, the similarity of the retrieval results is calculated, the most similar one among the similar retrieval results is retained, and the user-specified number of retrieval results (top-k) is returned to the user. This method of first expanding the retrieval results and then filtering the diversity can provide the user with more rich and informative retrieval results, and improve the richness and accuracy of the generated content.
[0052] The method provided by the present application can provide the user with more rich and informative retrieval results, and improve the richness and accuracy of the generated content,
[0053] Embodiment 2, the application provides a diversity enhanced text retrieval enhancement generation system, comprising a knowledge base construction module, a retrieval module, a diversity filtering module and an intelligent question and answer module. Among them, the knowledge base construction module utilizes knowledge data to construct a local knowledge base, and continuously updates the field knowledge to ensure the timeliness of the knowledge. The rewriting module rewrites the user question through a large language model to obtain the rewritten question, thereby increasing the diversity of the retrieval query. The retrieval module expands the retrieval range, expands the number of retrieval results from top-k to top-2k, and then converts the user question into a vector using a vectorization model. Then, the retrieval result is obtained by vector retrieval. The diversity filtering module calculates the similarity between the retrieval results, filters the similar retrieval results based on the similarity calculation result (only the one with the highest similarity to the user question and the rewritten question is retained in the similar retrieval results), and retains top-k retrieval results. The intelligent question and answer module integrates the user question and the diversity retrieval result through a prompt engineering after accepting the user input question, inputs the large language model, and returns the model answer to the user.
[0054] In order to facilitate the understanding of the application, an embodiment is given below, taking the scene of writing the context of the field as an example:
[0055] Knowledge base construction module: by combining traditional retrieval engine and policy, report knowledge base, obtain more comprehensive, real-time related research knowledge fragment.
[0056] Rewriting module: rewrite the user question through a large language model to obtain the rewritten question, thereby increasing the diversity of the retrieval query.
[0057] Retrieval module: expand the retrieval range, expand the number of retrieval results from top-3 to top-6, and then convert the user question into a vector using a vectorization model. Then, the retrieval result is obtained by vector retrieval.
[0058] Diversity filtering module: calculate the similarity between the retrieval results, filter the similar retrieval results based on the similarity calculation result (only the one with the highest similarity to the user question and the rewritten question is retained in the similar retrieval results), and retain top-3 retrieval results.
[0059] Intelligent question and answer module: after accepting the user input question, integrate the user question and the diversity retrieval result through a prompt engineering, input the large language model, and return the model answer to the user.
[0060] Embodiment 3, a computer readable storage medium, the computer readable storage medium comprises a stored program, wherein the program controls the device where the computer readable storage medium executes the method in embodiment 1 when the program runs.
[0061] In embodiment 4, the present application provides an electronic device, comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the electronic device is triggered to execute the method of embodiment 1.
[0062] The electronic device can comprise a processor, a memory and a communication unit. These components communicate through one or more buses, and those skilled in the art can understand that the structure of the electronic device does not constitute a limitation on the embodiments of the present application, which can be a bus structure or a star structure, or a combination of some components, or different component arrangements.
[0063] The communication unit is configured to establish a communication channel, so that the electronic device can communicate with other devices. It receives user data sent by other devices or sends user data to other devices.
[0064] The processor is the control center of the electronic device, which connects various parts of the electronic device through various interfaces and lines, executes software programs and / or modules stored in the memory, and calls data stored in the memory, to perform various functions of the electronic device and / or process data. The processor can be composed of integrated circuits (IC), such as a single packaged IC or a plurality of packaged ICs connected together. For example, the processor can only include a central processing unit (CPU). In the embodiments of the present application, the CPU can be a single operation core or can include multiple operation cores.
[0065] The memory is configured to store the execution instructions of the processor. The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0066] When the execution instructions in the memory are executed by the processor, the electronic device can execute part or all of the steps of embodiment 1.
[0067] The above merely describes preferred embodiments of the present application, and is not intended to limit the present application in other forms. Any person skilled in the art can make changes or modifications to the above disclosed technical contents into equivalent embodiments with equivalent changes, and apply them to other fields. However, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present application, without departing from the technical solution content of the present application, still belongs to the protection scope of the present application technical solution.
Claims
1. A method for enhancing text retrieval and generating data with increased diversity, characterized in that: include: Build a local knowledge base using knowledge data; Obtain the number of user questions and expected search results; In the retrieval phase, the user's question is rewritten using a large language model to obtain the rewritten question. Then, the retrieval scope is expanded to increase the number of retrieval results. Vector retrieval is performed on the user's question and the rewritten question in the knowledge base to obtain retrieval results. Calculate the similarity between search results, and based on the similarity calculation results, filter out diverse search results; The prompting process integrates the filtered search results and user questions, inputs them into a large language model, and returns the model-generated results as answers to the user.
2. The text retrieval enhancement generation method with enhanced diversity according to claim 1, characterized in that, The expansion of the number of search results is from top-k to top-2k.
3. A text retrieval enhancement and generation system with enhanced diversity, characterized in that, include: The knowledge base construction module is configured to: build a local knowledge base using knowledge data; The search module is configured to retrieve the user's question and the expected number of search results. In the retrieval phase, the user's question is rewritten using a large language model to obtain the rewritten question. Then, the retrieval scope is expanded to increase the number of retrieval results. Vector retrieval is performed on the user's question and the rewritten question in the knowledge base to obtain retrieval results. The diversity filtering module is configured to: calculate the similarity between search results, and filter out diverse search results based on the similarity calculation results; The intelligent question-answering module is configured to integrate the filtered search results and user questions through a prompting process, input them into a large language model, and return the model-generated results as the answer to the user.
4. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the diversity-enhanced text retrieval enhancement generation method according to any one of claims 1-2.
5. An electronic device, characterized in that, It includes a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the electronic device is triggered to execute the diversity-enhanced text retrieval enhancement generation method according to any one of claims 1-2.
Citation Information
Patent Citations
Combined method of search result similar items and system of the same
CN102930038A
Open domain natural language reasoning question-answering system and method driven by large language model
CN116932708A
Medical question and answer text generation method and equipment based on retrieval enhancement generation
CN117763114A
Question and answer type retrieval method and system based on large language model
CN118051590A
Diversity-enhanced text retrieval enhancement generation method and system
CN118260406A
Cited By
Multi-stage retrieval enhancement generation method, computer system and computer readable storage medium
CN121388078A
Text generation method and system for strong fact constraint demand in mine field
CN121524339A
A text generation method and system for the mining industry with strong factual constraints
CN121524339B