Model tool calling method and device, equipment and medium

By introducing a lightweight tool calling model into the big model, the problem of long-term call time and large computing resources consumption of large model tool calling is solved, achieving faster response and improved user experience.

CN120144708APending Publication Date: 2025-06-13BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510220396.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-26
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

The large model takes a long time during the tool call process, occupying a large amount of computing resources, affecting the response speed and user experience.

Method used

By introducing a lightweight tool calling model, we can determine whether the user input problem needs to call tools, and determine the calling functions and parameters when needed, and replace the big model for tool calling.

Benefits of technology

It reduces the time-consuming tool call, reduces the number of calls to the conversation model, avoids excessive use of computing resources, and improves response speed and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144708A_ABST
    Figure CN120144708A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to a tool calling method and device for a model, equipment and a medium. The method comprises the steps that a target question input by a user is obtained; inputting the target question into a tool calling model, and outputting to obtain a tool calling result; in response to the fact that the tool calling result comprises a target calling function of the target tool, obtaining a target calling parameter of the target calling function; calling the target tool based on the target calling parameter and the target calling function to obtain a tool execution result; and inputting the tool execution result into the dialogue model, and outputting a first target answer corresponding to the target question. According to the embodiment of the invention, a small-scale tool calling model is used for replacing a large-scale dialogue model for tool calling, the dialogue capability and the tool calling capability are decoupled, the tool calling time consumption is greatly reduced, the calling times of the dialogue model are reduced, a large number of computing resources are prevented from being occupied, and the response speed is effectively improved. And the dialogue experience effect of the user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technologies, and in particular, to a method, apparatus, device, and medium for tool invocation of a model. Background Art

[0002] With the development of technologies, large models can understand user requirements, execute complex tasks, and interact with the external world. Among them, the tool call mechanism is one of the core capabilities for large models to interact with external tools. In related technologies, the tool call of large models takes a long time, occupies a large amount of computing resources, affects the response speed, and further affects the user experience. Summary of the Invention

[0003] To solve the above technical problems, the present disclosure provides a method, apparatus, device, and medium for tool invocation of a model.

[0004] An embodiment of the present disclosure provides a method for tool invocation of a model, and the method includes:

[0005] Obtain a target problem input by a user;

[0006] Input the target problem into a tool invocation model, and output a tool invocation result;

[0007] In response to the tool invocation result including a target invocation function of a target tool, obtain target invocation parameters of the target invocation function;

[0008] Call the target tool based on the target invocation parameters and the target invocation function to obtain a tool execution result;

[0009] Input the tool execution result into a dialogue model, and output a first target answer corresponding to the target problem.

[0010] An embodiment of the present disclosure further provides a device for tool invocation of a model, and the device includes:

[0011] An obtaining module, configured to obtain a target problem input by a user;

[0012] A call judgment module, configured to input the target problem into a tool invocation model, and output a tool invocation result;

[0013] A parameter module, configured to, in response to the tool invocation result including a target invocation function of a target tool, obtain target invocation parameters of the target invocation function;

[0014] A tool invocation module, configured to call the target tool based on the target invocation parameters and the target invocation function to obtain a tool execution result;

[0015] An output module, configured to input the tool execution result into a dialogue model and output a first target answer corresponding to the target question.

[0016] An embodiment of the present disclosure further provides an electronic device, which includes: a processor; a memory for storing executable instructions executable by the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the tool call method of the model provided by the embodiment of the present disclosure.

[0017] An embodiment of the present disclosure further provides a computer-readable storage medium, which stores a computer program for executing the tool call method of the model provided by the embodiment of the present disclosure.

[0018] The technical solution provided by the embodiment of the present disclosure has the following advantages compared with the prior art: The tool call solution of the model provided by the embodiment of the present disclosure obtains a target question input by a user; inputs the target question into a tool call model to output a tool call result; in response to the tool call result including a target call function of a target tool, obtains target call parameters of the target call function; calls the target tool based on the target call parameters and the target call function to obtain a tool execution result; inputs the tool execution result into a dialogue model to output a first target answer corresponding to the target question. By adopting the above technical solution, it is determined whether a tool needs to be called for a question input by a user through a tool call model, and when a tool needs to be called, a call function of the tool to be called is determined, the tool is called based on the call function and call parameters to obtain a tool execution result, and the dialogue model outputs an answer to the question based on the tool execution result. A small-scale tool call model is used to replace a large-scale dialogue model for tool call, so as to decouple the dialogue ability and the tool call ability, greatly reduce the tool call time-consuming, reduce the number of calls of the dialogue model, avoid occupying a large amount of computing resources, effectively improve the response speed, and further improve the user dialogue experience effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In combination with the accompanying drawings and with reference to the following specific embodiments, the above and other features, advantages and aspects of the embodiments of the present disclosure will become more obvious. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic and the original elements and elements are not necessarily drawn to scale.

