Question and answer method and system based on memory agent, medium and terminal

By constructing the current task history Q&A record and a full historical Q&A record, judging the user's intention based on the current task history Q&A record and calling the large language model to extract execution parameters, the problem of low accuracy of the agent when identifying and processing external calls is solved, and the accuracy of user's intentions is improved.

CN119557393APending Publication Date: 2025-03-04CHINA UNIONPAY MERCHANT SERVICES CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411400178.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-09
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

The accuracy of existing agents in identifying and processing external calls is low, especially when the diversity and uncertainty of user intentions increase in multiple rounds of historical sessions, resulting in the accuracy of agents' understanding of user intentions and the inability to accurately answer user questions.

Method used

By constructing the current task history Q&A record and a full historical Q&A record, judging user intentions based on the current task history Q&A record, filtering matching tools, and calling a large language model to extract execution parameters, improving the accuracy of user intentions.

Benefits of technology

It effectively improves the accuracy of understanding of user intentions, makes the reply obtained by executing the call function based on execution parameters more accurate, and solves the problem that the agent cannot accurately answer user questions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557393A_ABST
    Figure CN119557393A_ABST
Patent Text Reader

Abstract

The invention discloses a question answering method and system based on a memory agent, a medium and a terminal, relates to the technical field of artificial intelligence, and mainly aims to solve the problem that a user question cannot be accurately answered due to the fact that an existing agent is low in user intention understanding accuracy. Comprises: receiving a consultation question input by a user based on a target question-answering module; obtaining a corresponding current task historical question and answer record, a current task state identifier and a total historical question and answer record; generating a first cue word based on the updated historical question and answer record of the current task and the tool information of the target question and answer module, and calling a large language model to screen a matching tool; generating a second cue word based on the total historical question and answer record and the tool information of the matching tool, and calling the large language model to extract execution parameters required for executing the matching tool according to the second cue word; and calling a calling function corresponding to the matching tool, and generating a reply for the consultation question based on the execution parameter.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a question-answering method and system, medium, and terminal based on a memory agent. Background Art

[0002] After the emergence of large language models such as Chatgpt, intelligent agent technology also emerged, which can understand user intentions and call corresponding tools to perform tasks. At present, most intelligent agents are implemented based on function call technology. Function call technology usually encapsulates the functions and operations of tools into callable functions or methods to realize the functions and tasks of intelligent agents.

[0003] However, when function calls internalize external call recognition into the large language model through pre-training / fine-tuning technology, the accuracy of the intelligent agent in identifying and processing these external calls is low due to the limitations of the training data; and with the increase of multiple rounds of historical conversations, the diversity and uncertainty of user intentions will further increase, further leading to a decrease in the accuracy of the intelligent agent's understanding of user intentions, which in turn leads to an inability to accurately answer user questions. Summary of the invention

[0004] In view of this, the present application provides a question-answering method and system, medium, and terminal based on a memory agent, the main purpose of which is to address the problem that existing agents have low accuracy in understanding user intentions, which in turn leads to the inability to accurately answer user questions.

[0005] According to one aspect of the present application, a question-answering method based on a memory agent is provided, comprising:

[0006] Receiving a consulting question input by a user based on a target question-answering module, wherein the consulting question carries an identity identifier of the user;

[0007] According to the identity identifier, the corresponding current task historical question and answer record, current task status identifier, and full historical question and answer record are obtained;

[0008] If the current task status is marked as unfinished, the consulting question is added to the current task history question and answer record to obtain an updated current task history question and answer record, and based on the updated current task history question and answer record and tool information of each tool included in the target question and answer module, a first prompt word is generated, and a large language model is called to filter matching tools according to the first prompt word;

[0009] If the matching tool is a non-alternative tool, generating a second prompt word based on the full historical question and answer record and the tool information of the matching tool, and calling the large language model to extract execution parameters required for executing the matching tool according to the second prompt word;

[0010] The calling function corresponding to the matching tool is called, and a response to the consultation question is generated based on the execution parameters.

[0011] Preferably, after calling the calling function corresponding to the matching tool and generating a response to the consultation question based on the execution parameter, the method further comprises:

[0012] If the reply is generated successfully, determining whether the consulting question is a preset consulting question;

[0013] If so, output the response;

[0014] If not, the large language model is called to generate an integrated reply based on the consultation question and the reply, and the integrated reply is output.

[0015] Preferably, after calling the calling function corresponding to the matching tool and generating a response to the consultation question based on the execution parameter, the method further comprises:

[0016] If the reply generation fails, all execution parameters of the calling function are traversed to find the missing execution parameters, and prompt information is generated according to the missing execution parameters, and the prompt information is output to prompt the user to supplement the missing execution parameters, wherein the full execution parameters are used to represent all execution parameters used when executing the calling function;

[0017] Adding the prompt information to the full historical question-and-answer record, so that the large language model extracts execution parameters from the full historical question-and-answer record after the prompt information is added in the next round of question-and-answer;

[0018] And, the prompt information and the matching tool are added to the updated current task history question and answer record, so that in the next round of question and answer, the user's intention is judged based on the current task history question and answer record after adding the prompt information and the matching tool.

[0019] Preferably, before generating a response to the consultation question based on the execution parameter, the method further includes:

[0020] Preset execution parameters required for executing the calling function are obtained, and the execution parameters are corrected based on the preset execution parameters to generate a reply to the consulting question based on the corrected execution parameters.

