Agent-based text generation method, device, equipment, and storage medium

By having the intelligent agent extract concise reference text that is relevant to the question from the retrieval results and initial answers, the problems of waste of computing resources and decreased answer accuracy caused by redundant information in RAG technology are solved, and more efficient and accurate answer generation is achieved.

CN119740669BActive Publication Date: 2025-10-03BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411898166.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-10-03
Estimated Expiration
2044-12-20

AI Technical Summary

Technical Problem

When generating answers, existing RAG technology faces the problem of redundant information input leading to waste of computing resources and reduced answer accuracy, especially in complex problem scenarios where it is difficult to generate reasonable answers.

Method used

The intelligent agent is used to extract concise reference text related to the question from the retrieval results and initial answers. The text generation process is optimized through the intelligent agent training method, which reduces the computing resources occupied by redundant content and improves the accuracy and efficiency of the answer.

Benefits of technology

Through the text extraction and training methods of intelligent agents, the computing resources occupied by redundant information are reduced, the accuracy and efficiency of answer generation are improved, and the performance of large models in complex problem scenarios is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119740669B_ABST
    Figure CN119740669B_ABST
Patent Text Reader

Abstract

The present disclosure provides an agent-based text generation method, apparatus, device, and storage medium, relating to the fields of artificial intelligence technology, particularly deep learning, large models, and retrieval-enhanced generation. A specific implementation of the text generation method includes: obtaining an initial text based on an input target question, wherein the initial text includes: a search result for the target question based on a knowledge base and an initial answer to the target question generated by an agent; extracting a reference text from the initial text using an agent; wherein the reference text is related to the target question and indicates a summary of the initial text; generating a target answer based on the target question and the reference text using an agent; and outputting the target answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to deep learning, large models, retrieval-enhanced generation, and other technical fields. Specifically, it relates to an agent-based text generation method, apparatus, device, and storage medium. Background Art

[0002] Retrieval-Augmented Generation (RAG) is a method that combines information retrieval and natural language generation technologies to improve the accuracy and reliability of AI systems when processing natural language questions. By combining retrieval and generation models, RAG enables AI systems to leverage external knowledge sources when generating content, thereby improving the relevance and accuracy of generated content. This method is not only applicable to question-answering systems but also in a variety of fields, such as text summarization and dialogue systems. Summary of the Invention

[0003] The present disclosure provides an agent-based text generation method, device, electronic device, and storage medium.

[0004] According to one aspect of the present disclosure, an agent-based text generation method is provided, comprising: obtaining an initial text based on an input target question, wherein the initial text includes: a retrieval result for the target question based on a knowledge base and an initial answer generated for the target question based on a large model; extracting a reference text from the initial text using an agent; wherein the reference text is related to the target question and indicates a summary of the initial text; generating a target answer based on the target question and the reference text using an agent; and outputting the target answer.

[0005] According to another aspect of the present disclosure, a method for training an intelligent agent is provided, comprising: obtaining a sample text based on an input sample question, wherein the sample text comprises: a retrieval result for the sample question based on a knowledge base and an initial sample answer for the sample question generated by the intelligent agent; extracting a sample reference text from the sample text using the initial intelligent agent; wherein the sample reference text is related to the sample question and indicates a summary of the sample text; generating a sample answer based on the sample question and the sample reference text using the intelligent agent; outputting the sample answer; and adjusting the model parameters of the intelligent agent based on the sample answer and the true answer to the sample question based on a reward function to obtain a trained intelligent agent.

[0006] According to an embodiment of the present disclosure, an agent-based text generation device is provided, including: a first acquisition module, a first extraction module, a first generation module and a first output module.

[0007] The first acquisition module is used to acquire an initial text according to the input target question. The initial text includes: a retrieval result for the target question based on the knowledge base and an initial answer generated by the intelligent agent for the target question.

[0008] The first extraction module is used to extract reference text from the initial text using an intelligent agent; wherein the reference text is related to the target question and indicates a summary of the initial text.

[0009] The first generation module is used to use an intelligent agent to generate a target answer based on a target question and a reference text.

[0010] The first output module is used to output the target answer.

[0011] According to an embodiment of the present disclosure, a training device for an intelligent agent is provided, comprising: a second acquisition module, a second extraction module, a second generation module, a second output module and an adjustment module.

[0012] The second acquisition module is used to obtain sample text according to the input sample question, wherein the sample text includes: a retrieval result for the target question based on the knowledge base and an initial answer generated for the target question based on the initial intelligent agent.

[0013] The second extraction module is used to extract sample reference text from the sample text using the initial intelligent agent; wherein the sample reference text is related to the sample question and indicates a summary of the initial text.

[0014] The second generation module is used to use the intelligent agent to generate sample answers based on sample questions and sample reference texts.

[0015] The adjustment module is used to adjust the model parameters of the intelligent agent based on the reward function according to the sample answers and the actual answers to the sample questions to obtain a trained intelligent agent.

[0016] According to an embodiment of the present disclosure, an intelligent agent is provided, comprising: an input module, a processing module, and an output module. The input module is configured to receive input information. The processing module is configured to determine a target task based on the input information received by the input module, determine at least two large models based on the target task, and execute the large model-based text generation method described above by calling the large models to obtain output information. The output module is configured to output the output information obtained by the processing module.

[0017] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described above.

[0018] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described above.

[0019] According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program, which implements the method described above when executed by a processor.

[0020] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.

[0022] Figure 1 Schematically illustrates an exemplary system architecture to which an agent-based text generation method, an agent training method, and an apparatus according to an embodiment of the present disclosure can be applied;

[0023] Figure 2 Schematically shows a flow chart of an agent-based text generation method according to an embodiment of the present disclosure;

[0024] Figure 3 The following schematically illustrates a method for generating text based on an agent according to an embodiment of the present disclosure;

[0025] Figure 4A Schematically shows a schematic diagram of text extraction based on an agent according to an embodiment of the present disclosure;

[0026] Figure 4B Schematically shows a schematic diagram of text extraction based on an agent according to another embodiment of the present disclosure;

[0027] Figure 4C Schematically shows a schematic diagram of text extraction based on an agent according to another embodiment of the present disclosure;

[0028] Figure 5 Schematically shows a schematic diagram of text generation based on an agent according to an embodiment of the present disclosure;

[0029] Figure 6 A schematic diagram of an agent-based text generation method in a complex problem scenario according to an embodiment of the present disclosure is schematically shown;

[0030] Figure 7 The flowchart of the training method of an intelligent agent according to an embodiment of the present disclosure is schematically shown;

[0031] Figure 8A A schematic diagram schematically illustrates an agent training method according to an embodiment of the present disclosure;

[0032] Figure 8B A schematic diagram schematically illustrates an agent training method according to another embodiment of the present disclosure;

[0033] Figure 9 Schematically shows a block diagram of an agent-based text generation device according to an embodiment of the present disclosure;

[0034] Figure 10 Schematically shows a block diagram of an intelligent agent training device according to an embodiment of the present disclosure;

[0035] Figure 11 A block diagram schematically illustrates an intelligent agent according to an embodiment of the present disclosure; and

[0036] Figure 12 A block diagram of an electronic device suitable for implementing an agent-based text generation method and an agent training method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0037] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0038] By combining retrieval and generation, RAG technology can dynamically acquire relevant external knowledge and use it as the basis for generating answers, thereby improving the performance of large models in complex scenarios. This combination not only expands the model's knowledge coverage but also greatly enhances the accuracy and logic of the answers, making large models more reliable and efficient in answering complex questions.

[0039] However, because knowledge base content must be segmented into multiple text blocks, search results are often a collection of text blocks related to the question. These blocks may contain only a portion of the key information and contain a large amount of redundant content. When fed into a large model, this redundant information not only wastes computing resources but also potentially interferes with the accuracy of the final answer. Answer accuracy includes, but is not limited to, how well the answer matches the user's question intent and the user's satisfaction with the intended response indicated by the answer. Furthermore, even if a large model's internal parameters store a wealth of knowledge, it may still struggle to generate a reasonable answer when presented with inappropriate prompts.