[0020] Figure 1 It is a schematic diagram of the tool call process of the model in the related art;

[0021] Figure 2 It is a schematic diagram of the tool call process of another model in the related art;

[0022] Figure 3Flow chart of the tool invocation method for the model provided by some embodiments of the present disclosure;

[0023] Figure 4 Flow chart of the tool invocation method for another model provided by some embodiments of the present disclosure;

[0024] Figure 5 Schematic diagram of the tool invocation process of the model provided by an embodiment of the present disclosure;

[0025] Figure 6 Schematic diagram of the model processing process provided by some embodiments of the present disclosure;

[0026] Figure 7 Schematic diagram of another model processing process provided by some embodiments of the present disclosure;

[0027] Figure 8 Schematic diagram of the structure of the tool invocation device of the model provided by some embodiments of the present disclosure;

[0028] Figure 9 Schematic diagram of the structure of the electronic device provided by some embodiments of the present disclosure. Detailed implementation manners

[0029] The embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. On the contrary, these embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not used to limit the protection scope of the present disclosure.

[0030] It should be understood that the various steps recorded in the method embodiments of the present disclosure can be executed in a different order and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this regard.

[0031] The term "including" and its variants used herein are open-ended, that is, "including but not limited to". The term "based on" is "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0032] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order of the functions executed by these devices, modules or units or their interdependent relationships.

[0033] It should be noted that the modification of "one" and "multiple" mentioned in this disclosure is illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly specified in the context, it should be understood as "one or more".

[0034] The names of the messages or information exchanged between multiple devices in the embodiments of this disclosure are only for illustrative purposes and are not used to limit the scope of these messages or information.

[0035] In the related art, by way of example, Figure 1 is a schematic diagram of the tool call process of a model in the related art; Figure 2 is a schematic diagram of the tool call process of another model in the related art, such as Figure 1 and Figure 2 shown, Figure 1 shows the process of calling a weather tool to query the weather, including three rounds of follow-up questions, Figure 2 shows the implementation process of the corresponding large model, which may include: after the user inputs a question, the large model determines whether a tool needs to be called. If so, it determines whether the call parameters of the call function are complete; otherwise, it directly generates a text reply; if the call parameters of the call function are complete, the call function and call parameters can be determined, the corresponding tool is parsed and executed, the tool execution result is obtained, a text reply is generated, and returned to the user; if the call parameters of the call function are incomplete, parameters can be obtained through follow-up questions until they are complete. The entire process of tool call is analyzed and implemented by the large model. When calling a tool, it is necessary to take into account tool selection, dialogue ability, and parameter extraction ability, etc., which requires a relatively large model to achieve a relatively usable level in all aspects. The larger the size of the large model, the stronger the reasoning and dialogue ability, but in the scenario of multiple calls during tool call, it will inevitably cause a very large delay overhead requirement, resulting in a poor experience. When the large model makes a tool call, there are the following problems: 1. Efficiency problem, it takes a long time, affecting the response speed. The parameter extraction process may require multiple rounds of dialogue, increasing the overall delay; 2. Resource consumption, each time a reply is generated, it consumes a large number of text processing units (tokens), increasing the computing cost. Frequent calls to the large model will occupy a large amount of computing resources; 3. The interaction experience is poor. The reply stability of the large model is insufficient. Multiple rounds of follow-up questions may lead to a poor user experience. There is a certain degree of randomness and hallucination problem in parameter extraction by the large model. The effects obtained from multiple questions and answers may not be consistent, affecting the user experience. There is a certain hallucination problem in parameter extraction by the large model. For missing parameters, hallucination errors are often extracted, resulting in wrong answers.

[0036] To solve the above problems, the embodiments of this disclosure provide a method for tool call of a model, and the method will be introduced below in combination with specific embodiments.

[0037] Figure 3Schematic flowchart of a tool invocation method for a model provided by some embodiments of the present disclosure. This method can be executed by a tool invocation device of the model, where the device can be implemented using software and / or hardware and is generally integrated in an electronic device. As Figure 3 shown, the method includes:

[0038] Step 101, obtain the target question input by the user.

[0039] The tool invocation method of the model in the embodiments of the present disclosure can be executed by an application program supporting a large model. This application program can interact with the user to implement functions such as knowledge Q&A, information retrieval, writing, and translation. The large model in the embodiments of the present disclosure is a dialogue model based on a large language model. The target question can be the information that the user currently inputs and wants to obtain an answer or complete a certain task. For example, the target question can be "Help me query the weather", which is only an example.

[0040] Specifically, the tool invocation device of the model can obtain the target question in response to the user's input operation.

[0041] Step 102, input the target question into the tool invocation model and output the tool invocation result.

