Retrieval enhancement generation method based on intelligent agent and related device

Retrieval enhancement processing is carried out through the coordinated responsive collection of agents, which solves the problem of large language models producing "illusions" in specific fields or knowledge-intensive tasks, and achieves efficient retrieval enhancement, reduces the probability of "illusions" and improves the quality and accuracy of generated texts.

CN119903174APending Publication Date: 2025-04-29QINGDAO ZHONGKE SHUGUANG TECH SERVICE CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411982361.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

Existing large language models (LLMs) may produce 'illusions' in specific domains or knowledge-intensive tasks, that is, return content that is irrelevant to the problem or factual errors. How to efficiently improve the retrieval enhancement efficiency for LLM has become an urgent problem to be solved.

Method used

The retrieval enhancement generation method based on the agent is adopted, and the search enhancement processing is performed through the collection of agents, including the first agent for determining whether the retrieval enhancement processing is needed, and multiple text blocks are retrieved in the knowledge base. The second agent generates a high-quality second text and provides it to a large language model to reduce the probability of 'illusion'.

Benefits of technology

It improves the retrieval enhancement efficiency, improves the quality of generated text, reduces the occurrence of "illusion" in the LLM generation results, and makes the generated text more accurate and relevant.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119903174A_ABST
    Figure CN119903174A_ABST
Patent Text Reader

Abstract

The invention provides an intelligent agent-based retrieval enhancement generation method and a related device, which are used for improving the retrieval enhancement efficiency and reducing the illusion condition in an LLM (Logistics Language Model) generation result. The method comprises the steps that an agent set determines whether retrieval enhancement processing is needed or not according to a first text; if it is determined that retrieval enhancement processing is needed, retrieving in a knowledge base based on the first text to obtain a plurality of text blocks; generating a second text corresponding to the first text based on the first text and the plurality of text blocks; providing the second text to a large language model; and the large language model outputs a third text corresponding to the first text according to the text provided by the agent set.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of electronic technology and provides a method for generating retrieval enhancement based on an intelligent agent and a related device. Background Art

[0002] With the widespread application of large language models (LLMs), the knowledge acquired by LLMs based on training data may not cover the needs of specific fields or knowledge-intensive tasks, and the results generated by LLMs will frequently produce "hallucinations", which means that LLMs return content that is irrelevant to the problem or factually incorrect.

[0003] In order to alleviate the "hallucination" caused by LLM, Retrieval-augmented Generation (RAG) was proposed. RAG technology retrieves relevant document blocks from external knowledge bases as the context of the large language model, providing the large language model with additional knowledge related to the problem to enhance the ability of LLM, thereby effectively alleviating the hallucination problem in the generated text. How to effectively improve the efficiency of retrieval enhancement for LLM has become an urgent problem to be solved. Summary of the invention

[0004] The embodiments of the present application provide an agent-based retrieval enhancement generation method and related devices to improve the efficiency of retrieval enhancement and reduce the occurrence of hallucinations in LLM generation results.

[0005] In a first aspect, the present application provides an agent-based retrieval enhancement generation method according to an embodiment, the method comprising:

[0006] The agent set determines whether retrieval enhancement processing is required based on the first text; and if it is determined that retrieval enhancement processing is required, based on the first text, retrieves multiple text blocks in the knowledge base; based on the first text and the multiple text blocks, generates a second text corresponding to the first text; and provides the second text to the large language model;

[0007] The large language model outputs a third text corresponding to the first text based on the text provided by the agent set.

[0008] In the embodiment of the present application, the agent set may include multiple agents, and the multiple agents collaborate to perform retrieval enhancement processing. Such a design can increase the processing speed, enhance the retrieval enhancement effect, make the second text have higher quality, and reduce the probability of "hallucination" of LLM.

[0009] In a possible implementation, in the agent-based retrieval enhancement method provided in the embodiment of the present application, the agent set includes a first agent and a second agent;

[0010] wherein the first agent determines whether retrieval enhancement processing is required based on the first text; and if it is determined that retrieval enhancement processing is required, a plurality of text blocks are retrieved from a knowledge base based on the first text;

[0011] The second agent generates a second text corresponding to the first text based on the first text and the multiple text blocks; and provides the second text to the large language model.

[0012] In the embodiment of the present application, the agent set may include a first agent and a second agent. The first agent retrieves multiple text blocks from the knowledge base. The second agent generates a second text based on the multiple text blocks and the first text. Such a design can fully utilize the potential of the first agent and the potential of the second agent, and the flexibility of the overall operation of the agent set.

[0013] In a possible implementation manner, in the agent-based retrieval enhancement method provided in the embodiment of the present application, generating a second text corresponding to the first text based on the first text and the multiple text blocks includes:

[0014] Based on the similarity between each text block in the plurality of text blocks and the first text, determining target text blocks corresponding to the largest K similarities, where K is an integer greater than or equal to 2;