[0040] In view of this, the embodiment of the present disclosure utilizes an intelligent agent to extract reference text that is relevant to the question and has concise content from the retrieval results and initial answers, thereby reducing the interference of redundant content in the retrieval results and initial answers on answer generation, and reducing the computing resources occupied by redundant information in the calculation process of generating answers, thereby further improving the accuracy and efficiency of the intelligent agent in generating answers.

[0041] Figure 1 An exemplary system architecture to which an agent-based text generation method, an agent training method, and an apparatus according to an embodiment of the present disclosure can be applied is schematically illustrated.

[0042] It should be noted that Figure 1 The examples shown are merely examples of system architectures to which the embodiments of the present disclosure may be applied, to help those skilled in the art understand the technical content of the present disclosure, but do not imply that the embodiments of the present disclosure may not be applied to other devices, systems, environments, or scenarios. For example, in another embodiment, an exemplary system architecture to which the agent-based text generation method, agent training method, and apparatus may be applied may include a terminal device, but the terminal device may implement the agent-based text generation method, agent training method, and apparatus provided in the embodiments of the present disclosure without interacting with a server.

[0043] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a terminal device 101 , an agent 102 , a knowledge base 103 , a network 104 and a server 105 .

[0044] Terminal device 101 can receive a target question input by a user and call agent 102 to determine a question-answering task, so that agent 102 can call a large question-answering model to generate an initial answer to the target question input by the user. The large question-answering model can be any generative model with natural language understanding capabilities capable of performing question-answering tasks, such as a large language model.

[0045] Next, the terminal device 101 may call the knowledge base 103 to search for the target text input by the user and generate a search result.

[0046] The terminal device 101 can then use the search results and the initial answer as initial text, call the intelligent agent 102 to perform text extraction, and obtain a concise reference text related to the target question. The reference text is then input into the intelligent agent 102 as a prompt along with the target question to generate the target answer 110.

[0047] The terminal device 101 may be any electronic device having a display screen and supporting web browsing, including but not limited to a smart phone, a tablet computer, a laptop computer, a desktop computer, and the like.

[0048] It should be noted that the agent-based text generation method and agent training method provided in the embodiments of the present disclosure can generally be executed by the terminal device 101. Accordingly, the agent-based text generation method and agent training device provided in the embodiments of the present disclosure can also be set in the terminal device 101.

[0049] Alternatively, the agent-based text generation method and agent training method provided in the embodiments of the present disclosure may also generally be executed by the server 105. Accordingly, the agent-based text generation method and agent training device provided in the embodiments of the present disclosure may generally be set in the server 105. The agent-based text generation method and agent training method provided in the embodiments of the present disclosure may also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal device 101 and / or the server 105. Accordingly, the agent-based text generation method and agent training device provided in the embodiments of the present disclosure may also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal device 101 and / or the server 105.

[0050] For example, the terminal device 101 receives a target question input by a user in any manner, such as voice input or text input. The target question can be directly sent to the server 105 via the network 104. The server 105 executes the method of the embodiment of the present disclosure by calling the knowledge base 103 and the agent 102 to generate a target answer, sends the target answer to the terminal device 101, and displays the target answer to the user via the terminal device 101.

[0051] For example, after receiving a target question input by a user in any manner, terminal device 101 first invokes agent 102 to generate an initial answer. If the user determines that the initial answer does not meet the question's intent, it then invokes knowledge base 103 to generate search results. The target question, search results, and initial answer are then transmitted to server 105 via network 104. Server 105 invokes agent 102 to execute the method of the disclosed embodiment, generating a target answer, transmitting the target answer to terminal device 101, and displaying the target answer to the user via terminal device 101.

[0052] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.

[0053] In the technical solution disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure and application of user personal information involved comply with the provisions of relevant laws and regulations, take necessary confidentiality measures, and do not violate public order and good morals.

[0054] In the technical solution disclosed herein, the user's authorization or consent is obtained before obtaining or collecting the user's personal information.

[0055] Figure 2 The flowchart of the agent-based text generation method and the agent training method according to the embodiment of the present disclosure is schematically shown.

[0056] like Figure 2 As shown, the method includes operations S210 to S240.

[0057] In operation S210 , an initial text is acquired according to the input target question.

[0058] In operation S220, a reference text is extracted from the initial text using an agent.

[0059] In operation S230, an agent is utilized to generate a target answer based on the target question and the reference text.

[0060] In operation S240, a target answer is output.

[0061] According to an embodiment of the present disclosure, the initial text may include a retrieval result for the target question based on the knowledge base and an initial answer generated for the target question based on the intelligent agent.

[0062] According to an embodiment of the present disclosure, the intelligent agent can determine the target task based on the received input information, and determine at least two large models based on the target task, and obtain output information by calling the large models to execute the target task.

[0063] First, when the agent determines the target task is a question-answering task based on the input information, it can determine a large question-answering model based on the question-answering task. This large question-answering model can be a large model pre-trained for question-answering tasks, or any large model with natural language understanding capabilities and capable of performing question-answering tasks. By calling the large model, the agent outputs an initial answer based on the target question in the input information.

[0064] Then, when the agent determines the target task is a retrieval task based on the input information, it can determine a retrieval model based on the retrieval task. The retrieval model can be a large model pre-trained for the retrieval task, or any model with retrieval capabilities. By calling this retrieval model, it can retrieve text blocks that are relevant to the target question from the knowledge base and output the retrieval results.

[0065] Since the initial answer and retrieval results may contain content that is irrelevant to the target question and may also include repeated content, the initial answer, retrieval results, and target question can be input into the intelligent agent as input information. At this time, the intelligent agent determines that the target task is a text extraction task, and can determine a strategy model based on the text extraction task. The strategy model can be a model trained based on any deep learning algorithm using the text extraction task. For example, it can be a reinforcement learning algorithm, so that the strategy model can extract reference text related to the target question and indicating the initial text summary from the initial answer and retrieval results.

[0066] For example: The target question can be "Who is the entrepreneur who graduated from a certain university and founded a company with a certain business as its main business?" The initial text can include: "A is a doctor who graduated from a certain university in xx with a major. A first founded a certain company in a certain city. The main business of the company is a certain business, and its call rate has been at the top of the list for many years. The business is booming in the xx field. The annual meeting of entrepreneurs was held in a certain university" and so on.

[0067] In the initial text, "A certain business is booming in the xx field. The annual entrepreneur meeting was held at a certain university" is obviously irrelevant to the target question. These redundant contents will not only take up too many computing resources, but also introduce interference factors in the answer generation process, affecting the accuracy of the answer.

[0068] In some embodiments, a strategic macro model can be used to extract content related to the target question from the initial text, and to delete redundant content that is irrelevant to the target question or is repeated as much as possible.

[0069] For example, the abridged text output by the strategy model might include "A graduated with a PhD in a certain major from a certain university in xx. A first founded a certain company in a certain city. The company's main business is a certain business, and its call rate has ranked first for many consecutive years."

[0070] In some embodiments, the strategic macro model can be used to further extract the core semantics of the abridged text, so that the content of the reference text is as concise as possible.

[0071] For example: After the strategy model further extracts the core semantics based on the deleted text, the output reference text may include: "A graduated from a certain university. A founded a certain company. The main business of the certain company is a certain business."

[0072] At this time, the reference text output by the policy model can be used as evidence to support the target question and used by the intelligent agent to call the question-answering model to perform the question-answering task.

[0073] For example, the target question "Who is the entrepreneur who graduated from a certain university and founded a company with a certain business as its main business?" and the reference text "A graduated from a certain university. A founded a certain company. The main business of the company is a certain business." can be used as prompts to input the question-answering model, and the target answer "A" can be output.

[0074] The disclosed embodiment utilizes an intelligent agent to extract reference text that is relevant to the question and has concise content from the retrieval results and initial answers, thereby reducing the interference of redundant content in the retrieval results and initial answers on answer generation, and reducing the occupation of computing resources by redundant information in the calculation process of generating answers, thereby further improving the accuracy and efficiency of the intelligent agent in generating answers.

