Methods for training large models, methods for calling tools, and electronic devices
By training a large model using both positive and negative sample sets, the problem of traditional large models being unable to accurately call upon tools was solved, thus improving the accuracy of intelligent question answering.
Patent Information
- Application Number
- CN202511388334.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-26
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2045-09-26
AI Technical Summary
Traditional large-scale models cannot accurately determine the tools to use in intelligent question answering, leading to incorrect answers.
By training a large model using a sample set containing both positive and negative samples, the model's ability to distinguish between correct and incorrect answers is improved, ensuring accurate tool invocation during intelligent question answering.
It improves the accuracy of tool calls during intelligent question answering, thereby enhancing the accuracy of answers.
Smart Images

Figure CN120873615B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of large model technology, and more particularly to a method for training large models, a method for calling tools, and an electronic device. Background Technology
[0002] Intelligent question answering requires an intelligent agent to invoke appropriate large-scale models and corresponding tools to answer the question, or to invoke relevant tools to respond to control commands in the question. For example, if a user enters the question "Add Zhang San's phone number to the blacklist," the agent needs to invoke a search tool to find Zhang San from the contact list and a security tool to perform the blacklisting operation. If the invoked tool malfunctions, it will lead to an incorrect answer to the question.
[0003] However, with the continuous development of technology, users may ask increasingly diverse questions, and traditional large models cannot accurately determine the correct tool.
[0004] Therefore, improving the accuracy of tool calls during intelligent question answering has become an urgent technical problem to be solved. Summary of the Invention
[0005] This application provides a method for training large models, a method for calling tools, and an electronic device that can improve the accuracy of calling tools during intelligent question answering, thereby improving the accuracy of answers.
[0006] Firstly, a method for training a large model is provided, applied to a training device. This method includes: acquiring a first sample set, comprising multiple samples, each sample including a question and a corresponding correct label, the correct label being the correct answer to the tool and related parameters required to respond to the question; training a first large model using the first sample set to obtain a trained first large model; acquiring a second sample set, comprising multiple samples, each sample including a question and a corresponding positive and negative concatenation label, the positive and negative concatenation label including the correct and incorrect answers to the tool and related parameters required to respond to the question; training a second large model using the second sample set and the trained first large model to obtain a trained second large model; the trained second large model is the target large model used to determine the tools and related parameters to be invoked based on the question during intelligent question answering.
[0007] In this technical solution, a first-large model is trained using a set containing positive samples to obtain a well-trained first-large model. Then, a second-large model is trained using the first-large model and a set of concatenated samples containing both positive and negative samples to obtain a well-trained second-large model. This well-trained second-large model is used to determine the target large model for the tools to be invoked during intelligent question answering. This solution, by allowing the large model to learn not only correct but also incorrect samples, enables the target large model to better distinguish correct answers, thereby effectively improving the accuracy of intelligent question answering when it is used.
[0008] To a certain extent, this application's solution can be understood as follows: one large model learns correct knowledge, while another large model, while learning correct knowledge, also deepens its understanding of the differences between correct and incorrect answers. This allows the target large model to learn both correct and incorrect knowledge, thus enabling it to more firmly grasp the correct knowledge. In other words, it not only learns correct knowledge but also reinforces its understanding of incorrect answers, thereby effectively improving the accuracy of the target large model's reasoning.
[0009] In conjunction with the first aspect, in some implementations of the first aspect, the initial model of the second large model is the trained first large model.
[0010] In this implementation, the second model is trained on the basis of the first model, which has already been trained. This allows for faster acquisition of higher inference accuracy, essentially a relearning process based on a certain level of prior learning.
[0011] In conjunction with the first aspect, in certain implementations of the first aspect, the first large model is trained using the first sample set to obtain the trained first large model, including:
[0012] For each sample in the first sample set, perform the following operations: input the question in each sample into the first large model, and obtain the predicted answer through the first large model. The predicted answer includes the prediction results of the tools and related parameters that need to be called to respond to the question; update the parameters of the first large model with the aim of reducing the difference between the predicted answer and the correct answer in the sample.
[0013] If the first large model meets the preset training conditions, the trained first large model is obtained.
[0014] In this implementation, for each sample, the question is input into the primary model to obtain a predicted answer. This predicted answer is then compared with the correct answer in the sample. The parameters of the primary model are adjusted in reverse (updated) to minimize the difference between the two, thus making the updated primary model increasingly capable of inferring the correct answer. This training process is repeated for each sample until the primary model meets the preset training conditions, resulting in a well-trained primary model. The well-trained primary model has a high ability to determine which tools and parameters to use.
[0015] In conjunction with the first aspect, in some implementations of the first aspect, the preset training conditions include at least one of the following: the first large model has completed a preset number of training rounds; the first large model has been trained using a preset number of samples; all samples in the first sample set have been used for training; and the prediction accuracy of the updated first large model meets the preset accuracy condition.
[0016] In this implementation, several preset training conditions are given. The training process can be controlled by the number of training rounds, by setting the number of samples, by the number of samples in the first sample set, or by the accuracy of the first large model after training.
[0017] In conjunction with the first aspect, in certain implementations of the first aspect, the second large model is trained using the second sample set and the pre-trained first large model to obtain the trained second large model, including:
[0018] For each sample in the second sample set, perform the following operations: input the question in each sample into the trained first and second large models; obtain a first predicted answer through the trained first large model and a second predicted answer through the second large model; both the first and second predicted answers include the prediction results of the tools and related parameters required to respond to the question; update the parameters of the second large model with the aim of reducing the fluctuation of the difference between the first and second predicted answers and increasing the log-likelihood difference between the second predicted answer and the correct and incorrect answers to the question;
[0019] If the second model meets the preset training conditions, a well-trained second model is obtained.
[0020] In this implementation, for each sample, the question is input into a pre-trained first-level model to obtain a predicted answer, and into a second-level model to obtain another predicted answer. The predicted answer output by the second-level model is then compared with the correct and incorrect answers in the sample, as well as the predicted answer output by the pre-trained first-level model. The primary objective is to maximize the difference in log-likelihood between the predicted answer from the second-level model and the correct and incorrect answers, while the secondary objective is to minimize the change in the difference between the two predicted answers. This process is used to adjust the parameters of the second-level model (updating its parameters), making the updated second-level model increasingly capable of inferring the correct answer. This training process is repeated for each sample until the second-level model meets the preset training conditions, resulting in a well-trained second-level model. The trained second-level model has a high ability to determine the appropriate tools and parameters. Since the first large model, which has been trained, can already output the correct answer, the two objectives mentioned above require the second large model to, while ensuring that the correctness of the correct answer is not reduced as much as possible (the fluctuation of the difference value between the first predicted answer and the correct answer is minimized), make the difference between the positive prediction and the negative prediction increasingly larger, and the difference between the positive prediction and the correct answer as small as possible, so as to effectively improve the accuracy of the target large model.
[0021] In conjunction with the first aspect, in some implementations of the first aspect, the preset training conditions include at least one of the following: the second large model has completed a preset number of training rounds, the second large model has been trained using a preset number of samples, all samples in the second sample set have been used for training, and the prediction accuracy of the updated second large model meets the preset accuracy condition.
[0022] Several preset training conditions are given. The training process can be controlled by the number of training rounds, by setting the number of samples, by the number of samples in the second sample set, or by the accuracy of the second large model after training.
[0023] In conjunction with the first aspect, in some implementations of the first aspect, obtaining the second sample set includes: obtaining a third sample set, which includes multiple samples, each sample including a question and a corresponding correct label, the correct label being the correct answer to the tool and related parameters required to respond to the question; inputting the question of each sample in the third sample set into a trained first large model, obtaining a predicted answer through the trained first large model, and combining samples whose predicted answers do not match the correct answers into negative samples, thereby obtaining a fourth sample set, which includes at least one negative sample, each negative sample including a question and an incorrect answer to the tool and related parameters required to respond to the question; obtaining a fifth sample set, which includes multiple negative samples, each negative sample including a question and an incorrect answer to the tool and related parameters required to respond to the question; concatenating the correct and incorrect answers of the same questions in the samples of the third sample set and the samples of the fourth sample set, and concatenating the correct and incorrect answers of the same questions in the samples of the fifth sample set, to obtain the second sample set.
[0024] In this implementation, a third sample set, including positive samples, is obtained. The questions from this third sample set are then input into the trained first large model. The incorrect answers output by the trained first large model are combined with their corresponding questions to construct negative samples, thus completing the collection of the fourth sample set. This fourth sample set is essentially the incorrect question set of the trained first large model, allowing subsequent training to focus on learning the differences between these incorrect and correct answers, effectively improving the accuracy of the target large model. The fifth sample set is the constructed negative sample set, obtained by concatenating positive samples (samples from the third sample set) and negative samples (samples from the fourth and fifth sample sets) to form the samples in the second sample set. Since the second sample set includes both correct and incorrect knowledge, and also focuses on collecting incorrectly answered questions from the trained first large model, it effectively improves the training effect when using the second sample set to train the second large model. This allows the second large model to more fully learn correct knowledge and the differences between correct and incorrect knowledge.
[0025] In conjunction with the first aspect, in some implementations of the first aspect, the samples in the third sample set are not completely identical to the samples in the first sample set.
[0026] In this implementation, by ensuring that the samples in the third sample set are not completely identical to those in the first sample set, the error inferences of the trained first model can be identified as much as possible. This is equivalent to testing the trained first model with "advanced questions" to identify the questions that the model might get wrong, thus making it easier to compensate for its shortcomings through subsequent training.
[0027] Secondly, a method for invoking tools is provided for use in an inference device. The method includes: obtaining a first question input by a user; inferring the first question using a pre-deployed target large model to obtain at least one target tool and its related parameters corresponding to the first question; the target large model is a target large model trained using any of the methods in the first aspect; and invoking at least one target tool and its related parameters to respond to the first question.
[0028] In this technical solution, the accuracy of the calling tool can be effectively improved by using the target large model provided in the first aspect.
[0029] In conjunction with the second aspect, in some implementations of the second aspect, obtaining the first question input by the user includes: the user inputting the first question through voice input or text input in the display interface of the first application, where the first application is an application capable of intelligent question answering; or, the user inputting the first question through voice wake-up in either the screen-on or screen-off state.
[0030] This implementation refines the various input methods, making the applicable scenarios of this solution more flexible and diverse. Input can be made within the application's display interface, or via voice activation in either screen-on or screen-off states. Voice activation in screen-on state is mostly keyword-based, while voice activation in screen-off state is mostly breath-based. This solution is applicable to various intelligent question-answering scenarios to better meet user needs.
[0031] In conjunction with the second aspect, in some implementations of the second aspect, at least one target tool is invoked to respond to the first question, including: if the first question is a question-and-answer question, invoking at least one target tool to obtain the answer to the question-and-answer question and providing feedback to the user through interface display or voice broadcast; or, if the first question is a control question, invoking at least one target tool to execute the control command corresponding to the control question.
[0032] This implementation refines the different response methods for different types of questions, thereby better meeting user needs. For question-and-answer type questions, the answer needs to be provided to the user, and the way to provide the answer can be flexible and diverse. For control questions, the corresponding control is executed.
[0033] In conjunction with the second aspect, in some implementations of the second aspect, when the first question is a question-and-answer question, at least one target tool is invoked to obtain the answer to the question-and-answer question and the answer is fed back to the user through interface display or voice broadcast, including: when the first question is input through the display interface of the first application, the answer to the question-and-answer question is displayed in the display interface of the first application; when the first question is input through voice wake-up, the answer to the question-and-answer question is broadcast through voice broadcast.
[0034] In this implementation, the answer is returned to the user in a way that matches the user's input method, which can further improve the user experience.
[0035] In conjunction with the second aspect, in some implementations of the second aspect, when the first problem is a control problem, at least one target tool is invoked to execute the control command corresponding to the control problem, including: executing the control command if the control command meets preset control conditions, the preset control conditions including at least one of the following: meeting security requirements, having control permissions, being able to find content matching the control command, and being in the control whitelist; if the control command does not meet the preset control conditions, the reason why the control command cannot be executed is fed back to the user through interface display or voice broadcast.
[0036] This implementation refines the restrictions on the execution conditions of control commands. Control commands that affect security or for which the user lacks the necessary permissions are ignored to prevent damage to user information and electronic devices. For example, if a user enters "delete a phone number," the electronic device cannot find that number. Similarly, if a user enters "uninstall an application," but that application is an essential application that cannot be uninstalled, other situations will not be listed. Forcibly executing control commands in these special cases, or executing commands on the wrong target, could lead to the corruption of user information or even damage to the inference device. The above solution precisely avoids such risks and improves security by setting control conditions.
[0037] In conjunction with the second aspect, in some implementations of the second aspect, the above method further includes: receiving a target large model from a training device; and deploying the target large model to an inference device.
[0038] In this implementation, the target large model is provided as a source on the inference device, and after the training device has trained it, the inference device receives and deploys it.
[0039] Thirdly, an apparatus for training large models is provided, the apparatus comprising units consisting of software and / or hardware for performing any of the methods of the first aspect.
[0040] Fourthly, an apparatus for invoking a tool is provided, the apparatus comprising a unit consisting of software and / or hardware for performing any of the methods of the second aspect.
[0041] Fifthly, an electronic device is provided, comprising: one or more processors, and a memory; the memory is coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, wherein the one or more processors invoke the computer instructions to enable the electronic device to implement any method of any of the above aspects.
[0042] In a sixth aspect, a chip system is provided, the chip system being applied to an electronic device, the chip system including one or more processors, the one or more processors being configured to invoke computer instructions to enable the electronic device to implement any of the methods described in any of the foregoing aspects.
[0043] Optionally, the chip system also includes a memory electrically connected to the processor.
[0044] Optionally, the chip system may also include a communication interface.
[0045] In a seventh aspect, a computer-readable storage medium is provided, the computer-readable storage medium including instructions that, when executed on an electronic device, enable the electronic device to implement any method of any of the above aspects.
[0046] Eighthly, a computer program product is provided, comprising a computer program that, when executed by an electronic device, enables the implementation of any of the methods described above. Attached Figure Description
[0047] Figures 1 to 3 These are interactive diagrams illustrating several intelligent question-answering scenarios applicable to the embodiments of this application.
[0048] Figure 4 This is a schematic diagram of a large-scale model application scenario applicable to the embodiments of this application.
[0049] Figure 5 This is a schematic diagram illustrating how to determine the tool to be invoked during intelligent question answering, as applicable to an embodiment of this application.
[0050] Figure 6 This is a schematic flowchart illustrating a method for training a large model according to an embodiment of this application.
[0051] Figure 7 This is a schematic diagram of a method for obtaining a first sample set according to an embodiment of this application.
[0052] Figure 8 This is a schematic diagram of a method for training a first large model according to an embodiment of this application.
[0053] Figure 9 This is a schematic diagram of a method for obtaining a second sample set according to an embodiment of this application.
[0054] Figure 10 This is a schematic diagram of a method for training a second large model according to an embodiment of this application.
[0055] Figure 11 This is a schematic flowchart illustrating a method for invoking a tool according to an embodiment of this application.
[0056] Figure 12 This is a schematic diagram of the structure of a device for training a large model according to an embodiment of this application.
[0057] Figure 13 This is a schematic diagram of the structure of a device for calling a tool according to an embodiment of this application.
[0058] Figure 14 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of this application. Detailed Implementation
[0059] The embodiments of this application will now be described in conjunction with the accompanying drawings.
[0060] Figures 1 to 3 These are schematic diagrams illustrating several intelligent interaction scenarios applicable to the embodiments of this application. For example... Figure 1 As shown in interface 101, in the sports and health application (an example of the first application below), the user enters its intelligent question-and-answer interface. The user can input their question via voice or text. Here, we take the user's input question as "How many steps did I take today?" as an example. The agent in the electronic device determines to answer the question using the sports and health question-and-answer big model, and uses another big model to determine the tools to be called and related parameters, such as needing to search for step count values. Then, it answers the question together with the sports and health question-and-answer big model. As shown in interface 101, the answer is "You took 18,225 steps today."
[0061] like Figure 1As shown in interface 102, this intelligent interactive application (also known as an intelligent interactive assistant, an example of the first application below) includes multiple functions. "Dialogue" refers to intelligent question answering, and it also includes other functional modules such as "Recommendation," "Text Creation," and "Knowledge Base." In the "Dialogue" interface, assuming a user inputs the question "How long did I sleep last night?" via voice or text input, after receiving the question, the electronic device needs to first determine which intelligent agent can answer it based on the key information of the question, i.e., the user's intent. Since the question clearly asks about sleep duration, the sports and health intelligent agent is the one that can answer it. Therefore, the electronic device confirms that the sports and health intelligent agent can answer the question and distributes the question to it. After receiving the question through the sports and health intelligent agent, the sports and health big model also needs to determine the tool to be invoked. In this application, the tool to be invoked is determined by another big model that determines the tool to be invoked. Assuming this involves invoking an interface, the tool to be invoked is the data interface, through which data is read. The sports and health intelligent agent, based on certain reasoning steps, progressively and rationally invokes the sports and health big model and calls relevant tools to read data from the database. This allows the sports and health big model to integrate the answer to the question and send it to the display module for display. As shown in interface 102, the answer to the question is "You slept for 8 hours and 45 minutes last night." In addition, as shown in interface 102, it also shows that the source of the answer is the sports and health app, allowing the user to know which app's intelligent agent answered the question. Interface 102 also displays additional statements such as "Good sleep quality, normal sleep duration." These additional statements can be obtained by combining the user's personal information, such as age, to determine whether the sleep duration last night was normal, and are presented to the user as additional responses.
[0062] Interface 101 shows access to the intelligent Q&A from a sports and health app. Since it's confirmed that access is through the sports and health app, it's easy to see that the sports and health intelligent agent needs to invoke the sports and health big model to answer the question. Interface 102, on the other hand, provides an example of asking a question through a general intelligent interaction assistant or an app considered a centralized intelligent interaction platform. This question can be answered based on data retrieved from a database. Furthermore, in addition to answering the user's question, it also provides additional hints based on the user's personal information, allowing the user to know additional information related to the answer, making the Q&A results more user-friendly and accurate.
[0063] Users can enter interface 106 by clicking the icon of the intelligent interactive assistant on the desktop, or by waking it up with their voice. Other possible scenarios will not be listed one by one, as long as the intelligent interactive assistant can be activated.
[0064] Figure 1 This example illustrates the interaction between two question-and-answer scenarios. The user asks a question to obtain an answer, therefore, in addition to determining the overall model of the tool being invoked, a comprehensive question-and-answer model is needed to integrate the answer. In practical applications, intelligent question answering is also combined with intelligent control. The user's input question corresponds to a control command, such as opening or closing an app, searching for products, turning the screen off or on, returning to the home screen, shutting down or restarting, adjusting volume, making a call, sending a message, etc. In this case, the electronic device needs to execute the control command corresponding to the user's input question. The following section will combine... Figure 2 Please provide an explanation.
[0065] like Figure 2 As shown, interface 103 is the interface of the intelligent interactive application. Users input the question "Help me open app1" via voice or text input. Based on the user's intent to open a specific app, the electronic device uses a large model for determining the tool to be invoked (an example of the target large model below) to determine the required tool and related parameters, and then launches app1 using the determined tool. Since app launch takes some time, the processing result can be displayed on the interactive interface during app1 launch, such as an answer like "Okay, done!" or "Completed," as shown in interface 104. After launching app1, the electronic device displays the app1 homepage, as shown in interface 105. However, it should be understood that interface 104 can also be omitted, and the interface can switch directly from interface 103 to interface 105; there are no limitations on this.
[0066] With the continuous development of electronic device technology, voice wake-up interaction has emerged, allowing users to input questions via voice. Voice wake-up includes keyword wake-up and non-keyword wake-up. Keyword wake-up requires speaking a pre-set wake-up word, while non-keyword wake-up relies on posture and breath detection. The above-mentioned voice wake-up scenarios can still utilize the solution proposed in this application. The following section combines... Figure 3 Please provide an explanation.
[0067] like Figure 3 As shown, the electronic device includes microphone A and microphone B. After the user enters the voice wake-up mode, the voice interaction interface shown in interface 106 is displayed. The user speaks a question containing control commands into microphone B, "Turn off the screen." The question is displayed in interface 106. The electronic device determines that the tool to be called is the screen control tool by determining the large model of the tool to be called, and uses the screen control tool to turn off the screen, as shown in interface 107, the screen turns off.
[0068] from Figure 3 It can be seen that the answer to the question does not necessarily have to be displayed on the intelligent question-and-answer interaction interface.
[0069] It should be understood that Figures 1 to 3 This only provides examples of a few types of intelligent question-answering scenarios. In practical applications, there may be other intelligent interaction scenarios, such as a user asking "I want to listen to soothing music," and the electronic device determining the tool to call, opening an app that can play music, searching for soothing music, and playing it. Other scenarios will not be listed one by one. As long as it is an intelligent question-answering scenario and requires calling different tools to answer or respond to user questions, it is sufficient.
[0070] Figures 1 to 3 The electronic devices can be mobile phones, tablets, laptops, smart wearable devices, in-vehicle systems, etc., as long as they can perform intelligent question answering and deploy large models that can call specific tools. Figures 1 to 3 Electronic devices utilize large models already deployed on them for inference. Figures 1 to 3 The electronic device is an example of the reasoning device mentioned below.
[0071] Figure 4 This is a schematic diagram illustrating a large-scale model application scenario applicable to an embodiment of this application. For example... Figure 4 As shown, a large model typically includes a training phase and an inference phase. During training, a large number of training samples are used to train the model. During inference, the model is used for inference tasks, such as classification or feature extraction. In the training phase, the training device acquires a large number of training samples to train the initial model of the large model, resulting in a trained large model. The trained large model possesses the corresponding capabilities. The prediction results are compared with the true results (labels) of the training samples to adjust the weights of the initial model, thus completing one training iteration. The specific process is not elaborated further.
[0072] Training devices, due to the need for extensive computation, often utilize large-scale data processing equipment with high computing power, such as cloud servers. Inference devices, on the other hand, can be terminal devices such as mobile phones, tablets, laptops, and personal computers.
[0073] Once a large model is trained, it will have corresponding capabilities, such as image recognition (identifying people or objects from images) or speech extraction (extracting text from audio signals). It may have one or more of these capabilities, which will not be listed one by one.
[0074] The main objective of this application is to enable the large model to determine the tools and related parameters that need to be invoked in response to user input questions.
[0075] After training a large model, it needs to be deployed to an inference device. Since inference devices may have relatively weak computing power or different usage requirements, the deployment strategy may vary depending on the usage requirements of the inference device and its hardware and software resources (and / or computing power). For example, the trained large model may be simplified or subjected to hierarchical grouping or other processing before deployment to the inference device.
[0076] Once a large model is deployed on the inference device, it can be used for inference tasks. The inference device can collect or acquire inference objects and use the deployed large model to perform inference operations on the inference objects to obtain the inference results. For example, for a face recognition task, the inference object can be a frame or an image. The deployed large model performs inference operations on the image to obtain the face information (inference result) in that image. Other cases will not be listed one by one.
[0077] In this application, the main approach is to utilize a pre-deployed target model to determine the tools to be invoked and their related parameters during intelligent question answering, thereby enabling the correct tools to be invoked to respond to user-input questions.
[0078] In short, during the training phase, the target large model needs to be trained on the training device, and during the inference phase, the target large model deployed on the inference device needs to perform inference to infer the correct tool and its correct relevant parameters corresponding to the user's input question.
[0079] Figure 5 This is a schematic diagram illustrating how to determine the tool to be invoked during intelligent question answering, applicable to an embodiment of this application. For example... Figure 5 As shown, the user inputs a question through device A. Device A uses a large model already deployed on device A to perform reasoning, selects the target tool from the candidate tools on device A, responds to the user's input question using the target tool, and presents the execution result to the user through device A. This example illustrates various tools such as security tools, settings tools, search tools, and shopping tools. In reality, other tools may exist, or the naming and functional division of tools may differ from the example above. Other cases will not be elaborated further, and there is no limitation on the type of tool.
[0080] Figure 6 This is a schematic flowchart illustrating a method for training a large model according to an embodiment of this application. Figure 6 This is the training phase, the process of training a large model on training equipment. The following is... Figure 6 The steps are explained below. Figure 6 The method shown is applied to the training device.
[0081] S601. Obtain the first sample set.
[0082] The first sample set includes multiple samples, each of which includes a question and the correct label corresponding to that question. The correct label is the correct answer to the tool and related parameters that need to be called in response to the question.
[0083] Responding to this question may involve providing an answer or performing one or more operations (such as control commands) that correspond to the question; there are no limitations.
[0084] A sample might be something like "Turn off the screen, screen control tool - turn off," where "Turn off the screen" is the question, "screen control tool" is the corresponding tool, and "turn off" is the relevant parameter. It should be understood that this is merely an example; there are no restrictions on the specific sample format or content. "Screen control tool - turn off" is the correct answer to the question "Turn off the screen."
[0085] The first sample set can be a set of samples manually annotated by annotators and stored in a database, electronic device, or a storage device / module. Therefore, step S601 can be reading the first sample set from the storage unit, or obtaining the first sample set from a database or network through a communication interface, etc., without any limitation.
[0086] S602. Use the first sample set to train the first large model to obtain the trained first large model.
[0087] The first sample set consists of questions and correct answers (positive samples), which allows the first model to learn the correct knowledge and thus have the ability to correctly predict the tools and related parameters that need to be called.
[0088] In one implementation, a first large model is trained using a first sample set to obtain a trained first large model, including:
[0089] For each sample in the first sample set, perform the following operations: input the question in each sample into the first large model, and obtain the predicted answer through the first large model. The predicted answer includes the prediction results of the tools and related parameters that need to be called to respond to the question; update the parameters of the first large model with the aim of reducing the difference between the predicted answer and the correct answer in the sample.
[0090] If the first large model meets the preset training conditions, the trained first large model is obtained.
[0091] In this implementation, for each sample, the question is input into the primary model to obtain a predicted answer. This predicted answer is then compared with the correct answer in the sample. The parameters of the primary model are adjusted in reverse (updated) to minimize the difference between the two, thus making the updated primary model increasingly capable of inferring the correct answer. This training process is repeated for each sample until the primary model meets the preset training conditions, resulting in a well-trained primary model. The well-trained primary model has a high ability to determine which tools and parameters to use.
[0092] When updating the parameters of the first major model with the goal of minimizing the difference between the two, the method of updating the parameters of the first major model can be determined by minimizing the difference between the two and taking the derivative.
[0093] Optionally, a loss function can be constructed with the goal of increasing (e.g., maximizing) the similarity between the predicted answer of the first-largest model and the correct answer in the corresponding training samples. It should be understood that the closer the predicted answer is to the correct answer, the more accurate the prediction is, since the minimum difference between the two is equivalent to the maximum similarity.
[0094] In one implementation, the preset training conditions include at least one of the following: the first large model has completed a preset number of training rounds; the first large model has been trained using a preset number of samples; all samples in the first sample set have been used for training; and the prediction accuracy of the updated first large model meets the preset accuracy condition.
[0095] In this implementation, several preset training conditions are given. The training process can be controlled by the number of training rounds, by setting the number of samples, by the number of samples in the first sample set, or by the accuracy of the first large model after training.
[0096] The preset accuracy condition may include at least one of the following: the inference accuracy of the first large model is greater than or equal to the preset accuracy threshold, the inference error of the first large model is less than or equal to the preset error threshold, and the confidence level of the inference result of the first large model is within the preset confidence level range.
[0097] S603, Obtain the second sample set.
[0098] The second sample set includes multiple samples, each of which includes a question and a corresponding positive or negative label. The positive or negative label includes the correct and incorrect answers to the tools and related parameters required to respond to the question.
[0099] A sample in the second sample set could be, for example, "Turn off screen, screen control tool - off, screen control - on", or "Turn off screen, screen control tool - off, power control tool - shut down". Here, "Turn off screen" is the question, "screen control tool - off" is the correct answer to the question "Turn off screen", "screen control tool" is the correct answer for the corresponding tool, "off" is the correct answer for the relevant parameters, "screen control tool - on" is an incorrect answer where the tool is correct but the relevant parameters are incorrect, and "power control tool - shut down" is an incorrect answer where both the tool and relevant parameters are incorrect. It should be understood that this is merely an example; there are no specific limitations on the sample format or related content.
[0100] The second sample set can be a set of samples manually annotated by annotators and stored in a database, electronic device, or a storage device / module. Therefore, step S603 can be reading the second sample set from the storage unit, or obtaining the second sample set from a database or network through a communication interface, etc., without any limitation.
[0101] Furthermore, since this application aims to enable the large model to better learn correct knowledge and distinguish between correct and incorrect knowledge, it is also possible to further learn from the incorrect answers produced by the first trained large model. Therefore, positive samples can be input into the first trained large model first, and then the incorrect answers output by the first trained large model can be collected to construct samples in the second sample set, thereby relearning the incorrect questions and further improving the accuracy of the target large model.
[0102] In one implementation, obtaining the second sample set includes:
[0103] Obtain a third sample set, which includes multiple samples. Each sample includes a question and the correct label corresponding to the question. The correct label is the correct answer to the tool and related parameters that need to be called in response to the question.
[0104] The question of each sample in the third sample set is input into the trained first large model. The predicted answer is obtained by the trained first large model. Samples whose predicted answers are inconsistent with the correct answers are combined into negative samples, thus obtaining the fourth sample set. The fourth sample set includes at least one negative sample. Each negative sample includes a question and the incorrect answer of the tool and related parameters that need to be called to respond to the question.
[0105] Obtain the fifth sample set, which includes multiple negative samples. Each negative sample contains a question and the incorrect answer to the question, which requires the use of the corresponding tools and related parameters to respond to the question.
[0106] The second sample set is obtained by concatenating the correct and incorrect answers to the same questions in the samples of the third sample set with those in the samples of the fourth sample set, and by concatenating the correct and incorrect answers to the same questions in the samples of the fifth sample set.
[0107] In this implementation, a third sample set, including positive samples, is obtained. The questions from this third sample set are then input into the trained first large model. The incorrect answers output by the trained first large model are combined with their corresponding questions to construct negative samples, thus completing the collection of the fourth sample set. This fourth sample set is essentially the incorrect question set of the trained first large model, allowing subsequent training to focus on learning the differences between these incorrect and correct answers, effectively improving the accuracy of the target large model. The fifth sample set is the constructed negative sample set, obtained by concatenating positive samples (samples from the third sample set) and negative samples (samples from the fourth and fifth sample sets) to form the samples in the second sample set. Since the second sample set includes both correct and incorrect knowledge, and also focuses on collecting incorrectly answered questions from the trained first large model, it effectively improves the training effect when using the second sample set to train the second large model. This allows the second large model to more fully learn correct knowledge and the differences between correct and incorrect knowledge.
[0108] The methods for obtaining the third and fifth sample sets can be found in the first sample set, and will not be repeated here.
[0109] It should also be noted that although the third sample set can directly use the first sample set, since the first large model was trained using the first sample set, the first large model itself has higher inference accuracy for samples in the first sample set. Therefore, in order to fully test the ability of the trained first large model, samples that are different from those in the first sample set can be added to the third sample set as much as possible.
[0110] In one implementation, the samples in the third sample set are not exactly the same as the samples in the first sample set.
[0111] In this implementation, by ensuring that the samples in the third sample set are not completely identical to those in the first sample set, the error inferences of the trained first model can be identified as much as possible. This is equivalent to testing the trained first model with "advanced questions" to identify the questions that the model might get wrong, thus making it easier to compensate for its shortcomings through subsequent training.
[0112] S604. Using the second sample set and the trained first model, train the second model to obtain the trained second model.
[0113] The second, well-trained model is the target model used to determine the tools and relevant parameters to be invoked based on the question during intelligent question answering.
[0114] In one implementation, the second large model is trained using the second sample set and the pre-trained first large model, resulting in a pre-trained second large model, including:
[0115] For each sample in the second sample set, perform the following operations: input the question in each sample into the trained first and second large models; obtain a first predicted answer through the trained first large model and a second predicted answer through the second large model; both the first and second predicted answers include the prediction results of the tools and related parameters required to respond to the question; update the parameters of the second large model with the aim of reducing the fluctuation of the difference between the first and second predicted answers and increasing the log-likelihood difference between the second predicted answer and the correct and incorrect answers to the question;
[0116] If the second model meets the preset training conditions, a well-trained second model is obtained.
[0117] In this implementation, for each sample, the question is input into a pre-trained first-level model to obtain a predicted answer, and into a second-level model to obtain another predicted answer. The predicted answer output by the second-level model is then compared with the correct and incorrect answers in the sample, as well as the predicted answer output by the pre-trained first-level model. The primary objective is to maximize the difference in log-likelihood between the predicted answer from the second-level model and the correct and incorrect answers, while the secondary objective is to minimize the change in the difference between the two predicted answers. This process is used to adjust the parameters of the second-level model (updating its parameters), making the updated second-level model increasingly capable of inferring the correct answer. This training process is repeated for each sample until the second-level model meets the preset training conditions, resulting in a well-trained second-level model. The trained second-level model has a high ability to determine the appropriate tools and parameters. Since the first large model, which has been trained, can already output the correct answer, the two objectives mentioned above require the second large model to, while ensuring that the correctness of the correct answer is not reduced as much as possible (the fluctuation of the difference value between the first predicted answer and the correct answer is minimized), make the difference between the positive prediction and the negative prediction increasingly larger, and the difference between the positive prediction and the correct answer as small as possible, so as to effectively improve the accuracy of the target large model.
[0118] The first and second objectives mentioned above can be achieved by constructing loss functions, calculating losses, and determining how to update the parameters of the second-largest model by maximizing the difference and minimizing the similarity, respectively.
[0119] Optionally, the first objective can be to maximize the log-likelihood difference between the output of the second largest model and the "preference response" (i.e., the correct answer) and the "non-preference response" (i.e., the wrong answer); and the second objective can be to minimize the fluctuation of the similarity between the output of the second largest model and the output of the first largest model. A loss function can be constructed, the loss can be calculated based on the loss function, and the parameters of the second largest model can be updated by taking the derivative of the calculus gradient.
[0120] It should be noted that the second model must learn both correct knowledge and the differences between correct and incorrect knowledge, in order to better determine the correct knowledge.
[0121] Optionally, the first and second objectives mentioned above can be achieved based on an optimization method based on direct preferences.
[0122] In one implementation, the preset training conditions include at least one of the following: the second largest model has completed a preset number of training rounds; the second largest model has been trained using a preset number of samples; all samples in the second sample set have been used for training; and the prediction accuracy of the updated second largest model meets the preset accuracy condition.
[0123] Several preset training conditions are given. The training process can be controlled by the number of training rounds, by setting the number of samples, by the number of samples in the second sample set, or by the accuracy of the second large model after training.
[0124] The preset accuracy condition may include at least one of the following: the inference accuracy of the second largest model is greater than or equal to the preset accuracy threshold, the inference error of the second largest model is less than or equal to the preset error threshold, and the confidence level of the inference result of the second largest model is within the preset confidence level range.
[0125] In one implementation, the initial model for the second-largest model is the pre-trained first-largest model.
[0126] In this implementation, the second model is trained on the basis of the first model, which has already been trained. This allows for faster acquisition of higher inference accuracy, essentially a relearning process based on a certain level of prior learning.
[0127] It should be understood that the initial model of the second major model can also be the same as the initial model of the first major model, trained from scratch, or it can be the first major model after a period of training. However, the training rounds and training data of the second major model may be more, which means that it is not as fast as directly using the first major model that has been trained to meet the requirements of inference accuracy.
[0128] Figure 6The method described primarily involves training a first-large model using a set containing positive samples, resulting in a well-trained first-large model. Then, a second-large model is trained using this first-large model and a set of concatenated samples containing both positive and negative samples, resulting in a well-trained second-large model. This second-large model is used to determine the target large model for the tools to be invoked during intelligent question answering. This approach, by allowing the target large model to learn not only correct but also incorrect samples, enables it to better distinguish correct answers, thus effectively improving the accuracy of intelligent question answering when used in this context.
[0129] To a certain extent, this application's solution can be understood as follows: one large model learns correct knowledge, while another large model, while learning correct knowledge, also deepens its understanding of the differences between correct and incorrect answers. This allows the target large model to learn both correct and incorrect knowledge, thus enabling it to more firmly grasp the correct knowledge. In other words, it not only learns correct knowledge but also reinforces its understanding of incorrect answers, thereby effectively improving the accuracy of the target large model's reasoning.
[0130] Actual testing revealed the following accuracy rates for security tools: the standard large model achieved 63% accuracy, the first large model trained using the proposed solution achieved 77% accuracy, and the second large model trained using the proposed solution achieved 87% accuracy. For shopping tools, the standard large model achieved 64% accuracy, the first large model trained using the proposed solution achieved 74% accuracy, and the second large model trained using the proposed solution achieved 81% accuracy. These results demonstrate that the proposed solution effectively improves the accuracy of tool invocation.
[0131] To facilitate understanding of this application's scheme, specific examples and... Figures 7-10 The method for training large models in this application will be further explained.
[0132] Let's take the following two settings tools on an electronic device as examples.
[0133] The settings for Tool 1 and its related parameters can be configured as follows.
[0134] {'type': 'function', 'function': {'description': 'This tool supports operations on device power and status, including power on, power off, restart, standby, hibernation, screen off, and screen lock.', 'name':'device_operation', 'parameters': {'properties': [{'actionType': {'type':'string', 'description': 'Operation type, optional parameter values include 'Power on', 'Power off', 'Restart', 'Standby', 'Hibernation', 'Screen off', 'Screen lock', 'Screen on', 'Exit', 'Q&A'.} ... 'Power On' means turning on the device power, 'Power Off' means turning off the device power, 'Reboot' means restarting the device, 'Standby' means the device enters standby mode, 'Hibernate' means the device enters hibernation mode, 'Screen Off' means turning off the device screen display, 'Lock Screen' means locking the device screen, 'Screen On' means turning on the device screen, 'Exit' means exiting the current operation, and 'Q&A' means engaging in Q&A interaction. ', 'parameterrequired': 'Required'}}, {'device': {'type': 'string', 'description': 'Specified device for the operation', 'parameter required': 'Optional'}}, {'time': {'type': 'string', 'description': 'Specified operation time', 'parameter required': 'Optional'}},{'confirmState': {'type': 'string', 'description': 'Whether the operation requires secondary confirmation; optional parameter values include 'Confirm' and 'Cancel'. 'Confirm' means confirming the execution of the operation, and 'Cancel' means canceling the operation.','parameter required': 'not required'}}, {'app': {'type': 'string', 'description':'the app for the specified operation', 'parameter required': 'not required'}}, {'query': {'type':'string', 'description': 'question and answer content', 'parameter required': 'not required'}}],'required list': ['actionType'], 'type': 'object', 'response': {'properties':[], 'type': 'object'}}}}.
[0135] The settings for Tool 2 and its related parameters can be configured as follows.
[0136] {'type': 'function', 'function': {'description': 'This tool supports automatic screen rotation (it can automatically adjust the screen orientation according to the device's orientation), and supports operations such as setting, querying, turning on, and turning off.', 'name': 'auto_rotate', 'parameters': {'properties': [{'actionType':{'type': 'string', 'description': 'Operation type, optional parameter values include 'setting', 'query', 'turn on', 'turn off', 'Q&A'. 'Setting' indicates setting the automatic screen rotation parameters, 'query' indicates querying the automatic screen rotation status, 'turn on' indicates enabling the automatic screen rotation function, 'turn off' indicates disabling the automatic screen rotation function, and 'Q&A' indicates performing a Q&A interaction ... ', 'parameter required': 'required'}}, {'app': {'type': 'string','description': 'app for the specified operation', 'parameter required': 'optional'}}, {'query':{'type': 'string', 'description': 'question and answer content', 'parameter required': 'optional'}}], 'required list': ['actionType'], 'type': 'object', 'response':{'properties': [], 'type': 'object'}}}}.
[0137] It should be understood that the above are just two examples of setting tools. In practice, many other tools exist, and there are no limitations. Furthermore, the way related parameters are expressed may differ from the examples above, and again, there are no limitations. For example... Figure 7 The document shows some specific tools within the settings tools, including the blacklist tool, floating window tool, traffic calibration tool, and query operation tool. More refined tools can also be provided for shopping tools, search tools, etc., which will not be listed individually.
[0138] Figures 7 to 10 It can be seen as a... Figure 6 An example of the method shown is given below. Figures 7 to 10 Please provide an explanation.
[0139] Figure 7 This is a schematic diagram of a method for obtaining a first sample set according to an embodiment of this application. Figure 7 This can be seen as an example of step S601.
[0140] Step 1: Construct the first sample set using tools and a list of typical user questions in the "Settings Operations" domain. A specific example is as follows: (Turn off phone, device_operation (actionType=Shut down)), where "Turn off phone" represents the user question, and "device_operation (actionType=Shut down)" represents the expected correct output, which is the correct answer.
[0141] In other words, the sample is constructed in the format of "user question X, corresponding tool and parameters", where X can be a positive integer, but it should be understood that... Figures 7-10 This is just an example sample; there are no restrictions on the format or specific content.
[0142] Figure 8 This is a schematic diagram of a method for training a first large model according to an embodiment of this application. Figure 8 This can be seen as an example of step S602.
[0143] Step 2: Input each training sample in the first sample set into the first large model (large model 1) in the format of (user question X, corresponding tool and parameters), and the first large model will give the output result.
[0144] Step 3: Input the content of user question X from the training samples in step 2 into the first large model, perform matrix operations based on the neurons in the first large model, and finally output the predicted tool and parameters, which may be: device_operation(actionType=shutdown).
[0145] Step 4: With the goal of maximizing the similarity between the predicted output (predicted answer) of the first large model and the expected output (known correct answer) in the training samples, a loss function is constructed. Based on the loss function, the loss is calculated between the output (predicted answer) of the first large model and the expected output (correct answer) in the corresponding training samples. The parameters of the first large model are updated by taking the derivative of the calculus gradient, thus completing one round of training.
[0146] After training with a preset number of training data (e.g., 500, 600, etc.), the training of the first large model ends, and the trained first large model (trained large model 1) is obtained.
[0147] Figure 9 This is a schematic diagram of a method for obtaining a second sample set according to an embodiment of this application. Figure 9 This can be seen as an example of step S603.
[0148] Step 5 uses the same construction method as Step 1 to construct a third sample set based on tools and a list of typical user questions from the "settings operation" domain. A specific example is as follows: (Turn off phone, device_operation (actionType=shutdown)), where "Turn off phone" represents the user question, and "device_operation (actionType=shutdown)" represents the expected correct output. It should be understood that Step 5 does not directly use the first sample set because the first large model was trained using it. Therefore, the inference accuracy for questions in the first sample set is relatively high. The next step is to use the second large model to learn error knowledge to compensate for possible inference errors in the first large model. Therefore, reconstructing a third sample set that is not entirely the same as the first sample set can effectively improve the training effect. It can be seen that the third sample set consists entirely of positive samples: question + correct answer.
[0149] Step 6: Input the questions from the user question list (e.g., the question list of the third sample set), such as "Turn off the phone", into the trained first model to generate the results.
[0150] Step 7: Combine the results generated by the first trained model with the user's question, such as: Example 1: (Turn off the phone, device_operation (actionType=turn on)), Example 2: (Turn off the phone, device_operation(actionType=turn off)), and other examples will not be listed one by one.
[0151] Step 8: Filter out the incorrect tools and parameters from step 7. For example, (turn off phone, device_operation(actionType=turn off)) is filtered out, while (turn off phone, device_operation(actionType=turn on)) is retained. Other cases will not be listed one by one.
[0152] The tools and parameters used for filtering errors can be used to construct a fourth sample set, which consists of negative samples of questions plus incorrect answers. Cases where the first large model has already made incorrect inferences need to be corrected even more. Therefore, the addition of the fourth sample set will further improve the training effect and enhance the accuracy of the target large model's inference. Essentially, it retains the incorrect questions to deepen the understanding of them, allowing for better avoidance of incorrect answers and the attainment of correct answers.
[0153] Step 9: Construct the error tool and parameters, such as: Error tool name: (Turn off phone, device_operation(actionType=turn off)); Error parameter name: (Turn off phone, device_operation(actiontype=turn off)); Error parameter value: (Turn off phone, device_operation(actiontype=turn off)). Other cases will not be listed one by one. This yields the fifth sample set. The fifth sample set also contains negative samples of questions + incorrect answers.
[0154] Negative samples can be constructed in the format of "user problem X, error tool and parameters", where X can be a positive integer.
[0155] Step 10: Combine the samples from the fourth sample set obtained in step 8 and the fifth sample set constructed in step 9 into a negative sample set. Each sample in the negative sample set represents a question plus an incorrect answer.
[0156] Step 11: Concatenate the positive and negative samples. That is, take the samples from the third sample set constructed in step 5 as positive samples and the samples from the negative sample set (fourth sample set + fifth sample set) obtained in step 10 as negative samples, and concatenate them to obtain the second sample set. Each sample in the second sample set is the question + correct answer + incorrect answer.
[0157] The samples in the second sample set can be constructed in the format of "user problem X, corresponding tool and parameters, error tool and parameters", where X can be a positive integer.
[0158] Figure 10 This is a schematic diagram of a method for training a second large model according to an embodiment of this application. Figure 10 This can be seen as an example of step S604.
[0159] Step 12: Input each training sample in the second sample set into the format (user question X, corresponding tool and parameters, error tool and parameters) into the already trained first large model (trained large model 1) and second large model (large model 2). The first and second large models will output the results respectively, which are the output results of steps 13 and 14.
[0160] Step 13: Input the content of user question X from the training samples in step 12 into the trained first large model, perform matrix operations based on the neurons in the trained first large model, and finally output the predicted tool and parameters, which may be: device_operation(actionType=shutdown).
[0161] Step 14: Input the content of user question X from the training samples in step 12 into the second large model, perform matrix operations based on the neurons in the second large model, and finally output the predicted tool and parameters, which may be: device_operation(actionType=shutdown).
[0162] Step 15: The first objective is to maximize the log-likelihood difference between the output of the second largest model and the "preference response" (i.e., the correct answer) and the "non-preference response" (i.e., the wrong answer); the second objective is to minimize the fluctuation of the similarity between the output of the second largest model and the output of the first largest model. A loss function is constructed, the loss is calculated based on the loss function, and the parameters of the second largest model are updated by taking the derivative of the calculus gradient.
[0163] After training with a preset number of training data (e.g., 1000, 1200, etc.), the training of the second large model ends, resulting in the trained second large model (trained large model 2).
[0164] It's important to note that the second-largest model can either start from an untrained initial model and be trained using the pre-trained first-largest model, or it can directly use the pre-trained first-largest model as the initial model for further training. Using the pre-trained first-largest model as the initial model for continued training effectively improves training efficiency; the former is equivalent to learning from scratch, while the latter involves learning from a pre-existing learning foundation. It should also be understood that the updated first-largest model at any point in time during its training can also be used as the initial model for the second-largest model.
[0165] Figure 11 This is a schematic flowchart illustrating a method for invoking a tool according to an embodiment of this application. Figure 11 This is the inference phase, the process of performing inference using the large target model already deployed on the inference device. The following section... Figure 11 The steps are explained below. Figure 11 The method shown is applied to inference devices.
[0166] S1101, The first question is how to obtain user input.
[0167] Users can input questions into the inference device via voice or text.
[0168] Users can enter questions in the appropriate application interface of the inference device or in certain screen states, such as entering them in the application's display interface or during voice wake-up, without any restrictions.
[0169] The above text Figures 1 to 3 Several examples of user input questions are also provided.
[0170] In one implementation, the first step in obtaining user input includes:
[0171] Users can enter their first question via voice or text input on the first application's display interface. The first application is one that can perform intelligent question answering. Alternatively, users can enter their first question via voice activation while the screen is on or off.
[0172] This implementation refines the various input methods, making the applicable scenarios of this solution more flexible and diverse. Input can be made within the application's display interface, or via voice activation in either screen-on or screen-off states. Voice activation in screen-on state is mostly keyword-based, while voice activation in screen-off state is mostly breath-based. This solution is applicable to various intelligent question-answering scenarios to better meet user needs.
[0173] S1102. Use the deployed target model to reason about the first problem and obtain at least one target tool and its related parameters corresponding to the first problem.
[0174] The target large model is the target large model trained by any of the methods mentioned above for training large models.
[0175] This solution effectively improves the accuracy of inference results by using the target large model obtained through the training method of this application, thereby enabling users to get correct answers and responses to their questions and enhancing the user experience.
[0176] S1103. Invoke at least one target tool and its related parameters to respond to the first question.
[0177] By calling the appropriate tools according to the corresponding parameters, the system can respond to the question and thus complete the intelligent question answering process.
[0178] In one implementation, invoking at least one target tool to respond to the first question includes: if the first question is a question-and-answer question, invoking at least one target tool to obtain the answer to the question-and-answer question and providing feedback to the user through interface display or voice broadcast; or, if the first question is a control question, invoking at least one target tool to execute the control command corresponding to the control question.
[0179] This implementation refines the different response methods for different types of questions, thereby better meeting user needs. For question-and-answer type questions, the answer needs to be provided to the user, and the way to provide the answer can be flexible and diverse. For control questions, the corresponding control is executed.
[0180] In one example, if the first question is a question-and-answer question, at least one target tool is invoked to obtain the answer to that question and the answer is provided to the user through a user interface display or voice broadcast, including:
[0181] If the first question is entered through the display interface of the first application, the answer to the question will be displayed on the display interface of the first application.
[0182] If the first question is input via voice activation, the answer to the question will be read aloud via voice.
[0183] In this example, providing the answer to the user in a way that matches the user's input method can further enhance the user experience.
[0184] In another example, if the first problem is a control problem, at least one target tool is invoked to execute the control instructions corresponding to that control problem, including:
[0185] If the control command meets the preset control conditions, the control command is executed. The preset control conditions include at least one of the following: meeting security requirements, having control permissions, being able to find content that matches the control command, or being in the control whitelist.
[0186] If the control command does not meet the preset control conditions, the reason why the control command cannot be executed will be fed back to the user through interface display or voice broadcast.
[0187] This example refines the restrictions on the execution conditions of control commands. Control commands that affect security or for which the user lacks the necessary permissions are ignored to prevent damage to user information and electronic devices. For instance, if a user enters "delete a phone number," the electronic device cannot find that number. Or, if a user enters "uninstall an application," but that application is an essential application that cannot be uninstalled, other situations will not be listed. Forcibly executing control commands in these special cases, or executing commands on the wrong target, could lead to the corruption of user information or even damage to the inference device. The above solution precisely avoids such risks and improves security by setting control conditions.
[0188] In one implementation, the method further includes: receiving a target large model from a training device; and deploying the target large model to an inference device.
[0189] In this implementation, the target large model is provided as a source on the inference device, and after being trained on the training device, it is received and deployed by the inference device. However, it should be understood that it is also possible to use the target large model directly on the training device, in which case the training device serves as both a training device and an inference device.
[0190] The methods of the embodiments of this application have been described above with reference to the accompanying drawings. It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially, these steps are not necessarily executed in the order shown in the figures. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the steps or stages of other steps. The apparatus of the embodiments of this application will now be described with reference to the accompanying drawings.
[0191] Figure 12 This is a schematic diagram of the structure of a device for training a large model according to an embodiment of this application. Figure 12 As shown, the device 2000 includes an acquisition unit 2001 and a training unit 2002. The device 2000 can be integrated into electronic devices capable of training large models, such as servers or cloud servers. In other words, the device 2000 can be integrated into a training device.
[0192] The device 2000 can be used to execute any of the methods described above for training large models. For example, the acquisition unit 2001 can be used to execute steps S601 and S603, and the training unit 2002 can be used to execute steps S602 and S604. The device 2000 can also be used to execute... Figure 4 The steps of the training phase shown, and the methods for execution Figures 7-10 The steps will not be described in detail here.
[0193] In one implementation, the device 2000 may further include a storage unit for storing relevant data. This storage unit may be integrated into any of the aforementioned units, or it may be a unit independent of all of the aforementioned units.
[0194] Since the training data (sample set) is large in quantity, it can be stored in a database outside of device 2000.
[0195] Figure 13 This is a schematic diagram of the structure of a device for invoking a tool according to an embodiment of this application. Figure 13 As shown, the device 3000 includes an acquisition unit 3001 and a processing unit 3002. The device 3000 can be integrated into electronic devices capable of intelligent question answering, such as mobile phones, laptops, tablets, in-vehicle systems, and smart wearable devices. In other words, the device 3000 can be integrated into an inference device.
[0196] The device 3000 can be used to execute any of the above-described methods for invoking the tool. For example, the acquisition unit 3001 can be used to execute step S1101, and the processing unit 3002 can be used to execute steps S1102-S1103. The device 3000 can also be used to execute the steps of the inference stage shown in 4, and to execute... Figures 1-3 as well as Figure 5 The steps will not be described in detail here.
[0197] In one implementation, the device 3000 may further include a storage unit for storing relevant data. This storage unit may be integrated into any of the aforementioned units, or it may be a unit independent of all of the aforementioned units.
[0198] Figure 14 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of this application. Figure 14 As shown, the electronic device 4000 includes: at least one processor 4001 ( Figure 14(Only one is shown) a processor, a memory 4002, and a computer program 4003 stored in the memory 4002 and executable on the at least one processor 4001, wherein the processor 4001 executes the computer program 4003 to implement the steps of any of the methods described above. That is, the electronic device 4000 can be either the training device or the inference device described above.
[0199] Those skilled in the art will understand that Figure 14 This is merely an example of an electronic device and does not constitute a limitation on electronic devices. In practice, electronic devices may include more or fewer components than those shown in the illustration, or combinations of certain components, or different components. For example, they may also include input / output modules, network access modules, etc.
[0200] Processor 4001 may include one or more processing units, such as: a central processing unit (CPU), an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network process unit (NPU), other general-purpose processors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor. Different processing units may be independent devices or integrated into one or more processors.
[0201] The controller can serve as the nerve center and command center of the electronic device 4000. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.
[0202] In some embodiments, memory 4002 may be an internal storage unit of electronic device 4000, such as a hard disk or memory of electronic device 4000. In other embodiments, memory 4002 may be an external storage device of electronic device 4000, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on electronic device 4000. Optionally, memory 4002 may include both internal and external storage units of electronic device 4000. Memory 4002 is used to store operating system, application programs, bootloaders, data, and other programs, such as program code of computer programs. Memory 4002 may also be used to temporarily store data that has been output or will be output.
[0203] The processor 4001 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 4001 is a cache memory. This memory can store instructions or data that the processor 4001 has just used or that are used repeatedly. If the processor 4001 needs to use the instruction or data again, it can directly retrieve it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 4001, and thus improves the efficiency of the system.
[0204] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0205] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0206] This application also provides an electronic device, which includes: one or more processors and a memory; the memory is coupled to one or more processors, and the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to enable the electronic device to perform the steps in any of the above methods.
[0207] This application also provides a chip system applied to an electronic device. The chip system includes one or more processors, which invoke computer instructions to cause the electronic device to perform the steps in any of the methods described above. Optionally, the chip system further includes a memory electrically connected to the processor. Optionally, the chip system may also include a communication interface.
[0208] This application also provides a computer-readable storage medium storing instructions that, when executed by an electronic device, can implement any of the above-described methods. This computer-readable medium may include at least: any entity or device capable of carrying computer program code (instructions) to a photographic device / electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks.
[0209] This application also provides a computer program product, which includes a computer program that, when executed by an electronic device, can implement any of the above-described methods. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form.
[0210] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0211] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0212] In the embodiments provided in this application, it should be understood that the disclosed apparatus / devices and methods can be implemented in other ways. For example, the apparatus / device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0213] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0214] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0215] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0216] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0217] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0218] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for training large models, applied to a training device, characterized in that, include: Obtain a first sample set, which includes multiple samples. Each sample includes a question and the correct label corresponding to the question. The correct label is the correct answer to the tool and related parameters that need to be invoked in response to the question. The first large model is trained using the first sample set to obtain the trained first large model; Obtain a second sample set, which includes multiple samples. Each sample includes a question and a corresponding positive and negative concatenation label. The positive and negative concatenation label includes the correct and incorrect answers of the tools and related parameters required to respond to the question. Using the second sample set and the trained first large model, the second large model is trained to obtain the trained second large model; the trained second large model is the target large model used to determine the tools and related parameters to be invoked based on the question during intelligent question answering.
2. The method according to claim 1, characterized in that, The initial model of the second largest model is the first largest model that has been trained.
3. The method according to claim 1, characterized in that, The step of training the first large model using the first sample set to obtain the trained first large model includes: For each sample in the first sample set, the following operations are performed: input the question in each sample into the first large model, and obtain a predicted answer through the first large model. The predicted answer includes the prediction results of the tools and related parameters that need to be invoked to respond to the question; update the parameters of the first large model with the aim of reducing the difference between the predicted answer and the correct answer in the sample. Under the condition that the first large model meets the preset training conditions, the trained first large model is obtained.
4. The method according to claim 3, characterized in that, The preset training conditions include at least one of the following: the first large model has completed a preset number of training rounds; the first large model has been trained using a preset number of samples; all samples in the first sample set have been used for training; and the prediction accuracy of the updated first large model meets the preset accuracy condition.
5. The method according to any one of claims 1 to 4, characterized in that, The step of training the second large model using the second sample set and the trained first large model to obtain the trained second large model includes: For each sample in the second sample set, the following operations are performed: input the question in each sample into the trained first large model and the second large model; predict a first predicted answer through the trained first large model; and predict a second predicted answer through the second large model. Both the first and second predicted answers include the prediction results of the tools and related parameters required to respond to the question. The parameters of the second large model are updated with the aim of reducing the fluctuation of the difference between the first and second predicted answers and increasing the log-likelihood difference between the second predicted answer and the correct and incorrect answers to the question. Under the condition that the second major model meets the preset training conditions, the trained second major model is obtained.
6. The method according to claim 5, characterized in that, The preset training conditions include at least one of the following: the second large model has completed a preset number of training rounds; the second large model has been trained using a preset number of samples; all samples in the second sample set have been used for training; and the prediction accuracy of the updated second large model meets the preset accuracy condition.
7. The method according to any one of claims 1 to 4, characterized in that, The process of obtaining the second sample set includes: Obtain a third sample set, which includes multiple samples. Each sample includes a question and the correct label corresponding to the question. The correct label is the correct answer to the tool and related parameters that need to be called in response to the question. The question of each sample in the third sample set is input into the trained first large model. The predicted answer is obtained by the trained first large model. Samples whose predicted answers are inconsistent with the correct answers are combined into negative samples to obtain a fourth sample set. The fourth sample set includes at least one negative sample. Each negative sample includes a question and the incorrect answer of the tool and related parameters that need to be called to respond to the question. Obtain a fifth sample set, which includes multiple negative samples. Each negative sample includes a question and an incorrect answer to the question, along with the tools and related parameters required to respond to that question. The second sample set is obtained by concatenating the correct and incorrect answers to the same questions in the samples of the third sample set with the samples of the fourth sample set, and by concatenating the correct and incorrect answers to the same questions in the samples of the fifth sample set.
8. The method according to claim 7, characterized in that, The samples in the third sample set are not exactly the same as the samples in the first sample set.
9. A method for invoking a tool, applied to an inference device, characterized in that, include: The first question in obtaining user input; Using the deployed target model, reason about the first problem to obtain at least one target tool and its related parameters corresponding to the first problem; The target large model is a target large model trained using the method described in any one of claims 1 to 8; The first problem is responded to by invoking at least one target tool and its associated parameters.
10. The method according to claim 9, characterized in that, The first question regarding obtaining user input includes: The user inputs the first question via voice or text input on the display interface of the first application, which is an application capable of intelligent question answering; or... The user can input the first question by voice activation, whether the screen is on or off.
11. The method according to claim 9, characterized in that, The invocation of the at least one target tool to respond to the first problem includes: If the first question is a question-and-answer question, the at least one target tool is invoked to obtain the answer to the question-and-answer question, and the answer is provided to the user through interface display or voice broadcast; or... If the first problem is a control problem, the at least one target tool is invoked to execute the control instructions corresponding to the control problem.
12. The method according to claim 11, characterized in that, When the first question is a question-and-answer question, the step of invoking at least one target tool to obtain the answer to the question-and-answer question and providing feedback to the user through interface display or voice broadcast includes: When the first question is entered through the display interface of the first application, the answer to the question is displayed in the display interface of the first application; If the first question is input via voice activation, the answer to the question will be read aloud via voice.
13. The method according to claim 11, characterized in that, When the first problem is a control problem, invoking the at least one target tool to execute the control instructions corresponding to the control problem includes: The control command is executed when the control command meets the preset control conditions. The preset control conditions include at least one of the following: meeting security requirements, having control permissions, being able to find content that matches the control command, or being in the control whitelist. If the control command does not meet the preset control conditions, the reason why the control command cannot be executed will be fed back to the user through interface display or voice broadcast.
14. The method according to any one of claims 9 to 13, characterized in that, The method further includes: Receive the target large model from the training device; The target large model is deployed to the inference device.
15. An electronic device, characterized in that, The electronic device includes: one or more processors, and memory; The memory is coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, the one or more processors calling the computer instructions to cause the electronic device to perform the method as described in any one of claims 1 to 8, or to perform the method as described in any one of claims 9 to 14.
16. A chip system, characterized in that, The chip system is applied to an electronic device, the chip system including one or more processors, the one or more processors being used to invoke computer instructions to cause the electronic device to perform the method as described in any one of claims 1 to 14.
17. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1 to 14.
18. A computer program product, characterized in that, The computer program product includes a computer program that, when run on an electronic device, causes the electronic device to perform the method as described in any one of claims 1 to 14.
Citation Information
Patent Citations
Model training method and device, electronic equipment and storage medium
CN114691815A
Network model training method, recommendation method and system
CN119538984A