[0015] For each of the target text blocks, based on the content in the target text block related to the first text and the first text, a second text corresponding to the first text is generated.

[0016] In the embodiment of the present application, K target text blocks are determined from multiple text blocks, so that the retrieved text blocks can be filtered, the redundancy of the text block content can be reduced, the efficiency of the retrieved content can be improved, and the probability of hallucinations in the third text generated by the large language model can be reduced.

[0017] In a possible implementation, in the agent-based retrieval enhancement method provided in the embodiment of the present application, the agent set includes a first agent, a second agent, and a third agent;

[0018] wherein the first agent determines whether retrieval enhancement processing is required based on the first text; and if it is determined that retrieval enhancement processing is required, a plurality of text blocks are retrieved from a knowledge base based on the first text;

[0019] The third agent determines the text blocks corresponding to the largest K similarities based on the similarity between each text block in the text blocks provided by the first agent and the first text, and outputs them to the second agent, where K is an integer greater than or equal to 2; or the third agent outputs the multiple text blocks to the second agent;

[0020] The second agent is used to receive multiple target text blocks, and based on the content related to the first text in the target text blocks and the first text, generate a second text corresponding to the first text; provide the second text to the large language model, wherein the target text block is a text block provided by the third agent.

[0021] In the embodiment of the present application, the first agent is used to retrieve multiple text blocks from the knowledge base, and the third agent can provide the second agent with multiple text blocks or K text blocks from multiple text blocks according to a preset strategy. The execution process of the third agent can improve the flexibility of the retrieval enhancement method.

[0022] In a possible implementation, in the agent-based retrieval enhancement method provided in the embodiment of the present application, the first agent retrieves multiple text blocks in the knowledge base based on the first text, including:

[0023] Based on the first text, a hybrid search process is performed in a preset knowledge base, wherein the hybrid search process includes at least two search methods;

[0024] The multiple text blocks are obtained according to the weight parameters corresponding to each search method and the search results corresponding to each search method, wherein the ratio of the search results corresponding to any search method in the multiple text blocks to the multiple text blocks is the weight parameter corresponding to any search method.

[0025] In the embodiment of the present application, in the process of retrieving multiple text blocks from the knowledge base, a mixed search processing operation can be used, and different search methods are used for searching, and according to the weight parameters corresponding to each search method, the search results corresponding to each search method are mixed to obtain multiple text blocks. Such a design can improve the quality of the text blocks retrieved from the knowledge base.

[0026] In a possible implementation, in the agent-based retrieval enhancement method provided in the embodiment of the present application, the agent set further includes a fourth agent; the method further includes:

[0027] The fourth agent updates the weight parameters corresponding to each retrieval method based on the retrieval methods corresponding to the third text and the second text.

[0028] In the embodiment of the present application, the weight parameters corresponding to different retrieval methods are dynamically updated. Such a design can make the quality of the text blocks retrieved from the knowledge base more stable.

[0029] In a possible implementation, in the agent-based retrieval enhancement method provided in the embodiment of the present application, the at least two retrieval modes include a full-text retrieval mode; the agent set includes a third agent; and the method further includes:

[0030] The third agent receives a plurality of text blocks provided by the first agent;

[0031] When the third intelligent agent determines that the number of the multiple text blocks is less than a first quantity threshold, or when it determines that the weight parameter corresponding to the full-text retrieval method is greater than or equal to a preset parameter threshold, and the number of the multiple text blocks is less than a second quantity threshold, the multiple text blocks are sent to the second intelligent agent, and the first quantity threshold is less than the second quantity threshold.

[0032] In the embodiment of the present application, the third intelligent agent determines whether to filter multiple text blocks based on preset conditions. Such a design has high flexibility and can meet a wider range of application scenarios.

[0033] In a second aspect, an embodiment of the present application further provides an electronic device which may include a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the agent-based retrieval enhancement generation method provided in the first aspect or any possible implementation scheme of the first aspect.

[0034] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, which includes a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the agent-based retrieval enhancement generation method provided in the first aspect or any possible implementation scheme of the first aspect.

[0035] In a fourth aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the steps of the agent-based retrieval enhancement generation method provided in the first aspect or any possible implementation manner of the first aspect.

[0036] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0038] Figure 1 A schematic diagram showing a retrieval enhancement generation process according to an exemplary embodiment;

[0039] Figure 2 A schematic diagram of an execution process of an agent-based retrieval enhancement generation method provided in an embodiment of the present application;

[0040] Figure 3 A schematic diagram of a flow chart of an agent-based retrieval enhancement generation method provided in an embodiment of the present application;

[0041] Figure 4 A schematic diagram of a flow chart of an agent-based retrieval enhancement generation method provided in an embodiment of the present application;