[0075] Reference below Figures 3 to 6 , combined with specific embodiments Figure 2 The method shown is further explained.

[0076] Figure 3 A schematic diagram of an agent-based text generation method according to an embodiment of the present disclosure is schematically shown.

[0077] like Figure 3 As shown, first, the knowledge base is searched based on question 301, obtaining search results 302a. Simultaneously, the large model is queried based on question 301, generating an initial answer 302b. Then, question 301, search results 302a, and initial answer 302b are input into the agent 3100, which performs text extraction 310 and text generation 320, respectively, to generate a target answer 303.

[0078] Since there is a lot of redundant information in the retrieval results, in some embodiments, the text blocks in the retrieval results 302a can be sorted from high to low based on the relevance between the text blocks and the target question, and only the top 10 or 20 retrieval results are input into the intelligent agent 3100 to reduce the occupation of the intelligent agent's computing resources by redundant information.

[0079] In some embodiments, the top 10 or 20 search results may be deduplicated before being input into the intelligent agent 3100 to reduce the occupancy of the intelligent agent's computing resources by redundant information.

[0080] According to an embodiment of the present disclosure, extracting reference text from initial text using an agent may include the following operations: extracting intermediate text from the initial text using an agent; and extracting core semantics of the intermediate text using an agent to generate a reference text.

[0081] According to an embodiment of the present disclosure, the intermediate text is a text related to the target question, and the relevance to the target question includes the relevance to the questioning intention and the support degree to the answering intention.

[0082] For example, the target question, "Who is the entrepreneur who graduated from a certain university and founded a certain business?" asks, "Who is the entrepreneur?" Therefore, the initial text, "A certain business is thriving in the xx field," is irrelevant to the question and can be deleted.

[0083] Similarly, consider the initial text "A first established a certain company in a certain city." Since the question intent is "Who is the entrepreneur?", the answer intent only needs to include the person's name. The content in the initial text that supports the answer intent only includes the task "A" and the action "establishing a certain company." The rest of the content is redundant.

[0084] Search results from a knowledge base often include content within a specific context. During the search process, the search model will recall any content that it identifies as relevant to the target question. However, certain contextual expressions can be complex or lengthy, which can interfere with answer generation.

[0085] For example, consider the intermediate text: "A graduated from a certain university with a PhD in a certain major in xx." Since the target question only mentions "graduated from a certain university" and doesn't specify information like degree, major, or time of birth, we can extract the core semantics of the intermediate text based on the question intent, resulting in the reference text "A graduated from a certain university."

[0086] By extracting the intermediate text related to the target question and performing core semantic extraction on the intermediate text, the content of the reference text is further simplified, the data processing volume of the large model is reduced, and the efficiency of answer generation is further improved.

[0087] According to an embodiment of the present disclosure, extracting an intermediate text from an initial text using an intelligent agent may include the following operations: extracting a first text from the initial text based on the relevance between the initial text and the target question using an intelligent agent; deleting duplicate content in the first text to obtain an intermediate text.

[0088] According to embodiments of the present disclosure, the relevance between the initial text and the target question can be obtained by detecting the initial text and the target question using any relevance detection model. The relevance between the first text and the target question is greater than a predetermined threshold. The predetermined threshold can be determined based on the needs of the actual application scenario and is not specifically limited in the embodiments of the present disclosure.

[0089] Figure 4A The figure schematically shows a schematic diagram of text extraction based on an agent according to an embodiment of the present disclosure.

[0090] like Figure 4AAs shown, in this embodiment 310A, first, an intelligent agent is used to remove noise text blocks from the initial text 302 based on the relevance between the initial text and the target question and question 301, thereby obtaining a first text 411. The first text 411 only includes text blocks T1 3021, T2 3022, and T3 3023 from the initial text 302.

[0091] In some embodiments, a prompt can be constructed based on the relevance, question 301, and initial text 302 and input to the agent. The agent determines the target task as a text extraction task based on the input prompt, then calls the strategic model to remove noise text blocks from the initial text 302 and outputs the first text 411.

[0092] Then, the repeated text block T33023 is deleted from the first text 411 and the intermediate text 412 is output.

[0093] In some embodiments, two sets may be initialized first: set A is empty, and set B includes all text blocks in the first text 411. Then, when the number of text blocks in set A is less than the number of text blocks in set B, the semantic similarity between the text blocks in set B is calculated sequentially. Then, text blocks with semantic similarity less than a predetermined threshold are added to set A, and the text blocks added to set A are deleted from set B, thereby obtaining intermediate text 412.

[0094] Next, core semantics are extracted from text blocks T1 3021 and T2 3022 to generate reference text 413. Reference text 413 may include extracted evidence text that can be used to support the answer, for example, evidence 1 and evidence 2.

[0095] In related examples, text filtering is usually achieved by sorting search results based on specific document reordering rules. The filtering accuracy of this method depends on the setting of the document reordering rules, and the document reordering rules in different application scenarios are poorly reproducible, resulting in low accuracy of the filtering results.

[0096] However, the embodiment of the present disclosure utilizes an intelligent agent to deduplicate and denoise the initial text based on the correlation between the initial text and the target question. The intelligent agent can identify specific extraction tasks based on the input information and call the corresponding large model for text extraction. It can be applied to any application scenario, eliminating the dependence of the text extraction process on document reordering rules and improving the accuracy of the screening results.

[0097] In some embodiments, an intelligent agent may be used to detect the relevance between the initial text and the target question to generate a relevance.

[0098] Figure 4BA schematic diagram of text extraction based on an agent according to another embodiment of the present disclosure is schematically shown.

[0099] like Figure 4B As shown, the difference between embodiment 310B and embodiment 310A is that the intelligent agent can be used to detect the relevance between the question and the initial text.

[0100] In the embodiment of the present disclosure, the relevance may represent the relevance of the initial text to the question intention and the support of the initial text to the answer intention.

[0101] According to an embodiment of the present disclosure, using an intelligent agent to detect the relevance between the initial text and the target question and generate the relevance can include the following operations: constructing a first prompt text based on the initial text and the target question; inputting the first prompt text into the intelligent agent to obtain an output detection result.

[0102] According to an embodiment of the present disclosure, the first prompt text includes an example for characterizing the relevance between the reference answer and the reference question.

[0103] For example, the reference question in the first prompt text might be "Are kittens curious?" The corresponding reference answers could include a positive example related to the reference question: "Kittens belong to the cat family, and cats are full of curiosity about the unknown world." It could also include a negative example unrelated to the reference question: "Kittens belong to the cat family, and cats have different living habits from other animals."

[0104] In addition, the first prompt text may also include scores of positive reference responses and scores of negative reference responses, so that the intelligent agent can score each text block in the initial text based on the reference examples in the first prompt text, and output the relevance based on the scoring results.

[0105] In some embodiments, the score may be a weighted result based on a relevance score of the reference answer to the question intent of the reference question and a support score of the reference answer to the answer intent.

[0106] In some embodiments, the agent can call the detection model based on the relevance detection task and output the relevance 401 between each text block and the question 301. Then, the agent calls the strategy model based on the text extraction task and outputs the first text 411.

[0107] In some embodiments, the agent can also perform more complex, comprehensive tasks, such as "selecting text highly relevant to the question from the initial text." Through analysis, the agent can split this comprehensive task into two sequential subtasks: "detecting the relevance between the initial text and the question" and "extracting text based on relevance." Then, based on the different subtasks, the agent invokes the large model corresponding to subtask Ta1 to first perform relevance detection. Based on the detection results, the agent invokes the large model corresponding to subtask Ta2 to perform text extraction, ultimately outputting the first text 411.