[0042] Among them, the tool invocation model can be a model used to execute the invocation function of external tools during the interaction between the dialogue model and the user. The tool invocation model is a lightweight model that can analyze whether a tool needs to be invoked and select the corresponding tool when needed, obtain the functions and parameters required for invoking the tool to perform tool invocation subsequently. The tool invocation model has characteristics such as relatively simple tasks, easy training, and high inference efficiency. The tool invocation model is used to implement the tool invocation ability, is good at using tools, and can respond more quickly, avoiding the disadvantage of long response caused by the delay of the large model. The tool invocation result can include the result of using the tool invocation model to judge whether a tool needs to be invoked for the target question and the result of extracting the functions and parameters required for the tool. When a tool needs to be invoked, the tool invocation result is the invocation function of the specifically selected tool, and the invocation function includes the extracted invocation parameters. When no tool needs to be invoked, the tool invocation result is the result of not needing to invoke.

[0043] In some embodiments, inputting the target question into the tool invocation model and outputting the tool invocation result may include: constructing a tool invocation prompt word based on the target question and the tool invocation prompt word template; inputting the tool invocation prompt word into the tool invocation model and outputting the tool invocation result.

[0044] Among them, the tool call prompt template can be a template for configuring the content and position included in the tool call prompt, and is used to generate the tool call prompt. In the embodiments of the present disclosure, the tool call prompt template includes a placeholder for filling the target problem. Moreover, the tool call prompt template may include tool description information of multiple tools. The tools can include various types. For example, the tools can include a Bluetooth tool, a weather search tool, an information query tool, a navigation tool, an alarm tool, a schedule tool, etc., without specific limitation. The tool description information can be information for explaining the function and call method of a tool. The tool description information includes the function information, call parameters, and call function of a tool. The call function can be the specific function or method for calling the tool, and the call parameters can be the parameters necessary for the call function to complete the call. A prompt can be a text or statement segment used to trigger and guide the model to execute a specific task and generate specific output content. In the embodiments of the present disclosure, the tool call prompt is used to guide the tool call model to perform judgment, parsing, and parameter extraction for tool calls. The tool call model is used to analyze whether the target problem requires tool calls, and when tool calls are required, determine the target call function of the corresponding target tool and extract the call parameters of the target call function in the target problem. The target problem may include all or part of the parameters of the target call function.

[0045] Specifically, after obtaining the target problem, the tool call device of the model can fill the target problem into the tool call prompt template to construct the tool call prompt, and input the tool call prompt into the tool call model for analysis to output the tool call result. For example, if the target problem is "where is the barbershop", the target tool determined by the tool call model can be an information query tool.

[0046] Step 103, in response to the tool call result including the target call function of the target tool, obtain the target call parameters of the target call function.

[0047] Among them, the target tool can be the tool required to solve the target problem, and can be selected by the tool call model from multiple tools. For example, when the target problem involves querying the weather, the target tool can be a weather search tool. The target call function can be the specific function or code for calling the target tool, and the target call parameters can be the complete parameters required when the target call function executes the call.

[0048] Specifically, after the tool call device of the model determines the tool call result, if the tool call result includes the target call function of the target tool, it indicates that the target problem requires tool calls. At this time, the target call parameters of the target call function can be obtained. Since the target call function may already include some parameters, the acquisition here can be to obtain the remaining parameters by asking the user to obtain the complete target call parameters. When the target call function already includes complete parameters, there is no need to ask.

[0049] Exemplarily, Figure 4 FIG. 5 is a schematic flowchart of a tool call method for another model provided by some embodiments of the present disclosure. In a feasible implementation manner, obtaining the target call parameters of the target call function may include the following steps:

[0050] Step 401: Determine the first parameter in the target call function as the parameter to be matched, and determine whether the parameter to be matched matches the target call parameters of the target tool. If so, execute Step 402; otherwise, execute Step 403.

[0051] Among them, the first parameter may be the parameter of the target call function extracted by the tool call model from the target problem. The first parameter may be the complete parameter, partial parameter or empty parameter of the target call parameter. The parameter to be matched may be the parameter currently matched with the target call parameter of the target call tool. Initially, the parameter to be matched is the first parameter.

[0052] Specifically, when the tool call device of the model obtains the target call parameters of the target call function, it may first match the first parameter in the target call function with the target call parameters, and determine whether the first parameter includes the complete parameters of the target call parameters. If so, execute Step 402; if the first parameter does not match the target call parameters, that is, the first parameter includes partial parameters or empty parameters of the target call parameters, Step 403 can be executed.

[0053] Step 402: Determine the parameter to be matched as the target call parameter.

[0054] Step 403: Use the rule module to obtain the reply template corresponding to the parameter to be matched, and based on the reply template, ask the user to obtain the second parameter. Determine the second parameter and the first parameter as the new parameter to be matched, and return to execute Step 401 until the match is determined.