[0021] Preferably, the method further comprises:

[0022] If the matching tool is an alternative tool, determining whether the consulting question is a business consulting question;

[0023] If yes, then call the preset business document question-answering model to generate a response to the consultation question and output it;

[0024] If not, the large language model is called to generate a response to the consultation question and output it.

[0025] Preferably, after outputting the response to the consultation question, the method further comprises:

[0026] Adding the reply or the integrated reply, and the consulting question to the full historical question and answer record;

[0027] Adding the reply or the integrated reply to the updated historical question and answer record of the current task;

[0028] The current task status indicator is updated to completed.

[0029] Preferably, the method further comprises:

[0030] If the current task status is marked as completed, the historical question and answer record of the current task is cleared, and the consulting question is added to the cleared historical question and answer record of the current task, and the current task status is marked as unfinished to start a new round of question and answer.

[0031] According to another aspect of the present application, a memory agent-based question-answering system is provided, comprising:

[0032] A consultation question receiving module, used to receive consultation questions input by a user based on a target question-answering module, wherein the consultation questions carry the identity of the user;

[0033] A question and answer record acquisition module is used to obtain the corresponding current task historical question and answer record, current task status identifier, and full historical question and answer record according to the identity identifier;

[0034] A tool screening module, for, if the current task status is marked as unfinished, adding the consulting question to the current task historical question and answer record to obtain an updated current task historical question and answer record, and generating a first prompt word based on the updated current task historical question and answer record and the tool information of each tool included in the target question and answer module, and calling a large language model to screen matching tools according to the first prompt word;

[0035] an execution parameter extraction module, for generating a second prompt word based on the full historical question and answer record and the tool information of the matching tool if the matching tool is a non-alternative tool, and calling the large language model to extract the execution parameters required for executing the matching tool according to the second prompt word;

[0036] The reply generation module is used to call the calling function corresponding to the matching tool and generate a reply to the consultation question based on the execution parameters.

[0037] Preferably, after the reply generation module, the system further includes an integration module for:

[0038] If the reply is generated successfully, determining whether the consulting question is a preset consulting question;

[0039] If so, output the response;

[0040] If not, the large language model is called to generate an integrated reply based on the consultation question and the reply, and the integrated reply is output.

[0041] Preferably, after the reply generation module, the system further includes a prompt module for:

[0042] If the reply generation fails, all execution parameters of the calling function are traversed to find the missing execution parameters, and prompt information is generated according to the missing execution parameters, and the prompt information is output to prompt the user to supplement the missing execution parameters, wherein the full execution parameters are used to represent all execution parameters used when executing the calling function;

[0043] Adding the prompt information to the full historical question-and-answer record, so that the large language model extracts execution parameters from the full historical question-and-answer record after the prompt information is added in the next round of question-and-answer;

[0044] And, the prompt information and the matching tool are added to the updated current task history question and answer record, so that in the next round of question and answer, the user's intention is judged based on the current task history question and answer record after adding the prompt information and the matching tool.

[0045] Preferably, the reply generation module, before generating a reply to the consultation question based on the execution parameter, is further used to:

[0046] Preset execution parameters required for executing the calling function are obtained, and the execution parameters are corrected based on the preset execution parameters to generate a reply to the consulting question based on the corrected execution parameters.

[0047] Preferably, the system further comprises a business consultation question reply module, which is used to:

[0048] If the matching tool is an alternative tool, determining whether the consulting question is a business consulting question;

[0049] If yes, then call the preset business document question-answering model to generate a response to the consultation question and output it;

[0050] If not, the large language model is called to generate a response to the consultation question and output it.

[0051] Preferably, after the integration module or the business consultation question reply module, the system further includes an update module for:

[0052] Adding the reply or the integrated reply, and the consulting question to the full historical question and answer record;

[0053] Adding the reply or the integrated reply to the updated historical question and answer record of the current task;

[0054] The current task status indicator is updated to completed.

[0055] Preferably, the update module is further used for:

[0056] If the current task status is marked as completed, the historical question and answer record of the current task is cleared, and the consulting question is added to the cleared historical question and answer record of the current task, and the current task status is marked as unfinished to start a new round of question and answer.

[0057] According to another aspect of the present application, a storage medium is provided, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to perform operations corresponding to the above-mentioned memory agent-based question-answering method.

[0058] According to another aspect of the present application, a terminal is provided, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus;

[0059] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the above-mentioned memory-agent-based question-answering method.

[0060] By means of the above technical solution, the technical solution provided by the embodiment of the present application has at least the following advantages:

[0061] The present application provides a question-and-answer method and system, medium, and terminal based on a memory intelligent agent, which first receives a consulting question input by a user based on a target question-and-answer module, wherein the consulting question carries the identity of the user; secondly, the corresponding current task history question-and-answer record, current task status identifier, and full history question-and-answer record are obtained according to the identity; thirdly, if the current task status identifier is incomplete, the consulting question is added to the current task history question-and-answer record to obtain an updated current task history question-and-answer record, and based on the updated current task history question-and-answer record and the tool information of each tool contained in the target question-and-answer module, a first prompt word is generated, and a large language model is called to filter a matching tool according to the first prompt word; further, if the matching tool is a non-alternative tool, a second prompt word is generated based on the full history question-and-answer record and the tool information of the matching tool, and the large language model is called to extract the execution parameters required to execute the matching tool according to the second prompt word; finally, the calling function corresponding to the matching tool is called, and a reply to the consulting question is generated based on the execution parameters. Compared with the prior art, the embodiment of the present application constructs a current task history question and answer record for storing the current task question and answer record, and a full history question and answer record for storing historical question and answer records. When the current task is not completed, the user intention is judged based on the current task history question and answer record, the matching tool is screened, and the calling function corresponding to the matching tool is called, and the execution parameters required to execute the calling function are extracted based on the full history question and answer record. Since the user intention is judged based on the current task history question and answer record when calling the function, and the execution parameters are extracted based on the full history question and answer record, the accuracy of understanding the user intention is effectively improved, so that the reply obtained by executing the calling function based on the execution parameters is more accurate.

[0062] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0064] Figure 1 A flow chart of a question-answering method based on a memory agent provided in an embodiment of the present application is shown;

[0065] Figure 2A flow chart of a second memory agent-based question-answering method provided in an embodiment of the present application is shown;

[0066] Figure 3 A flow chart of a third memory agent-based question-answering method provided in an embodiment of the present application is shown;

[0067] Figure 4 A flowchart of a fourth memory agent-based question-answering method provided in an embodiment of the present application is shown;

[0068] Figure 5 A block diagram of a question-answering system based on a memory agent provided in an embodiment of the present application is shown;

[0069] Figure 6 A schematic diagram of the structure of a terminal provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0070] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0071] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.

[0072] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present application, its application, or uses.

[0073] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.

[0074] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0075] The embodiments of the present application can be applied to computer systems / servers, which can operate with many other general or special computing system environments or configurations. Examples of well-known computing systems, environments and / or configurations suitable for use with computer systems / servers include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, large computer systems, and distributed cloud computing technology environments including any of the above systems, etc.

[0076] Computer systems / servers may be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. In general, program modules may include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers may be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules may be located on local or remote computing system storage media including storage devices.

[0077] The present application embodiment provides a question-answering method based on a memory agent, such as Figure 1 As shown, the method includes:

[0078] 101. Receive consulting questions input by the user based on the target question and answer module.

[0079] Among them, the consulting question carries the user's identity; the identity information includes but is not limited to the user name, user ID, etc.; the target question and answer module includes but is not limited to the business question and answer module, the free question and answer module, etc. The business question and answer module can also be configured with specific business question and answer modules according to different business categories, such as financial business question and answer modules, insurance business question and answer modules, etc. In the embodiment of the present application, the current execution end can be a memory intelligent body. When the user logs in to the system, the user enters the user name and user ID and other identity identifiers, and can further enter the target question and answer module by clicking, and enter the consulting question in the window of the module. The current execution end receives the consulting question and obtains the user's identity information.

[0080] 102. Obtain the corresponding current task historical question and answer record, current task status identifier, and full historical question and answer record according to the identity identifier.

[0081] In an embodiment of the present application, if the current user is logging into the system again, the corresponding current task history question and answer record, current task status identifier, and full history question and answer record are obtained according to the user's identity identifier. Among them, the current task history question and answer record is used to store the question and answer record of the current task, that is, the history record of a tool call. It should be noted that if a tool call does not get a correct answer, the content in the current task history question and answer record will not be cleared, and the next user's input will continue to be recorded in it; the full history question and answer record is used to store historical question and answer records, that is, the user's multiple or multiple rounds of question and answer history on the current session page; the current task status identifier is used to mark whether the current task is completed, and "1" can be used to indicate completion, and "0" can be used to indicate incomplete. If the current user is logging into the system for the first time, the system will assign exclusive identity information to it, and establish the current task history question and answer record, the current task status identifier, and the full history question and answer record, among which the current task history question and answer record and the full history question and answer record are empty, and the current task status identifier is incomplete.

[0082] 103. If the current task status is marked as incomplete, the consulting question is added to the current task history question and answer record to obtain an updated current task history question and answer record, and based on the updated current task history question and answer record and the tool information of each tool contained in the target question and answer module, a first prompt word is generated, and the large language model is called to filter matching tools according to the first prompt word.

[0083] Among them, each question and answer module will be configured with multiple tools, and the tools configured for different question and answer modules will also be different. For example, the financial business question and answer module supports tools a, b, and c, the insurance business question and answer module supports tools d, e, f, and g, and the free question and answer module supports tools h and i, etc.; the tool information is used to describe the functions and parameters of the tool, etc., and can be pre-configured. For example, the tool information of the tool yjy_get_time is "Query the current date, time, day of the week and lunar date. Note: the yjy_get_time tool does not require any parameters"; the first prompt word is used to instruct the large language model to filter and match tools, which may include indicating which tools the large model can choose from, the functions and parameters of each tool, the user's consulting questions received, instructing the large language model to filter tools based on the tool information and the updated current task history question and answer records, and returning in that format, etc. Exemplarily, the target question-answering module includes three tools: weather check, date check, and Internet search. The inquiry question is: What day is today? The first prompt word is: {'role':'system','content':'Answer the following questions as best as you can. You must use one of the following tools:\n{\n"common_tool":{\n"tool":"common_tool",\n"description":"When other tools are not available, use this tool. Prioritize selecting the appropriate tools above.",\n"params":[\n{\n"name":"question",\n"description":"question"\n}\n]\n},\n"yjy_get_time":{\n"tool":"yjy_get_time",\n"description":"Query the current date, time, day of the week and lunar date. Special note: the yjy_get_time tool does not require any parameters. ",\n"params":[]\n},\n"yjy_get_weather":{\n"tool":"yjy_get_weather",\n"description":"Query the weather according to the city name",\n"params":[\n{\n"name":"city_name",\n"description":"The city to be queried.Special note: If not mentioned in the question, city_name must default to an empty string "\n}\n]\n},\n"yjy_web_search":{\n"tool":"yjy_web_search",\n"description":"Internet search tool. If it is not a creative question, yjy_web_search is used as the answer instead of common_tool",\n"params":[\n{\n"name":"question",\n"description":"A search question that combines historical conversations and the last user's question summary"\n}\n]\n}\n}\n,Please note that only the required tools are returned in the following json format:{"tool_name":"Selected tool name"}'}, this part is the agent role, which is used to indicate which tools the large language model can choose from, and what are the functions and parameters of each tool;{'role':'user','content':'What day of the week is today'}, this part is the user role, including the user's consulting questions, and then the matching tool{"tool_name":"yjy_get_time"} is obtained.