[0108] Since the relevance detection takes into account both the relevance of the initial text to the question intention and the support of the initial text to the answer intention, when using the intelligent agent to detect the relevance of the initial text, it focuses more on judging whether the initial text has evidence support for generating the answer, so that the text that can support the answer can be targeted and provided with reasonable prompts for generating the large model, further reducing the interference of redundant information on answer generation and improving the accuracy and efficiency of the intelligent agent in generating answers.

[0109] In some embodiments, an agent may also be used to delete repeated content in the first text 411 to obtain an intermediate text.

[0110] For example: constructing a second prompt text based on the first text; and inputting the second prompt text into the intelligent agent to obtain an output intermediate text.

[0111] According to an embodiment of the present disclosure, the second prompt text includes an example for representing deletion of repeated content in the reference text.

[0112] For example: The example can be "Make the repeated content in the following text appear only once in the text: "apple, pear, peach, peach, orange, apple", and the text after deletion is "apple, pear, peach, orange".

[0113] Since the large model has strong natural language understanding capabilities, compared with the method of filtering text based on semantic similarity, using intelligent agents to delete duplicate content in text saves computing resources occupied by calculating the semantic similarity of each text block, further improving the efficiency of text extraction.

[0114] Figure 4C A schematic diagram of text extraction based on an agent according to another embodiment of the present disclosure is schematically shown.

[0115] like Figure 4C As shown, the difference between embodiment 310C and embodiment 310B is that a deletion operation is added to the intermediate text 412 to generate a second text 414.

[0116] Retrieval results from the initial text are usually in the form of text blocks. Due to the segmentation and storage of text blocks, there may still be redundant content in the text blocks. For the redundant content in the text blocks filtered out through similarity detection and deduplication, an intelligent agent can be used to extract the core semantics of the intermediate text to generate reference text.

[0117] For example: using an intelligent agent to delete redundant content of an intermediate text to obtain a second text; and using an intelligent agent to extract the core semantics of the second text to generate a reference text.

[0118] like Figure 4C As shown, the text in the second text 414 exists in the form of paragraph content, rather than text blocks. Therefore, the deletion operation on the middle text 412 can be the deletion of the content of each text block in the middle text 412.

[0119] For example, for the target question "What is the latest research progress of a certain project?", the content of text block T13021 is "A certain project conducted xx research in xx year and achieved xx results. Three years later, based on the research results, extended research into xx branch field was carried out. Currently, no corresponding research data has been obtained."

[0120] In this text block, since the target question is intended to ask about the latest research progress, the research results from three years ago obviously cannot serve as evidence to answer this question. Therefore, the intelligent agent can be used to delete the content "A certain project conducted xx research in xx year and achieved certain results" to generate a second text.

[0121] According to an embodiment of the present disclosure, using an intelligent agent to delete redundant content of an intermediate text to obtain a second text may include the following operations: constructing a third prompt text based on the intermediate text and the target question; and inputting the third prompt text into the intelligent agent to obtain an output second text.

[0122] According to an embodiment of the present disclosure, the third prompt text includes an example for characterizing deletion of content irrelevant to the reference question from the reference answer.

[0123] For example: The third prompt text may include the following content: For the reference question "Where did mankind originate?", delete "It has been xxx years so far" from the text "Humanity originated in a certain place in xxx year, and it has been xxx years so far". Please refer to the above example and delete content that is not related to the question from the input text.

[0124] According to the embodiments of the present disclosure, based on the natural language understanding ability of the large model called by the intelligent agent, by understanding the question intention of the target question, the redundant content in the text block is further streamlined, and the interference of the redundant content on the extraction of semantics is reduced, thereby improving the relevance of the reference text to the question intention of the target question and the support for the answer intention, and further improving the accuracy of answer generation.

[0125] The same semantics can be expressed in many different ways, some lengthy and others concise. Because the text in a knowledge base is often derived from a variety of published sources, even after deduplication and denoising, some ambiguities in the meaning may still exist. This can interfere with the generation of large models.

[0126] As shown in FIG4 , an intelligent agent may be used to extract core semantics from paragraphs P1 and P2 in the second text 414 , respectively, to generate evidence 1 and evidence 2 in the reference text 413 .

[0127] According to an embodiment of the present disclosure, using an intelligent agent to extract the core semantics of the second text and generate a reference text may include the following operations: constructing a fourth prompt text based on the second text and the target question; inputting the fourth prompt text into the intelligent agent to obtain an output reference text.

[0128] According to an embodiment of the present disclosure, the fourth prompt text includes examples for characterizing the extraction of core semantics related to the reference question from the reference answer.

[0129] For example, in this example, the following content related to the question "What did A study?" can be extracted from "A is a student majoring in xx at xx University in xx year": "A is a student majoring in xx."

[0130] According to the embodiments of the present disclosure, by extracting the core semantics in the text, the accuracy of the expression intention in the reference text is improved. Therefore, when the reference text is used as the answer support for generating the large model, it is easier to generate the large model to understand the question intention of the question, further improving the support of the reference text for the reply intention and improving the accuracy of the output answer of the generated large model.

[0131] When the agent performs relevance testing on the initial text, the initial answer also receives a corresponding test result. If the initial answer is less relevant to the target question, to further reduce the number of interactions between the user and the large model, the less relevant initial answer can be added to the reference text as an error example. This reduces the probability of the agent repeatedly generating incorrect answers when calling the large model to generate answers.

[0132] In view of this, the method of the embodiment of the present disclosure may also include the following operations: determining a reference answer from the initial answers; wherein the correlation between the reference answer and the target question is less than a predetermined threshold; and adding the reference answer as an error example to the reference text.

[0133] Figure 5 A schematic diagram of text generation based on an agent according to an embodiment of the present disclosure is schematically shown.

[0134] like Figure 5 As shown, in this embodiment 320A, a reference answer 511 is added to the reference text 413 generated by any of the embodiments described above. The reference answer 511 is an initial answer whose relevance to the target question is less than a predetermined threshold.

[0135] The reference answer 511 is added to the reference text 411 as an error example and input into the agent together with the question 301 to call the generated large model to output the target answer 303.

[0136] When the intelligent agent calls the large model to generate answers, it can reduce the probability of repeatedly generating incorrect answers based on incorrect examples, reducing the number of interactions between the user and the large model, further improving interaction efficiency, and enhancing user experience.

[0137] During the retrieval process, the accuracy of retrieval results for complex questions is usually poor, which increases the difficulty of text extraction and the amount of data processing during the text extraction process.

[0138] In view of this, the method provided by the embodiment of the present disclosure may also include the following operations: based on the question intention of the target question, split the target question into multiple sub-questions; each sub-question has a single question intention; based on each sub-question, search the knowledge base to obtain the retrieval results for each sub-question; and use the intelligent agent to generate the initial answer for each sub-question based on each sub-question.

[0139] For example, the target question could be "What are the differences in living habits between primates and cats?" It can be split into the following sub-questions based on the question intent: "What are the living habits of primates?" "What are the living habits of cats?" "What are the differences between primates and cats?" etc.

[0140] Figure 6 A schematic diagram of an agent-based text generation method in a complex problem scenario according to an embodiment of the present disclosure is schematically shown.

[0141] like Figure 6 As shown, the difference between embodiment 600 and embodiment 300 is that the operation of problem splitting is added.

[0142] First, question 301 can be split into sub-questions Q1610, ..., sub-questions Q m Then, for each sub-question, the knowledge base and query model are searched separately. For example, for sub-question Q1610, sub-search result F1611 and sub-answer 612A1 can be obtained. m 620 can obtain the sub-search result F2621 and the sub-answer 622A2.

[0143] Next, the sub-search result F1611 and the sub-search result F2621 are aggregated into the search result 302a, and the sub-answer 612A1 and the sub-answer 622A2 are aggregated into the search result 302b. The subsequent operations are the same as those in the embodiment 300 and will not be described in detail here.

[0144] According to the embodiments of the present disclosure, by splitting the question, the question's intent and the knowledge required to answer it are further clarified. This allows for the acquisition of preliminary texts highly relevant to the target question during the retrieval phase and preliminary inquiry, reducing the amount of data processing required during the text extraction process and further improving the efficiency of text extraction.