[0055] Among them, the rule module may include multiple reply templates for multiple call functions of multiple tools. One call function may correspond to multiple reply templates, and each reply template is associated with null parameters, partial parameters, or complete parameters of the call parameters of the corresponding call function. The reply templates corresponding to different parameters may be different. For example, if the target tool is a weather search tool and the target call parameters include date and location, there are three reply templates, which are respectively associated with null parameters, date, and location. The second parameter may be a parameter obtained by asking the user based on the reply template of the first parameter, and may be partial parameters of the target call function. The new parameter to be matched may be the parameter to be matched updated after asking the user, and may be a parameter obtained by combining the first parameter and the second parameter obtained by asking. If further questions are needed later, the new parameter to be matched can be continuously updated by combining the current parameter with the parameter obtained by further asking.

[0056] Specifically, if the parameter to be matched does not match the target call parameter, that is, the first parameter includes partial parameters or null parameters of the target call parameter, it is necessary to continue to ask the user to obtain the remaining parameters. The tool call device of the model can obtain the associated reply template from the rule module according to the first parameter of the parameter to be matched at this time, and display the reply template to the user for questioning, obtain the second parameter input by the user based on the reply template, and combine the second parameter and the first parameter to obtain a new parameter to be matched.

[0057] After the tool call device of the model determines the new parameter to be matched, it returns to continue to judge whether the new parameter to be matched matches the target call parameter until it is determined to match, and determines the parameter to be matched at this time as the target call parameter. That is, it can return to step 401 to judge whether the new parameter to be matched matches the target call parameter, and judge whether the new parameter to be matched includes the complete parameters of the target call parameter. If so, determine the new parameter to be matched as the target call parameter; if the new parameter to be matched does not match the target call parameter, that is, the new parameter to be matched includes partial parameters of the target call parameter, it can return to execute step 403, continue to obtain the reply template of the new parameter to be matched, obtain the third parameter based on the reply template, combine the third parameter and the new parameter to be matched in step 403 to obtain a new parameter to be matched, and return to continue to judge whether the new parameter to be matched matches the target call parameter until it is determined to match, and determine the parameter to be matched at the time of matching as the target call parameter.

[0058] In the above solution, when obtaining the call parameters of the call function of the tool, the reply template pre-set in the rule module is used to replace the questioning logic of the large model result. Compared with the large model for questioning, the latency is greatly reduced and the efficiency of obtaining call parameters is improved.

[0059] Step 104: Call the target tool based on the target call parameter and the target call function to obtain the tool execution result.

[0060] Specifically, after the tool invocation device of the model determines the target invocation parameters, it can invoke the target tool through an interface based on the target invocation function including the target invocation parameters to utilize the target tool to execute the required queries, functions, etc. for the target problem. After the execution is completed, the corresponding tool execution result is obtained. For example, when the target tool is a weather search tool, the weather search tool is used to execute the weather search for the date and location of the target invocation parameters, and the searched weather result is used as the tool execution result.

[0061] Step 105: Input the tool execution result into the dialogue model and output the first target answer corresponding to the target problem.

[0062] Among them, the dialogue model can be a model that interacts with the user in a dialogue form, used to implement functions such as knowledge Q&A, information retrieval, writing, and translation, and has capabilities such as ensuring the authenticity, processability, and factuality of the dialogue ability. The dialogue model can analyze the problem input by the user and answer the problem. In the analysis process, it can call external tools. The dialogue model can be a large language model pre-trained based on a large amount of data, and can be pre-trained through a series of subtasks on the basis of a large amount of data (text, images, videos, etc.), and has a powerful content understanding ability. The first target answer can be the answer output by the dialogue model according to the tool execution result when the target problem needs to call the tool.

[0063] Specifically, after the tool invocation device of the model obtains the tool execution result, it can input the tool execution result and the target problem into the dialogue model. The dialogue model generates the first target answer based on the tool execution result and displays the first target answer to the user.

[0064] Exemplarily, Figure 5 is a schematic diagram of the tool invocation process of the model provided by an embodiment of the present disclosure, as Figure 5As shown in the figure, assume that the target question is "Help me query the weather". Assume that the tool invocation model supports three tools: the music tool, the weather search tool, and the information query tool. The tool invocation model can determine that the target tool is the weather search tool from the three tools according to the target question. The target invocation function includes empty parameters at this time. The target invocation function can be expressed as "get_weather()". The reply template corresponding to the empty parameters is "Okay, which day's weather do you want to query?" Ask the user to obtain the "tomorrow's" input by the user. At this time, the target invocation function can be expressed as "get_weather(tomorrow)". The parameter to be matched is "tomorrow". The parameter to be matched does not include the complete parameters of the target invocation parameter. The corresponding reply template at this time can be "Okay, which city's weather do you need to query specifically tomorrow?" Ask the user to obtain the "City A" input by the user. At this time, the target invocation function can be expressed as "get_weather(tomorrow, City A)". The parameters to be matched are "tomorrow" and "City A". The parameters to be matched include the complete parameters of the target invocation parameter. The parameter to be matched is the target invocation parameter; the weather search tool is called through the target invocation function including the target invocation parameter to execute the weather query, and the weather information is obtained in real time as the tool execution result. The weather information is input into the dialogue model, and the first target answer output can be "The weather in City A tomorrow is 20 degrees, and it is sunny." The tool invocation function expands the practicality of the dialogue model. It can not only implement conversation tasks but also complete dynamic interactions with various digital services and applications at the same time.