[0084] Preferably, after the matching tool is determined, only the matching tool may be retained and other tools may be deleted.

[0085] Based on the above method, the user intention can be accurately judged and instructions can be given to the large language model to screen out matching tools, thereby improving the accuracy of the reply.

[0086] 104. If the matching tool is a non-alternative tool, a second prompt word is generated based on the full historical question and answer records and the tool information of the matching tool, and the large language model is called to extract the execution parameters required to execute the matching tool according to the second prompt word.

[0087] Among them, the alternative tool is used to characterize the pre-configured backup tool. When other tools do not match, this tool can be used as a backup to improve the user experience. The tool common_tool in the above example is an alternative tool; the second prompt word is used to instruct the large language model to extract the execution parameters required for the call function corresponding to the execution matching tool. In the embodiment of the present application, if the matching tool is a non-alternative tool, it means that the large language model has screened the matching tool. At this time, it is necessary to call the large language model to extract the execution parameters. For example, the user's previous consultation question is: Which is the most economically developed city in China. The intelligent agent replied: The most economically developed city in China is Shanghai. According to the latest national GDP ranking of the top ten cities, Shanghai ranks first. The user's current consultation question is: What is the weather like in this city? According to step 103 of the embodiment, the large language model will screen and return the query weather tool. At this time, the memory intelligent experience will generate a second prompt word based on the full amount of historical question and answer records and the tool information of the matching tool: {'role':'system','content':'You are a certain application, and your task is to extract the execution parameters required by the tool, rather than directly answering the question. It is known that the description of the tool currently in use is:\n{\n"tool":"yjy_get_weather",\n"description":"Query weather according to city name",\n"params":[\n{\n"name":"city_name",\n"description":"The city to be queried. Special note: If not mentioned in the question, city_name must default to an empty string"\n}\n]\n}. Please combine the above tool description and the historical dialogue content below to extract the execution parameters of the tool for the [last] user's consultation question. Please be sure to return in the following json format:{"tool_name":"Selected tool name","params":{"Parameter name":"Parameter value"}},, I need you to extract parameters, not directly answer questions! ! '}This part is the role of the intelligent agent, which is used to instruct the large language model to extract execution parameters,{'role':'user','content':'Which city is the most economically developed in China'}{'role':'assistant','content':'The most economically developed city in China is Shanghai. According to the latest ranking of the top ten cities in China in terms of GDP, Shanghai ranks first. '}{'role':'user','content':'What is the weather like in this city? '}, this part is the user role, including the user's consulting questions and the full historical Q&A records, and then the execution parameters are obtained: "{\"tool_name\":\"yjy_get_weather\",\"params\":{\"city_name\":\"Shanghai\"}}".

[0088] Based on the above method, the extraction accuracy of execution parameters can be improved.

[0089] 105. Call the call function corresponding to the matching tool, and generate a reply to the consultation question based on the execution parameters.

[0090] Continuing with the above example, the extracted execution parameters are {"tool_name": "yjy_get_weather", "params": {"city_name": "Shanghai"}}, and the call function corresponding to the matching tool is the yjy_get_weather tool function. Based on the execution parameters, the call function is executed to obtain the execution result, which is the reply to the consultation question.

[0091] Compared with the prior art, in the embodiment of the present application, by constructing the current task historical Q&A record for storing the Q&A records of the current task and the full - volume historical Q&A record for storing the historical Q&A records, when the current task is not completed, based on the current task historical Q&A record, the user intention is judged, the matching tool is screened, and the call function corresponding to the matching tool is called, and based on the full - volume historical Q&A record, the execution parameters required to execute the call function are extracted. Since the call function is obtained by judging the user intention according to the current task historical Q&A record, and the execution parameters are extracted based on the full - volume historical Q&A record, the accuracy of understanding the user intention is effectively improved, making the reply obtained by executing the call function based on the execution parameters more accurate.

[0092] The embodiment of the present application provides another Q&A method based on a memory agent, as Figure 2 shown, the method includes:

[0093] 201. Receive the consultation question input by the user based on the target Q&A module.

[0094] 202. Obtain the corresponding current task historical Q&A record, current task status flag, and full - volume historical Q&A record according to the identity identifier.

[0095] 203. If the current task status flag is not completed, add the consultation question to the current task historical Q&A record to obtain the updated current task historical Q&A record, and based on the updated current task historical Q&A record and the tool information of each tool included in the target Q&A module, generate a first prompt word, and call the large - language model to screen the matching tool according to the first prompt word.

[0096] 204. If the matching tool is not an alternative tool, generate a second prompt word based on the full - volume historical Q&A record and the tool information of the matching tool, and call the large - language model to extract the execution parameters required to execute the matching tool according to the second prompt word.

[0097] 205. Call the calling function corresponding to the matching tool, and generate a response to the consultation question based on the execution parameters.

[0098] The embodiment steps 201 to 205 have been described in detail in the above embodiment steps 101 to 105 and will not be repeated here.

[0099] Further optionally, before generating a response to the consulting question based on the execution parameters in step 205 of the embodiment, the embodiment method also includes: obtaining preset execution parameters required to execute the calling function, and correcting the execution parameters based on the preset execution parameters, so as to generate a response to the consulting question based on the corrected execution parameters.

[0100] Among them, the preset execution parameters are used to characterize the accurate execution parameters required for calling the function, and can be stored in a pre-configured mapping table. In the embodiment of the present application, in order to improve the accuracy of the execution parameters, after the large language model extracts the execution parameters according to the second prompt word, all the preset execution parameters required for the calling function can be obtained from the mapping table, and the execution parameters extracted by the large language model can be corrected based on this. For example, if the execution parameter extracted by the large language model is a province name and the preset execution parameter is a city name, the province name is modified to a city name, and further, based on the corrected execution parameter, that is, the city name, a response to the consultation question is generated.

[0101] 206. If the reply is generated successfully, determine whether the consulting question is a preset consulting question.

[0102] 207a. If yes, output a reply.

[0103] 207b. If not, call the large language model to generate an integrated response based on the consultation question and the response, and output the integrated response.

[0104] Steps 206 to 207b of the embodiment are executed when the parameters are accurate and the reply is generated successfully. Among them, the preset consulting questions can be pre-configured and used to represent consulting questions that do not need to be integrated by calling a large language model. For example, consulting questions about querying merchant numbers. Since the calling function returns a query result in json format, if the query result is summarized by a large language model, it may cause errors or ambiguity. Therefore, for such consulting questions, there is no need for large language models to integrate and they can be directly output. In the embodiment of the present application, when the reply is successfully generated, it is determined again whether the consulting question is a preset consulting question. If so, the execution result is directly output; otherwise, the large language model is called to generate an integrated reply according to the consulting question and the reply, and the integrated reply is output. For example, taking the weather query tool as an example, the weather, temperature or weather-related consulting questions all need to call the weather query tool, and the execution result is: {"temp_C":"33","FeelsLikeC":"39","humidity":"56","weatherDesc":[{"value":"Partlycloudy"}]}, however, directly outputting the reply will cause the user to have a poor reading experience of the current execution end. At this time, the consulting question and the execution result can be encapsulated as prompt words, and the large language model can be called for integration to obtain the integrated reply, and the integrated reply is output. For example, the consulting question is how many degrees is Shanghai today? The integrated reply is 33 degrees in Shanghai today, thereby improving the accuracy of the reply and the user's experience.

[0105] 208. Add the reply or the integrated reply, and the consulting question to the full historical question and answer record; add the reply or the integrated reply to the updated historical question and answer record of the current task; update the current task status mark to completed.

[0106] It should be noted that in the embodiment of the present application, the final output reply and consulting question are added to the full historical question and answer record; the reply is only added to the updated historical question and answer record of the current task because the updated historical question and answer record of the current task already contains the consulting question.

[0107] In an embodiment of the present application, as another possible situation parallel to step 206 of the embodiment, such as Figure 3 As shown, the embodiment method also includes:

[0108] 301. If the response generation fails, all execution parameters of the calling function are traversed to find the missing execution parameters, and prompt information is generated according to the missing execution parameters, and the prompt information is output.

[0109] To prompt the user to supplement the missing execution parameters;

[0110] 302. Add prompt information to the full historical question and answer records.

[0111] This allows the large language model to extract execution parameters from the full amount of historical question and answer records after adding prompt information in the next round of question and answer.

[0112] 303. Add prompt information and matching tools to the updated historical question and answer record of the current task.

[0113] So that in the next round of question and answer, the user's intention can be judged based on the added prompt information and the historical question and answer records of the current task after matching the tool.

[0114] Steps 301 to 303 of the embodiment are situations where the execution parameters are not completely accurate, resulting in a failure to generate a reply. Among them, the full amount of execution parameters is used to characterize all the execution parameters used when executing the calling function; the prompt information is used to prompt the user to supplement the missing execution parameters. In the embodiment of the present application, for example, the consultation question is "I want to check the weather". Due to the lack of the execution parameter city_name, the reply generation fails. When the large language model extracts the execution parameter, the specific value of the execution parameter is not extracted. The large language model will default the specific value of the execution parameter to an empty string. The execution of the yjy_get_weather calling function cannot generate a reply. At this time, all the execution parameters used when executing the calling function are traversed, and the missing execution parameter city_name is found. A prompt message is generated, such as "Please enter the city name!" and output. Furthermore, prompt information is added to the full historical question and answer records to indicate that the current task is not completed, so that the large language model can extract execution parameters from the full historical question and answer records after the prompt information is added in the next round of question and answer; the prompt information and the matching tool are added to the updated historical question and answer records of the current task, so that in the next round of question and answer, the user's intention can be judged based on the current task historical question and answer records after the prompt information and the matching tool are added. Since the matching tool and the prompt information are added to the updated historical question and answer records of the current task, in the next round of question and answer, the current execution end can easily know that the weather query tool is also being used, thereby improving the recognition accuracy of user intentions.

[0115] In an embodiment of the present application, as another possible situation parallel to step 204 of the embodiment, such as Figure 4 As shown, the embodiment method also includes:

[0116] 401. If the matching tool is an alternative tool, determine whether the consulting question is a business consulting question.

[0117] 402a. If yes, call the preset business document question-and-answer model to generate a response to the consultation question and output it.

[0118] 402b. If not, call the large language model to generate a response to the consultation question and output it.

[0119] Steps 401 to 402b of the embodiment are the case where the matching tool is an alternative tool. Among them, the business document question and answer model can be a business document question and answer module implemented based on a large language model and retrieval enhanced recall technology. In the embodiment of the present application, when the matching tool is an alternative tool, it means that other tools are not matched. At this time, it can be determined whether the consulting question is a business consulting question. If so, a reply to the consulting question is generated based on the business document question and answer model to improve the accuracy of the reply to the business consulting question; if not, a reply to the consulting question is generated based on the large language model.

[0120] In an embodiment of the present application, as another possible situation parallel to step 203 of the embodiment, the embodiment method also includes: if the current task status is marked as completed, the current task history question and answer record is cleared, and the consulting question is added to the cleared current task history question and answer record, and the current task status mark is updated to unfinished to start a new round of question and answer.

[0121] In a specific application scenario, the historical question-and-answer records of the current task and the full historical question-and-answer records can be stored in the database in the form of a string type. Therefore, the historical question-and-answer records of the current task and the full historical question-and-answer records are parsed as list types, and the list elements are conversation types, that is, list[Conversation]. Conversation contains three attributes: role is the role, content is the content, and tool is the tool name.

[0122] The present application provides a question-and-answer method based on a memory agent, which first receives a consulting question input by a user based on a target question-and-answer module, wherein the consulting question carries the identity identifier of the user; secondly, the corresponding current task history question-and-answer record, current task status identifier, and full history question-and-answer record are obtained according to the identity identifier; thirdly, if the current task status identifier is incomplete, the consulting question is added to the current task history question-and-answer record to obtain an updated current task history question-and-answer record, and based on the updated current task history question-and-answer record and the tool information of each tool contained in the target question-and-answer module, a first prompt word is generated, and a large language model is called to filter a matching tool according to the first prompt word; further, if the matching tool is a non-alternative tool, a second prompt word is generated based on the full history question-and-answer record and the tool information of the matching tool, and the large language model is called to extract the execution parameters required to execute the matching tool according to the second prompt word; finally, the calling function corresponding to the matching tool is called, and a reply to the consulting question is generated based on the execution parameters. Compared with the prior art, the embodiment of the present application constructs a current task history question and answer record for storing the current task question and answer record, and a full history question and answer record for storing historical question and answer records. When the current task is not completed, the user intention is judged based on the current task history question and answer record, the matching tool is screened, and the calling function corresponding to the matching tool is called, and the execution parameters required to execute the calling function are extracted based on the full history question and answer record. Since the user intention is judged based on the current task history question and answer record when calling the function, and the execution parameters are extracted based on the full history question and answer record, the accuracy of understanding the user intention is effectively improved, so that the reply obtained by executing the calling function based on the execution parameters is more accurate.

[0123] Furthermore, as a response to the above Figure 1 The implementation of the method shown in the embodiment of the present application provides a question-answering system based on a memory agent, such as Figure 5 As shown, the system includes:

[0124] Consulting question receiving module 51, question and answer record acquisition module 52, tool screening module 53, execution parameter extraction module 54, reply generation module 55;

[0125] A consulting question receiving module 51 is used to receive a consulting question input by a user based on a target question-answering module, wherein the consulting question carries an identity identifier of the user;

[0126] A question and answer record acquisition module 52 is used to acquire the corresponding current task historical question and answer record, current task status identifier, and full historical question and answer record according to the identity identifier;

[0127] A tool screening module 53 is used for, if the current task status is marked as unfinished, adding the consulting question to the current task historical question and answer record to obtain an updated current task historical question and answer record, and generating a first prompt word based on the updated current task historical question and answer record and the tool information of each tool included in the target question and answer module, and calling the large language model to screen matching tools according to the first prompt word;

[0128] An execution parameter extraction module 54 is used to generate a second prompt word based on the full historical question and answer record and the tool information of the matching tool if the matching tool is a non-alternative tool, and call the large language model to extract the execution parameters required to execute the matching tool according to the second prompt word;

[0129] The reply generation module 55 is used to call the calling function corresponding to the matching tool and generate a reply to the consultation question based on the execution parameters.

[0130] In a specific application scenario, after the reply generation module, the system further includes an integration module for:

[0131] If the reply is generated successfully, determining whether the consulting question is a preset consulting question;

[0132] If so, output the response;

[0133] If not, the large language model is called to generate an integrated reply based on the consultation question and the reply, and the integrated reply is output.

[0134] In a specific application scenario, after the reply generation module, the system further includes a prompt module for:

[0135] If the reply generation fails, all execution parameters of the calling function are traversed to find the missing execution parameters, and prompt information is generated according to the missing execution parameters, and the prompt information is output to prompt the user to supplement the missing execution parameters, wherein the full execution parameters are used to represent all execution parameters used when executing the calling function;

[0136] Adding the prompt information to the full historical question-and-answer record, so that the large language model extracts execution parameters from the full historical question-and-answer record after the prompt information is added in the next round of question-and-answer;

[0137] And, the prompt information and the matching tool are added to the updated current task history question and answer record, so that in the next round of question and answer, the user's intention is judged based on the current task history question and answer record after adding the prompt information and the matching tool.

[0138] In a specific application scenario, the reply generation module, before generating a reply to the consultation question based on the execution parameter, is further used to:

[0139] Preset execution parameters required for executing the calling function are obtained, and the execution parameters are corrected based on the preset execution parameters to generate a reply to the consulting question based on the corrected execution parameters.

[0140] In a specific application scenario, the system further includes a business consultation question reply module, which is used to:

[0141] If the matching tool is an alternative tool, determining whether the consulting question is a business consulting question;

[0142] If yes, then call the preset business document question-answering model to generate a response to the consultation question and output it;

[0143] If not, the large language model is called to generate a response to the consultation question and output it.

[0144] In a specific application scenario, after the integration module or the business consultation question reply module, the system further includes an update module for:

[0145] Adding the reply or the integrated reply, and the consulting question to the full historical question and answer record;

[0146] Adding the reply or the integrated reply to the updated historical question and answer record of the current task;

[0147] The current task status indicator is updated to completed.

[0148] In a specific application scenario, the update module is also used to:

[0149] If the current task status is marked as completed, the historical question and answer record of the current task is cleared, and the consulting question is added to the cleared historical question and answer record of the current task, and the current task status is marked as unfinished to start a new round of question and answer.

[0150] The present application provides a question-and-answer system based on a memory agent, which first receives consulting questions input by a user based on a target question-and-answer module, wherein the consulting questions carry the identity identifier of the user; secondly, the corresponding current task history question-and-answer record, current task status identifier, and full history question-and-answer record are obtained according to the identity identifier; thirdly, if the current task status identifier is incomplete, the consulting question is added to the current task history question-and-answer record to obtain an updated current task history question-and-answer record, and based on the updated current task history question-and-answer record and the tool information of each tool contained in the target question-and-answer module, a first prompt word is generated, and a large language model is called to filter a matching tool according to the first prompt word; further, if the matching tool is a non-alternative tool, a second prompt word is generated based on the full history question-and-answer record and the tool information of the matching tool, and the large language model is called to extract the execution parameters required to execute the matching tool according to the second prompt word; finally, the calling function corresponding to the matching tool is called, and a reply to the consulting question is generated based on the execution parameters. Compared with the prior art, the embodiment of the present application constructs a current task history question and answer record for storing the current task question and answer record, and a full history question and answer record for storing historical question and answer records. When the current task is not completed, the user intention is judged based on the current task history question and answer record, the matching tool is screened, and the calling function corresponding to the matching tool is called, and the execution parameters required to execute the calling function are extracted based on the full history question and answer record. Since the user intention is judged based on the current task history question and answer record when calling the function, and the execution parameters are extracted based on the full history question and answer record, the accuracy of understanding the user intention is effectively improved, so that the reply obtained by executing the calling function based on the execution parameters is more accurate.

[0151] According to one embodiment of the present application, a storage medium is provided, wherein the storage medium stores at least one executable instruction, and the computer executable instruction can execute the memory agent-based question-answering method in any of the above method embodiments.

[0152] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.

[0153] Figure 6 A schematic diagram of the structure of a terminal provided according to an embodiment of the present application is shown, and the specific embodiment of the present application does not limit the specific implementation of the terminal.

[0154] like Figure 6As shown, the terminal may include: a processor (processor) 602 , a communication interface (Communications Interface) 604 , a memory (memory) 606 , and a communication bus 608 .

[0155] The processor 602 , the communication interface 604 , and the memory 606 communicate with each other via a communication bus 608 .

[0156] The communication interface 604 is used to communicate with other devices such as clients or other servers.

[0157] Processor 602 is used to execute program 610, and specifically can execute the relevant steps in the above-mentioned memory agent-based question-answering method embodiment.

[0158] Specifically, the program 610 may include program codes, which include computer operation instructions.

[0159] The processor 602 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the computer device may be processors of the same type, such as one or more CPUs; or may be processors of different types, such as one or more CPUs and one or more ASICs.

[0160] The memory 606 is used to store the program 610. The memory 606 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0161] The program 610 may be specifically configured to enable the processor 602 to perform the following operations:

[0162] Receiving a consulting question input by a user based on a target question-answering module, wherein the consulting question carries an identity identifier of the user;

[0163] According to the identity identifier, the corresponding current task historical question and answer record, current task status identifier, and full historical question and answer record are obtained;

[0164] If the current task status is marked as unfinished, the consulting question is added to the current task history question and answer record to obtain an updated current task history question and answer record, and based on the updated current task history question and answer record and tool information of each tool included in the target question and answer module, a first prompt word is generated, and a large language model is called to filter matching tools according to the first prompt word;

[0165] If the matching tool is a non-alternative tool, generating a second prompt word based on the full historical question and answer record and the tool information of the matching tool, and calling the large language model to extract execution parameters required for executing the matching tool according to the second prompt word;

[0166] The calling function corresponding to the matching tool is called, and a response to the consultation question is generated based on the execution parameters.

[0167] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the physical device of the above-mentioned memory-based question-answering method, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.

[0168] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0169] The method and system of the present application may be implemented in many ways. For example, the method and system of the present application may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present application are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present application may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present application. Therefore, the present application also covers a recording medium storing a program for executing the method according to the present application.

[0170] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0171] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A question-answering method based on a memory agent, characterized in that: include: Receiving a consulting question input by a user based on a target question-answering module, wherein the consulting question carries an identity identifier of the user; According to the identity identifier, the corresponding current task historical question and answer record, current task status identifier, and full historical question and answer record are obtained; If the current task status is marked as unfinished, the consulting question is added to the current task history question and answer record to obtain an updated current task history question and answer record, and based on the updated current task history question and answer record and tool information of each tool included in the target question and answer module, a first prompt word is generated, and a large language model is called to filter matching tools according to the first prompt word; If the matching tool is a non-alternative tool, generating a second prompt word based on the full historical question and answer record and the tool information of the matching tool, and calling the large language model to extract execution parameters required for executing the matching tool according to the second prompt word; The calling function corresponding to the matching tool is called, and a response to the consultation question is generated based on the execution parameters.