[0145] Figure 7 The flowchart of the training method of an intelligent agent according to an embodiment of the present disclosure is schematically shown.

[0146] like Figure 7 As shown, the training method 700 may include: operations S710 to S750.

[0147] In operation S710, a sample text is acquired according to an input sample question.

[0148] In operation S720, a sample reference text is extracted from the sample text using an initial agent.

[0149] In operation S730, an agent is utilized to generate a sample answer based on the sample question and the sample reference text.

[0150] In operation S740, a sample answer is output.

[0151] In operation S750, based on the reward function and according to the sample answers and the real answers to the sample questions, the model parameters of the agent are adjusted to obtain a trained agent.

[0152] According to an embodiment of the present disclosure, the sample text includes: a search result for a sample question based on a knowledge base and an initial sample answer generated by an agent for the sample question. The sample reference text is related to the sample question and indicates a summary of the sample text.

[0153] According to the embodiments of the present disclosure, the definition scope of the initial intelligent agent, sample text, sample reference text, and sample answer is the same as that of the intelligent agent, initial text, reference text, and target answer described above, and will not be repeated here.

[0154] According to an embodiment of the present disclosure, the real answer to the sample question may be a pre-collected answer that is confirmed by the user to be consistent with the user's intention.

[0155] According to an embodiment of the present disclosure, the initial agent may include an extraction module and a generation module. The extraction module is used to call the strategy model to perform the text extraction task.

[0156] The strategic large model can be a large language model that has been pre-trained for text extraction tasks or text refinement tasks. The pre-training data can include sample text blocks, sample questions, and refined sample text.

[0157] For example, a sample text block and a sample question can be fed into a large language model, which then outputs text. The refined sample text is then used as a label, and a loss function, such as cross-entropy loss, is used to calculate the loss between the refined sample text and the output text.

[0158] In some embodiments, semantic features of the output text and semantic features of the sample text may be extracted separately, and the loss value may be calculated based on feature similarity.

[0159] Finally, the parameters of the large language model are fine-tuned based on the loss value to obtain the pre-trained policy large model.

[0160] Pre-training the policy model for text extraction or text refinement tasks can improve the accuracy of the policy model during text extraction or text refinement, and further improve the efficiency of agent training.

[0161] In the disclosed embodiments, a reinforcement learning algorithm and a reward function can be used to calculate a reward value based on sample answers and the true answer to a sample question. The model parameters of the initial agent can then be adjusted based on the reward value to obtain a trained agent. This trained agent is used in the agent-based text generation method described above.

[0162] The intelligent agent is trained based on the reinforcement learning algorithm, so that the intelligent agent can extract and extract texts with high support for the answer to the target question in a targeted manner. The intelligent agent can adjust the model's text extraction and extraction strategy in time according to the reward value, further improving the training efficiency of the intelligent agent.

[0163] Figure 8A A schematic diagram of an intelligent agent training method according to an embodiment of the present disclosure is schematically shown.

[0164] like Figure 8A As shown, in this embodiment 800A, first, the knowledge base is searched based on sample question 801 to obtain sample retrieval result 802a. Simultaneously, the large model is queried based on sample question 801 to generate an initial sample answer 802b. Then, the sample question 301, sample retrieval result 302a, and initial sample answer 802b are input into the extraction module 810 and generation module 820 of the intelligent agent 3100, which perform text extraction and text generation, respectively, to generate a sample answer 803. Finally, Q (reward value) 805 is calculated based on the sample answer 803 and the true answer 804, and the model parameters of the intelligent agent 3100 are adjusted based on reward value 805. When Q is maximized, the intelligent agent training is determined to be complete. The training termination condition can be that Q is maximized within a limited number of training times, or that training terminates when the Q value converges.

[0165] According to an embodiment of the present disclosure, based on a reward function, the model parameters of the intelligent agent are adjusted according to the sample answers and the real answers to the sample questions to obtain a trained intelligent agent, which may include the following operations: extracting the first semantic feature of the sample answer and the second semantic feature of the real answer respectively; calculating the reward value according to the first semantic feature and the second semantic feature; and adjusting the model parameters of the intelligent agent based on the reward value to obtain a trained intelligent agent.

[0166] For example, a pre-trained BERT model can be used to extract the first semantic feature of the sample answer and the second semantic feature of the true answer. A reward value is then calculated based on the first and second semantic features. The model parameters of the agent are then adjusted based on the reward value to produce a trained agent.

[0167] For example, the goal of reinforcement learning can be expressed as formula (1):

[0168] (1)

[0169] in, represents the reward function, Indicates semantic similarity; represents a hyperparameter; represents divergence; Represents the model parameters of the last round of fine-tuning in the iterative training process; Represents the model parameters of this round of fine-tuning during iterative training.

[0170] Since the same semantics has multiple ways of expression, when calculating the reward value of the sample answer and the true answer based on the reward function, the reward value can be calculated based on the semantic similarity, which further improves the agent's ability to extract and extract texts with high semantic support for the true answer.

[0171] According to an embodiment of the present disclosure, adjusting the model parameters of the agent based on the reward value to obtain a trained agent may include the following operations: fixing the model parameters of the generation module; and adjusting the model parameters of the extraction module based on the reward value to obtain a trained agent.

[0172] In some embodiments, the model parameters of the generation module can be fixed during training. Based on the reward value, only the model parameters of the extraction module are adjusted. When performing text extraction tasks, the extraction module calls the strategic large model. This allows the strategic large model to learn how to extract and extract text based on the question intent of the target question and the answer intent of the true answer, thereby providing more targeted reference text for the generation large model.

[0173] Since large models have stronger natural language capabilities, only adjusting the model parameters of the extraction module can reduce the number of model parameter adjustments and improve model training efficiency.

[0174] For scenarios with high requirements for answer accuracy, when training the intelligent agent, you can first fix the model parameters of the generation module. After adjusting the model parameters of the extraction module based on the reward value, you can fine-tune the model parameters of the generation module to further improve the answer generation accuracy of the large model.

[0175] Figure 8B A schematic diagram of an agent training method according to another embodiment of the present disclosure is schematically shown.

[0176] like Figure 8B As shown, the difference between embodiment 800B and embodiment 800A lies in the inclusion of a deletion submodule 811 and an extraction submodule 812 in the extraction module 810. The deletion submodule is used to delete redundant content in the sample text that is not related to the sample question. The extraction submodule is used to extract the core semantics of the text after the redundant content is deleted.

[0177] According to an embodiment of the present disclosure, adjusting the model parameters of the extraction module based on the reward value to obtain a trained intelligent agent may also include the following operations: fixing the model parameters of the extraction submodule; and adjusting the model parameters of the deletion submodule based on the reward value to obtain a trained intelligent agent.

[0178] In some embodiments, the model parameters of the extraction submodule can be fixed during training. Based on the reward value, only the model parameters of the deletion submodule are adjusted. This allows the extraction module to call the strategic macromodel when performing text extraction tasks. This allows the strategic macromodel to learn how to extract text based on both the question intent of the target question and the answer intent of the true answer, thereby providing more targeted reference text for generating the macromodel.

[0179] The strategy model obtained by this training method can better extract targeted reference texts. Then, based on the natural language understanding of the large model itself, it can also better complete the text extraction task. Therefore, based on the reward value, only the model parameters of the deleted sub-module can be adjusted to improve the training efficiency of the intelligent agent.

[0180] For scenarios with high requirements for answer accuracy, when training the intelligent agent, you can first fix the model parameters of the extraction sub-module. After adjusting the model parameters of the deletion sub-module based on the reward value, you can fine-tune the model parameters of the extraction sub-module and / or the model parameters of the generation module to further improve the answer generation of the large model.

[0181] Figure 9 A block diagram of an agent-based text generation device according to an embodiment of the present disclosure is schematically shown.

[0182] like Figure 9 As shown, the text generation device 900 may include: a first acquisition module 910 , a first extraction module 920 , a first generation module 930 and a first output module 940 .