[0065] In the related technology, adding new tool invocation capabilities to the large model may require large-scale retraining or fine-tuning, with a relatively high cost. In this solution, a lightweight small model is used to achieve more efficient and flexible parameter extraction and tool invocation. The training cost of the small model is relatively lower and the efficiency is higher, which expands the efficiency and scalability of the dialogue model in practical applications, especially in scenarios where tool invocation is required frequently.

[0066] The tool invocation solution of the model provided by the embodiments of the present disclosure obtains the target problem input by the user; inputs the target problem into the tool invocation model to output the tool invocation result; in response to the tool invocation result including the target invocation function of the target tool, obtains the target invocation parameters of the target invocation function; calls the target tool based on the target invocation parameters and the target invocation function to obtain the tool execution result; inputs the tool execution result into the dialogue model to output the first target answer corresponding to the target problem. By adopting the above technical solution, the tool invocation model determines whether a tool needs to be invoked for the problem input by the user, and when a tool needs to be invoked, determines the invocation function of the tool that needs to be invoked. The tool is called based on the invocation function and the invocation parameters to obtain the tool execution result, and the dialogue model outputs the answer to the problem based on the tool execution result. A small-scale tool invocation model is used to replace the large-scale dialogue model for tool invocation, which greatly reduces the tool invocation time, reduces the number of calls to the dialogue model, avoids occupying a large amount of computing resources, effectively improves the response speed, and further improves the user dialogue experience effect.

[0067] In some embodiments, after inputting the target problem into the tool invocation model and outputting the tool invocation result, the tool invocation method of the model may further include: in response to the tool invocation result indicating that no tool needs to be invoked, inputting the target problem into the dialogue model to output the second target answer corresponding to the target problem.

[0068] Among them, the second target answer may be the answer output by the dialogue model when the target problem does not require tool invocation, and the second target answer may be the reply when the target problem is for casual chat. When the tool invocation device of the model selects from multiple tools through the tool invocation model and determines that none of them meet the requirements, the rejection function can be used as the tool invocation result to indicate that no tool needs to be invoked. If it is determined that the tool invocation result does not require tool invocation, the target problem can be directly input into the dialogue model. After analysis and processing by the dialogue model, the second target answer is output and the second target answer is displayed. By using the rejection function in the tool invocation model to process the output of non-tool invocation problems, the judgment efficiency and judgment accuracy of non-tool invocation are improved.

[0069] In the related art, when unable to reply to the user or unable to meet the user's needs, the model may generate a long explanation instead of a concise rejection signal. In this solution, the tool invocation model of the present disclosure outputs a rejection signal indicating that no tool needs to be invoked and inputs it into the dialogue model, enabling the dialogue model to quickly process problems with non-tool invocation intentions and generate corresponding replies, optimizing the rejection processing flow. The single rejection signal achieves the effects of high efficiency, stability, and simple judgment.

[0070] In some embodiments, after obtaining the target question input by the user, the tool invocation method of the model may further include: inputting the target question into the intent recognition model, and outputting an intent result, where the intent result includes a tool invocation intent or a non-tool invocation intent; where inputting the target question into the tool invocation model and outputting a tool invocation result includes: in response to the intent result being a tool invocation intent, performing inputting the target question into the tool invocation model and outputting a tool invocation result.

[0071] Among them, the intent recognition model may be a model for recognizing the intent of the target question, and is used to analyze whether the target question belongs to a tool invocation intent or a non-tool invocation intent. The intent recognition model may be a pre-trained small model, and the specific type is not limited. The tool invocation intent may be an intent that requires tool invocation, and the non-tool invocation intent may be an intent that does not require tool invocation. The intent result may be the result output by the intent recognition model after intent recognition. After obtaining the target question, the tool invocation device of the model may first input the target question into the intent recognition model, and obtain an intent result after being processed by the intent recognition model. If the intent result is a tool invocation intent, the above step 102 may be executed; if the intent result is a non-tool intent result, the target question may be directly input into the dialogue model, and a second target answer to the target question may be output. Through the intent recognition of the intent recognition model, the steps and time for the tool invocation model to judge whether tool invocation is required can be effectively saved, and the efficiency can be further improved.

