Tool calling and tool calling model training method and data generation model training method
By using a data generation model to perform data augmentation and training in the information retrieval system, high-quality query data is generated, and the tool invocation model is optimized. This solves the problems of insufficient training data and parameter imbalance in the existing system, and enables more efficient tool invocation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ALIBABA (CHINA) CO LTD
- Filing Date
- 2024-10-15
- Publication Date
- 2026-04-17
AI Technical Summary
Existing information retrieval systems suffer from a lack of high-quality training data and uneven distribution of tool call parameters when processing complex time-dependent queries. This results in the inability to quickly and accurately call the correct tools, thus failing to meet users' needs for real-time information.
By determining the target intent and tool invocation parameters, data augmentation is performed using a data generation model to generate high-quality query data. The tool invocation model is then trained to optimize tool invocation accuracy. Adversarial training and knowledge distillation techniques are employed to improve the model's accuracy and efficiency.
It significantly improves the accuracy and efficiency of tool invocation models, reduces the occurrence of incorrect tool invocations, and enhances the system's responsiveness when handling complex and time-sensitive queries.
Smart Images

Figure CN121880981A_ABST
Abstract
Description
Technical Field
[0001] The embodiments in this specification relate to the field of computer technology, and in particular to a tool invocation and tool invocation model training method, and a data generation model training method. Background Technology
[0002] With the continuous development of information technology, users' demand for real-time information is increasing. In information fields that require continuous updates, such as weather forecasts and news reports, users expect to be able to quickly obtain the latest information and analysis.
[0003] However, existing information retrieval systems face significant challenges in meeting such real-time information acquisition needs, especially when dealing with complex time-dependent queries that involve not only the past and present but also future predictions, which places higher demands on the system's understanding and parsing capabilities.
[0004] The emergence of Large Language Models (LLMs) has made handling complex queries more feasible. Specifically, LLMs can dynamically invoke external tools or services to assist or enhance their capabilities when processing query tasks. However, existing models often perform poorly when handling time-sensitive queries. This is mainly because the training data used lacks high quality and sufficient annotation, and there is an imbalance in the distribution of tool invocation parameters. Therefore, they cannot quickly and accurately invoke the correct tools, resulting in the system failing to fully meet user expectations when handling time-sensitive scheduling and real-time information needs. Summary of the Invention
[0005] In view of this, embodiments of this specification provide a tool invocation model training method, a data generation model training method, and a tool invocation method. One or more embodiments of this specification also relate to a tool invocation model training device, a data generation model training device, a tool invocation device, a computing device, a computer-readable storage medium, and a computer program product, to solve the technical defects in the prior art where the lack of high-quality, adequately labeled training data and the uneven distribution of tool invocation parameters prevent the rapid and accurate invocation of the correct tool to accurately respond to user needs.
[0006] According to a first aspect of the embodiments of this specification, a tool-invoking model training method is provided, comprising: Determine the target intent and the target tool invocation parameters corresponding to the target intent; The target intent is input into the data generation model to obtain the target query data corresponding to the target intent. The data generation model is obtained by training the initial data generation model through positive and negative sample pairs composed of intent samples and query data samples. The positive and negative sample pairs are determined by a preset sample classification method. The query data samples are determined by data augmentation of the intent samples. Input the target query data into the initial tool invocation model to obtain the prediction tool invocation parameters; The initial tool invocation model is trained based on the predicted tool invocation parameters and the target tool invocation parameters to obtain the tool invocation model.
[0007] According to a second aspect of the embodiments of this specification, a data generation model training method is provided, comprising: Determine the intent sample; The intent sample is input into the initial data generation model to obtain the query data sample; Using a preset sample classification method, determine the positive and negative sample pairs consisting of the intent sample and the query data sample; The initial data generation model is trained based on the positive and negative sample pairs to obtain the data generation model.
[0008] According to a third aspect of the embodiments of this specification, a tool invocation method is provided, including: The target query data is determined and input into the tool invocation model to obtain the tool invocation parameters corresponding to the target query data. The tool invocation model is obtained through the tool invocation model training method described above. Use the tool's call parameters to determine the target tool; Invoke the target tool to obtain the target processing result corresponding to the target query data.
[0009] According to a fourth aspect of the embodiments of this specification, a tool-invoking model training apparatus is provided, comprising: The data determination module is configured to determine the target intent and the target tool invocation parameters corresponding to the target intent; The data acquisition module is configured to input the target intent into the data generation model to obtain the target query data corresponding to the target intent. The data generation model is obtained by training an initial data generation model through positive and negative sample pairs composed of intent samples and query data samples. The positive and negative sample pairs are determined by a preset sample classification method, and the query data samples are determined by data augmentation of the intent samples. The parameter acquisition module is configured to input the target query data into the initial tool invocation model to obtain the prediction tool invocation parameters; The model training module is configured to train the initial tool invocation model based on the prediction tool invocation parameters and the target tool invocation parameters, thereby obtaining the tool invocation model.
[0010] According to a fifth aspect of the embodiments of this specification, a data generation model training apparatus is provided, comprising: The sample determination module is configured to determine the intent sample; The data acquisition module is configured to input the intent sample into the initial data generation model to obtain the query data sample; The sample classification module is configured to use a preset sample classification method to determine the positive and negative sample pairs consisting of the intent sample and the query data sample; The model training module is configured to train the initial data generation model based on the positive and negative sample pairs to obtain the data generation model.
[0011] According to a sixth aspect of the embodiments of this specification, a tool invocation device is provided, comprising: The data acquisition module is configured to determine the target query data and input the target query data into the tool invocation model to obtain the tool invocation parameters corresponding to the target query data, wherein the tool invocation model is obtained through the tool invocation model training method described above; The tool determination module is configured to determine the target tool using the tool invocation parameters. The result acquisition module is configured to call the target tool to obtain the target processing result corresponding to the target query data.
[0012] According to a seventh aspect of the embodiments of this specification, a computing device is provided, comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, they implement the steps of the tool invocation model training method, the data generation model training method, and the tool invocation method described above.
[0013] According to an eighth aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores a computer program / instructions, which, when executed by a processor, implement the steps of the above-described tool invocation model training method, data generation model training method, and tool invocation method.
[0014] According to a ninth aspect of the embodiments of this specification, a computer program product is provided, including a computer program / instructions that, when executed by a processor, implement the steps of the above-described tool invocation model training method, data generation model training method, and tool invocation method.
[0015] This specification provides a tool invocation model training method in one embodiment. This method generates a model from target intent input data to obtain target query data corresponding to the target intent. The data generation model is trained using positive and negative sample pairs composed of intent samples and query data samples. Furthermore, the query data samples are determined by data augmentation of the intent samples. Therefore, the target query data output by the data generation model is also high-quality query data corresponding to the target intent and augmented with data. Thus, by using an initial tool invocation model to obtain predicted tool invocation parameters corresponding to the target query data, and then training the initial tool invocation model based on these predicted tool invocation parameters and the target tool invocation parameters corresponding to the target intent, the tool invocation accuracy of the tool invocation model is optimized by improving the quality of the training data (target query data). This significantly reduces the phenomenon of incorrect tool invocation and improves the accuracy of tool invocation. In the process of generating target query data and optimizing the tool invocation model, by integrating accurate tool invocation parameter parsing, the tool invocation model can achieve high efficiency when handling complex and time-sensitive queries. Attached Figure Description
[0016] Figure 1 This is a schematic diagram illustrating a scenario of a tool invocation method provided in one embodiment of this specification; Figure 2 This is a flowchart illustrating a tool-invoking model training method provided in one embodiment of this specification; Figure 3 This is a flowchart illustrating a data generation model training method provided in one embodiment of this specification; Figure 4 This is a flowchart illustrating a tool invocation method provided in one embodiment of this specification; Figure 5 This is a schematic diagram of an adversarial training process provided in one embodiment of this specification; Figure 6 This is a schematic diagram of the structure of a tool-calling model training device provided in one embodiment of this specification; Figure 7 This is a schematic diagram of the structure of a data generation model training device provided in one embodiment of this specification; Figure 8 This is a schematic diagram of the structure of a tool calling device provided in one embodiment of this specification; Figure 9 This is a structural block diagram of a computing device provided in one embodiment of this specification. Detailed Implementation
[0017] Many specific details are set forth in the following description to provide a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0018] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0019] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0020] Furthermore, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties. Moreover, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0021] First, the terms and concepts used in one or more embodiments of this specification will be explained.
[0022] LLM: Large Language Model. A large language model is a type of model that uses deep learning techniques to obtain a high level of language understanding and generation capabilities by training on massive amounts of text data. RAG: Retrieval-Augmented Generation is a technique that combines language generation with information retrieval. It enhances the understanding and generation capabilities of an LLM model by connecting external data sources to it. Information retrieval is a technique for quickly finding relevant documents from a large collection of unstructured documents. SFT: Supervised Fine-tuning, refers to the technique of using labeled data to adjust a pre-trained model to better suit a specific task. Alignment: Alignment refers to ensuring that the output of an LLM aligns with human expectations and values. In practice, this often involves specific technical approaches such as RLHF (Reinforcement Learning from Human Feedback) and DPO (Direct Preference Optimization). Reward Model: A reward model is a type of model used in reinforcement learning (RL) and human-computer alignment tasks to evaluate and assign reward signals to guide the model in generating expected outputs. Training a reward model allows for better measurement and prediction of the quality and relevance of the output, thereby improving the performance of LLM. Reward models are often combined with techniques such as RLHF (Reinforcement Learning with Human Feedback) to further optimize the model's behavior and alignment through human feedback. Tool Use: Tool use refers to the ability of a model to dynamically invoke external tools or services to assist or enhance its capabilities when processing tasks. Synthetic data refers to datasets created manually or automatically by tools for training and evaluating models. This specification provides a tool invocation model training method, a data generation model training method, and a tool invocation method. This specification also relates to a tool invocation model training device, a data generation model training device, a tool invocation device, a computing device, a computer-readable storage medium, and a computer program product, which will be described in detail in the following embodiments.
[0023] See Figure 1 , Figure 1 A schematic diagram of a tool invocation method provided according to an embodiment of this specification is shown. Specifically, the tool's calling method is implemented using the application-side device 102 and the server 104. The application-side device 102 is used to send target query data to the server 104, such as "What clothes would be suitable to wear if I go out today?" In practical applications, users can input target query data into the application-side device 102 via text or voice. If voice is used, the application-side device 102 will also include corresponding voice processing components, such as voice parsing, voice-to-text conversion, and voice synthesis modules, to convert the target query data input by the user via voice into text. This specification does not impose any restrictions on this.
[0024] A tool invocation model is trained in server 104. When server 104 receives target query data sent by end device 102, it inputs the target query data into the tool invocation model to obtain the tool invocation parameters corresponding to the target query data. Using the tool invocation parameters, the target tool is determined (e.g., the target tool is the "weather" tool). The target tool is invoked to obtain the target processing result corresponding to the target query data (e.g., the target processing result is "Today's temperature is 20 degrees Celsius, cloudy, suitable for wearing long-sleeved clothes").
[0025] The edge device 102 may include a browser, an app (application), or a web application such as an H5 (Hypertext Markup Language 5) application, a lightweight application (also known as a mini-program), or a cloud application. The edge device can be developed based on a software development kit (SDK) provided by the server, such as a real-time communication (RTC) SDK. The edge device can be deployed in an electronic device and depends on the device's operation or certain apps within the device to run. The electronic device may have a display screen and support information browsing, such as a personal mobile terminal like a mobile phone, tablet, or personal computer. Various other types of applications can also be configured in the electronic device, such as human-computer interaction applications, model training applications, tool calling applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, and social media platform software.
[0026] Server 104 can be understood as a server providing various services, including physical servers and cloud servers. Examples include servers providing communication services to multiple clients, servers supporting backend training of models used on clients, and servers processing data sent by clients. It's important to note that Server 104 can be implemented as a distributed server cluster composed of multiple servers, or as a single server. Server 104 can also be a server in a distributed system, or a server integrated with blockchain. Server 104 can also be a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.
[0027] It is worth noting that the tool invocation method provided in the embodiments of this specification can be executed by the server 104. In other embodiments of this specification, the tool invocation model can be deployed in the end-side device 102, so that the end-side device 102 can also have similar functions to the server 104, thereby executing the tool invocation method provided in the embodiments of this specification. In other embodiments, the tool invocation method provided in the embodiments of this specification can also be jointly executed by the end-side device 102 and the server 104.
[0028] This specification provides a tool invocation model training method in one embodiment. By generating a model from target intent input data, the method obtains target query data corresponding to the target intent. The data generation model is trained using positive and negative sample pairs composed of intent samples and query data samples. Furthermore, the query data samples are determined by data augmentation of the intent samples. Therefore, the target query data output by the data generation model is also high-quality query data corresponding to the target intent and augmented with data. Thus, by using an initial tool invocation model to obtain predicted tool invocation parameters corresponding to the target query data, and then training the initial tool invocation model based on these predicted parameters and the target tool invocation parameters corresponding to the target intent, the method optimizes the tool invocation accuracy of the tool invocation model by improving the quality of the training data (target query data), significantly reducing erroneous tool invocations and improving the accuracy of tool invocation. In the process of generating target query data and optimizing the tool invocation model, by integrating accurate tool invocation parameter parsing, the tool invocation model can achieve high efficiency when handling complex and time-sensitive queries.
[0029] See Figure 2 , Figure 2The flowchart of a tool invocation model training method provided in one embodiment of this specification is shown, which specifically includes the following steps.
[0030] Step 202: Determine the target intent and the target tool invocation parameters corresponding to the target intent.
[0031] Here, the target intent can be understood as the actor's true purpose. For example, when a user asks "What clothes should I wear today?", the user's target intent is "What will the weather be like on January 1, 2024?" The target tool invocation parameters can be understood as the attribute parameters of the tool that needs to be used when responding to the target intent. That is, using the target tool invocation parameters can call the correct tool to respond correctly to the target intent. Continuing with the previous example, the target tool invocation parameters corresponding to the target intent can include "Tool name: Weather, Location parameter: Beijing, Date parameter: January 1, 2024".
[0032] In practical applications, determining the target intent and the target tool invocation parameters corresponding to the target intent includes: Determine the original intent and additional information, wherein the additional information is background information used to describe the original intent; Based on the original intent and the additional information, the target intent and the target tool invocation parameters corresponding to the target intent are determined.
[0033] The original intent can be understood as intent data generated from a random seed. It's a broad concept, and without additional information, the tool call parameters corresponding to that original intent cannot be clearly defined. For example, the original intent might be intent data composed of "today," "tomorrow," "next week," "weather," or "news." Additional information further defines the contextual information of the original intent, helping to more accurately understand specific needs or expectations. For example, additional information could include current time, current location, and other contextual information. This contextual information can be understood as the implicit contextual information included when a user sends their original intent. For instance, when a user's original intent is to inquire about the weather, the contextual information includes, but is not limited to, time and location information; when a user's original intent is to seek recommendations, the contextual information includes, but is not limited to, information about user behavior and preferences.
[0034] For example, if the additional information includes "the current time is January 1, 2024", then if the original intent is "to check today's weather", it can be determined that the target intent is "to check the weather on January 1, 2024", and the target tool call parameters include tool name: weather, date parameter: January 1, 2024.
[0035] The tool invocation model training method provided in the embodiments of this specification can more accurately determine the true target intent and the corresponding target tool invocation parameters by accurately understanding the original intent and additional information, thereby providing a data foundation for subsequent training of the tool invocation model using the accurate target intent and target tool invocation parameters.
[0036] Step 204: Input the target intent into the data generation model to obtain the target query data corresponding to the target intent. The data generation model is obtained by training the initial data generation model through positive and negative sample pairs composed of intent samples and query data samples. The positive and negative sample pairs are determined by a preset sample classification method. The query data samples are determined by data augmentation of the intent samples.
[0037] The intent sample can be a series of collected samples containing user intent, or an intent sample synthesized through random seeding, etc., without limitation. Data augmentation can be understood as enriching a simple intent into a variety of complex queries; for example, if the intent sample is "check the weather in Beijing today", the query data sample could be "what clothes to wear if I go to Beijing today".
[0038] Specifically, when the data generation model is trained using positive and negative samples consisting of intent samples and query data samples, diverse and complex target query data can be obtained by inputting the target intent into the data generation model.
[0039] In one or more embodiments of this specification, a positive and negative sample pair consisting of intent samples and query data samples is determined by a preset sample classification method. This positive and negative sample pair is then used to train an initial data generation model, thereby improving the complexity of the query data generated by the data generation model. Specific implementation methods are described below: Before generating a model from the target intent input data to obtain the target query data corresponding to the target intent, the method further includes: Determine the intent sample; The intent sample is input into the initial data generation model to obtain the query data sample; Using a preset sample classification method, determine the positive and negative sample pairs consisting of the intent sample and the query data sample; The initial data generation model is trained based on the positive and negative sample pairs to obtain the data generation model.
[0040] The preset sample classification method can be understood as defining a set of clear rules to determine the positive or negative category of the initial sample pair consisting of the generated query data sample and the intent sample; these rules can be based on factors such as semantic similarity, keyword matching, and contextual consistency.
[0041] Specifically, a series of intent samples representing different user intentions are collected or synthesized. The intent samples can be in text form, such as query requests, commands, or instructions. A basic initial data generation model is selected, which can be a simple sequence-to-sequence (Seq2Seq) model, a text generation model, or any other model suitable for generating text data. The intent samples are input into the initial data generation model, which generates corresponding query data samples based on the learned mapping relationship.
[0042] Using a preset sample classification method, positive and negative sample pairs consisting of intent samples and query data samples are determined. For example, if the query data samples are determined to be complex enough and have a high degree of consistency with the intent samples according to the preset sample classification method, the intent samples and query data samples are determined to form a positive sample pair; otherwise, a negative sample pair is formed. This positive and negative sample pair is used to perform SFT on the initial data generation model to obtain a data generation model, so as to obtain sufficiently complex and diverse query data through the data generation model.
[0043] The initial data generation model is trained using constructed positive and negative sample pairs. During training, the initial data generation model learns how to generate more accurate and complex query data samples based on intent samples. In practical applications, a loss function can be defined to evaluate the difference between the query data samples generated by the model and the real or expected query data samples. This loss function will guide the optimization process of the initial data generation model. An appropriate optimization algorithm is selected to minimize the loss function. By continuously adjusting the parameters of the initial data generation model through the optimization algorithm, a data generation model is obtained, which improves the accuracy and diversity of the query data samples generated by the data generation model.
[0044] The tool invocation model training method provided in the embodiments of this specification constructs a data generation model that can generate accurate and diverse query data based on simple intent data, performs data augmentation on the intent data, and then uses the data generation model to synthesize data to provide training data for the subsequent training of the tool invocation model.
[0045] In one or more embodiments of this specification, an initial sample pair consisting of intent samples and query data samples is classified using a sample evaluation model and adversarial training. The classified positive and negative samples are then used to train and obtain a data generation model. Specific implementation methods are described below: The step of determining positive and negative sample pairs consisting of the intent sample and the query data sample using a preset sample classification method includes: Using a sample evaluation model, the initial sample pair consisting of the intent sample and the query data sample is evaluated, and the initial sample pair is classified as positive or negative based on the sample evaluation results, thereby determining the positive or negative sample pair consisting of the intent sample and the query data sample.
[0046] The sample evaluation model can be implemented using a reward model. This model is used to evaluate the initial sample pairs consisting of intent samples and query data samples to classify them. For example, if the initial sample pairs consisting of intent samples and query data samples are evaluated using a reward model, the reward model can determine the sample evaluation result by determining a reward score. That is, the sample evaluation result can be understood as the matching degree between the query data sample and the corresponding intent sample, or the generation quality of the query data sample, etc. When the sample evaluation model is a reward model, the sample evaluation result can be represented by the reward score output by the reward model.
[0047] Specifically, based on a given intent sample (such as "check the weather"), a corresponding query data sample (i.e., a specific query statement or request, such as "what is the weather like today") is generated; the sample evaluation model is used to evaluate the matching degree between the generated query data sample and the intent sample, and the quality of the query data sample.
[0048] For example, after generating query data samples, the intent sample and the query data sample are passed as input to the reward model. The model outputs a score representing the matching degree or quality of the sample pair. The reward model can be rule-based (such as checking whether the query data sample contains intent-related keywords) or machine learning-based (such as using a classifier or regression model) to determine the reward score; no limitation is made here. Based on the sample evaluation results, the sample pairs are divided into positive sample pairs (high-quality, expected sample pairs) and negative sample pairs (low-quality, unexpected sample pairs).
[0049] The tools provided in the embodiments of this specification call the model training method, which obtains positive and negative sample pairs by classifying the initial sample pairs. The positive sample pairs can be used to train or optimize the downstream model, while the negative sample pairs can be used for negative sampling training of the data generation model to improve the generalization ability of the data generation model and continuously improve the quality of the query data samples generated by the data generation model.
[0050] In one or more embodiments of this specification, when classifying initial sample pairs, multiple dimensions can be used to evaluate the initial sample pairs, thereby obtaining accurate sample evaluation results and thus more accurate classification results. Specific implementation methods are described below: The sample evaluation model includes at least one of the following: difficulty sample evaluation model, intent sample evaluation model, and parameter call sample evaluation model; The step of using a sample evaluation model to evaluate the initial sample pair consisting of the intent sample and the query data sample, and classifying the initial sample pair as positive or negative based on the evaluation results, to determine the positive or negative sample pair consisting of the intent sample and the query data sample, includes: When the sample evaluation model includes the difficulty sample evaluation model, the query data sample is input into the difficulty sample evaluation model to obtain the difficulty sample evaluation score of the query data sample, wherein the difficulty sample evaluation score is used to describe the complexity of the query data sample; When the sample evaluation model includes the intent sample evaluation model, the intent sample and the query data sample are input into the intent sample evaluation model to obtain an intent sample evaluation score, wherein the intent sample evaluation score is used to describe the consistency between the intent sample and the query data sample; When the sample evaluation model includes the parameter call sample evaluation model, the query data sample and the tool call parameter sample corresponding to the intent sample are input into the parameter call sample evaluation model to obtain the parameter call sample evaluation score, wherein the parameter call sample evaluation score is used to describe the consistency between the query data sample and the tool call parameter sample; Based on the difficulty sample evaluation score, the intent sample evaluation score, and / or the parameter call sample evaluation score, a target sample evaluation score is determined, and the target sample evaluation score is determined as the sample evaluation result; Based on the target sample evaluation score, the initial sample pair is classified as positive or negative to determine the positive or negative sample pair consisting of the intent sample and the query data sample.
[0051] The difficulty sample evaluation score, intent sample evaluation score, and parameter call sample evaluation score all range from -1 to 1. The difficulty sample evaluation model is used to evaluate the complexity of the query data sample, the intent sample evaluation model is used to evaluate the consistency between the intent sample and the query data sample, and the parameter call sample evaluation model is used to evaluate the consistency between the query data sample and the tool call parameter sample.
[0052] Specifically, the difficulty sample assessment model will give high rewards to query data samples with high difficulty (e.g., a difficulty sample assessment score greater than 0 can be considered a high reward); and low rewards to query data samples with low difficulty. This difficulty level can be determined by human feedback, or by inputting query data samples into a tool to call the model and determining the accuracy of the tool's call parameters. When positive and negative sample pairs are determined by using the difficulty sample assessment model, the data generation model can be adjusted using the positive and negative sample pairs, thereby guiding the data generation model to generate more challenging query data.
[0053] Similarly, the input to the intent sample evaluation model is an intent sample and a query data sample, and the output is an intent sample evaluation score that reflects the consistency between the intent and the query data. If the consistency between the intent sample and the query data sample is high, the intent sample evaluation score is high; otherwise, the intent sample evaluation score is low. The input to the parameter call sample evaluation model is a tool call parameter sample and a query data sample, and the output is a parameter call sample evaluation score that reflects the consistency between the tool call and the query data. If the consistency between the tool call and the query data is high, the parameter call sample evaluation score is high; otherwise, the parameter call sample evaluation score is low.
[0054] Based on the aforementioned difficulty sample evaluation score, intention sample evaluation score, and / or parameter call sample evaluation score, the target sample evaluation score is determined, and the comprehensive target sample evaluation score is determined as the sample evaluation result; thereby, the target sample evaluation score is used to classify the initial sample pairs as positive and negative samples, and the positive and negative sample pairs are determined.
[0055] The tool-calling model training method provided in the embodiments of this specification evaluates the query data samples through different sample evaluation models, thereby achieving a comprehensive evaluation of the query data samples in different dimensions, and thus obtaining more accurate sample evaluation results based on the evaluation in different dimensions.
[0056] In one or more embodiments of this specification, when multiple sample evaluation scores are obtained, the target sample evaluation score can be accurately obtained by averaging. Specific implementation methods are described below: The step of determining the target sample evaluation score based on the difficulty sample evaluation score, the intent sample evaluation score, and / or the parameter-called sample evaluation score includes: Given at least two of the difficulty sample evaluation scores, the intent sample evaluation score, and the parameter call sample evaluation score, the target sample evaluation score is determined by averaging the at least two sample evaluation scores.
[0057] Specifically, when multiple evaluation scores are obtained using different sample evaluation models, the average of these multiple evaluation scores can be calculated. Based on the calculated average evaluation score, a comprehensive target sample evaluation score can be determined, ensuring the comprehensiveness and completeness of the target sample evaluation score.
[0058] In practical applications, given a target sample evaluation score, the initial sample pairs can be classified by comparing the target sample evaluation score with a sample evaluation score threshold. The specific implementation method is as follows: The step of classifying the initial sample pairs as positive or negative based on the target sample evaluation score, and determining the positive or negative sample pairs consisting of the intent sample and the query data sample, includes: If the target sample evaluation score is greater than or equal to the sample evaluation score threshold, the initial sample pair is determined as a positive sample pair; If the target sample evaluation score is less than the sample evaluation score threshold, the initial sample pair is determined as a negative sample pair; Based on the positive sample pairs and the negative sample pairs, a positive and negative sample pair consisting of the intent sample and the query data sample is determined.
[0059] The sample evaluation score threshold can be set according to the actual situation, such as setting the sample evaluation score threshold to 0, without any restrictions here.
[0060] In practical applications, the initial sample pairs can be sorted according to the target sample evaluation score from largest to smallest, and the positive and negative sample pairs can be determined based on the sorting results. For example, the initial sample pairs in the top 5 of the sorting results can be determined as positive sample pairs. That is, there are many ways to determine the positive and negative sample pairs based on the target sample evaluation score, which are not limited here.
[0061] The tool invocation model training method provided in the embodiments of this specification utilizes different reward models and data generation models to ensure that the generated query data can challenge the tool invocation model while maintaining consistency with user intent and tool invocation. By using an adversarially generated dataset (which is obtained by generating the data model using positive and negative samples), the tool invocation model is trained. In this way, through multiple rounds of iteration, the accuracy of the tool invocation model in responding to timely queries can be gradually enhanced.
[0062] Step 206: Input the target query data into the initial tool invocation model to obtain the prediction tool invocation parameters.
[0063] In one or more embodiments of this specification, before inputting the target query data into the initial tool invocation model, an initial tool invocation model can be pre-trained. This allows for supervised adjustment of the pre-trained initial tool invocation model when training the tool invocation model using the target query data generated by the data generation model, thus reducing the consumption of training resources. Specific implementation methods are described below: Before inputting the target query data into the initial tool invocation model to obtain the prediction tool invocation parameters, the process also includes: Determine the initial intent sample and the initial query data sample corresponding to the initial intent sample, and train the initial data generation model based on the initial intent sample and the initial query data sample; Determine the initial intent and the corresponding initial tool invocation parameters; Input the initial intent into the initial data generation model to obtain the initial query data corresponding to the initial intent; The initial query data and the initial tool call parameters are used to train the initial tool call model.
[0064] Specifically, firstly, an initial data generation dataset is obtained through pre-training using an initial intent sample and the corresponding initial query data sample. This initial data generation dataset can augment the input initial intent to obtain rich initial query data. Then, using this initial query data and the initial tool call parameters corresponding to the initial intent, an initial tool call model is obtained through pre-training.
[0065] In practical applications, training of the initial tool invocation model can be terminated when the accuracy reaches a set threshold, such as 80%. However, when the initial data generation model has limited capabilities, the generated initial query data is often not complex enough, while the initial tool invocation model can easily fit these generated initial query data and achieve 100% accuracy. Therefore, the above-mentioned sample evaluation method is needed to improve the complexity of the query data generated by the data generation model.
[0066] The tool invocation model training method provided in the embodiments of this specification optimizes the training process of the tool invocation model and reduces the consumption of training resources by effectively utilizing pre-training techniques and initial data to generate a model.
[0067] In one or more embodiments of this specification, the initial intent sample and the corresponding initial query data sample can be obtained through an existing large language model. The large language model is then used to infer the corresponding intent from the existing query, producing distilled data, which is then used to train a smaller model such as the initial data generation model. Specific implementation methods are described below: The determination of the initial intent sample and the corresponding initial query data sample includes: The received query data is input into the large language model to obtain the intent data corresponding to the query data; The intent data is determined as the initial intent sample, and the query data is determined as the initial query data sample corresponding to the initial intent sample.
[0068] Specifically, the large language model can infer the intent data behind the query data input by online users, use the inferred intent data as the initial intent sample, and directly use the original query data as the initial query data sample corresponding to the initial intent sample; ensuring that each initial intent sample has a corresponding initial query data sample, forming a one-to-one correspondence.
[0069] By combining all the initial intent samples and their corresponding initial query data samples, a distillation dataset can be formed. This distillation dataset can then be used to train an initial data generation model (small model).
[0070] The tool-calling model training method provided in the embodiments of this specification utilizes knowledge distillation technology to transfer the superior performance of the large language model to the initial data generation model (small model), achieving efficient computation and low-cost operation. Furthermore, the large language model can automatically generate a large amount of high-quality intent-query pair data, thereby greatly alleviating the burden of manually labeling data. At the same time, by utilizing the capabilities of the large language model for intent inference, it is also possible to ensure that the generated data is more semantically accurate and richer.
[0071] Step 208: Train the initial tool invocation model based on the predicted tool invocation parameters and the target tool invocation parameters to obtain the tool invocation model.
[0072] Specifically, a suitable loss function can be selected to quantify the difference between the predicted tool call parameters and the target tool call parameters. For example, for regression tasks (if the tool call parameters are continuous), mean squared error can be selected, while for classification tasks (if the tool call parameters are discrete or belong to a finite set), cross-entropy loss can be selected. An optimization algorithm can be selected to update the weights of the initial tool call model to minimize the loss function. Commonly used optimization algorithms include stochastic gradient descent, gradient descent, etc., which are not limited here.
[0073] The target query data is input into the initial tool call model. The predicted tool call parameters are calculated through forward propagation, and then the loss function value is calculated. Next, the gradient of the loss function is propagated back to the model through the backpropagation algorithm, and the model weights are updated using the optimization algorithm. This process is repeated many times (i.e., multiple training cycles or iterations) until the performance of the initial tool call model on the validation set no longer improves significantly or reaches the preset number of training rounds. At this point, the tool call model is obtained.
[0074] The tool invocation model training method provided in the embodiments of this specification uses adversarial generative techniques to synthesize training data, improving the accuracy and diversity of the generated data. This provides rich and comprehensive training data for the tool invocation model, enhancing its generalization ability. Furthermore, the application of knowledge distillation techniques injects knowledge from a large speech model into a smaller model, ensuring the high efficiency of the data generation model while significantly reducing computational resource consumption and operating costs. This greatly improves the system's ability to handle timely queries, enhancing accuracy, efficiency, and diversity, and achieving the goal of low operating costs.
[0075] See Figure 3 , Figure 3 A flowchart of a data generation model training method provided in one embodiment of this specification is shown, which specifically includes the following steps.
[0076] Step 302: Determine the intent sample; Step 304: Input the intent sample into the initial data generation model to obtain the query data sample; Before inputting the intent sample into the initial data generation model to obtain the query data sample, the method further includes: Determine the initial intent sample and the corresponding initial query data sample, and train the initial data generation model based on the initial intent sample and the initial query data sample.
[0077] The determination of the initial intent sample and the corresponding initial query data sample includes: The received query data is input into the large language model to obtain the intent data corresponding to the query data; The intent data is determined as the initial intent sample, and the query data is determined as the initial query data sample corresponding to the initial intent sample.
[0078] Step 306: Using a preset sample classification method, determine the positive and negative sample pairs consisting of the intent sample and the query data sample; The step of determining positive and negative sample pairs consisting of the intent sample and the query data sample using a preset sample classification method includes: Using a sample evaluation model, the initial sample pair consisting of the intent sample and the query data sample is evaluated, and the initial sample pair is classified as positive or negative based on the sample evaluation results, thereby determining the positive or negative sample pair consisting of the intent sample and the query data sample.
[0079] The sample evaluation model includes at least one of the following: difficulty sample evaluation model, intent sample evaluation model, and parameter call sample evaluation model; The step of using a sample evaluation model to evaluate the initial sample pair consisting of the intent sample and the query data sample, and classifying the initial sample pair as positive or negative based on the evaluation results, to determine the positive or negative sample pair consisting of the intent sample and the query data sample, includes: When the sample evaluation model includes the difficulty sample evaluation model, the query data sample is input into the difficulty sample evaluation model to obtain the difficulty sample evaluation score of the query data sample, wherein the difficulty sample evaluation score is used to describe the complexity of the query data sample; When the sample evaluation model includes the intent sample evaluation model, the intent sample and the query data sample are input into the intent sample evaluation model to obtain an intent sample evaluation score, wherein the intent sample evaluation score is used to describe the consistency between the intent sample and the query data sample; When the sample evaluation model includes the parameter call sample evaluation model, the query data sample and the tool call parameter sample corresponding to the intent sample are input into the parameter call sample evaluation model to obtain the parameter call sample evaluation score, wherein the parameter call sample evaluation score is used to describe the consistency between the query data sample and the tool call parameter sample; Based on the difficulty sample evaluation score, the intent sample evaluation score, and / or the parameter call sample evaluation score, a target sample evaluation score is determined, and the target sample evaluation score is determined as the sample evaluation result; Based on the target sample evaluation score, the initial sample pair is classified as positive or negative to determine the positive or negative sample pair consisting of the intent sample and the query data sample.
[0080] Step 308: Train the initial data generation model based on the positive and negative sample pairs to obtain the data generation model.
[0081] For specific implementation details, please refer to the above embodiments, which will not be repeated here.
[0082] This specification provides a data generation model training method in one embodiment. It utilizes different reward models to drive the training of the data generation model, enabling the generated query data to maintain consistency with user intent and tool calls while challenging the tool call model. By using an adversarially generated dataset (obtained by using positive and negative samples to train the data generation model) to train the tool call model, the tool call model's ability to accurately respond to timely queries can be gradually enhanced through multiple iterations.
[0083] See Figure 4 , Figure 4 A flowchart of a tool invocation method provided in one embodiment of this specification is shown, which specifically includes the following steps.
[0084] Step 402: Determine the target query data and input the target query data into the tool invocation model to obtain the tool invocation parameters corresponding to the target query data, wherein the tool invocation model is obtained through the above-described tool invocation model training method; Step 404: Use the tool call parameters to determine the target tool; Step 406: Invoke the target tool to obtain the target processing result corresponding to the target query data.
[0085] Specifically, the target query data is determined. This target query data can come from various data sources such as user input and data synthesis. The target query data is used as input and passed to the tool invocation model that has been trained. This tool invocation model has learned how to map query data to the corresponding tool invocation parameters. Therefore, after processing the input data, the tool invocation model will output a set of tool invocation parameters. These tool invocation parameters specify which tool should be invoked and how to invoke the tool (e.g., tool name, date, location, etc.).
[0086] The system determines the target tool to be invoked based on the information in the tool invocation parameters. By invoking the target tool, it obtains the target processing result corresponding to the target query data. For example, for the target query data "Tomorrow's weather in Shanghai," given additional information including the date "January 1, 2024" and the location "Hangzhou," the tool invocation parameters need to include the name of the tool to be invoked, "Weather," the location parameter for invoking the weather tool, "Shanghai," and the date parameter for invoking the weather tool, "January 2, 2024," thus obtaining the target processing result "January 2, 2024, Shanghai's temperature is 0 degrees Celsius, cloudy."
[0087] In practical applications, this tool invocation model can be combined with a large language model. The tool invocation model can be used in the large language model to make accurate tool invocations, thereby achieving search enhancement generation based on RAG technology and enabling the large language model to generate more accurate and richer responses.
[0088] The tool invocation method provided in the embodiments of this specification utilizes the adaptive timeliness parameter parsing capability integrated into the tool invocation model to improve the tool invocation model's understanding and processing capabilities for time-dependent queries, thereby accurately responding to user needs. This significantly improves the accuracy, efficiency, and response diversity of timeliness tool invocation, while reducing operating costs, thus providing an effective, feasible, and practical solution for open domain information retrieval.
[0089] See Figure 5 , Figure 5 This specification illustrates a schematic diagram of an adversarial training process provided in one embodiment.
[0090] Specifically, the tool invocation model training method is applied to a tool invocation model training system, which consists of two main modules: a data generation model and a tool invocation model. The data generation model is primarily responsible for generating timely user queries based on intent data, while the tool invocation model focuses on learning how to provide correct tool invocation parameters based on user queries, especially those related to timeliness. This system improves performance through adversarial training, as described below: The data generation model D is trained to generate user queries. The input to the model includes intent data *i* and additional information such as the current date *x_date* and current location *x_location*. The output is a query *x_query*, i.e., *x_query = D(i, x_date, x_location). The intent data *i* is generated from a random seed, and the corresponding tool invocation parameters *y* can be generated based on this seed. In other words, the data generation model D can obtain the mapping relationship from *i*, *x_date*, *x_location* to *x_query*, *y*.
[0091] However, data generated directly using large language models often lacks diversity. For example, queries generated directly from the intent "Today's weather in Beijing" using a large language model are typically "What's the weather like in Beijing today?", which is monotonous and lacks variety and challenge. Therefore, large language models can be used to infer user intent from online queries. For instance, by querying "What clothes should I wear to the Temple of Heaven today?", the intent can be inferred as "Today's weather in Beijing".
[0092] By obtaining the data pairs of intents and queries derived from reverse engineering, a data generation model can be trained to generate diverse queries. For example, for the intent "Tomorrow's weather in Shanghai", the data generation model can generate queries that actual users might ask, such as "What clothes should I wear when I go to the Bund tomorrow?"; of course, it can also generate diverse queries for different times such as "the day after tomorrow", "next weekend", "next month", etc., without limitation.
[0093] Furthermore, due to significant discrepancies in the distribution of online user data—for example, the number of weather queries far exceeds the number of queries for gold prices, oil prices, and other long-tail tools—and the similar patterns in timeliness parameters across multiple tools, it's possible to balance the proportion of different tools and the diversity of queries by specifying queries such as "the price of xx metal next week." Such queries not only increase diversity but also better meet users' daily query needs.
[0094] The tool invocation model E is used to generate tool invocation parameters. The input to the tool invocation model is the query x, along with additional information, such as the given current date x_date and current location x_location. The output is the tool invocation parameter y. Since the corresponding tool invocation parameter y can be generated simultaneously with the intention i based on the same random seed, the tool invocation model E learns how to map from x_query, x_date, and x_location to y.
[0095] Of course, in practical applications, constructing different types of edge case data can improve the robustness and reliability of the tool's calling model against noisy or anomalous data.
[0096] Given the limited capabilities of the data generation model D, the generated queries are often not complex enough, while the tool calling model E can easily fit these generated queries and achieve 100% accuracy. Therefore, adversarial training is employed to improve the complexity of the queries generated by the data generation model D.
[0097] When the accuracy of the tool invocation model E reaches a set threshold, such as 80%, training of the tool invocation model is paused. Correct and incorrect tool invocations are sampled, and then a Query difficulty reward model R_query (i.e., the difficulty sample evaluation model in the above embodiment) is trained to determine the difficulty of query data. The input is the query x_query, and the output is the reward score (corresponding to the difficulty sample evaluation score in the above embodiment): s_query = R_query(x_query). For queries with high difficulty, the reward model R_query will give a high reward; for queries with low difficulty, the reward model R_query will give a low reward.
[0098] For example, if the intent "Today's weather in Beijing" is generated based on a random seed, and the data generation model generates the query "Today's weather in Beijing", then R_query is low; if it generates "What should I wear when I go to Beijing today?", then R_query is high; by adjusting the data generation model D using R_query, it can be guided to generate more challenging queries.
[0099] In addition, the system may also include an intent reward model R_intent (i.e., the intent sample evaluation model in the above embodiments) and a parameter call reward model R_tool (i.e., the parameter call sample evaluation model in the above embodiments). The input to the intent reward model R_intent is the user intent i and the query x_query, and the output is a reward score (corresponding to the intent sample evaluation score in the above embodiments): s_intent = R_intent(i, x_query). If the consistency between the intent and the query is high, the reward score is high; otherwise, the reward score is low. For example, continuing with the previous example, if the query generated by the data generation model is "What should I wear when I go to Beijing tomorrow?", then R_intent is low because the intent is incorrect; in this case, the R_intent for the query "Beijing weather today" is actually high.
[0100] The parameter call reward model R_tool takes a tool call t and a query x_query as input and outputs a reward score (corresponding to the parameter call sample evaluation score in the above embodiment): s_tool = R_tool(t, x_query). A high consistency between the tool call and the query results in a high reward score; conversely, a low consistency results in a low reward score. For example, if today is August 1, 2024, the parameter should be {"Time": "August 1, 2024", "Location": "Beijing"}, resulting in a high R_tool score; if the parameter is {"Time": "August 2, 2024", "Location": "Shanghai"}, then R_tool will be low.
[0101] The three reward models above work together to drive the training of the data generation model D, making the generated queries both challenging and consistent with user intent and tool calls.
[0102] During adversarial training, the model is iteratively trained by calling the tool, rewarding the model, and generating data. This ensures that the generated queries maintain consistency with user intent and tool calls while challenging the tool to call model E. This not only improves the system's accuracy but also increases its stability and reliability. Using adversarially generated datasets for model training allows for multiple iterations, progressively enhancing the model's ability to accurately respond to timely queries.
[0103] High-quality and diverse training data is generated through adversarial generation. This technique can effectively generate high-quality data, thereby enriching and comprehensively covering various complex time-sensitive query scenarios and reducing the number of errors in the generated data. In other words, by applying adversarial generation and data augmentation techniques, it is ensured that the generated data covers multiple scenarios, thereby improving the model's generalization ability and enabling it to cope with various complex real-world query environments.
[0104] Corresponding to the above method embodiments, this specification also provides embodiments for tool invocation of model training devices. Figure 6 A schematic diagram of a tool-invoking model training apparatus according to one embodiment of this specification is shown. Figure 6 As shown, the device includes: The data determination module 602 is configured to determine the target intent and the target tool invocation parameters corresponding to the target intent; The data acquisition module 604 is configured to input the target intent into the data generation model to obtain the target query data corresponding to the target intent. The data generation model is obtained by training an initial data generation model through positive and negative sample pairs composed of intent samples and query data samples. The positive and negative sample pairs are determined by a preset sample classification method, and the query data samples are determined by data augmentation of the intent samples. The parameter acquisition module 606 is configured to input the target query data into the initial tool invocation model to obtain the prediction tool invocation parameters; The model training module 608 is configured to train the initial tool invocation model based on the prediction tool invocation parameters and the target tool invocation parameters, thereby obtaining the tool invocation model.
[0105] The apparatus further includes: a model acquisition module configured to determine an intent sample; input the intent sample into an initial data generation model to obtain a query data sample; determine a positive and negative sample pair consisting of the intent sample and the query data sample using a preset sample classification method; and train the initial data generation model based on the positive and negative sample pair to obtain the data generation model.
[0106] Optionally, the model acquisition module is further configured to: use a sample evaluation model to evaluate the initial sample pair consisting of the intent sample and the query data sample, and classify the initial sample pair as positive or negative samples based on the sample evaluation results, thereby determining the positive or negative sample pair consisting of the intent sample and the query data sample.
[0107] Optionally, the model obtaining module is further configured to: when the sample evaluation model includes the difficulty sample evaluation model, input the query data sample into the difficulty sample evaluation model to obtain the difficulty sample evaluation score of the query data sample, wherein the difficulty sample evaluation score is used to describe the complexity of the query data sample; When the sample evaluation model includes the intent sample evaluation model, the intent sample and the query data sample are input into the intent sample evaluation model to obtain an intent sample evaluation score, wherein the intent sample evaluation score is used to describe the consistency between the intent sample and the query data sample; When the sample evaluation model includes the parameter call sample evaluation model, the query data sample and the tool call parameter sample corresponding to the intent sample are input into the parameter call sample evaluation model to obtain the parameter call sample evaluation score, wherein the parameter call sample evaluation score is used to describe the consistency between the query data sample and the tool call parameter sample; Based on the difficulty sample evaluation score, the intent sample evaluation score, and / or the parameter call sample evaluation score, a target sample evaluation score is determined, and the target sample evaluation score is determined as the sample evaluation result; Based on the target sample evaluation score, the initial sample pair is classified as positive or negative to determine the positive or negative sample pair consisting of the intent sample and the query data sample.
[0108] Optionally, the model acquisition module is further configured to: determine the target sample assessment score by averaging the at least two sample assessment scores among the difficulty sample assessment score, the intent sample assessment score, and the parameter call sample assessment score.
[0109] Optionally, the model acquisition module is further configured to: determine the initial sample pair as a positive sample pair when the target sample evaluation score is greater than or equal to the sample evaluation score threshold; determine the initial sample pair as a negative sample pair when the target sample evaluation score is less than the sample evaluation score threshold; and determine the positive and negative sample pairs consisting of the intent sample and the query data sample based on the positive sample pairs and the negative sample pairs.
[0110] The apparatus further includes: an initial training module configured to determine an initial intent sample and an initial query data sample corresponding to the initial intent sample, and to train an initial data generation model based on the initial intent sample and the initial query data sample; determine an initial intent and initial tool call parameters corresponding to the initial intent; input the initial intent into the initial data generation model to obtain initial query data corresponding to the initial intent; and train the initial tool call model using the initial query data and the initial tool call parameters.
[0111] Optionally, the initial training module is further configured to: input the received query data into a large language model to obtain intent data corresponding to the query data; determine the intent data as the initial intent sample, and determine the query data as the initial query data sample corresponding to the initial intent sample.
[0112] Optionally, the data determination module 602 is further configured to: determine the original intent and additional information, wherein the additional information is background environment information used to describe the original intent; and determine the target intent and the target tool invocation parameters corresponding to the target intent based on the original intent and the additional information.
[0113] This specification provides a tool invocation model training apparatus in one embodiment. By generating a model from target intent input data, it obtains target query data corresponding to the target intent. The data generation model is trained using positive and negative sample pairs composed of intent samples and query data samples. Furthermore, the query data samples are determined by data augmentation of the intent samples. Therefore, the target query data output by the data generation model is also high-quality query data corresponding to the target intent and augmented with data. Thus, by using an initial tool invocation model to obtain predicted tool invocation parameters corresponding to the target query data, and training the initial tool invocation model based on the predicted tool invocation parameters and the target tool invocation parameters corresponding to the target intent, the tool invocation accuracy of the tool invocation model can be optimized by improving the quality of the training data (target query data), significantly reducing the phenomenon of incorrect tool invocation. During the generation of target query data and optimization of the tool invocation model, by fusing accurate tool invocation parameter parsing, the tool invocation model can achieve high efficiency when handling complex and time-sensitive queries.
[0114] The above is an illustrative scheme of a tool-invoking model training device according to this embodiment. It should be noted that the technical solution of this tool-invoking model training device and the technical solution of the tool-invoking model training method described above belong to the same concept. For details not described in detail in the technical solution of the tool-invoking model training device, please refer to the description of the technical solution of the tool-invoking model training method described above.
[0115] Corresponding to the above method embodiments, this specification also provides embodiments of a data generation model training device. Figure 7 A schematic diagram of a data generation model training apparatus according to one embodiment of this specification is shown. Figure 7 As shown, the device includes: The sample determination module 702 is configured to determine the intent sample; The data acquisition module 704 is configured to input the intent sample into the initial data generation model to obtain the query data sample; The sample classification module 706 is configured to determine the positive and negative sample pairs consisting of the intent sample and the query data sample using a preset sample classification method. The model training module 708 is configured to train the initial data generation model based on the positive and negative sample pairs to obtain the data generation model.
[0116] Optionally, the sample classification module 706 is further configured to: use a sample evaluation model to evaluate the initial sample pair consisting of the intent sample and the query data sample, and classify the initial sample pair as positive or negative based on the sample evaluation results, thereby determining the positive or negative sample pair consisting of the intent sample and the query data sample.
[0117] Optionally, the sample classification module 706 is further configured to: when the sample evaluation model includes the difficulty sample evaluation model, input the query data sample into the difficulty sample evaluation model to obtain the difficulty sample evaluation score of the query data sample, wherein the difficulty sample evaluation score is used to describe the complexity of the query data sample; When the sample evaluation model includes the intent sample evaluation model, the intent sample and the query data sample are input into the intent sample evaluation model to obtain an intent sample evaluation score, wherein the intent sample evaluation score is used to describe the consistency between the intent sample and the query data sample; When the sample evaluation model includes the parameter call sample evaluation model, the query data sample and the tool call parameter sample corresponding to the intent sample are input into the parameter call sample evaluation model to obtain the parameter call sample evaluation score, wherein the parameter call sample evaluation score is used to describe the consistency between the query data sample and the tool call parameter sample; Based on the difficulty sample evaluation score, the intent sample evaluation score, and / or the parameter call sample evaluation score, a target sample evaluation score is determined, and the target sample evaluation score is determined as the sample evaluation result; Based on the target sample evaluation score, the initial sample pair is classified as positive or negative to determine the positive or negative sample pair consisting of the intent sample and the query data sample.
[0118] The apparatus further includes: an initial training module configured to determine an initial intent sample and an initial query data sample corresponding to the initial intent sample, and to train the initial data generation model based on the initial intent sample and the initial query data sample.
[0119] Optionally, the initial training module is further configured to: input the received query data into a large language model to obtain intent data corresponding to the query data; determine the intent data as the initial intent sample, and determine the query data as the initial query data sample corresponding to the initial intent sample.
[0120] The above is an illustrative scheme of a data generation model training device according to this embodiment. It should be noted that the technical solution of this data generation model training device and the technical solution of the data generation model training method described above belong to the same concept. For details not described in detail in the technical solution of the data generation model training device, please refer to the description of the technical solution of the data generation model training method described above.
[0121] Corresponding to the above method embodiments, this specification also provides embodiments of a tool invocation device. Figure 8 A schematic diagram of a tool calling device according to one embodiment of this specification is shown. Figure 8 As shown, the device includes: The data acquisition module 802 is configured to determine target query data and input the target query data into the tool invocation model to obtain the tool invocation parameters corresponding to the target query data, wherein the tool invocation model is obtained through the above-mentioned tool invocation model training method; The tool determination module 804 is configured to determine the target tool using the tool invocation parameters. The result acquisition module 806 is configured to call the target tool to obtain the target processing result corresponding to the target query data.
[0122] The above is an illustrative scheme of a tool calling device according to this embodiment. It should be noted that the technical solution of this tool calling device and the technical solution of the tool calling method described above belong to the same concept. For details not described in detail in the technical solution of the tool calling device, please refer to the description of the technical solution of the tool calling method described above.
[0123] Figure 9A structural block diagram of a computing device 900 according to one embodiment of this specification is shown. The components of the computing device 900 include, but are not limited to, a memory 910 and a processor 920. The processor 920 is connected to the memory 910 via a bus 930, and a database 950 is used to store data.
[0124] The computing device 900 also includes an access device 940, which enables the computing device 900 to communicate via one or more networks 960. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 940 may include one or more of any type of wired or wireless network interface (e.g., a network interface card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, or a Near Field Communication (NFC) interface.
[0125] In one embodiment of this specification, the above-described components of the computing device 900 and Figure 9 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 9 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0126] The computing device 900 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 900 can also be a mobile or stationary server.
[0127] The processor 920 is used to execute the following computer program / instruction, which, when executed by the processor, implements the steps of the above-mentioned tool invocation model training method, data generation model training method, and tool invocation method.
[0128] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the computing device embodiments are basically similar to the tool-calling model training method, data-generating model training method, and tool-calling method embodiments, so the description is relatively simple. Relevant parts can be referred to the descriptions of the tool-calling model training method, data-generating model training method, and tool-calling method embodiments.
[0129] An embodiment of this specification also provides a computer-readable storage medium storing a computer program / instructions that, when executed by a processor, implement the steps of the above-described tool invocation model training method, data generation model training method, and tool invocation method.
[0130] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on its differences from other embodiments. In particular, the computer-readable storage medium embodiments are relatively simple in description because they are fundamentally similar to the tool-invoking model training method, data generation model training method, and tool-invoking method embodiments. Relevant details can be found in the descriptions of the tool-invoking model training method, data generation model training method, and tool-invoking method embodiments.
[0131] An embodiment of this specification also provides a computer program product, including a computer program / instruction that, when executed by a processor, implements the steps of the above-described tool invocation model training method, data generation model training method, and tool invocation method.
[0132] The above is an illustrative scheme of a computer program product according to this embodiment. It should be noted that the technical solution of this computer program product belongs to the same concept as the technical solutions of the tool calling model training method, data generation model training method, and tool calling method described above. For details not described in detail in the technical solution of the computer program product, please refer to the descriptions of the technical solutions of the tool calling model training method, data generation model training method, and tool calling method described above.
[0133] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0134] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added or removed according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0135] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments in this specification are not limited to the described order of actions, because according to the embodiments in this specification, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments in this specification.
[0136] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0137] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the embodiments described herein. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the embodiments, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A tool for invoking a model training method, comprising: Determine the target intent and the target tool invocation parameters corresponding to the target intent; The target intent is input into the data generation model to obtain the target query data corresponding to the target intent. The data generation model is obtained by training the initial data generation model through positive and negative sample pairs composed of intent samples and query data samples. The positive and negative sample pairs are determined by a preset sample classification method. The query data samples are determined by data augmentation of the intent samples. Input the target query data into the initial tool invocation model to obtain the prediction tool invocation parameters; The initial tool invocation model is trained based on the predicted tool invocation parameters and the target tool invocation parameters to obtain the tool invocation model.
2. The tool invocation model training method according to claim 1, before generating the model from the target intent input data and obtaining the target query data corresponding to the target intent, further includes: Determine the intent sample; The intent sample is input into the initial data generation model to obtain the query data sample; Using a preset sample classification method, determine the positive and negative sample pairs consisting of the intent sample and the query data sample; The initial data generation model is trained based on the positive and negative sample pairs to obtain the data generation model.
3. The tool invocation model training method according to claim 2, wherein determining the positive and negative sample pairs consisting of the intent sample and the query data sample using a preset sample classification method includes: Using a sample evaluation model, the initial sample pair consisting of the intent sample and the query data sample is evaluated, and the initial sample pair is classified as positive or negative based on the sample evaluation results, thereby determining the positive or negative sample pair consisting of the intent sample and the query data sample.
4. The tool invocation model training method according to claim 3, wherein the sample evaluation model includes at least one of a difficulty sample evaluation model, an intent sample evaluation model, and a parameter invocation sample evaluation model; The step of using a sample evaluation model to evaluate the initial sample pair consisting of the intent sample and the query data sample, and classifying the initial sample pair as positive or negative based on the evaluation results, to determine the positive or negative sample pair consisting of the intent sample and the query data sample, includes: When the sample evaluation model includes the difficulty sample evaluation model, the query data sample is input into the difficulty sample evaluation model to obtain the difficulty sample evaluation score of the query data sample, wherein the difficulty sample evaluation score is used to describe the complexity of the query data sample; When the sample evaluation model includes the intent sample evaluation model, the intent sample and the query data sample are input into the intent sample evaluation model to obtain an intent sample evaluation score, wherein the intent sample evaluation score is used to describe the consistency between the intent sample and the query data sample; When the sample evaluation model includes the parameter call sample evaluation model, the query data sample and the tool call parameter sample corresponding to the intent sample are input into the parameter call sample evaluation model to obtain the parameter call sample evaluation score, wherein the parameter call sample evaluation score is used to describe the consistency between the query data sample and the tool call parameter sample; Based on the difficulty sample evaluation score, the intent sample evaluation score, and / or the parameter call sample evaluation score, a target sample evaluation score is determined, and the target sample evaluation score is determined as the sample evaluation result; Based on the target sample evaluation score, the initial sample pair is classified as positive or negative to determine the positive or negative sample pair consisting of the intent sample and the query data sample.
5. The tool invocation model training method according to claim 4, wherein determining the target sample evaluation score based on the difficulty sample evaluation score, the intent sample evaluation score, and / or the parameter invocation sample evaluation score includes: Given at least two of the difficulty sample evaluation scores, the intent sample evaluation score, and the parameter call sample evaluation score, the target sample evaluation score is determined by averaging the at least two sample evaluation scores.
6. The tool invocation model training method according to claim 4 or 5, wherein classifying the initial sample pair as positive or negative based on the target sample evaluation score to determine the positive or negative sample pair consisting of the intent sample and the query data sample includes: If the target sample evaluation score is greater than or equal to the sample evaluation score threshold, the initial sample pair is determined as a positive sample pair; If the target sample evaluation score is less than the sample evaluation score threshold, the initial sample pair is determined as a negative sample pair; Based on the positive sample pairs and the negative sample pairs, a positive and negative sample pair consisting of the intent sample and the query data sample is determined.
7. The tool invocation model training method according to claim 1 or 2, before inputting the target query data into the initial tool invocation model to obtain the predicted tool invocation parameters, further comprising: Determine the initial intent sample and the initial query data sample corresponding to the initial intent sample, and train the initial data generation model based on the initial intent sample and the initial query data sample; Determine the initial intent and the corresponding initial tool invocation parameters; Input the initial intent into the initial data generation model to obtain the initial query data corresponding to the initial intent; The initial query data and the initial tool call parameters are used to train the initial tool call model.
8. The tool invocation model training method according to claim 7, wherein determining the initial intent sample and the initial query data sample corresponding to the initial intent sample includes: The received query data is input into the large language model to obtain the intent data corresponding to the query data; The intent data is determined as the initial intent sample, and the query data is determined as the initial query data sample corresponding to the initial intent sample.
9. The tool invocation model training method according to any one of claims 1-5 and 8, wherein determining the target intent and the target tool invocation parameters corresponding to the target intent includes: Determine the original intent and additional information, wherein the additional information is background information used to describe the original intent; Based on the original intent and the additional information, the target intent and the target tool invocation parameters corresponding to the target intent are determined.
10. A method for training a data generation model, comprising: Determine the intent sample; The intent sample is input into the initial data generation model to obtain the query data sample; Using a preset sample classification method, determine the positive and negative sample pairs consisting of the intent sample and the query data sample; The initial data generation model is trained based on the positive and negative sample pairs to obtain the data generation model.
11. The data generation model training method according to claim 10, wherein determining the positive and negative sample pairs consisting of the intent sample and the query data sample using a preset sample classification method includes: Using a sample evaluation model, the initial sample pair consisting of the intent sample and the query data sample is evaluated, and the initial sample pair is classified as positive or negative based on the sample evaluation results, thereby determining the positive or negative sample pair consisting of the intent sample and the query data sample.
12. A tool invocation method, comprising: The target query data is determined, and the target query data is input into the tool invocation model to obtain the tool invocation parameters corresponding to the target query data. The tool invocation model is obtained by the tool invocation model training method of any one of claims 1-9. Use the tool's call parameters to determine the target tool; Invoke the target tool to obtain the target processing result corresponding to the target query data.
13. A tool for calling a model training device, comprising: The data determination module is configured to determine the target intent and the target tool invocation parameters corresponding to the target intent; The data acquisition module is configured to input the target intent into the data generation model to obtain the target query data corresponding to the target intent. The data generation model is obtained by training an initial data generation model through positive and negative sample pairs composed of intent samples and query data samples. The positive and negative sample pairs are determined by a preset sample classification method, and the query data samples are determined by data augmentation of the intent samples. The parameter acquisition module is configured to input the target query data into the initial tool invocation model to obtain the prediction tool invocation parameters; The model training module is configured to train the initial tool invocation model based on the prediction tool invocation parameters and the target tool invocation parameters, thereby obtaining the tool invocation model.
14. A data retrieval model training device, comprising: The sample determination module is configured to determine the intent sample; The data acquisition module is configured to input the intent sample into the initial data generation model to obtain the query data sample; The sample classification module is configured to use a preset sample classification method to determine the positive and negative sample pairs consisting of the intent sample and the query data sample; The model training module is configured to train the initial data generation model based on the positive and negative sample pairs to obtain the data generation model.
15. A tool calling device, comprising: The data acquisition module is configured to determine target query data and input the target query data into the tool invocation model to obtain the tool invocation parameters corresponding to the target query data, wherein the tool invocation model is obtained through the tool invocation model training method described above; The tool determination module is configured to determine the target tool using the tool invocation parameters. The result acquisition module is configured to call the target tool to obtain the target processing result corresponding to the target query data.
16. A computing device, comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions, which, when executed by the processor, implement the steps of the method according to any one of claims 1-12.
17. A computer-readable storage medium storing a computer program / instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1-12.
18. A computer program product comprising a computer program / instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1-12.
Citation Information
Cited By
A large model calling detection method, device, medium and equipment
CN122132274A