[0042] Figure 5 A schematic diagram of a flow chart of an agent-based retrieval enhancement generation method provided in an embodiment of the present application;

[0043] Figure 6 A schematic diagram of a flow chart of an agent-based retrieval enhancement generation method provided in an embodiment of the present application;

[0044] Figure 7 A schematic diagram of the structure of an electronic system provided in an embodiment of the present application;

[0045] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0046] Fig. 9 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.

[0048] It should be noted that in the description of this application, "multiple" is understood as "at least two". "And / or" describes the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone. A and B are connected, which can represent two situations: A and B are directly connected and A and B are connected through C. In addition, in the description of this application, words such as "first" and "second" are only used for the purpose of distinguishing descriptions, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.

[0049] The user can provide a query text, and LLM can generate an answer text corresponding to the query text. In some examples, the query text can be a question text, such as "What is a large language model". In other examples, the query text can be a search text, such as "Give a directory of junior high school physics textbooks". The text generated by LLM can be the answer corresponding to the question text, or the search result corresponding to the search text. In fact, they are all texts generated by LLM as answers to the query text, which are simply referred to as answer text.

[0050] Please combine Figure 1 ,Currently, RAG technology retrieves relevant document blocks from the ,external knowledge base of LLM as the context of LLM, and ,provides LLM with additional knowledge related to the user’s query text to ,enhance the ability of LLM. This approach can alleviate the ,illusion problem in the text generated by LLM, so that the answer text corresponding to the ,query text generated by LLM has higher quality.

[0051] RAG technology usually includes three parts: knowledge base index construction (indexing), retrieval (retrieval), and generation (generation). Knowledge base index construction can include steps such as document loading, text segmentation, and vector embedding. Among them, the document loading operation is used to extract document data from original materials in different formats such as txt, md, pdf, etc., and convert the document data into a unified text format. The text segmentation operation is used to divide the extracted documents into smaller and more understandable text blocks to adapt to the context length limit of LLM. The vector embedding operation is used to encode text blocks into different vectors using an embedding model and store them in vector databases such as FAISS and Chroma.

[0052] In RAG technology, query text is used to search in the knowledge base, and the search results and query text are provided to LLM, which generates the answer text.

[0053] In order to improve the efficiency of retrieval enhancement and reduce the occurrence of hallucinations in LLM generation results, an embodiment of the present application provides an agent-based retrieval enhancement generation method and related devices.

[0054] It should be noted that the acquisition, storage, use, and processing of data in the embodiments of the present application are in compliance with the relevant provisions of national laws and regulations.

[0055] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments of the present application and the features in the embodiments may be combined with each other if there is no conflict.

[0056] Figure 2 The working process of an electronic device is exemplified. The agent set can determine whether to perform retrieval enhancement processing on the first text according to the first text. The first text can be implemented as a query text.

[0057] In one possible scenario, if the first text needs to be searched and enhanced, the agent set can query the relevant text block from the knowledge base, and generate the second text based on the queried text block and the first text. The second text can be used as a prompt with context. The agent set then provides the second text to the LLM. The LLM then generates a third text based on the first text and the second text. The third text is also the answer text corresponding to the first text.

[0058] In a possible scenario, if the first text does not need to be search enhanced, the agent set can directly call the LLM and provide the first text to the LLM, and then the LLM generates the third text based on the first text.

[0059] The agent has a built-in large language model as the "brain", which can be used to perform specific tasks, interact with the environment, and realize a variety of real-time functions. The built-in large language model can make decisions in the form of Chain of Thought (CoT), etc., can realize the disassembly of sub-goals, conduct self-criticism and reflection on past actions, and improve subsequent operations. In this application, the agent set can include multiple agents, and multiple agents collaborate to perform retrieval enhancement processing. Such a design can increase the processing speed, improve the retrieval enhancement effect, make the second text have higher quality, and reduce the probability of "hallucination" of LLM.

[0060] Figure 3 An agent-based retrieval enhancement generation method is exemplarily shown, which can be executed by an electronic device. The method may include the following steps:

[0061] S301, the agent set determines whether retrieval enhancement processing is required based on the first text; and if it is determined that retrieval enhancement processing is required, based on the first text, retrieves multiple text blocks in the knowledge base; based on the first text and the multiple text blocks, generates a second text corresponding to the first text; and provides the second text to a large language model;

[0062] S302: The large language model outputs a third text corresponding to the first text based on the text provided by the agent set.

[0063] In a possible implementation manner, in the operation of the agent set generating the second text corresponding to the first text based on the first text and the multiple text blocks, the following process may be performed:

[0064] The agent set determines target text blocks corresponding to the largest K similarities based on the similarity between each text block in the plurality of text blocks and the first text, where K is an integer greater than or equal to 2;

[0065] For each of the target text blocks, the agent set generates a second text corresponding to the first text based on the content related to the first text in the target text block and the first text.