[0072] In some embodiments, before inputting the target question into the tool invocation model and outputting a tool invocation result, the invocation method of the model may further include: using a tool recall module to screen a preset number of candidate tools corresponding to the target question from multiple tools, so that the tool invocation model can select from the preset number of candidate tools.

[0073] Among them, the tool recall module may be a module that pre-screens a preset number of tools that may be the most matched with the target question from multiple tools. When the number of tools is large, the tool recall module can narrow the scope from a large number of tools. The candidate tools may be the tools that are most likely to be hit determined by the tool recall module according to the recall rule. The number of candidate tools is a preset number, and the preset number may be set according to the actual situation. For example, the preset number may be 10.

[0074] Specifically, before the model calling device executes step 102, the target problem can be recalled by the tool recall module, and a preset number of candidate tools can be extracted from multiple tools based on the target problem according to the recall rule. The recall rule can be set according to the actual situation. For example, the recall rule can be similarity. Then, when executing step 102, when the tool calling model determines that the target problem requires tool calling, the target tool corresponding to the target problem can be determined from the preset number of candidate tools, and the range of tools that may be hit can be narrowed by the tool recall module, reducing the consumption of the text processing unit, effectively improving the efficiency and accuracy of the tool calling model to determine the tool, further reducing the latency, and improving the tool calling efficiency.

[0075] Next, a specific example is used to further illustrate the tool calling method of the model in the embodiments of the present disclosure. Exemplarily, Figure 6 is a schematic diagram of the model processing process provided by some embodiments of the present disclosure. As Figure 6 shown, in the figure, it is taken as an example that the application includes an intent recognition model, a dialogue agent, and a tool agent. The dialogue agent includes a dialogue model, and the tool agent includes a tool recall module and a tool calling model. The specific model processing process may include: the user inputs a target problem, and inputs the target problem into the intent recognition model, and the output obtains an intent result including a tool calling intent or a non-tool calling intent; when the intent result is a tool calling intent, a preset number of candidate tools can be first extracted from multiple tools based on the target problem by the tool recall module according to the recall rule. Then, when the tool calling model determines that the target problem requires tool calling, the target tool corresponding to the target problem can be determined from the preset number of candidate tools, and a tool calling result including the target calling function of the target tool is output, and the target tool is called based on the tool calling result to obtain a tool execution result, and the tool execution result is input into the dialogue model for summary reply, and the first target answer corresponding to the target problem is output; when the intent result is a non-tool calling intent, the target problem can be input into the dialogue model for summary reply, and the second target answer corresponding to the target problem is output.

[0076] In the above solution, based on the enhancement of the capabilities of the agent, the dialogue ability and the tool calling ability can be decoupled. The dialogue model is responsible for completing user dialogue problems, such as knowledge answering, information retrieval, writing, translation, etc., to ensure the authenticity, processability, factuality, etc. of the dialogue ability; the tool agent dialogue model is responsible for completing the tool calling ability, is good at using tools, and can respond more quickly, avoiding the long response caused by the latency of the large model. Commonly used tools can include, for example, Bluetooth tools, weather search tools, information query tools, navigation tools, alarm tools, and schedule tools, etc.

[0077] Exemplarily, Figure 7A schematic diagram of another model processing process provided by some embodiments of the present disclosure. As Figure 7 shown, the model processing process in the figure may include: a user inputs a question; whether to call a tool. If so, the tool calls the model to determine the call function and call parameters, and then it can be determined whether the call parameters of the call function are complete. If so, the corresponding basis is parsed and executed, and the dialogue model obtains the tool execution result and generates a text reply to return to the user; otherwise, the parameters are obtained by asking questions based on the reply template until the call parameters are complete. If there is no need to call the tool, the dialogue model directly generates a text reply to return to the user.

[0078] In this solution, a small-scale tool call model is used to replace the large-scale dialogue model for tool calls, reducing the call latency each time and reducing the number of calls to the dialogue model, avoiding occupying a large amount of computing resources; by setting a tool call model dedicated to tool calls and parameter extraction, since this model has been specifically strengthened, the parameter extraction ability of the small model can be enhanced, and the tool call and parameter extraction efficiency can be improved, and the effect of the large model can be optimized in a targeted manner; the delay caused by multi-round question asking is reduced through the reply template; the rejection recognition processing process is optimized, and a single signal rejection recognition signal is used to efficiently and stably handle the rejection recognition situation; the capabilities of the large and small models are fully combined to effectively achieve the accurate call of the tool, overall improving the system response speed and user experience, and improving the scalability and adaptability of the model.

[0079] Figure 8 A schematic diagram of the structure of a tool call device of a model provided by some embodiments of the present disclosure. This device can be implemented by software and / or hardware and is generally integrated in an electronic device. As Figure 8 shown, this device includes:

[0080] An acquisition module 801, configured to acquire a target question input by a user;

[0081] A call judgment module 802, configured to input the target question into a tool call model and output a tool call result;

[0082] A parameter module 803, configured to, in response to the tool call result including a target call function of a target tool, acquire target call parameters of the target call function;

[0083] A tool call module 804, configured to call the target tool based on the target call parameters and the target call function to obtain a tool execution result;

[0084] An output module 805, configured to input the tool execution result into a dialogue model and output a first target answer corresponding to the target question.

[0085] Optionally, the call judgment module 802 is configured to:

[0086] Construct a tool call prompt based on the target problem and the tool call prompt template;

[0087] Input the tool call prompt into the tool call model to obtain a tool call result. The tool call model is used to analyze whether the target problem requires tool calls, and when tool calls are required, determine the target call function of the corresponding target tool and extract the call parameters of the target call function in the target problem.

[0088] Optionally, the tool call prompt template includes tool description information of multiple tools. The tool description information includes the function information, call parameters, and call function of a tool.

[0089] Optionally, the parameter module 803 is used for:

[0090] Determine the first parameter in the target call function as the parameter to be matched, and determine whether the parameter to be matched matches the target call parameters of the target tool. If so, determine the parameter to be matched as the target call parameter;

[0091] Otherwise, use the rule module to obtain the reply template corresponding to the parameter to be matched, and ask the user for the second parameter based on the reply template. Combine the second parameter and the first parameter to determine a new parameter to be matched, and return to continue to determine whether the new parameter to be matched matches the target call parameter until a match is determined.

[0092] Optionally, the device further includes a second output module, which is used for: after inputting the target problem into the tool call model and obtaining a tool call result,

[0093] In response to the tool call result indicating that tool calls are not required, input the target problem into the dialogue model to obtain the second target answer corresponding to the target problem.

[0094] Optionally, the device further includes an intention module, which is used for: after obtaining the target problem input by the user,

[0095] Input the target problem into the intention recognition model to obtain an intention result. The intention result includes a tool call intention or a non-tool call intention;

[0096] Among them, the call judgment module 802 is used for:

[0097] In response to the intention result being the tool call intention, execute the operation of inputting the target problem into the tool call model to obtain a tool call result.

[0098] Optionally, the device further includes a recall module for, before inputting the target question into the tool invocation model and obtaining a tool invocation result,

[0099] using a tool recall module to screen a preset number of candidate tools corresponding to the target question from multiple tools, so that the tool invocation model can select from the preset number of candidate tools.

[0100] The tool invocation device of the model provided by the embodiments of the present disclosure can execute the tool invocation method of the model provided by any embodiment of the present disclosure, and has corresponding functional modules and beneficial effects for executing the method.

[0101] The embodiments of the present disclosure also provide a computer program product, including a computer program / instructions, which when executed by a processor, implement the tool invocation method of the model provided by any embodiment of the present disclosure.

[0102] Figure 9 It is a schematic structural diagram of an electronic device provided by some embodiments of the present disclosure.

[0103] Specifically refer to Figure 9 , which shows a schematic structural diagram of an electronic device 900 suitable for implementing the embodiments of the present disclosure. The electronic device 900 in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (PADs), portable media players (PMPs), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 9 The electronic device shown is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present disclosure.

[0104] As Figure 9As shown, the electronic device 900 may include a processing device 901 (such as a central processing unit, a graphics processing unit, etc.), which may perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 902 or the program loaded from the storage device 908 into the random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the electronic device 900 are also stored. The processing device 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. The input / output (I / O) interface 905 is also connected to the bus 904.

[0105] Generally, the following devices may be connected to the I / O interface 905: an input device 906 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 908 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 909. The communication device 909 may allow the electronic device 900 to communicate with other devices wirelessly or wirelesly to exchange data. Although Figure 9 the electronic device 900 with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices may be implemented or had.

[0106] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart may be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes program codes for executing the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from the network through the communication device 909, or installed from the storage device 908, or installed from the ROM 902. When the computer program is executed by the processing device 901, the above functions defined in the method for calling the tool of the model of the embodiment of the present disclosure are executed.

[0107] It should be noted that the above-mentioned computer-readable medium in the present disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory, a read-only memory, an electrically erasable programmable read-only memory (EPROM), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable signal medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, radio frequency (RF), etc., or any suitable combination of the above.

[0108] In some embodiments, the client and the server can communicate using any currently known or future-developed network protocol such as the HyperText Transfer Protocol (HTTP), and can be interconnected with digital data communication in any form or medium (for example, a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), the Internet (for example, the Internet), and end-to-end networks (for example, ad hoc end-to-end networks), as well as any currently known or future-developed networks.

[0109] The above-mentioned computer-readable medium can be included in the above-mentioned electronic device; it can also exist separately and not be assembled into the electronic device.