[0183] The first acquisition module is used to acquire an initial text according to the input target question. The initial text includes: a retrieval result for the target question based on the knowledge base and an initial answer generated by the intelligent agent for the target question.

[0184] The first extraction module 920 is configured to extract reference text from the initial text using an agent; the reference text is related to the target question and indicates a summary of the initial text.

[0185] The first generation module 930 is used to generate a target answer based on the target question and the reference text using an intelligent agent.

[0186] The first output module is used to output the target answer.

[0187] According to an embodiment of the present disclosure, the first extraction module may include: a first extraction submodule and an extraction submodule.

[0188] The first extraction submodule is used to extract intermediate text from the initial text using an intelligent agent, wherein the intermediate text is related to the target question. The extraction submodule is used to extract the core semantics of the intermediate text using an intelligent agent to generate a reference text.

[0189] According to an embodiment of the present disclosure, the first extraction submodule may include: an extraction unit and a first deletion unit.

[0190] The extraction unit is used to extract a first text from the initial text based on the relevance between the initial text and the target question by using an intelligent agent; wherein the relevance between the first text and the target question is greater than a predetermined threshold.

[0191] The first deletion unit is used to delete repeated content in the first text to obtain an intermediate text.

[0192] According to an embodiment of the present disclosure, the first extraction submodule further includes: a relevance detection module, which is used to use an intelligent agent to perform relevance detection on the initial text and the target question to generate a relevance.

[0193] According to an embodiment of the present disclosure, a relevance detection module includes a first construction submodule and a first input submodule. The first construction submodule is configured to construct a first prompt text based on an initial text and a target question, wherein the first prompt text includes an example representing the relevance between a reference answer and a reference question. The first input submodule is configured to input the first prompt text into an intelligent agent to obtain an output detection result.

[0194] According to an embodiment of the present disclosure, the first deletion unit includes: a first construction subunit and a first input subunit. The construction subunit is configured to construct a second prompt text based on the first text, wherein the second prompt text includes an example for deleting repeated content from the reference text. The input subunit is configured to input the second prompt text into the agent to generate an output intermediate text.

[0195] According to an embodiment of the present disclosure, the device further includes a determination module and an addition module. The determination module is configured to determine a reference answer from the initial answers, wherein the relevance between the reference answer and the target question is less than a predetermined threshold. The addition module is configured to add the reference answer as an error example to the reference text.

[0196] According to an embodiment of the present disclosure, the extraction submodule may include: a second deletion unit and an extraction unit. The second deletion unit is configured to utilize an agent to delete redundant content from the intermediate text to obtain a second text. The extraction unit is configured to utilize an agent to extract core semantics from the second text to generate a reference text.

[0197] According to an embodiment of the present disclosure, the second deleting unit may include: a second constructing subunit and a second inputting subunit.

[0198] The second construction sub-unit is used to construct a third prompt text based on the intermediate text and the target question; wherein the third prompt text includes examples for representing the deletion of content irrelevant to the reference question from the reference answer.

[0199] The second input subunit is used to input the third prompt text into the intelligent agent to obtain the output second text.

[0200] According to an embodiment of the present disclosure, the extracting unit may include: a third constructing subunit and a third inputting subunit.

[0201] The third construction subunit is used to construct a fourth prompt text based on the second text and the target question; wherein the fourth prompt text includes examples for representing the core semantics related to the reference question extracted from the reference answer.

[0202] The third input subunit is used to input the fourth prompt text into the intelligent agent to obtain an output reference text.

[0203] According to an embodiment of the present disclosure, the device further includes a splitting module and a retrieval module. The splitting module is configured to split the target question into multiple sub-questions based on the question intent of the target question; each sub-question has a single question intent. The retrieval module is configured to search the knowledge base based on each sub-question to obtain retrieval results for each sub-question. The question-answering module is configured to utilize an intelligent agent to generate an initial answer to each sub-question.

[0204] Figure 10 The block diagram of the intelligent agent training device according to an embodiment of the present disclosure is schematically shown.

[0205] like Figure 10 As shown, the training device 1000 may include a second acquisition module 1010 , a second extraction module 1020 , a second generation module 1030 , a second output module 1040 and an adjustment module 1050 .

[0206] The second acquisition module 1010 is used to acquire sample text according to the input sample question, wherein the sample text includes: a retrieval result for the target question based on the knowledge base and an initial answer generated for the target question based on the initial intelligent agent.

[0207] The second extraction module 1020 is configured to extract a sample reference text from the sample text using the initial agent; wherein the sample reference text is related to the sample question and indicates a summary of the sample text.

[0208] The second generating module 1030 is used to generate sample answers based on the sample questions and sample reference texts using an intelligent agent.

[0209] The second output module 1040 is for the user to output a sample answer.

[0210] The adjustment module 1050 is used to adjust the model parameters of the intelligent agent based on the reward function and the actual answers to the sample answers and sample questions to obtain a trained intelligent agent.

[0211] According to an embodiment of the present disclosure, the adjustment module may include a second extraction submodule, a calculation submodule, and an adjustment submodule.

[0212] The second extraction submodule is used to extract the first semantic feature of the sample answer and the second semantic feature of the true answer respectively.

[0213] The calculation submodule is used to calculate the reward value according to the first semantic feature and the second semantic feature.

[0214] The adjustment submodule is used to adjust the model parameters of the agent based on the reward value to obtain a trained agent.

[0215] According to an embodiment of the present disclosure, the initial agent includes an extraction module and a generation module. The extraction module is used to extract sample reference text; the generation module is used to generate sample answers. The adjustment submodule includes a first fixing unit and a first adjustment unit.

[0216] The first fixing unit is used to fix the model parameters of the generation module. The first adjustment unit is used to adjust the model parameters of the extraction module based on the reward value to obtain a trained intelligent agent.

[0217] According to an embodiment of the present disclosure, the extraction module includes a deletion submodule and an extraction submodule. The deletion submodule is used to delete redundant content in the sample text that is irrelevant to the sample question, and the extraction submodule is used to extract the core semantics of the text after the redundant content is deleted. The adjustment submodule may include a second fixing unit and a second adjustment unit.

[0218] The second fixing unit is used to fix the model parameters of the extraction submodule; and the second adjusting unit is used to adjust the model parameters of the deletion submodule based on the reward value to obtain a trained intelligent agent.

[0219] Figure 11 Schematically shows a block diagram of an intelligent agent according to an embodiment of the present disclosure

[0220] In the embodiments of the present disclosure, inspired by the von Neumann structure in modern computer theory, such as Figure 11 As shown, the AI ​​agent 1100 may include three core modules: an input module 1110, an output module 1120, and a processing module 1130. The processing module 1130 may include a control unit 1131, a storage unit 1132, and an operation unit 1133.

[0221] Input module 1110 is responsible for receiving or perceiving information such as queries, requests, instructions, signals, or data from the outside world (e.g., users or the external environment) and converting it into a format that AI agent 1100 can understand and process. Input module 1110 is the primary link for AI agent 1100 to interact with the outside world. It enables AI agent 1100 to efficiently and accurately obtain necessary "sensory" information from the outside world and respond to this information.

[0222] In an example, the input information received by the input module 1110 may be the target question described above.

[0223] In this example, processing module 1130 is the core support for AI agent 1100's ability to handle complex tasks. Processing module 1130 can determine a target task based on the input information received by input module 1010, determine at least two large models based on the target task, and execute the large model-based text generation method described above by calling the large models to output a target answer.

[0224] In the example, the control unit 1131 in the processing module 1130 will continuously interact with the storage unit 1132, the computing unit 1133, and / or the output module 1120 during operation. However, it should be noted that in the embodiment of the present disclosure, the control unit 1131 acts as a single initiator to initiate communication with the storage unit 1132, the computing unit 1133, and / or the output module 1120, and there is no communication coupling between the storage unit 1132, the computing unit 1133, and the output module 1120.