[0066] In a possible design, the agent set may perform the following process in the operation of retrieving multiple text blocks from the knowledge base based on the first text:

[0067] The agent set may perform a hybrid search process in a preset knowledge base based on the first text, wherein the hybrid search process includes at least two search methods;

[0068] The intelligent agent set can obtain the multiple text blocks based on the weight parameters corresponding to each retrieval method and the retrieval results corresponding to each retrieval method, wherein the ratio of the retrieval results corresponding to any retrieval method in the multiple text blocks to the multiple text blocks is the weight parameter corresponding to any retrieval method.

[0069] In some examples, the agent set may also update weight parameters corresponding to each retrieval method based on the retrieval method corresponding to the third text and the second text, for the next execution of the agent-based retrieval enhancement generation method.

[0070] In some examples, the agent set determines target text blocks corresponding to the largest K similarities based on the similarity between each text block in the multiple text blocks and the first text, where K is an integer greater than or equal to 2; for each target text block, based on the content related to the first text in the target text block and the first text, a second text corresponding to the first text is generated.

[0071] The agent set provided in the embodiment of the present application may include multiple agents. The following is a detailed introduction of each agent in the agent set. Figure 4 The exemplary implementation shows a method for generating retrieval enhancement based on an agent, which may include the following steps:

[0072] S401, a first agent receives a first text;

[0073] S402, the first agent determines whether retrieval enhancement processing is required based on the first text, if so, the next step is to execute step S403, if not, the next step is to execute step S404.

[0074] In some examples, the first agent may call the large language model and determine through the large language model whether the large language model can use its own knowledge to generate a third text corresponding to the first text. If the large language model can use its own knowledge to generate the third text corresponding to the first text, it may reflect that no retrieval enhancement processing is required. If the large language model cannot use its own knowledge to generate the third text corresponding to the first text, it may reflect that retrieval enhancement processing is required.

[0075] In some examples, the first agent can determine whether retrieval enhancement processing is needed based on pre-configured keywords and the first text. If any keyword is included in the first text, it reflects that retrieval enhancement processing is needed. If no keyword is included in the first text, it reflects that retrieval enhancement processing is not needed. In such a design, the presence of keywords in the query text can start the retrieval enhancement processing process, which can ensure retrieval stability. Only a small number of high-frequency words are configured in the first agent, and there is no need to reserve lengthy high-frequency words.

[0076] In some other examples, the first agent can determine whether retrieval enhancement processing is needed based on pre-configured keywords and the first text. If any keyword is included in the first text, it reflects that retrieval enhancement processing is needed. If the first text does not include any keyword, the large language model is called to determine whether the large language model can use its own knowledge to generate a third text corresponding to the first text. If the large language model can use its own knowledge to generate a third text corresponding to the first text, it can reflect that retrieval enhancement processing is not needed. The large language model cannot use its own knowledge to generate a third text corresponding to the first text, which can reflect that retrieval enhancement processing is needed.

[0077] S403, the first agent retrieves a plurality of text blocks from a knowledge base based on the first text;

[0078] S404, the first agent provides the first text to the large language model;

[0079] S405: The second agent generates a second text corresponding to the first text based on the first text and the multiple text blocks, and provides the second text to the large language model.

[0080] In specific implementation, for each of the multiple text blocks retrieved from the knowledge base, the second agent can determine the relevance (degree of relevance) between the text in each text block and the first text, and retain the content related to the first text in each text block, remove the content unrelated to the first text in each text block, and filter out the irrelevant content in each text block. The second agent can generate a prompt word corresponding to the text block as the second text based on the content related to the first text and the first text in each text block.

[0081] In some examples, a text block may include multiple texts. If the relevance between a text and a first text is greater than or equal to a preset relevance threshold, it can be reflected that the text is content related to the first text. If the relevance between a text and a second text is less than the relevance threshold, it can be reflected that the text is irrelevant to the first text.

[0082] S406: The large language model outputs a third text corresponding to the first text based on the text provided by the agent set.

[0083] Optionally, the large language model may be any large language model. Optionally, the agent set may include a large language model agent, and the large language model may be implemented as a large language model agent.

[0084] Figure 5 The exemplary implementation shows a method for generating retrieval enhancement based on an agent, which may include the following steps:

[0085] S501, the first agent receives a first text;

[0086] S502, the first agent determines whether retrieval enhancement processing is required based on the first text, if so, the next step is to execute step S503, if not, the next step is to execute step S503;

[0087] S503, the first agent retrieves a plurality of text blocks from a knowledge base based on the first text, and provides the plurality of text blocks to a third agent;

[0088] S504, the first agent provides the first text to the large language model;

[0089] S505: The third agent determines the text blocks corresponding to the largest K similarities based on the similarity between each text block in the text blocks provided by the first agent and the first text, and outputs them to the second agent.