[0110] The above computer-readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: obtain a target question input by a user; input the target question into a tool invocation model to output a tool invocation result; in response to the tool invocation result including a target invocation function of a target tool, obtain target invocation parameters of the target invocation function; call the target tool based on the target invocation parameters and the target invocation function to obtain a tool execution result; and input the tool execution result into a dialogue model to output a first target answer corresponding to the target question.

[0111] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or combinations thereof. The programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may execute entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network or a wide area network, or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0112] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that, in some alternative implementations, the functions marked in the blocks may occur in an order different from that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system for performing the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.

[0113] The units described in the embodiments of the present disclosure may be implemented in software or in hardware. In some cases, the name of the unit does not constitute a limitation on the unit itself.

[0114] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: Field-Programmable Gate Array (FPGA), Application Specific Integrated Circuit (ASIC), Application Specific Standard Parts (ASSP), System on Chip (SOC), Complex Programmable Logic Device (CPLD), and so on.

[0115] In the context of this disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memories, read-only memories, erasable programmable read-only memories, flash memories, optical fibers, portable compact disk read-only memories, optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0116] It can be understood that before using the technical solutions disclosed in the various embodiments of this disclosure, the type, scope of use, usage scenarios, etc. of the information involved in this disclosure should be informed to users and the authorization of users should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0117] The above description is only for the preferred embodiments of this disclosure and the explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in this disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the (but not limited to) technical features with similar functions disclosed in this disclosure.

[0118] Moreover, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the present disclosure. Certain features that are described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, the various features that are described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.

[0119] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. On the contrary, the specific features and acts described above are merely example forms of implementing the claims.

Claims

1. A tool calling method for a model, characterized in that: include: Get the target question input by the user; Input the target problem into the tool calling model, and output the tool calling result; In response to the tool calling result including a target calling function of a target tool, obtaining a target calling parameter of the target calling function; Calling the target tool based on the target calling parameter and the target calling function to obtain a tool execution result; The tool execution result is input into the dialogue model, and a first target answer corresponding to the target question is output.

2. The method according to claim 1, characterized in that The target problem is input into the tool calling model, and the tool calling result is output, including: Building a tool call prompt word based on the target problem and the tool call prompt word template; The tool call prompt word is input into the tool call model, and a tool call result is output, wherein the tool call model is used to analyze whether the target problem requires a tool call, and when a tool call is required, determine the target call function corresponding to the target tool and extract the call parameters of the target call function in the target problem.

3. The method according to claim 2, characterized in that The tool calling prompt word template includes tool description information of multiple tools, and the tool description information includes function information, calling parameters and calling functions of a tool.

4. The method according to claim 1, characterized in that: Obtaining the target calling parameters of the target calling function includes: Determine the first parameter in the target calling function as the parameter to be matched, determine whether the parameter to be matched matches the target calling parameter of the target tool, and if so, determine the parameter to be matched as the target calling parameter; Otherwise, the rule module is used to obtain the reply template corresponding to the parameter to be matched, and based on the reply template, the user is asked to obtain a second parameter, the second parameter and the first parameter are combined to determine a new parameter to be matched, and the process returns to continue to determine whether the new parameter to be matched matches the target call parameter until a match is determined.

5. The method according to claim 1, characterized in that: After inputting the target problem into the tool calling model and outputting the tool calling result, the method further includes: In response to the tool calling result being that the tool does not need to be called, the target question is input into the dialogue model, and a second target answer corresponding to the target question is output.

6. The method according to claim 1, characterized in that After obtaining the target question input by the user, the method further includes: Input the target problem into the intention recognition model, and output an intention result, wherein the intention result includes a tool call intention or a non-tool call intention; The step of inputting the target problem into a tool calling model and outputting a tool calling result includes: In response to the intention result being the tool calling intention, the target problem is input into the tool calling model, and a tool calling result is output.

7. The method according to claim 1, characterized in that Before inputting the target problem into the tool calling model and outputting the tool calling result, the method further includes: A tool recall module is used to screen a preset number of candidate tools corresponding to the target problem from a plurality of tools, so that the tool calling model selects from the preset number of candidate tools.

8. A tool calling device for a model, characterized in that: include: An acquisition module is used to obtain the target question input by the user; A calling judgment module is used to input the target problem into the tool calling model and output a tool calling result; A parameter module, configured to obtain a target calling parameter of the target calling function in response to the tool calling result including the target calling function of the target tool; A tool calling module, used for calling the target tool based on the target calling parameter and the target calling function to obtain a tool execution result; The output module is used to input the tool execution result into the dialogue model and output the first target answer corresponding to the target question.

9. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the executable instructions to implement the tool calling method of the model described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program is used to execute the tool calling method of the model described in any one of claims 1-7.