2. The method according to claim 1, characterized in that After calling the calling function corresponding to the matching tool and generating a response to the consultation question based on the execution parameter, the method further includes: If the reply is generated successfully, determining whether the consulting question is a preset consulting question; If so, output the response; If not, the large language model is called to generate an integrated reply based on the consultation question and the reply, and the integrated reply is output.

3. The method according to claim 1, characterized in that After calling the calling function corresponding to the matching tool and generating a response to the consultation question based on the execution parameter, the method further includes: If the reply generation fails, all execution parameters of the calling function are traversed to find the missing execution parameters, and prompt information is generated according to the missing execution parameters, and the prompt information is output to prompt the user to supplement the missing execution parameters, wherein the full execution parameters are used to represent all execution parameters used when executing the calling function; Adding the prompt information to the full historical question-and-answer record, so that the large language model extracts execution parameters from the full historical question-and-answer record after the prompt information is added in the next round of question-and-answer; And, the prompt information and the matching tool are added to the updated current task history question and answer record, so that in the next round of question and answer, the user's intention is judged based on the current task history question and answer record after adding the prompt information and the matching tool.

4. The method according to claim 1, characterized in that: Before generating a response to the consultation question based on the execution parameter, the method further includes: Preset execution parameters required for executing the calling function are obtained, and the execution parameters are corrected based on the preset execution parameters to generate a reply to the consulting question based on the corrected execution parameters.