[0090] In specific implementation, for multiple text blocks provided by the first agent, the third agent can determine the similarity between each text block and the first text. According to the order of similarity from large to small, the largest K similarities can be determined. And the text blocks corresponding to the K similarities are provided to the second agent. Among them, K is an integer greater than or equal to 2, and K is less than or equal to the multiple text blocks. It can be seen that the third agent can filter out text blocks with low similarity. Such a design can reduce the probability of hallucination in the third text generated by the large language model.

[0091] S506: The second agent generates a second text corresponding to the first text based on the content related to the first text in the target text block and the first text, and provides the second text to the large language model.

[0092] During specific implementation, the second agent receives a plurality of target text blocks, wherein the target text blocks are text blocks provided by the third agent.

[0093] In a specific implementation, for each target text block in the plurality of target text blocks, the second agent can determine the relevance (degree of relevance) between the text in each target text block and the first text, and retain the content related to the first text in each target text block, and remove the content unrelated to the first text in each target text block, thereby filtering the irrelevant content in each target text block. The second agent can generate a prompt word corresponding to the target text block as the second text based on the content related to the first text and the first text in each target text block.

[0094] In some examples, a target text block may include multiple texts. If the relevance between a text and a first text is greater than or equal to a preset relevance threshold, it can be reflected that the text is content related to the first text. If the relevance between a text and a second text is less than the relevance threshold, it can be reflected that the text is irrelevant to the first text.

[0095] S507, the large language model outputs a third text corresponding to the first text based on the second text provided by the second agent.

[0096] Based on the agent-based retrieval enhancement generation method provided by any of the above embodiments, the process of the first agent retrieving multiple text blocks in the knowledge base based on the first text is introduced below.

[0097] In the embodiment of the present application, the number of knowledge bases may be one or more. The first agent may use one or more retrieval methods to retrieve multiple text blocks from the knowledge base.

[0098] In a possible design, there may be multiple knowledge bases. Multiple knowledge bases may be obtained based on content classification. Content classifications in different knowledge bases are different. The description of a knowledge base may reflect the content classification of the knowledge base.

[0099] The first agent can determine a target content classification based on the first text. The first agent can find a knowledge base whose content is assigned to the target content classification from multiple knowledge bases, and record it as the target knowledge base for introduction. The first agent can retrieve multiple text blocks in the target knowledge base.

[0100] In a possible design, the first agent may perform mixed retrieval in one or more knowledge bases. The first agent may use multiple retrieval methods to search in one or more knowledge bases. The multiple retrieval methods may include at least two retrieval methods.

[0101] The first agent performs a hybrid retrieval process in a preset knowledge base based on the first text, wherein the hybrid retrieval process includes at least two retrieval methods;

[0102] According to the weight parameters corresponding to each search method and the search results corresponding to each search method, the multiple text blocks are obtained, wherein the ratio of the search results corresponding to any search method in the multiple text blocks to the multiple text blocks is the weight parameter corresponding to any search method. For ease of introduction, the number of the multiple text blocks obtained is N, where N is a positive integer greater than or equal to 2.

[0103] In specific implementation, each search method is configured with a corresponding weight parameter. The first agent uses each search method to search in a preset knowledge base, and can obtain search results corresponding to each search method. The search results can include at least one text block.

[0104] For any retrieval method, the first agent can select part or all of the text blocks from the retrieval results of the retrieval method, where the ratio of the number of text blocks selected by the first agent from the retrieval results of the retrieval method to N is the weight parameter corresponding to the retrieval method.

[0105] For example, the at least two search methods include a first search method and a second search method, wherein the weight parameter corresponding to the first search method is a first weight parameter a1, and the weight parameter corresponding to the second search method is a second weight parameter a2.

[0106] The first agent can select a1*N text blocks from the search results corresponding to the first search method. The first agent can select a2*N text blocks from the search results corresponding to the second search method.

[0107] In some examples, the first search method can be implemented as a vector search method, and the second search method can be implemented as a full-text search method. In the vector search method, the semantic similarity between the first text and the knowledge base document can be calculated through the embedding model to obtain the search result. In the full-text search method, BM25 (Best Matching 25) can be used for keyword search.

[0108] The first agent can combine the weight parameters of the vector retrieval method and the weight parameters of the full-text retrieval method to perform mixed processing on the retrieval results of the two retrieval methods. Among them, the first agent can use the Reciprocal Rank Fusion (RRF) algorithm. For the retrieval results of any retrieval method, the first agent can determine the reciprocal rank of each text block under different sorting methods. The reciprocal rank of any text block can be recorded as 1 / r, where r is the ranking position of the text block under this sorting method. The first agent can determine the sum of the reciprocal ranks of any text block under all sorting methods, recorded as the sum of the reciprocal ranks corresponding to any text block.

