Text generation method and device based on intelligent agent, equipment and storage medium
Through the agent extracting concise reference text from the search results and initial answers, the problem of redundant content in RAG technology is solved, and the accuracy and efficiency of the answers are improved.
Patent Information
- Application Number
- CN202411898166.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-20
AI Technical Summary
When existing RAG technology deals with natural language problems, there is redundant content in the search results, resulting in waste of computing resources and reduced answer accuracy.
Through the agent, the reference text related to the question and the initial answer is extracted from the search results and concise content, which reduces the interference of redundant content on the generation of answers and reduces the use of computing resources.
It improves the accuracy and efficiency of the agent's answer generation, reduces the use of redundant information on computing resources, and enhances the relevance and accuracy of the answers.
Smart Images

Figure CN119740669A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to the technical fields of deep learning, large models, retrieval enhancement generation, etc. Specifically, it relates to a method, device, equipment and storage medium for text generation based on an intelligent agent. Background Art
[0002] RAG (Retrieval-Augmented Generation) is a method that combines information retrieval and natural language generation technologies, aiming to improve the accuracy and reliability of AI systems when dealing with natural language problems. RAG technology combines retrieval models and generation models to enable AI systems to utilize external knowledge sources when generating content, thereby improving the relevance and accuracy of generated content. This method is not only used in question-answering systems, but can also be used in multiple 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, there is provided an agent-based text generation method, comprising: obtaining an initial text according to an input target question, wherein the initial text comprises: 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 according to 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 generated for the sample question by the intelligent agent; extracting a sample reference text from the sample text by 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 by using the intelligent agent; outputting the sample answer; and adjusting the model parameters of the intelligent agent according to the sample answer and the actual 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, there is provided an agent-based text generation device, comprising: 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 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 an intelligent agent.
[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 utilize 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, there is provided a training device for an intelligent agent, 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 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.
[0013] The second extraction module is used to extract 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 initial text.
[0014] The second generation module is used to generate sample answers based on sample questions and sample reference texts using an intelligent agent.
[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 real 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 used to receive input information. The processing module is used 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 obtain output information by calling the large model to execute the text generation method based on the large model described above. The output module is used 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, including a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to better understand the present solution 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 A flowchart of an agent-based text generation method according to an embodiment of the present disclosure is schematically shown;
[0024] Figure 3 A schematic diagram of an agent-based text generation method according to an embodiment of the present disclosure is schematically shown;
[0025] Figure 4A A schematic diagram of text extraction based on an agent according to an embodiment of the present disclosure is schematically shown;
[0026] Figure 4B A schematic diagram of text extraction based on an agent according to another embodiment of the present disclosure is schematically shown;
[0027] Figure 4C A schematic diagram of text extraction based on an agent according to another embodiment of the present disclosure is schematically shown;
[0028] Figure 5 A schematic diagram of text generation based on an agent according to an embodiment of the present disclosure is schematically shown;
[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 A flowchart of a method for training an intelligent agent according to an embodiment of the present disclosure is schematically shown;
[0031] Fig. 8A A schematic diagram schematically shows an intelligent agent training method according to an embodiment of the present disclosure;
[0032] Figure 8B A schematic diagram schematically shows an agent training method according to another embodiment of the present disclosure;
[0033] Fig. 9 A block diagram of an agent-based text generation device according to an embodiment of the present disclosure is schematically shown;
[0034] Fig.10 A block diagram of an intelligent agent training device according to an embodiment of the present disclosure is schematically shown;
[0035] Fig.11 A block diagram schematically shows an intelligent agent according to an embodiment of the present disclosure; and
[0036] Fig.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 is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art 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 knowledge coverage of the model, but also greatly enhances the accuracy and logic of the answers, making the large model more reliable and efficient in answering complex questions.
[0039] However, since the knowledge base content needs to be divided into multiple text blocks, the retrieval results are often a collection of text blocks related to the question. These text blocks may only partially contain key information, and at the same time contain a lot of redundant content. After these redundant information are input into the large model, it not only wastes computing resources, but also may interfere with the accuracy of the final answer. The accuracy of the answer includes but is not limited to the matching degree between the answer and the user's question intention, and the user's satisfaction with the answer intention indicated by the answer. In addition, even if the internal parameters of the large model have stored rich knowledge, it may still be difficult for the model to generate a reasonable answer under unreasonable prompts.
[0040] In view of this, the embodiments of the present disclosure utilize an intelligent agent to extract reference texts that are relevant to the question and have concise content from the retrieval results and the initial answers, thereby reducing the interference of redundant content in the retrieval results and the 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.
[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 shown.
[0042] It should be noted that Figure 1 The examples shown are only examples of system architectures to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but do not mean that the embodiments of the present disclosure cannot be used in 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 device can be applied may include a terminal device, but the terminal device may implement the agent-based text generation method, agent training method and device provided in the embodiments of the present disclosure without interacting with the 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] The terminal device 101 can receive the target question input by the user and call the agent 102 to determine the question-answering task, so that the agent 102 calls the question-answering big model to generate an initial answer for the target question input by the user. The question-answering big model can be any generative model that has natural language understanding capabilities and can perform question-answering tasks, such as a big 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] Then, the terminal device 101 can also use the search results and the initial answer as the initial text, call the intelligent agent 102 to extract the text, and obtain a reference text that is related to the target question and has concise content. The reference text is used as a prompt and input into the intelligent agent 102 together 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 be generally 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 arranged 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 arranged 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, etc. The target question can be directly sent to the server 105 through the network 104, and the server 105 executes the method of the embodiment of the present disclosure by calling the knowledge base 103 and the agent 102, generates a target answer, sends the target answer to the terminal device 101, and displays the target answer to the user through the terminal device 101.
[0051] For example, after receiving the target question input by the user in any way, the terminal device 101 first calls the agent 102 to generate an initial answer. When the user determines that the initial answer does not meet the question intention, the knowledge base 103 is called to generate a search result. Then, the target question, the search result and the initial answer are sent to the server 105 through the network 104. The server 105 generates a target answer by calling the agent 102 to execute the method of the embodiment of the present disclosure, and sends the target answer to the terminal device 101, and displays the target answer to the user through the terminal device 101.
[0052] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0053] In the technical solution of the present disclosure, 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 of the present disclosure, 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 embodiments 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 used 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 a target question based on a knowledge base and an initial answer generated by an agent for the target question.
[0062] According to an embodiment of the present disclosure, the intelligent agent can determine a target task based on 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 that the target task is a question-answering task based on the input information, a question-answering big model can be determined based on the question-answering task. The question-answering big model can be a big model pre-trained based on the question-answering task, or any big model with natural language understanding capabilities that can be used to perform the question-answering task. The initial answer is output based on the target question in the input information by calling the big model.
[0064] Then, when the agent determines that the target task is a retrieval task based on the input information, a retrieval model can be determined based on the retrieval task. The retrieval model can be a large model pre-trained based on the retrieval task, or any model with retrieval capabilities. By calling the retrieval model, a text block with a certain relevance to the target question can be retrieved from the knowledge base and the retrieval result can be output.
[0065] Since the initial answer and the retrieval results may contain content that is irrelevant to the target question and may also include repeated content, the initial answer, the retrieval results, and the 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 big model based on the text extraction task. The strategy big model can be a big 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 big model can extract reference text that is related to the target question and indicates the initial text summary from the initial answer and the 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 doctoral student in a certain major who graduated from a certain university in xx. 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 topped the list for many years. The business is booming in the xx field. The annual meeting of entrepreneurs is 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 in a certain university." These contents are 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, the strategic big model can be used to extract content related to the target question from the initial text, and try to delete redundant content that is irrelevant to the target question or repetitive.
[0069] For example, the abridged text output by the strategy model may include "A is a PhD graduate from a certain university in xx. A 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."
[0070] In some embodiments, the strategic big model can also be used to further extract the core semantics of the deleted text, so that the content of the reference text is as concise as possible.
[0071] For example: After the strategy big 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 point, the reference text output by the policy big model can be used as evidence to support the target question and can be used by the intelligent agent to call the question-answering big model to perform question-answering tasks.
[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 the 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 answer generation by the intelligent agent.
[0075] Reference below Figure 3~Figure 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 to obtain search result 302a. At the same time, the large model is queried based on question 301 to generate an initial answer 302b. Then, question 301, search result 302a and initial answer 302b are input into the intelligent agent 3100, and text extraction 310 and text generation 320 are performed respectively to generate a target answer 303.
[0078] Since there is a lot of redundant information in the search results, in some embodiments, the search results 302a can be sorted from high to low based on the relevance between each text block and the target question, and only the top 10 or 20 search 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 reference text.
[0081] According to an embodiment of the present disclosure, the intermediate text is text related to the target question, and the relevance to the target question includes the relevance to the question intention and the support to the answer intention.
[0082] For example, the target question "Who is the entrepreneur who graduated from a certain university and founded a certain business?" is intended to ask "Who is the entrepreneur?" Therefore, it can be determined that "a certain business is booming in the field of xx" in the initial text is irrelevant to the question intention and can be deleted.
[0083] Similarly, for the question "A founded a certain company for the first time in a certain city" in the initial text, since the question intent is "Who is the entrepreneur?", the answer intent only needs to include the name of the person, and the content in the initial text that supports the answer intent only includes the task "A" and the action "founding a certain company." The rest of the content is redundant.
[0084] The search results from the knowledge base usually include content in a specific context. During the search process, as long as the search model recognizes that the content is relevant to the target question, it will be recalled as a search result. However, the expressions in certain specific contexts may be cumbersome or lengthy, which may also introduce interference factors into the generated answer.
[0085] For example, the intermediate text is: "A graduated from a certain university with a doctorate in a certain major in xx". Since the target question only mentions "graduated from a certain university" and does not limit information such as degree, major, and time, the core semantics of the intermediate text can be extracted based on the question intent, and the reference text obtained is "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 amount of data processing for large models is reduced, and the efficiency of answer generation is further improved.
[0087] According to an embodiment of the present disclosure, extracting intermediate text from 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 repeated content in the first text to obtain an intermediate text.
[0088] According to an embodiment 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 through 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 the embodiment of the present disclosure does not specifically limit this.
[0089] Figure 4A A schematic diagram of text extraction based on an agent according to an embodiment of the present disclosure is schematically shown.
[0090] like Figure 4AAs shown, in this embodiment 310A, first, based on the correlation between the initial text and the target question and the question 301, the intelligent agent is used to remove the noise text blocks in the initial text 302 to obtain the first text 411. The first text 411 only includes the text blocks T1 3021, T2 3022 and T3 3023 in the initial text 302.
[0091] In some embodiments, a prompt can be constructed based on relevance, question 301 and initial text 302 and input into the agent. The agent determines the target task as a text extraction task based on the input prompt, and then calls the strategy model to remove the noise text block in 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 in sequence, and then, the 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, to obtain the intermediate text 412.
[0094] Next, the core semantics of the text block T1 3021 and the text block T2 3022 are extracted to generate reference text 413. The reference text 413 may include the 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 for different application scenarios are poorly reproducible, resulting in low accuracy of the filtering results.
[0096] However, the disclosed embodiment 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 to perform text extraction. It can be applied to any application scenario, eliminating the dependence of the text extraction process on document re-arrangement rules and improving the accuracy of the screening results.
[0097] In some embodiments, an intelligent agent may also 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 disclosed embodiment, 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 an initial text and a target question and generate a relevance may 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 may be "Are kittens curious?" The corresponding reference answer may 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 may 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 scores as relevance.
[0105] In some embodiments, the score may be a weighted result of 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, for example, "screening texts with high relevance to the question from the initial text", and the agent can analyze and split the comprehensive task into two continuous subtasks, namely "the relevance detection task between the initial text and the question" and "the text extraction task based on the relevance". Then, according to different subtasks, the large model corresponding to the subtask Ta1 is called to perform the relevance detection first, and then the large model corresponding to the subtask Ta2 is called based on the detection result to perform the text extraction task, and finally the first text 411 is output.
[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 targetedly screened out to provide 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 characterizing the 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 to the method of filtering text based on semantic similarity, using an intelligent agent to delete duplicate content in the text saves the 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 yet another embodiment of the present disclosure is schematically shown.
[0115] like Figure 4C As shown, the difference between the embodiment 310C and the embodiment 310B is that a deletion operation is added to the intermediate text 412 to generate the second text 414.
[0116] The retrieval results in 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 by similarity detection, deduplication and other operations, the intelligent agent can be used to extract the core semantics of the intermediate text and generate a 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 and achieved certain results. Three years later, based on the research of the certain results, an extended research was conducted in the xx branch field. Currently, no corresponding research data has been obtained."
[0120] In this text block, since the target question is intended to focus on 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 the 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 a 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 the deletion of contents 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 capability of the large model called by the intelligent agent, by understanding the question intent of the target question, the redundant content in the text block is further streamlined, reducing the interference of the redundant content on the extracted semantics, thereby improving the relevance of the reference text to the question intent of the target question and the support for the answer intent, and further improving the accuracy of answer generation.
[0125] There are many different ways to express the same semantics, some of which are lengthy and some are concise. Since the text content in the knowledge base generally comes from a variety of published texts, even after deduplication and denoising, these texts still have ambiguous expressions. These contents will still interfere with the generation of large models.
[0126] As shown in FIG. 4 , an intelligent agent may be used to extract core semantics of 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 a 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 can be extracted from "A is a student majoring in xx from xx university who graduated in xx year" to answer the question "What did A study?": "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, so that when the reference text is used as the answer support for generating the big model, it is easier to generate the big model to understand the question intention of the question, further improve the support of the reference text for the reply intention, and improve the accuracy of the output answer of the generated big model.
[0131] When the agent performs relevance detection on the initial text, the initial answer will also obtain the corresponding detection result. When the initial answer has a low relevance to the target question, in order to further reduce the number of interactions between the user and the large model, the initial answer with low relevance can be added to the reference text as an error example, so that when the agent calls the large model to generate answers, the probability of repeatedly generating wrong answers can be reduced.
[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 wrong answers based on wrong examples, reducing the number of interactions between the user and the large model, further improving interaction efficiency and enhancing user experience.
[0137] In 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 in 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 a search result for each sub-question; and use an intelligent agent to generate an initial answer for each sub-question based on each sub-question.
[0139] For example: The target question may be "What are the differences in living habits between primates and cats?" It can be divided into the following sub-questions according to the intention of the question: "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 the embodiment 600 and the 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 the query model are searched separately. For example, for sub-question Q1610, a sub-search result F1611 and a sub-answer 612A1 can be obtained. m 620 can obtain sub-search result F2621 and 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 questions, the question intention and the knowledge required to answer the questions are further clarified. Thus, preliminary texts with high relevance to the target questions can be obtained in the retrieval stage and preliminary inquiry, which reduces the data processing amount of the text extraction process and further improves 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 the 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 used 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 for the sample question based on an agent. 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 agent, sample text, sample reference text, and sample answer is the same as that of the 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 in line 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 big model to perform the text extraction task.
[0156] The policy big model can be a big language model that has been pre-trained for a text extraction task or a text refinement task. 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 input into a large language model to output text. Then, the refined sample text is used as a label, and a loss value is calculated based on the refined sample text and the output text based on a loss function. The loss function can be, for example, a cross entropy loss.
[0158] In some embodiments, the semantic features of the output text and the semantic features of the sample text may be extracted respectively, and the loss value may be calculated based on the feature similarity.
[0159] Finally, fine-tune the parameters of the large language model based on the loss value to obtain the pre-trained policy large model.
[0160] Pre-training the large policy model for text extraction tasks or text refinement tasks can improve the accuracy of the large policy model in the text extraction or text refinement process, and further improve the efficiency of agent training.
[0161] In the disclosed embodiment, based on the reinforcement learning algorithm and the reward function, the reward value can be calculated according to the sample answer and the real answer of the sample question, and then the model parameters of the initial agent are adjusted based on the reward value to obtain a trained agent. The 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 target the target question and extract text with high support for the answer. The intelligent agent can adjust the model's strategy for text extraction and extraction in time according to the reward value, further improving the training efficiency of the intelligent agent.
[0163] Fig. 8A A schematic diagram of an intelligent agent training method according to an embodiment of the present disclosure is schematically shown.
[0164] like Fig. 8A As shown, in this embodiment 800A, first, the knowledge base is searched based on the sample question 801 to obtain the sample search result 802a. At the same time, the large model is queried based on the sample question 801 to generate the initial sample answer 802b. Then, the sample question 301, the sample search result 302a and the initial sample answer 802b are input into the extraction module 810 and the generation module 820 in the agent 3100, and text extraction and text generation are performed respectively to generate the 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 agent 3100 are adjusted based on the reward value 805. When Q is maximized, it is determined that the agent training is completed. The termination condition of the training can be that Q is maximized within a limited number of training times, or that the training is terminated when the Q value converges.
[0165] According to an embodiment of the present disclosure, based on a reward function, according to sample answers and real answers to sample questions, the model parameters of the agent are adjusted to obtain a trained agent, which may include the following operations: respectively extracting a first semantic feature of the sample answer and a second semantic feature of the real answer; calculating a reward value based on the first semantic feature and the second semantic feature; and adjusting the model parameters of the agent based on the reward value to obtain a trained agent.
[0166] For example, the pre-trained BERT model can be called to extract the first semantic feature of the sample answer and the second semantic feature of the true answer. Then, the reward value is calculated 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.
[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 values of sample answers and true answers based on the reward function, the reward values can be calculated based on semantic similarity, which can further improve 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 the training process. Based on the reward value, only the model parameters of the extraction module are adjusted. When the extraction module performs the text extraction task, it calls the strategy model, which enables the strategy model to learn how to extract and extract text according to the questioning intention of the target question and the answering intention of the real answer, thereby providing more targeted reference text for the generation model.
[0173] Since the large model has 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, and then fine-tune the model parameters of the generation module after adjusting the model parameters of the extraction module based on the reward value, so as to further improve the answer generation accuracy of the large model.
[0175] Figure 8B A schematic diagram of an intelligent agent training method according to another embodiment of the present disclosure is schematically shown.
[0176] like Figure 8B As shown, the difference between the embodiment 800B and the embodiment 800A is that the deletion submodule 811 and the extraction submodule 812 in the extraction module 810 are shown. The deletion submodule is used to delete the 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, the model parameters of the extraction module are adjusted based on the reward value to obtain a trained intelligent agent, which 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 the training process. Based on the reward value, only the model parameters of the deletion submodule are adjusted, so that when the extraction module performs the text extraction task, the strategy large model is called, which can enable the strategy large model to learn how to extract text based on the questioning intention of the target question and the answering intention of the real answer, thereby providing more targeted reference text for generating the large model.
[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, only the model parameters of the deleted sub-module can be adjusted based on the reward value 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 submodule, and after adjusting the model parameters of the deletion submodule based on the reward value, fine-tune the model parameters of the extraction submodule and / or the model parameters of the generation module to further improve the answer generation of the large model.
[0181] Fig. 9 A block diagram of an agent-based text generation device according to an embodiment of the present disclosure is schematically shown.
[0182] like Fig. 9 As shown, the text generating 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 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 an intelligent agent.
[0184] The first extraction module 920 is used 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 the 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 deleting unit is used to delete repeated contents 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, the relevance detection module includes: a first construction submodule and a first input submodule. The first construction submodule is used to construct a first prompt text according to the initial text and the target question, wherein the first prompt text includes an example for characterizing the relevance between the reference answer and the reference question. The first input submodule is used to input the first prompt text into the 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 used to construct a second prompt text based on the first text, wherein the second prompt text includes an example for characterizing the deletion of repeated content in the reference text. The input subunit is used to input the second prompt text into the agent to obtain an output intermediate text.
[0195] According to an embodiment of the present disclosure, the device further includes a determination module and an adding module. The determination module is used to determine a reference answer from the initial answer; wherein the correlation between the reference answer and the target question is less than a predetermined threshold. The adding module is used 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 used to use an intelligent agent to delete redundant content of the intermediate text to obtain a second text. The extraction unit is used to use an intelligent agent to extract the core semantics of 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 subunit 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 characterizing the extraction of core semantics related to the reference question 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 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. The retrieval module is used 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 generate an initial answer for each sub-question based on each sub-question using an intelligent agent.
[0204] Fig.10 A block diagram of an intelligent agent training device according to an embodiment of the present disclosure is schematically shown.
[0205] like Fig.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 search 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 used to extract 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 generation module 1030 is used to generate sample answers based on sample questions and sample reference texts using an 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 according to the sample answers and the real answers to the 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 texts; 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 adjusting 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; wherein the deletion submodule is used to delete redundant content in the sample text that is not related 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] A second fixing unit is used to fix the model parameters of the extraction submodule; and a second adjustment unit is used to adjust the model parameters of the deletion submodule based on the reward value to obtain a trained intelligent agent.
[0219] Fig.11 A block diagram schematically shows 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 Fig.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] The input module 1110 is responsible for receiving or sensing information such as queries, requests, instructions, signals or data from the outside world (such as users or external environment), and converting them into a format that can be understood and processed by the AI agent 1100. The input module 1110 is the primary link for the AI agent 1100 to interact with the outside world. It enables the AI agent 1100 to efficiently and accurately obtain the 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 the example, the processing module 1130 is the core support for the AI agent 1100 to handle complex tasks. The processing module 1130 can determine the target task based on the input information received by the 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 model to output the 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 the example, the performance of the control unit 1131 may be closely related to the large model on which the AI agent 1100 is based. In order to give full play to the capabilities of the large language model, the internal structure of the control unit 1131 may be designed to be highly configurable and scalable to cope with various types of tasks and requirements in real 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. Then, the control unit 1131 can use the fed back data resources to generate the target answer. It is also possible to retrieve the relevant data resources from the storage unit 1132 and feed it back to the control unit 1131, and then the control unit 1131 can use the returned data resources to generate the target answer. And pass the target answer to the output module 1120.
[0228] The operation unit 1133 may be regarded as a predefined tool library. The renderer and display controls mentioned above may be included in the operation unit 1133 .
[0229] In the example, when the AI agent 1100 needs to render multiple output data, the relevant renderer and display control can be called from the operation unit 1133 and fed 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.
[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 improve 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 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.
[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] Fig.12 A schematic block diagram of an example electronic device 1200 that can be used to implement an embodiment 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 processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0237] like Fig.12 As shown, the 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. In the RAM 1203, various programs and data required for the operation of the device 1200 can also be stored. The computing unit 1201, the ROM 1202, and the RAM 1203 are connected to each other via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.
[0238] A number of components in the device 1200 are connected to the I / O interface 1205, including: an input unit 1206, such as a keyboard, a mouse, etc.; an output unit 1207, such as various types of displays, speakers, etc.; a storage unit 1208, such as a disk, an optical disk, etc.; and a communication unit 1209, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1209 allows the device 1200 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0239] The computing unit 1201 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1201 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1201 performs the various methods and processes described above, such as an agent-based text generation method or an agent training method. For example, in some embodiments, an agent-based text generation method or an agent training method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 1208. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1200 via the ROM 1202 and / or the communication unit 1209. When the computer program is loaded into the RAM 1203 and executed by the computing unit 1201, one or more steps of the agent-based text generation method or agent training method described above may 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 implementations of the systems and techniques described above herein 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), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including 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 may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, 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, device, or equipment. 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, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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), an optical fiber, 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 may 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 may 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 the server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises through computer programs running on 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 combined with a blockchain.
[0246] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0247] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A text generation method based on an agent, comprising: Acquire an initial text according to the 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 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 the intelligent agent; and The target answer is output.
2. The method according to claim 1, wherein: The step of extracting the 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 related 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 step of extracting the intermediate text from the initial text by using the intelligent agent comprises: Using the agent, extracting a first text from the initial text based on the 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 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 characterizing the relevance between the reference answer and the reference question; and The first prompt text is input into the agent to obtain the output detection result.
6. The method according to claim 3, wherein: The step of deleting repeated contents in the first text to obtain the intermediate text includes: Constructing a second prompt text according to 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 any one of claims 3 to 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 step of 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 using the agent to delete redundant content of the intermediate text to obtain a second text includes: Constructing a third prompt text according to 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 according to the second text and the target question; wherein the fourth prompt text includes an example for representing the extraction of core semantics related to the reference question from the reference answer; The fourth prompt text is input into the agent to obtain the output reference text.
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; Using 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 the input sample question, wherein the sample text includes: a search result for the target question based on a knowledge base and an initial answer generated for the target question based on an initial intelligent agent; Extracting a sample reference text from the sample text using an initial agent; 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 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 step of adjusting the model parameters of the agent based on the reward function according to the sample answer and the real answer to the sample question to obtain a trained agent includes: Respectively extracting a first semantic feature of the sample answer and a second semantic feature of the true answer; Calculating the reward value according to 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 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 step of adjusting the model parameters of the agent based on the reward value to obtain a trained agent includes: When the model parameters of the generation module are fixed, 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; and 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 Under the condition that the model parameters of the extraction submodule are fixed, the model parameters of the deletion submodule are adjusted based on the reward value to obtain the trained intelligent agent.
16. A text generation device based on an agent, comprising: A first acquisition module is used 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, configured to extract 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; A first generating module, 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 comprises: A first extraction submodule, configured to extract 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 comprises: an extracting unit, configured to extract a first text from the initial text based on the relevance between the initial text and the target question by using the intelligent agent; wherein the relevance between the first text and the target question is greater than a predetermined threshold; and The first deleting unit is used 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 relevance detection module comprises: 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 agent to obtain the output detection result.
21. The device according to claim 18, wherein The first deleting unit includes: A first construction subunit is used to construct a second prompt text according to the first text, wherein the second prompt text includes an example for representing the 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 any one of claims 18 to 21, wherein: The device also includes: A determination module, configured to determine a reference answer from the initial answer; wherein the correlation 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 device according to claim 17, wherein: The extraction submodule comprises: A second deleting unit, 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 agent to extract the core semantics of the second text to generate the reference text.
24. The device according to claim 23, wherein: The second deleting unit includes: A second construction subunit is used to construct a third prompt text according to 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 output second text.
25. The device according to claim 23, wherein: The extraction unit comprises: A third construction subunit is used to construct a fourth prompt text according to 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, used for splitting 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, used 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 used to acquire a sample text according to an input sample question, wherein the sample text includes: a search result for the target question based on a knowledge base and an initial answer generated for the target question based on an initial intelligent agent; A second extraction module is used to extract a sample reference text from the sample text using an initial agent; wherein the sample reference text is strongly related to the sample question and indicates a summary of the sample text; A second generation module, configured to generate a sample answer based on the sample question and the sample reference text using the 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 agent based on a reward function according to the sample answers and the real answers to the sample questions to obtain a trained agent.
28. The training device according to claim 27, wherein the adjustment module comprises: A second extraction submodule, 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 the reward value according to 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 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 comprises: 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; and the extraction submodule is used to extract the core semantics of the text after the redundant content is deleted; The adjustment submodule comprises: 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 obtain output information by calling the large models to execute the method according to any one of claims 1 to 15; 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 so that the at least one processor can execute 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 cause the computer to execute the method according to any one of claims 1 to 15.
34. A computer program product, comprising a computer program, which, when executed by a processor, 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
Classification model training and text classification method and device, and electronic equipment
CN118916480A
Problem processing method, computing device and computer readable storage medium
CN118917322A
Answer generation method and device, electronic equipment and storage medium
CN119106110A
Cited By
Text generation method based on large model, electronic equipment and storage medium
CN121881996A