5. The method according to claim 1, characterized in that The method further comprises: If the matching tool is an alternative tool, determining whether the consulting question is a business consulting question; If yes, then call the preset business document question-answering model to generate a response to the consultation question and output it; If not, the large language model is called to generate a response to the consultation question and output it.

6. The method according to claim 2 or 5, characterized in that: After outputting the response to the consultation question, the method further includes: Adding the reply or the integrated reply, and the consulting question to the full historical question and answer record; Adding the reply or the integrated reply to the updated historical question and answer record of the current task; The current task status indicator is updated to completed.

7. The method according to claim 1, characterized in that The method further comprises: If the current task status is marked as completed, the historical question and answer record of the current task is cleared, and the consulting question is added to the cleared historical question and answer record of the current task, and the current task status is marked as unfinished to start a new round of question and answer.

8. A question-answering system based on memory agent, characterized in that: include: A consultation question receiving module, used to receive consultation questions input by a user based on a target question-answering module, wherein the consultation questions carry the identity of the user; A question and answer record acquisition module is used to obtain the corresponding current task historical question and answer record, current task status identifier, and full historical question and answer record according to the identity identifier; A tool screening module, for, if the current task status is marked as unfinished, adding the consulting question to the current task historical question and answer record to obtain an updated current task historical question and answer record, and generating a first prompt word based on the updated current task historical question and answer record and the tool information of each tool included in the target question and answer module, and calling a large language model to screen matching tools according to the first prompt word; an execution parameter extraction module, for generating a second prompt word based on the full historical question and answer record and the tool information of the matching tool if the matching tool is a non-alternative tool, and calling the large language model to extract the execution parameters required for executing the matching tool according to the second prompt word; The reply generation module is used to call the calling function corresponding to the matching tool and generate a reply to the consultation question based on the execution parameters.

9. A storage medium, wherein at least one executable instruction is stored in the storage medium, characterized in that: The executable instructions enable the processor to perform operations corresponding to the memory agent-based question-answering method as described in any one of claims 1-7.

10. A terminal, comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, wherein the executable instruction enables the processor to perform operations corresponding to the memory agent-based question-answering method as described in any one of claims 1-7.

Citation Information

Cited By

  • Low-delay intelligent question answering method and device, electronic equipment and storage medium

    CN121597799A

  • Low-latency intelligent question answering methods, devices, electronic devices, and storage media

    CN121597799B

  • Large model agent memory construction method and memory system

    CN121638303A

  • Intelligent customer service Agent method and system for specialist in bill field

    CN121936589A