[0109] The first agent can sort the text blocks in the search results of the vector search method in descending order of the sum of the reciprocal rank, and select the first a1*N text blocks in the sorting. The first agent can sort the text blocks in the search results of the full-text search method in descending order of the sum of the reciprocal rank, and select the first a2*N text blocks in the sorting. Thus, the first agent can obtain N text blocks. The first agent can provide the N text blocks to the third agent.

[0110] In a possible implementation, weight parameters corresponding to different retrieval methods are preconfigured.

[0111] In another possible implementation, the weight parameters corresponding to different retrieval methods are dynamically updated. The collective agent may also include a fourth agent.

[0112] The second agent generates a second text corresponding to the first text based on the first text and the N text blocks, and also generates a second text corresponding to each of the N text blocks, wherein the search method corresponding to each text block is used as the search method corresponding to the second text. The second agent provides the second text to the large language model; the large language model can output a third text corresponding to the first text based on the text provided by the agent set.

[0113] The fourth agent can determine the contribution of each second text to the generation of the third text based on the third text corresponding to the first text generated in the last execution of the agent-based retrieval enhancement generation method and each second text. The fourth agent can count the sum of the contribution of the second texts corresponding to the first retrieval method, recorded as the first sum. The fourth agent can count the sum of the contribution of the second texts corresponding to the second retrieval method, recorded as the second sum.

[0114] The fourth agent may update the weight parameter corresponding to the first search method and the weight parameter corresponding to the second search method based on the first sum and the second sum. Generally, if the first sum is greater than the second sum, the weight parameter corresponding to the first search method is greater than the weight parameter corresponding to the second search method; if the first sum is less than the second sum, the weight parameter corresponding to the first search method is less than the weight parameter corresponding to the second search method.

[0115] It can be seen that the fourth agent can evaluate the reference value of different retrieval methods to the third text. The weight parameters of the retrieval methods with higher reference values ​​are increased, and the weight parameters of the retrieval methods with lower reference values ​​are reduced. As the number of times the electronic device executes the agent-based retrieval enhancement generation method increases, the weight parameters corresponding to each retrieval method provided by the fourth agent will be more suitable for the hybrid retrieval processing process of the current knowledge base.

[0116] It should be noted that in this example, updating the weight parameters corresponding to the first search method and the second search method is used as an example for explanation. Those skilled in the art should understand the implementation method of updating the weight parameters corresponding to different search methods. This application does not elaborate on the implementation method of updating the weight parameters corresponding to each search method when there are more than two search methods.

[0117] In a possible application scenario, the electronic device executes the agent-based retrieval enhancement generation method for the first time. The fourth agent can provide the first agent with the initial weight parameters corresponding to each pre-configured retrieval method.

[0118] In a possible implementation, the first agent uses the weight parameters corresponding to each search method provided by the fourth agent to determine N text blocks and provide them to the third agent. The third agent receives the N text blocks provided by the first agent. When the third agent determines that the number of the multiple text blocks is less than a first quantity threshold, or determines that the weight parameter corresponding to the full-text search method is greater than or equal to a preset parameter threshold, and the number of the multiple text blocks is less than a second quantity threshold, the third agent sends the multiple text blocks to the second agent, and the first quantity threshold is less than the second quantity threshold. Optionally, the second quantity threshold is t times the first quantity threshold, where t is a natural number greater than 1.

[0119] Figure 6 The exemplary implementation shows a method for generating retrieval enhancement based on an agent, which may include the following steps:

[0120] S601, the first agent receives a first text;

[0121] S602, the first agent determines whether retrieval enhancement processing is required based on the first text, if so, the next step is to execute step S603, if not, the next step is to execute step S604;

[0122] S603, the first agent retrieves a plurality of text blocks from a knowledge base based on the first text and a plurality of retrieval methods, and provides the plurality of text blocks to a third agent;

[0123] S604, the first agent provides the first text to the large language model;

[0124] S605, the third agent determines whether the preset conditions are met, if so, the next step is to execute step S606, if not, the next step is to execute step S607.

[0125] The preset conditions can include any of the following conditions:

[0126] Condition 1: the number of the plurality of text blocks is less than a first number threshold;

[0127] Condition 2: the weight parameter corresponding to the full-text search method is greater than or equal to a preset parameter threshold, and the number of the multiple text blocks is less than a second number threshold.

[0128] S606: The third agent determines the text blocks corresponding to the largest K similarities based on the similarity between each text block in the text blocks provided by the first agent and the first text, and outputs them to the second agent.

[0129] S607, the third agent outputs the received multiple text blocks to the second agent.

[0130] S608: The second agent generates a second text corresponding to the first text based on the content related to the first text in the target text block and the first text, and provides the second text to the large language model.

[0131] In the embodiment of the present application, after double enhanced filtering by the third agent and the second agent, the target text block has a high semantic similarity with the first text.

