CN-121979968-A - Search enhancement generation method, device, equipment and program product
Abstract
The present application relates to the field of intelligent search, and in particular, to a method, apparatus, device, and program product for generating search enhancement. The method comprises the steps of receiving a user question, encoding the user question to obtain a query vector, determining a candidate knowledge fragment set according to query vector retrieval, generating an answer through a generation model according to the candidate knowledge fragment set and the user question, determining the attention distribution of the knowledge fragment, updating the query vector according to the attention distribution under the condition that the current state does not meet a preset ending condition, and jumping to the step of determining the candidate knowledge fragment set according to query vector retrieval for iterative updating until the preset ending condition is met, wherein the answer generated when the ending condition is met is the answer of the user question. The candidate knowledge segment set obtained after repeated iterative computation can more effectively supplement missing knowledge segments, perfect knowledge coverage and is beneficial to improving the integrity of answers.
Inventors
- WU WEIQI
- SU FAN
- QU YUTAO
- CAO ZHILIN
- LIN SHU
- LUO JIACHENG
- CHEN DUAN
- SHAO ZHUDE
- LI TONG
- XI XIANQIANG
Assignees
- 中国人民武装警察部队第二机动总队
- 中电科新型智慧城市研究院有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20251204
Claims (10)
- 1. A search enhancement generation method, the method comprising: receiving a user problem, and carrying out vector coding on the user problem to obtain a query vector; Searching a candidate knowledge segment set in a preset multi-granularity knowledge system according to the query vector, wherein the candidate knowledge segment set comprises a plurality of knowledge segments, and the knowledge segments are segments obtained by dividing a knowledge base; Generating answers through a generation model according to the candidate knowledge segment set and the user questions, and determining the attention distribution of knowledge segments in the candidate knowledge segment set; And under the condition that the current state does not meet the preset ending condition, updating the query vector according to the attention distribution, and jumping to the step of searching the candidate knowledge fragment set in the preset multi-granularity knowledge system according to the query vector for iterative updating until the preset ending condition is met, wherein the answer generated when the ending condition is met is the answer of the user question.
- 2. The method of claim 1, wherein prior to retrieving a set of candidate knowledge segments in a preset multi-granularity knowledge hierarchy from the query vector, the method further comprises: decomposing the knowledge base with different granularities to construct knowledge fragments with different granularities; according to the query vector, searching the candidate knowledge fragment set in a preset multi-granularity knowledge system comprises the following steps: Evaluating the complexity of the user problem; determining a target granularity corresponding to the complexity of the user problem according to a corresponding relation between the preset complexity and granularity; And calculating the semantic similarity of each knowledge segment in the user problem and the target granularity, and determining the candidate knowledge segment set according to the semantic similarity.
- 3. The method of claim 2, wherein after computing the semantic similarity of each knowledge segment in the user question and the target granularity, the method further comprises: when the target granularity corresponding to the complexity of the user problem comprises more than two target granularities, determining a weight coefficient of the target granularity; And according to the weight coefficient of the target granularity, combining the weighted average vector of each knowledge segment in the target granularity, and determining the comprehensive knowledge representation of the target granularity related to the user problem.
- 4. The method of claim 2, wherein after retrieving the set of candidate knowledge segments in a preset multi-granularity knowledge hierarchy based on the query vector, the method further comprises: Determining the credibility and freshness of each knowledge segment in the candidate knowledge segment set, and determining the relevance of each knowledge segment in the candidate knowledge segment set to a problem; determining a weight vector corresponding to the knowledge segment in the target granularity according to the correlation, the credibility and the freshness; And according to the normalized weight determined by the weight vector, combining knowledge segments in the target granularity, carrying out knowledge arrangement on the knowledge segments in the candidate knowledge segment set, and determining the comprehensive knowledge representation of the target granularity related to the user problem.
- 5. The method of claim 3 or 4, wherein after determining the integrated knowledge representation of the target granularity associated with the user problem, the method further comprises: Acquiring a question type of the user question, wherein the question type comprises at least one of a real type, an explanation type and an inference type; When the question type is a fact type, determining an answer to the user question according to the knowledge segment with the largest weight coefficient; Generating an answer to the user question through a predetermined generation model based on the candidate knowledge segment set and the user question when the question type is an interpretation type; And when the question type is an inference type, generating an answer to the user question through a predetermined generation model by combining the user question based on the comprehensive knowledge representation as a condition vector.
- 6. The method of claim 2, wherein the knowledge base is decomposed at different granularities to construct knowledge segments at different granularities, comprising at least two of the following: Decomposing the knowledge base into document data according to document granularity, and constructing knowledge fragments with the document granularity; Decomposing the knowledge base into section data according to section granularity, and constructing a section-granularity knowledge fragment; decomposing the knowledge base into paragraph data according to paragraph granularity, and constructing knowledge fragments with paragraph granularity; Decomposing the knowledge base into sentence data according to the sentence granularity, and constructing knowledge fragments with the sentence granularity; classifying the knowledge base into entity data according to entity granularity, and constructing knowledge segments with entity granularity.
- 7. The method of claim 6, wherein determining a target granularity for the complexity of the user question based on a predetermined complexity to granularity correspondence comprises: when the complexity of the user problem is lower than a first preset complexity, determining that the target granularity corresponding to the complexity of the user problem is sentence granularity and/or entity granularity; When the complexity of the user problem is lower than a second preset complexity and higher than a first preset complexity, determining that the target granularity corresponding to the complexity of the user problem is paragraph granularity and/or article granularity, wherein the second preset complexity is higher than the first preset complexity; And when the complexity of the user problem is higher than a second preset complexity, determining that the target granularity corresponding to the complexity of the user problem is the document granularity.
- 8. A retrieval enhancement generation device, the device comprising: the problem coding unit is used for receiving user problems and carrying out vector coding on the user problems to obtain query vectors; The problem retrieval unit is used for retrieving a candidate knowledge segment set in a preset multi-granularity knowledge system according to the query vector, wherein the candidate knowledge segment set comprises a plurality of knowledge segments which are segments obtained by dividing a knowledge base; An attention distribution determining unit, configured to generate an answer by generating a model according to the candidate knowledge segment set and the user question, and determine an attention distribution of knowledge segments in the candidate knowledge segment set; And the iteration updating unit is used for updating the query vector according to the attention distribution under the condition that the current state does not meet the preset ending condition, and jumping to the step of searching the candidate knowledge segment set in the preset multi-granularity knowledge system according to the query vector for carrying out iteration updating until the preset ending condition is met, and obtaining that the generated answer is the answer of the user question when the ending condition is met.
- 9. A retrieval enhancement generation device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, causes the retrieval enhancement generation device to implement the method of any of claims 1-7.
- 10. A computer program product comprising computer program instructions which, when run, cause the method of any of claims 1-7 to be performed.
Description
Search enhancement generation method, device, equipment and program product Technical Field The present application relates to the field of intelligent search, and in particular, to a method, apparatus, device, and program product for generating search enhancement. Background With the wide application of large language models (English is called Large Language Model, english is called LLM for short) in the fields of question and answer, search enhancement, knowledge reasoning and the like, the technology of search enhancement generation (English is called RETRIEVAL-Augmented Generation, english is called RAG for short) gradually becomes a mainstream scheme for constructing an intelligent question and answer and knowledge service system. The RAG combines the related document retrieval results in the external knowledge base with the generated model, so that the model can refer to the external knowledge when answering the questions, and the accuracy and the interpretability of the answers are improved. The traditional RAG system generally adopts a single Top-k search, a plurality of searched documents or paragraphs are directly spliced and input into a generated model, and the single Top-k search mode is easy to miss key information, and particularly under complex or cross-domain problem scenes, the model may miss key facts or reasoning clues, so that the answer is incomplete. Disclosure of Invention In view of the above, the embodiments of the present application provide a method, apparatus, device and program product for generating search enhancement, so as to solve the problem that the search method in the prior art can miss key facts or reasoning clues, resulting in incomplete answers. A first aspect of an embodiment of the present application provides a search enhancement generation method, where the method includes: receiving a user problem, and carrying out vector coding on the user problem to obtain a query vector; Searching a candidate knowledge segment set in a preset multi-granularity knowledge system according to the query vector, wherein the candidate knowledge segment set comprises a plurality of knowledge segments, and the knowledge segments are segments obtained by dividing a knowledge base; Generating answers through a generation model according to the candidate knowledge segment set and the user questions, and determining the attention distribution of knowledge segments in the candidate knowledge segment set; And under the condition that the current state does not meet the preset ending condition, updating the query vector according to the attention distribution, and jumping to the step of searching the candidate knowledge fragment set in the preset multi-granularity knowledge system according to the query vector for iterative updating until the preset ending condition is met, wherein the answer generated when the ending condition is met is the answer of the user question. With reference to the first aspect, in a first possible implementation manner of the first aspect, before retrieving, according to the query vector, the candidate knowledge segment set in a preset multi-granularity knowledge system, the method further includes: decomposing the knowledge base with different granularities to construct knowledge fragments with different granularities; according to the query vector, searching the candidate knowledge fragment set in a preset multi-granularity knowledge system comprises the following steps: Evaluating the complexity of the user problem; determining a target granularity corresponding to the complexity of the user problem according to a corresponding relation between the preset complexity and granularity; And calculating the semantic similarity of each knowledge segment in the user problem and the target granularity, and determining the candidate knowledge segment set according to the semantic similarity. With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, after calculating the semantic similarity of each knowledge segment in the user problem and the target granularity, the method further includes: when the target granularity corresponding to the complexity of the user problem comprises more than two target granularities, determining a weight coefficient of the target granularity; And according to the weight coefficient of the target granularity, combining the weighted average vector of each knowledge segment in the target granularity, and determining the comprehensive knowledge representation of the target granularity related to the user problem. With reference to the first possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, after retrieving, according to the query vector, the candidate knowledge segment set in a preset multi-granularity knowledge system, the method further includes: Determining the credibility and freshness of e