[0225] In this example, the performance of control unit 1131 can be closely related to the large model on which AI agent 1100 is based. To fully utilize the capabilities of the large language model, the internal structure of control unit 1131 can be designed to be highly configurable and scalable to cope with various types of tasks and requirements in real-world scenarios.

[0226] The storage unit 1132 may be responsible for memorizing information such as historical conversations, event flows, etc. The text generated in each round as described above may be included in the storage unit 1132 .

[0227] In the example, after the AI ​​agent 1100 obtains the text generation request, the AI ​​agent 1100 can perform the task corresponding to the input information by calling the large model and output the corresponding text. The corresponding text can be stored in the storage unit 1132. The AI ​​agent 1100 can retrieve the relevant data resources from the storage unit 1132 and feed it back to the control unit 1131. The control unit 1131 can then use the fed-back data resources to generate the target answer. The relevant data resources can also be retrieved from the storage unit 1132 and fed back to the control unit 1131. The control unit 1131 can then use the returned data resources to generate the target answer. The target answer is then passed to the output module 1120.

[0228] The computing unit 1133 can be viewed as a predefined tool library, and the renderer and presentation controls mentioned above can be included in the computing unit 1133 .

[0229] In the example, when the AI ​​agent 1100 needs to render multiple output data, it can call the relevant renderer and display control from the operation unit 1133 and feed it back to the control unit 1132. Then, the control unit 1132 can use the feedback renderer and display control to render the first search result and pass the first search result to the output module 1120. It can be understood that although the large language model has excellent language understanding and generation capabilities, it is the same as a human being. Without the help of any tools, the tasks that can be solved are very limited. When the AI ​​agent 1100 is given the ability to call tools, it can achieve tasks such as completing mathematical operations with the help of a calculator, completing data analysis with the help of Python, and completing prediction tasks with the help of a certain tool.

[0230] In an example, the output module 1120 may output the target answer described above.

[0231] The AI ​​agent 1100 according to the embodiment of the present disclosure can simply and effectively improve the level of intelligence, and enhance flexibility and versatility.

[0232] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0233] According to an embodiment of the present disclosure, an electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method described above.

[0234] According to an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method described above.

[0235] According to an embodiment of the present disclosure, a computer program product includes a computer program, and when the computer program is executed by a processor, the computer program implements the method described above.

[0236] Figure 12 A schematic block diagram of an example electronic device 1200 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are provided as examples only and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0237] like Figure 12 As shown, device 1200 includes a computing unit 1201, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1202 or a computer program loaded from a storage unit 1208 into a random access memory (RAM) 1203. RAM 1203 may also store various programs and data required for the operation of device 1200. Computing unit 1201, ROM 1202, and RAM 1203 are connected to each other via a bus 1204. An input / output (I / O) interface 1205 is also connected to bus 1204.

[0238] Various components in device 1200 are connected to I / O interface 1205, including an input unit 1206, such as a keyboard and mouse; an output unit 1207, such as various types of displays and speakers; a storage unit 1208, such as a magnetic disk and optical disk; and a communication unit 1209, such as a network card, a modem, a wireless communication transceiver, etc. Communication unit 1209 allows device 1200 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0239] Computing unit 1201 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of computing unit 1201 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Computing unit 1201 performs the various methods and processes described above, such as the agent-based text generation method or the agent training method. For example, in some embodiments, the agent-based text generation method or the agent training method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as storage unit 1208. In some embodiments, part or all of the computer program can be loaded and / or installed onto device 1200 via ROM 1202 and / or communication unit 1209. When the computer program is loaded into RAM 1203 and executed by computing unit 1201, one or more steps of the agent-based text generation method or the agent training method described above can be performed. Alternatively, in other embodiments, the computing unit 1201 may be configured to execute an agent-based text generation method or an agent training method in any other appropriate manner (eg, by means of firmware).

[0240] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-a-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0241] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0242] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fibers, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0243] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0244] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0245] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact through a communication network. The client-server relationship arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.

[0246] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not a limitation herein.

[0247] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.

Claims

1. An agent-based text generation method, comprising: Acquire an initial text according to an input target question, wherein the initial text includes: a search result for the target question based on a knowledge base and an initial answer generated by an intelligent agent for the target question; Extracting reference text from the initial text using an intelligent agent, wherein the reference text includes: a summary that is relevant to the target question and indicates the initial text, and a reference answer whose relevance to the target question is less than a predetermined threshold; the summary is a shortened text obtained by deleting redundant content irrelevant to or repetitive to the target question from the initial text, and extracting core semantics from the shortened text; and the reference answer serves as an error example; generating a target answer based on the target question and the reference text using the intelligent agent; and Output the target answer.

2. The method according to claim 1, wherein The step of extracting a reference text from the initial text using an intelligent agent comprises: extracting an intermediate text from the initial text using the agent, wherein the intermediate text is relevant to the target question; and The intelligent agent is used to extract the core semantics of the intermediate text to generate the reference text.

3. The method according to claim 2, wherein: The extracting the intermediate text from the initial text by using the intelligent agent comprises: Extracting a first text from the initial text based on a relevance between the initial text and the target question using the agent; wherein the relevance between the first text and the target question is greater than a predetermined threshold; and The repeated contents in the first text are deleted to obtain the intermediate text.

4. The method according to claim 3, wherein: The method further comprises: The intelligent agent is used to detect the relevance between the initial text and the target question to generate the relevance.

5. The method according to claim 4, wherein The using the intelligent agent to detect the relevance between the initial text and the target question to generate the relevance includes: Constructing a first prompt text according to the initial text and the target question, wherein the first prompt text includes an example for representing the relevance between the reference answer and the reference question; and The first prompt text is input into the intelligent agent to obtain an output detection result.

6. The method according to claim 3, wherein: Deleting repeated content in the first text to obtain the intermediate text includes: Constructing a second prompt text based on the first text, wherein the second prompt text includes an example for representing deletion of repeated content in the reference text; The second prompt text is input into the agent to obtain the output intermediate text.

7. The method according to claim 6, wherein: The method further comprises: Determining a reference answer from the initial answer; wherein the relevance between the reference answer and the target question is less than a predetermined threshold; and The reference answer is added to the reference text as an error example.

8. The method according to claim 2, wherein: The extracting the core semantics of the intermediate text by using the intelligent agent to generate the reference text includes: Deleting redundant content of the intermediate text using the agent to obtain a second text; and The intelligent agent is used to extract the core semantics of the second text to generate the reference text.

9. The method according to claim 8, wherein The step of utilizing the agent to delete redundant content of the intermediate text to obtain a second text includes: Constructing a third prompt text based on the intermediate text and the target question; wherein the third prompt text includes an example for representing that content irrelevant to the reference question is deleted from the reference answer; and The third prompt text is input into the agent to obtain the second text as output.

10. The method according to claim 8, wherein The step of extracting the core semantics of the second text by using the intelligent agent to generate the reference text includes: Constructing a fourth prompt text based on the second text and the target question; wherein the fourth prompt text includes an example for representing the core semantics related to the reference question extracted from the reference answer; The fourth prompt text is input into the agent to obtain the reference text as output.

11. The method according to any one of claims 1 to 10, further comprising: Based on the questioning intention of the target question, split the target question into multiple sub-questions; Each sub-question has a single questioning intention; Search the knowledge base based on each sub-question to obtain a search result for each sub-question; Utilizing the intelligent agent, an initial answer to each of the sub-questions is generated based on each of the sub-questions.

12. A method for training an intelligent agent, comprising: Acquire a sample text according to an input sample question, wherein the sample text includes: a search result for a target question based on a knowledge base and an initial answer generated by an initial intelligent agent for the target question; A sample reference text is extracted from the sample text using an initial agent; the sample reference text includes: a summary related to the sample question and indicating the sample text, and a sample reference answer whose relevance to the sample question is less than a predetermined threshold; the sample reference text is obtained by deleting redundant content irrelevant to or repeated in the sample text, and extracting core semantics from the deleted sample text; the sample reference answer is used as a sample error example generating a sample answer based on the sample question and the sample reference text using the intelligent agent; outputting the sample answer; and Based on the reward function, the model parameters of the agent are adjusted according to the sample answers and the real answers to the sample questions to obtain a trained agent.