[0132] S609, the second agent generates a second text corresponding to the first text based on the content related to the first text in each text block of the multiple text blocks and the first text, and provides the second text to the large language model.

[0133] S610: The large language model outputs a third text corresponding to the first text based on the second text.

[0134] S611, the fourth agent determines the weight parameters corresponding to each search method based on the third text corresponding to the first text and the second text, and provides them to the first agent.

[0135] In the embodiment of the present application, multiple agents in the agent set work together to maximize the potential of the agents, improve the flexibility of the agent-based retrieval enhancement generation method, reduce the content redundancy in the text block used to generate the second text, improve the efficiency of the retrieval content, and avoid the situation where the large language model generates hallucinations.

[0136] Based on the same inventive concept, the present application also provides an electronic system. Figure 7 As shown, the electronic system may include the first agent, the second agent, the third agent, the fourth agent, the preset knowledge base, and the large language model in the aforementioned embodiment. The electronic system may implement the agent-based retrieval enhancement generation method provided in any of the aforementioned embodiments. See the relevant introduction in the aforementioned embodiment for details, which will not be repeated here.

[0137] Next, an electronic device according to an exemplary embodiment of the present application is introduced. Figure 8 is a block diagram of an electronic device 900 according to an exemplary embodiment, the device comprising:

[0138] Processor 910;

[0139] A memory 920 for storing instructions executable by the processor 910;

[0140] The processor 910 is configured to execute instructions to implement the steps in the agent-based retrieval enhancement generation method provided in any one of the aforementioned embodiments.

[0141] In an exemplary embodiment, a storage medium including operations is also provided, such as a memory 920 including operations, and the above operations can be executed by the processor 910 of the electronic device 900 to complete the steps in the agent-based retrieval enhancement generation method provided in any of the above embodiments. Optionally, the storage medium can be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a portable compact disk read-only memory (CD-ROM), a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0142] Based on the same inventive concept, refer to Fig. 9 As shown, the embodiment of the present application further provides a terminal device 1000, which includes a display unit 1040, a processor 1080 and a memory 1020, wherein the display unit 1040 includes a display panel 1041, which is used to display information input by a user or information provided to a user and various operation interfaces of the terminal device 1000, etc. In the embodiment of the present application, it is mainly used to display the operation interface, block window, etc. of the application installed in the terminal device 1000. Optionally, the display panel 1041 can be configured in the form of LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).

[0143] The processor 1080 is used to read the computer program and then execute the method defined by the computer program. For example, the processor 1080 reads the application, thereby running the application on the terminal device 1000 and displaying the operation interface on the display unit 1040. The processor 1080 may include one or more general-purpose processors and may also include one or more DSPs (Digital Signal Processors) to perform related operations to implement the technical solutions provided in the embodiments of the present application.

[0144] The memory 1020 generally includes internal memory and external memory, and the internal memory can be RAM, ROM, and cache (CACHE), etc. The external memory can be a hard disk, an optical disk, a USB disk, a floppy disk or a tape drive, etc. The memory 1020 is used to store computer programs and other data, and the computer program includes an application program, etc. The other data may include data generated after the operating system or the application program is run, and the data includes system data (such as configuration parameters of the operating system) and user data. In the embodiment of the present application, program instructions are stored in the memory 1020, and the processor 1080 executes the program instructions in the memory 1020 to implement the agent-based retrieval enhancement generation method discussed above.

[0145] In addition, the terminal device 1000 may also include a display unit 1040 for receiving input digital information, character information or contact touch operation / contactless gesture, and generating signal input related to user settings and function control of the terminal device 1000. Specifically, in the embodiment of the present application, the display unit 1040 may include a display panel 1041. The display panel 1041, for example, a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the display panel 1041 or on the display panel 1041 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the display panel 1041 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the touch position of the user, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact point coordinates, and then sends it to the processor 1080, and can receive and execute commands sent by the processor 1080. In an embodiment of the present application, if a user selects a control in the operation interface, the touch detection device in the display panel 1041 detects the touch operation, and sends a signal corresponding to the detected touch operation to the touch controller. The touch controller converts the signal into touch point coordinates and sends them to the processor 1080. The processor 1080 determines the control selected by the user based on the received touch point coordinates.

[0146] The display panel 1041 may be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the display unit 1040, the terminal device 1000 may further include an input unit 1030, which may include but is not limited to one or more of a physical keyboard, a function key (such as a volume control key, a switch key, etc.), a trackball, a mouse, and a joystick. Fig. 9 In the figure, the input unit 1030 includes an image input device 1031 and other input devices 1032 as an example.

[0147] In addition to the above, the terminal device 1000 may also include a power supply 1090 for supplying power to other modules, an audio circuit 1060, a near field communication module 1070, and an RF circuit 1010. The terminal device 1000 may also include one or more sensors 1050, such as an accelerometer, a light sensor, a pressure sensor, etc. The audio circuit 1060 specifically includes a speaker 1061 and a microphone 1062, etc. For example, the user can use voice control, the terminal device 1000 can collect the user's voice through the microphone 1062, can be controlled by the user's voice, and when the user needs to be prompted, the corresponding prompt tone is played through the speaker 1061.

[0148] Based on the same inventive concept, the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the agent-based retrieval enhancement generation method provided in various optional implementations of the above embodiments.

[0149] In some possible implementations, various aspects of the agent-based retrieval enhancement generation method provided by the present application may also be implemented in the form of a program product, which includes a computer program. When the program product is run on a computer device, the computer program is used to enable the computer device to execute the steps of the agent-based retrieval enhancement generation method according to the various exemplary embodiments of the present application described above in this specification. For example, the computer device may execute the steps of the agent-based retrieval enhancement generation method provided in any of the aforementioned embodiments.

[0150] The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a CD-ROM, an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0151] The program product of the embodiment of the present application may adopt a CD-ROM and include program code, and may be run on a computing device. However, the program product of the present application is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with a command execution system, device or device.

[0152] The readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in combination with a command execution system, device, or device. Although the preferred embodiments of the present application have been described, once the basic creative concept is known to those skilled in the art, additional changes and modifications may be made to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0153] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A method for retrieval enhancement generation based on an agent, characterized in that: The method comprises: The agent set determines whether retrieval enhancement processing is required based on the first text; and if it is determined that retrieval enhancement processing is required, based on the first text, retrieves multiple text blocks in the knowledge base; based on the first text and the multiple text blocks, generates a second text corresponding to the first text; and provides the second text to the large language model; The large language model outputs a third text corresponding to the first text based on the text provided by the agent set.

2. The method according to claim 1, characterized in that The agent set includes a first agent and a second agent; wherein the first agent determines whether retrieval enhancement processing is required based on the first text; and if it is determined that retrieval enhancement processing is required, a plurality of text blocks are retrieved from a knowledge base based on the first text; The second agent generates a second text corresponding to the first text based on the first text and the multiple text blocks; and provides the second text to the large language model.

3. The method according to claim 1, characterized in that The step of generating a second text corresponding to the first text based on the first text and the plurality of text blocks includes: Based on the similarity between each text block in the plurality of text blocks and the first text, determining target text blocks corresponding to the largest K similarities, where K is an integer greater than or equal to 2; For each of the target text blocks, based on the content in the target text block related to the first text and the first text, a second text corresponding to the first text is generated.

4. The method according to claim 3, characterized in that The agent set includes a first agent, a second agent and a third agent; wherein the first agent determines whether retrieval enhancement processing is required based on the first text; and if it is determined that retrieval enhancement processing is required, a plurality of text blocks are retrieved from a knowledge base based on the first text; The third agent determines the text blocks corresponding to the largest K similarities based on the similarity between each text block in the text blocks provided by the first agent and the first text, and outputs them to the second agent, where K is an integer greater than or equal to 2; or the third agent outputs the multiple text blocks to the second agent; The second agent is used to receive multiple target text blocks, and based on the content related to the first text in the target text blocks and the first text, generate a second text corresponding to the first text; provide the second text to the large language model, wherein the target text block is a text block provided by the third agent.

5. The method according to claim 2 or 4, characterized in that The first agent retrieves a plurality of text blocks from a knowledge base based on the first text, including: Based on the first text, a hybrid search process is performed in a preset knowledge base, wherein the hybrid search process includes at least two search methods; The multiple text blocks are obtained according to the weight parameters corresponding to each search method and the search results corresponding to each search method, wherein the ratio of the search results corresponding to any search method in the multiple text blocks to the multiple text blocks is the weight parameter corresponding to any search method.

6. The method according to claim 5, characterized in that The agent set further includes a fourth agent; the method further includes: The fourth agent updates the weight parameters corresponding to each retrieval method based on the retrieval methods corresponding to the third text and the second text.

7. The method according to claim 5, characterized in that The at least two retrieval modes include a full-text retrieval mode; the agent set includes a third agent; and the method further includes: The third agent receives a plurality of text blocks provided by the first agent; When the third intelligent agent determines that the number of the multiple text blocks is less than a first quantity threshold, or when it determines that the weight parameter corresponding to the full-text retrieval method is greater than or equal to a preset parameter threshold, and the number of the multiple text blocks is less than a second quantity threshold, the multiple text blocks are sent to the second intelligent agent, and the first quantity threshold is less than the second quantity threshold.

8. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the methods of claims 1 to 7.

9. A computer-readable storage medium, characterized in that: It includes a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of any method described in claims 1 to 7.

10. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Conversational enterprise knowledge question answering method and device, storage medium and electronic equipment

    CN120316235A

  • Automatic generation method and device of operation and maintenance test questions, medium and equipment

    CN120448535A