13. The method according to claim 12, wherein: The method of adjusting the model parameters of the agent based on the reward function according to the sample answers and the true answers to the sample questions to obtain a trained agent includes: Extracting a first semantic feature of the sample answer and a second semantic feature of the true answer respectively; Calculating a reward value based on the first semantic feature and the second semantic feature; and The model parameters of the agent are adjusted based on the reward value to obtain a trained agent.

14. The method according to claim 13, wherein: The initial intelligent agent includes: an extraction module and a generation module, wherein the extraction module is used to extract the sample reference text; the generation module is used to generate a sample answer; The adjusting the model parameters of the agent based on the reward value to obtain a trained agent includes: While fixing the model parameters of the generation module, the model parameters of the extraction module are adjusted based on the reward value to obtain the trained intelligent agent.

15. The method according to claim 14, wherein The extraction module includes: a deletion submodule and an extraction submodule; wherein the deletion submodule is used to delete redundant content in the sample text that is not related to the sample question; the extraction submodule is used to extract the core semantics of the text after the redundant content is deleted; The step of adjusting the model parameters of the extraction module based on the reward value to obtain the trained agent comprises: Fixing the model parameters of the extraction submodule; and While fixing the model parameters of the extraction submodule, the model parameters of the deletion submodule are adjusted based on the reward value to obtain the trained intelligent agent.

16. An agent-based text generation device, comprising: A first acquisition module is configured to acquire an initial text according to an input target question, wherein the initial text includes: a search result for the target question based on a knowledge base and an initial answer generated by an intelligent agent for the target question; A first extraction module is configured to utilize an agent to extract reference text from the initial text; wherein the reference text includes: a summary that is relevant to the target question and indicates the initial text, and a reference answer whose relevance to the target question is less than a predetermined threshold; the summary is obtained by deleting redundant content irrelevant to or repetitive to the target question from the initial text to obtain a shortened text, and extracting core semantics from the shortened text; the reference answer serves as an error example; A first generating module is configured to generate a target answer based on the target question and the reference text using the intelligent agent; and The first output module is used to output the target answer.

17. The device according to claim 16, wherein The first extraction module includes: A first extraction submodule is configured to extract an intermediate text from the initial text using the agent, wherein the intermediate text is related to the target question; and The extraction submodule is used to extract the core semantics of the intermediate text using the intelligent agent to generate the reference text.

18. The device according to claim 17, wherein The first extraction submodule includes: an extraction unit, configured to extract, using the agent, a first text from the initial text based on a relevance between the initial text and the target question; wherein the relevance between the first text and the target question is greater than a predetermined threshold; and The first deleting unit is configured to delete repeated content in the first text to obtain the intermediate text.

19. The device according to claim 18, wherein The first extraction submodule further includes: The relevance detection module is used to use the intelligent agent to perform relevance detection on the initial text and the target question to generate the relevance.

20. The device according to claim 19, wherein The correlation detection module includes: A first construction submodule is configured to construct a first prompt text according to the initial text and the target question, wherein the first prompt text includes an example for representing the relevance between the reference answer and the reference question; and The first input submodule is used to input the first prompt text into the intelligent agent to obtain an output detection result.

21. The apparatus according to claim 18, wherein The first deleting unit includes: A first constructing subunit is configured to construct a second prompt text based on the first text, wherein the second prompt text includes an example for representing deletion of repeated content in the reference text; The first input subunit is used to input the second prompt text into the agent to obtain the output intermediate text.

22. The device according to claim 21, wherein The device further comprises: a determination module, configured to determine a reference answer from the initial answer; wherein the relevance between the reference answer and the target question is less than a predetermined threshold; and An adding module is used to add the reference answer as an error example to the reference text.

23. The apparatus according to claim 17, wherein The extraction submodule includes: A second deleting unit is configured to use the agent to delete redundant content of the intermediate text to obtain a second text; and An extraction unit is used to use the intelligent agent to extract the core semantics of the second text and generate the reference text.

24. The device according to claim 23, wherein The second deleting unit includes: A second constructing subunit is configured to construct a third prompt text based on the intermediate text and the target question; wherein the third prompt text includes an example for representing that content irrelevant to the reference question is deleted from the reference answer; and The second input subunit is used to input the third prompt text into the agent to obtain the second text as output.

25. The apparatus according to claim 23, wherein The extraction unit comprises: A third construction subunit is configured to construct a fourth prompt text based on the second text and the target question; wherein the fourth prompt text includes an example for representing the core semantics related to the reference question extracted from the reference answer; The third input subunit is used to input the fourth prompt text into the agent to obtain the output reference text.

26. The device according to any one of claims 16 to 25, further comprising: A splitting module is used to split the target question into multiple sub-questions based on the questioning intention of the target question; each sub-question has a single questioning intention; A retrieval module, configured to search the knowledge base based on each sub-question to obtain a retrieval result for each sub-question; The question-answering module is used to utilize the intelligent agent to generate an initial answer to each of the sub-questions based on each of the sub-questions.

27. A training device for an intelligent agent, comprising: A second acquisition module is configured to acquire a sample text according to an input sample question, wherein the sample text includes: a search result for a target question based on a knowledge base and an initial answer generated by an initial agent for the target question; A second extraction module is configured to extract sample reference text from the sample text using the initial agent; wherein the sample reference text includes: a summary related to the sample question and indicating the sample text, and a sample reference answer whose relevance to the sample question is less than a predetermined threshold; the summary of the sample text is obtained by deleting redundant content irrelevant to or repetitive to the sample question in the sample text to obtain a shortened sample text, and extracting core semantics from the shortened sample text; the sample reference answer serves as an error example; A second generating module is configured to generate a sample answer based on the sample question and the sample reference text by using the intelligent agent; A second output module, in which the user outputs the sample answer; and An adjustment module is used to adjust the model parameters of the intelligent agent based on the reward function and the true answer to the sample answer and the sample question to obtain a trained intelligent agent.

28. The training device according to claim 27, wherein the adjustment module comprises: A second extraction submodule is used to extract the first semantic feature of the sample answer and the second semantic feature of the true answer respectively; a calculation submodule, configured to calculate a reward value based on the first semantic feature and the second semantic feature; as well as An adjustment submodule is used to adjust the model parameters of the agent based on the reward value to obtain a trained agent.

29. The training device according to claim 28, wherein The initial intelligent agent includes: an extraction module and a generation module, wherein the extraction module is used to extract the sample reference text; the generation module is used to generate a sample answer; The adjustment submodule includes: The first adjustment unit is used to adjust the model parameters of the extraction module based on the reward value while fixing the model parameters of the generation module to obtain the trained intelligent agent.

30. The training device according to claim 29, wherein The extraction module includes: a deletion submodule and an extraction submodule; wherein the deletion submodule is used to delete redundant content in the sample text that is not related to the sample question; the extraction submodule is used to extract the core semantics of the text after the redundant content is deleted; The adjustment submodule includes: The second adjustment unit is used to adjust the model parameters of the deletion submodule based on the reward value while fixing the model parameters of the extraction submodule to obtain the trained intelligent agent.

31. An intelligent agent comprising: An input module, used for receiving input information; a processing module, configured to determine a target task based on the input information received by the input module, determine at least two large models based on the target task, and execute the method according to any one of claims 1 to 15 by calling the large models to obtain output information; as well as An output module is used to output the output information obtained by the processing module.

32. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 15.

33. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 15.

34. A computer program product comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method according to any one of claims 1 to 15.

Citation Information

Patent Citations

  • Text processing model training method and device, equipment, medium and program product

    CN117972434A

  • Information processing method, question answering method and question answering system

    CN118410152A

  • Problem processing method, computing device and computer readable storage medium

    CN118917322A

  • Answer generation method and device, electronic equipment and storage medium

    CN119106110A