Interface calling method and related device
By splitting the API call task into multiple subtasks and designing specific templates, the stability and success rate problems of complex API call scenarios in the prior art are solved, and higher accuracy and stability are achieved.
Patent Information
- Application Number
- PCT/CN2024/091842
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-22
- Filing Date
- 2024-05-09
- Publication Date
- 2025-05-01
AI Technical Summary
The prior art is difficult to support complex and multi-demand API call scenarios, and the stability and success rate of LLM in API calls are poor, making it difficult to meet business needs.
By splitting the interface call task into multiple subtasks and designing specific prompt templates and reply templates for each subtask, it reduces the pressure of logical thinking in the language model and improves accuracy and stability.
Supports more complex and multi-demand API call scenarios, improves the accuracy and stability of natural language interaction systems, and improves the success rate of API call.
Smart Images

Figure CN2024091842_01052025_PF_FP_ABST
Abstract
Description
An interface calling method and related equipment
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on October 24, 2023, with application number 202311384899.7 and invention name “An interface calling method and related equipment”, and claims priority to the Chinese patent application filed with the State Intellectual Property Office on January 22, 2024, with application number 202410089511.9 and invention name “An interface calling method and related equipment”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of artificial intelligence (AI) technology, and in particular to an interface calling method, a natural language interaction system, a computing device cluster, a computer-readable storage medium, and a computer program product. Background Art
[0003] With the continuous development of AI technology, implementing AI capabilities based on large language models (LLMs) is becoming a growing trend. LLMs are essentially language models composed of artificial neural networks with many parameters (typically billions of weights or more). They can be trained on large amounts of unlabeled text using self-supervised or semi-supervised learning. Because LLMs have achieved good results across a wide range of tasks, a growing number of users expect to apply LLMs to a variety of services, leveraging their capabilities to provide more efficient, convenient, and user-friendly services, rather than being limited to a question-and-answer assistant.
[0004] Currently, using LLM to call application programming interfaces (APIs) is a hot topic of research. However, LLM typically only implements limited functionality in certain scenarios and is insufficient to support more complex and demanding API call scenarios. Furthermore, the stability and success rate of API calls using LLM are poor, making it difficult to meet business needs.
[0005] Summary of the Invention
[0006] This application provides an interface calling method. This method uses a unique subtask splitting method to split the task into multiple subtasks related to the interface call, reducing the pressure on language models such as LLM to perform logical thinking. This can support more complex and demanding API calling scenarios and improve the accuracy of the natural language interaction system. In addition, this method designs specific prompt templates and answer templates for each subtask to enhance the model's understanding of the prompts and generate fixed-format answers, reducing the randomness and instability of API calls and further improving accuracy. This application also provides a natural language interaction system, controller, computing device cluster, computer-readable storage medium, and computer program product corresponding to the above method.
[0007] In a first aspect, the present application provides an interface calling method. The method is applied to a natural language interaction system. The natural language interaction system can be a software system, which can be an independent software system, or a web application, a plug-in integrated into other applications, or a small program. The software system is deployed in a computing device cluster, and the computing device cluster executes the program code of the software system, thereby executing the interface calling method of the present application. The software system can be provided to the user in the form of a software package and deployed by the user. The software system can also be deployed in a public cloud and provided to the user in the form of a cloud service. The natural language interaction system can also be a hardware system, and when the hardware system is running, it executes the interface calling method of the present application.
[0008] The natural language interaction system is used to execute multiple subtasks related to the interface call based on the user's input information to realize the interface call. The natural language interaction system includes a controller. Among them, the controller can receive the natural language description input by the user, obtain the first prompt template corresponding to the first subtask among the multiple subtasks, splice the first prompt template with the natural language description input by the user, input the splicing result into the language model, and obtain the inference result output by the language model according to the first answer template corresponding to the first subtask. When the parameter integrity check subtask among the multiple subtasks is executed, and the inference result of the parameter integrity check subtask indicates that the necessary parameters of the target interface to be called are complete, the controller executes the interface call according to the necessary parameters of the target interface, obtains the interface call result, and presents the interface call result to the user.
[0009] This method splits the interface call task into multiple atomic subtasks, reducing the pressure on the language model to perform logical thinking, reducing the difficulty of language model reasoning, and improving the accuracy of language model reasoning. In addition, the method designs specific prompt templates and response templates for the subtasks, allowing the language model to reason and output reasoning results according to the templates, thereby reducing randomness and improving stability. This method enables the embedding of tool calls in natural language interaction systems such as chat dialogue systems. For example, there are more than 8,000 or even more APIs. Users can interact with the system through natural language to implement API calls.
[0010] In some possible implementations, the controller may further determine a second subtask to be executed based on the inference result of the first subtask. The controller obtains a second prompt template corresponding to the second subtask, concatenates the second prompt template with the user's input information, inputs the concatenated result into a language model, and obtains an inference result output by the language model based on the second answer template corresponding to the second subtask.
[0011] This method doesn't require a language model to control the process, reducing the burden of logical reasoning on the language model. Instead, it simply determines the next subtask to execute based on the results of the current subtask. Subtasks can be flexibly connected. This subtask chaining and logical reasoning effectively address various complex scenarios and improve the stability of the architecture.
[0012] In some possible implementations, when the first subtask is an interface identification subtask and the second subtask is a request parameter extraction subtask, the controller can also obtain the necessary parameter information of the target interface based on the interface identifier of the target interface in the reasoning result of the first subtask. When constructing the prompt, the controller can splice the second prompt template with the natural language description entered by the user and the necessary parameter information. This can provide richer information for the language model and improve the accuracy of language model reasoning.
[0013] In some possible implementations, when the first subtask is a request parameter extraction subtask and the second subtask is a parameter integrity check subtask, if the inference result of the parameter integrity check subtask indicates that the required parameters of the target interface are incomplete, the controller executes a prompt subtask from among the multiple subtasks, where the prompt subtask is used to prompt the user to provide the missing required parameters.
[0014] This method increases the ability to interact with users during the interface call process, guiding users to provide necessary parameters to improve the success rate of API calls.
[0015] In some possible implementations, the controller may receive a natural language description input by the user for the prompt subtask, then execute the input type identification subtask, and when the inference result of the input type identification subtask is an answer, execute the answer parameter extraction subtask.
[0016] When guiding the user to provide necessary parameters, this method does not limit the user's answer format. The user can provide parameters in various formats of natural language, thereby improving the flexibility of the system.
[0017] In some possible implementations, the controller can determine the second subtask to be executed based on the reasoning results of the first subtask and the relationships between multiple subtasks. This method determines the next subtask to be executed based on the reasoning results of the current first subtask and the logical relationships between different subtasks, thus achieving flexible connections between subtasks. Process control does not require a language model, reducing the burden of logical thinking in the language model.
[0018] In some possible implementations, the controller may also obtain a corpus pair corresponding to the prompt template and the reply template corresponding to the subtask, which may be a question-answer pair. The controller may then input the corpus pair into the language model for supervised fine-tuning SFT.
[0019] This method reduces the difficulty and quantity requirements of constructing training corpus, and does not require manual annotation of large amounts of data, including complex multi-round dialogue scenarios. For example, the task of parameter extraction does not need to cover all interfaces and parameter combinations, and only a small amount of data is needed to achieve generalization capabilities.
[0020] In some possible implementations, the multiple subtasks include a combination of the following subtasks:
[0021] Input type identification subtask, interface call requirement identification subtask, interface identification subtask, request parameter extraction subtask, parameter integrity check subtask, prompt subtask or answer parameter extraction subtask.
[0022] Through the unique sub-task splitting method mentioned above, this method reduces the pressure on the language model to perform logical thinking and improves the accuracy of the natural language interaction system.
[0023] In some possible implementations, the language model can be a large language model (LLM). By using the LLM as a classifier in classification tasks, constructing specific prompts for the LLM to make judgments and perform SFT, the trained model can generalize much better than smaller models and achieve good results with relatively small amounts of data, meeting business needs.
[0024] In a second aspect, the present application provides a natural language interaction system. The natural language interaction system is used to execute multiple subtasks related to interface calls based on user input information to implement interface calls, and the natural language interaction system includes a controller and a language model;
[0025] The controller is configured to receive a natural language description input by a user, obtain a first prompt template corresponding to a first subtask among the multiple subtasks, concatenate the first prompt template with the natural language description input by the user, input the concatenation result into the language model, and obtain an inference result output by the language model according to a first answer template corresponding to the first subtask;
[0026] The controller is also used to, when executing the parameter integrity check subtask among the multiple subtasks and the inference result of the parameter integrity check subtask indicates that the necessary parameters of the target interface to be called are complete, perform an interface call according to the necessary parameters of the target interface, obtain an interface call result, and present the interface call result to the user.
[0027] In some possible implementations, the controller is further configured to:
[0028] Determining a second subtask to be performed based on the reasoning result of the first subtask;
[0029] Obtain a second prompt template corresponding to the second subtask, splice the second prompt template with the user's input information, input the splicing result into the language model, and obtain the inference result output by the language model according to the second answer template corresponding to the second subtask.
[0030] In some possible implementations, when the first subtask is an interface identification subtask and the second subtask is a request parameter extraction subtask, the controller is further configured to:
[0031] Obtaining necessary parameter information of the target interface according to the interface identifier of the target interface in the reasoning result of the first subtask;
[0032] The controller is specifically used for:
[0033] The second prompt template is spliced with the natural language description input by the user and the necessary parameter information.
[0034] In some possible implementations, when the first subtask is a request parameter extraction subtask and the second subtask is a parameter integrity check subtask, the controller is further configured to:
[0035] When the reasoning result of the parameter integrity check subtask indicates that the necessary parameters of the target interface are incomplete, a prompt subtask among the multiple subtasks is executed, and the prompt subtask is used to prompt the user to provide the missing necessary parameters.
[0036] In some possible implementations, the controller is specifically configured to:
[0037] receiving a natural language description input by the user for the prompt subtask, and then performing an input type identification subtask;
[0038] The controller is also used to:
[0039] When the inference result of the input type identification subtask is an answer, the answer parameter extraction subtask is executed.
[0040] In some possible implementations, the controller is specifically configured to:
[0041] A second subtask to be executed is determined according to the inference result of the first subtask and the association relationship between the multiple subtasks.
[0042] In some possible implementations, the controller is further configured to:
[0043] Obtaining a corpus pair corresponding to a prompt template and a reply template corresponding to the subtask, wherein the corpus pair is a question-answer pair;
[0044] The corpus is input into the language model for supervised fine-tuning SFT.
[0045] In some possible implementations, the multiple subtasks include a combination of the following subtasks:
[0046] Input type identification subtask, interface call requirement identification subtask, interface identification subtask, request parameter extraction subtask, parameter integrity check subtask, prompt subtask or answer parameter extraction subtask.
[0047] In a third aspect, the present application provides a computing device cluster. The computing device cluster includes at least one computing device, wherein the at least one computing device includes at least one processor and at least one memory. The at least one processor and the at least one memory communicate with each other. The at least one processor is configured to execute instructions stored in the at least one memory, so that the computing device or computing device cluster performs the interface calling method described in the first aspect or any implementation of the first aspect.
[0048] In a fourth aspect, the present application provides a controller. The controller includes a processor and a memory. The memory stores computer-readable instructions, and the processor executes the computer-readable instructions to cause the controller to execute the interface calling method described in the first aspect or any implementation of the first aspect.
[0049] In a fifth aspect, the present application provides a computer-readable storage medium, in which instructions are stored, and the instructions instruct a computing device or a computing device cluster to execute the interface calling method described in the above-mentioned first aspect or any implementation of the first aspect.
[0050] In a sixth aspect, the present application provides a computer program product comprising instructions, which, when run on a computing device or a computing device cluster, enables the computing device or computing device cluster to execute the interface calling method described in the first aspect or any one of the implementations of the first aspect.
[0051] Based on the implementation methods provided in the above aspects, this application can also be further combined to provide more implementation methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the technical methods of the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments.
[0053] FIG1 is a schematic diagram of the architecture of a natural language interaction system provided by this application;
[0054] FIG2 is a schematic diagram of a method for disassembling multiple subtasks provided by the present application;
[0055] FIG3 is a flow chart of an interface calling method provided by the present application;
[0056] FIG4 is a schematic diagram of a subtask execution process provided by this application;
[0057] FIG5 is a schematic diagram of a subtask execution process provided by this application;
[0058] FIG6 is a schematic diagram of a subtask execution process provided by this application;
[0059] FIG7 is a schematic diagram of a subtask execution process provided by this application;
[0060] FIG8 is a schematic diagram of a subtask execution process provided by this application;
[0061] FIG9 is a schematic diagram of a subtask execution process provided by this application;
[0062] FIG10 is a schematic diagram of a subtask execution process provided by this application;
[0063] FIG11 is a schematic diagram of a subtask execution process provided by this application;
[0064] FIG12 is a flow chart of a non-API call input type provided by the present application;
[0065] FIG13 is a schematic diagram of the structure of a computing device provided by the present application;
[0066] FIG14 is a schematic diagram of the structure of a computing device cluster provided by this application;
[0067] FIG15 is a schematic diagram of the structure of another computing device cluster provided by the present application;
[0068] FIG16 is a schematic diagram of the structure of another computing device cluster provided in this application. DETAILED DESCRIPTION
[0069] The terms "first" and "second" in the embodiments of this application are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of technical features indicated. Therefore, features specified as "first" or "second" may explicitly or implicitly include one or more of the features.
[0070] First, some technical terms involved in the embodiments of this application are introduced.
[0071] A natural language interaction system, also known as a dialogue system, question-and-answer system, or chat system, is a system that responds to natural language input from users, such as answering questions. This response can be implemented using artificial intelligence (AI) models.
[0072] A typical example of an AI model is a language model (LM). A language model is a probability distribution model of words in a natural language. For example, a word sequence w1, w2…w of length m is provided. m , calculate the probability of these words: P(w1,w2…w m Language models can be used to determine which word is most likely to appear, or to predict the next most likely word based on several preceding contextual words. Language models are frequently used in many natural language processing applications, such as speech recognition, machine translation, part-of-speech tagging, syntactic analysis, handwriting recognition, and information retrieval.
[0073] Language models can be categorized into different types, such as n-gram language models and neural network-based language models. Language models can also be categorized into small language models and large language models (LLMs) based on parameter size. LLMs consist of artificial neural networks with many parameters (typically billions of weights or more) and are trained on large amounts of unlabeled text using self-supervised or semi-supervised learning. Due to their outstanding performance across a variety of tasks, LLMs are currently widely adopted by the industry for natural language processing-related tasks. For ease of description, the following examples use language models as LLMs.
[0074] Natural application interaction systems can be used in interface call scenarios. An interface can be an application programming interface (API), specifically a way for one program to interact with another. API calls enable interaction between different programs and enable the use of their capabilities. Most APIs define required parameters, also known as mandatory or optional parameters, which are typically required when making an API call. Currently, users manually enter the required parameters for API calls. Natural language interaction systems based on LLM can assist users in completing API calls. For example, a user can enter a natural language description in a chat box, and the natural language interaction system can identify whether to call an API and which API to call to fulfill the user's intent. Given that some API parameters are complex and users lack understanding of the API's internal structure, users expect the natural language interaction system to extract the API parameters from the user's natural language description. Or, if the parameters are incomplete, guide the user to provide the necessary parameters for a successful API call, thereby improving the success rate and efficiency of API calls.
[0075] Currently, the industry offers a method for making API calls based on LLM and prompts. This method requires pre-writing a prompt for the specific scenario, including the scenario, available actions, the basis for selection, and the format of the response. This prompt is then passed to the LLM, which then autonomously analyzes the next action based on its understanding of the scenario and the user's current input. The LLM then post-processes the LLM's response to extract key information, automatically concatenating the generated results and the user's input into the original prompt before passing it back to the LLM.
[0076] This approach relies primarily on the LLM's logical thinking and clear prompts, allowing it to independently control the entire conversation and call process, adapting to different scenarios. However, this approach requires pre-setting scenarios and clearly selecting the requirements for each action. Complex scenarios and execution rules can lead to LLMs' poor logical comprehension and difficulty understanding prompts. Furthermore, the inference results generated by this approach are highly unstable and random. For complex scenarios, users expect higher API call success rates and efficiency.
[0077] In view of this, the present application provides an interface calling method. The method can be executed by a natural language interaction system (also referred to as the system). The natural language interaction system is embedded with the ability to call interfaces. Users can have ordinary question-and-answer chats with LLM in the system, or they can put forward requirements. The system can call the corresponding tools to meet the user's needs. When making API calls, users do not need to tell the system which API should be called, nor do they need to click other function buttons to switch to the API call mode. They only need to put forward requirements in the form of natural language in the conversation. The system can automatically identify the user's intention to call the API, help the user find the correct API to call, and return the call results to the natural language interaction system. Moreover, the natural language interaction system can interact with the user during the API call process to guide the user to provide necessary parameters, thereby improving the success rate of API calls.
[0078] Among them, the natural language interaction system can be a software system, which can be an independent software system, or a web application, a plug-in integrated into other applications, or a small program. The software system is deployed in a computing device cluster, and the computing device cluster executes the program code of the software system, thereby executing the interface calling method of the present application. Among them, the software system can be provided to the user in the form of a software package and deployed by the user himself, for example, in a local data center or a private cloud. The software system can also be deployed in a public cloud and provided to users in the form of a cloud service. The natural language interaction system can also be a hardware system, and when the hardware system is running, it executes the interface calling method of the present application.
[0079] Specifically, the natural language interaction system is used to execute multiple subtasks related to the interface call based on the user's input information to realize the interface call. The natural language interaction system includes a controller, which can receive the natural language description input by the user, and then obtain the first prompt template corresponding to the first subtask among the multiple subtasks, splice the first prompt template with the natural language description input by the user, input the splicing result into the large language model LLM, and obtain the inference result output by the LLM according to the first answer template corresponding to the first subtask. When the parameter integrity check subtask among the multiple subtasks is executed, and the inference result of the parameter integrity check subtask indicates that the necessary parameters of the target interface to be called are complete, the controller executes the interface call according to the necessary parameters of the target interface, obtains the interface call result, and presents the interface call result to the user.
[0080] This method splits the interface call task into multiple atomic subtasks, reducing the pressure on the LLM to perform logical thinking, reducing the difficulty of LLM reasoning, and improving the accuracy of LLM reasoning. In addition, the method designs specific prompt templates and response templates for the subtasks, allowing the LLM to reason and output reasoning results according to the templates, thereby reducing randomness and improving stability. Among them, the method supports the construction of corpus pairs that match the format of the above-mentioned prompt templates and response templates, and inputs the corpus pairs into the LLM for supervised fine-tuning (SFT). This can achieve the use of the LLM's text comprehension capabilities, strengthen the model's understanding of the prompt and generate fixed-format answers through SFT, improve accuracy, and facilitate the extraction of relevant information from the LLM's reasoning results through fixed-format templates, improving post-processing efficiency.
[0081] Furthermore, this method incorporates a serialized subtask structure and logical reasoning to effectively address various complex scenarios and enhance the stability of the architecture. Furthermore, through the design of several subtasks, this method enhances user interaction during API calls, guiding users to provide necessary parameters and improving the success rate of API calls. Furthermore, this method does not restrict the format of user responses; users can provide parameters using a variety of natural language formats, enhancing system flexibility.
[0082] It should be noted that the technical solution of this application can be applied not only to LLM but also to other language models. LLM is only an example of a language model and does not constitute a limitation of the technical solution of this application. By splitting the interface call task into multiple subtasks related to the interface call, the pressure on the language model to perform logical thinking can be reduced, and the accuracy of language model reasoning can be improved.
[0083] In order to make the technical solution of this application clearer and easier to understand, the system architecture of this application is first introduced with reference to the accompanying drawings.
[0084] Referring to the architectural diagram of the natural language interaction system shown in FIG1 , the natural language interaction system 100 is used to execute multiple subtasks related to the interface call based on the user's input information to implement the interface call. The natural language interaction system 100 includes a controller 102. Furthermore, the natural application interaction system 100 also includes a large language model 104. The controller 102 can also be called a control system. The large language model can be a built-in large language model or a third-party large language model. This application does not limit the source or type of the large language model.
[0085] The controller 102 is a service system, including multiple disassembled subtasks. As shown in Figure 2, the multiple subtasks related to the interface call obtained by disassembly may include an input type identification subtask, an interface call requirement identification subtask, an interface identification subtask, a request parameter extraction subtask, a parameter integrity check subtask, a prompt subtask or an answer parameter extraction subtask. For the convenience of description, this application refers to the above subtasks as subtask 1 to subtask 7 in sequence. Subtask 1 is used to determine the type of user input, subtask 2 is used to determine whether the user input requires an API call, subtask 3 is used to identify the API, subtask 4 is used to extract parameters in the user request, subtask 5 is used to determine whether the necessary parameters are complete, subtask 6 is used to prompt the user to provide missing necessary parameters, and subtask 7 is used to extract parameters in the user's answer. When executing an API call, a combination of the above subtasks can be executed to implement the API call.
[0086] Specifically, controller 102 is configured to receive a natural language description input by a user, obtain a first prompt template corresponding to a first subtask among multiple subtasks, concatenate the first prompt template with the natural language description input by the user, input the concatenated result into large language model 104, and obtain an inference result output by large language model 104 based on the first answer template corresponding to the first subtask. The large language model can be a model that has undergone SFT, which can reduce randomness and improve stability.
[0087] The controller 102 is also used to execute an interface call according to the necessary parameters of the target interface when executing a parameter integrity check subtask among multiple subtasks, and when the inference result of the parameter integrity check subtask indicates that the necessary parameters of the target interface to be called are complete, obtain the interface call result, and present the interface call result to the user.
[0088] The natural language interaction system 100 may further include a prompt manager 106, or prompt manager. The prompt manager 106 stores a prompt template and a response template corresponding to at least one of the multiple subtasks. For example, the prompt manager 106 stores a prompt template and a response template corresponding to subtask 1, a prompt template and a response template corresponding to subtask 2, and prompt templates and response templates corresponding to other subtasks. The prompt manager 106 supports querying prompt templates or response templates corresponding to subtasks. The prompt model can be considered a prompt that requires splicing.
[0089] In some possible implementations, the natural language interaction system 100 may further include an interface database 108, such as an API database. The interface database 108 stores API parameter information and API descriptions. The API parameter information may include required API parameter information, such as parameter names and parameter types. When performing parameter extraction, the controller 102 may query the interface database 108 for required parameter information for a target interface, such as a target API, and perform parameter extraction based on this required parameter information.
[0090] Furthermore, the backend of the natural language interaction system 100 can be connected to an interface center 200, such as an API Center, to connect to a callable API. The interface center 200 can include multiple callable APIs and can execute actual API calls based on target API information provided by the natural language interaction system 100, such as the target API's interface name and interface parameters.
[0091] Based on the aforementioned natural language interaction system 100, the present application provides an interface calling method. The interface calling method of the present application is introduced below with reference to the accompanying drawings.
[0092] 3 shows a flowchart of an interface calling method, which is applied to a natural language interaction system 100. The natural language interaction system 100 is used to execute multiple subtasks related to the interface calling based on user input information to implement the interface calling. The method includes the following steps:
[0093] S302: The controller 102 receives a natural language description input by a user.
[0094] The natural language description may be a request described in natural language or a reply described in natural language. The controller 102 may provide an interactive interface or an interactive interface, through which a user may input a natural language description, and the controller 102 may receive the natural language description input by the user through the interactive interface or the interactive interface.
[0095] In some possible implementations, the controller 102 can display a graphical user interface (GUI) to the user. The graphical user interface, also known as a graphical user interface, refers to a computer operation user interface displayed in a graphical manner. The GUI may include a dialogue window, and the user can input a natural language description in text form through the dialogue window. In this case, the controller 102 can receive the natural language description text.
[0096] In some possible implementations, the controller 102 may provide an interactive interface to the user, such as a voice interaction interface, through which the user can input a natural language description in the form of voice. In this case, the controller 102 may receive the natural language description voice. Furthermore, the controller 102 may also convert the natural language description voice into natural language text through a speech-to-text algorithm or speech recognition.
[0097] S304. The controller 102 obtains a first prompt template corresponding to the first subtask among multiple subtasks, splices the first prompt template with the natural language description input by the user, inputs the splicing result into the large language model 104, and obtains the inference result output by the large language model 104 according to the first answer template corresponding to the first subtask.
[0098] In the present application, the interface call task can be split into multiple subtasks related to the interface call to realize the task call. Among them, the multiple subtasks split may include an input type identification subtask, an interface call requirement identification subtask, an interface identification subtask, a request parameter extraction subtask, a parameter integrity check subtask, a prompt subtask or an answer parameter extraction subtask, as shown in Figure 2. The controller 102 can execute several subtasks among the multiple subtasks split above to realize the interface call. For example, the controller 102 can execute the input type identification subtask, the interface call requirement identification subtask, the interface identification subtask, the request parameter extraction subtask, and the parameter integrity check subtask to obtain the parameters of the target interface to be called, and provide the parameters to the API center to make an API call. For another example, the controller 102 can execute all the above types of subtasks to obtain the parameters of the target interface to be called, and provide the parameters to the API center to make an API call.
[0099] Among them, the subtask is provided with a prompt template and a reply template. In specific implementation, each subtask can be provided with a prompt template and a reply template corresponding to the subtask. The template can be a template in a specific format. When executing the first subtask among multiple subtasks, the controller 102 obtains the first prompt template corresponding to the first subtask among the multiple subtasks. For example, the controller 102 can query the first prompt template corresponding to the first subtask from the prompt manager 106. The controller 102 then splices the first prompt template with the natural language description input by the user to obtain a splicing result. The splicing result can be a spliced prompt. The controller 102 inputs the spliced prompt into the large language model 104, and the large language model 104 can learn from the prompts and reason about the spliced prompts. Among them, during reasoning, the large language model 104 can output the reasoning result according to the first answer template corresponding to the first subtask.
[0100] In some possible implementations, the large language model 104 may be a model that has undergone SFT. SFT refers to pre-training a neural network model, i.e., the source model, on a source dataset, and then creating a new neural network model, i.e., the target model. The target model copies all model designs and parameters of the source model except the output layer. These model parameters contain the knowledge learned on the source dataset, and this knowledge is also applicable to the target dataset. The output layer of the source model is closely related to the labels of the source dataset, and therefore is not used in the target model. During fine-tuning, an output layer with an output size equal to the number of categories in the target dataset is added to the target model, and the model parameters of the layer are randomly initialized. When training the target model on the target dataset, the output layer will be trained from scratch, and the parameters of the remaining layers will be obtained based on the fine-tuning of the parameters of the source model. In this embodiment, the natural language interaction system 100 can obtain a corpus pair corresponding to the prompt template and the reply template corresponding to the subtask, the corpus pair being a question-answer pair, and the corpus pair is input into the large language model 104 for SFT. The set of corpus pairs can be considered as the target dataset. The output layer of the large language model 104 can be updated to an output layer with an output size equal to the number of categories in the target dataset, and the model parameters of this layer can be randomly initialized. The large language model can then be trained on the target dataset.
[0101] By performing SFT on the large language model 104 , the large language model 104 can enhance its understanding of prompts and generate answers in a fixed format, thereby improving accuracy and facilitating the extraction of information from the LLM generation results.
[0102] When the first subtask is not a parameter integrity check subtask, or the first subtask is a parameter integrity check subtask, but the execution result of the subtask is that the necessary parameters are incomplete, it means that the subtask execution process has not ended, and the controller 102 can continue to execute the next subtask. Specifically, the controller 102 determines the second subtask to be executed based on the reasoning result of the first subtask. Among them, the controller 102 can design the association relationship between multiple subtasks, such as the serial connection method and logical judgment of multiple subtasks. Accordingly, the controller 102 can determine the second subtask to be executed based on the reasoning result of the first subtask and the association relationship between multiple subtasks.
[0103] When executing the second subtask, controller 102 may adopt a similar approach to executing the first subtask. Specifically, controller 102 may obtain a second prompt template corresponding to the second subtask, concatenate the second prompt template with the user's input information, input the concatenated result into large language model 104, and obtain an inference result output by large language model 104 based on the second answer template corresponding to the second subtask.
[0104] In some possible implementations, when the first subtask is an interface identification subtask and the second subtask is a request parameter extraction subtask, the controller 102 can also obtain the necessary parameter information of the target interface based on the interface identifier of the target interface in the reasoning result of the first subtask, for example, by extracting the API name of the target API from the reasoning result of the first subtask. The necessary parameter information is information related to the necessary parameters of the target interface, including the parameter name and parameter type of the necessary parameters. In specific implementation, the controller 102 can query the API database based on the interface identifier of the target interface to obtain the necessary parameter information of the target interface. The controller 102 can then splice the second prompt template, the natural language description input by the user, and the above-mentioned necessary parameter information to obtain a spliced prompt.
[0105] In other possible implementations, the first subtask may be a request parameter extraction subtask, and the second subtask may be a parameter integrity check subtask. When the inference result of the parameter integrity check subtask indicates that the necessary parameters of the target interface are incomplete, the controller 102 may further execute a prompt subtask from among the multiple subtasks, the prompt subtask being used to prompt the user to provide the missing necessary parameters.
[0106] Accordingly, controller 102 can receive the natural language description entered by the user for the prompt subtask and then execute the input type identification subtask. If the inference result of the input type identification subtask is an answer, controller 102 executes the answer parameter extraction subtask. The answer parameter extraction subtask can extract missing parameters provided by the user. After extracting the parameters from the user's answer, they can be merged with the parameters extracted from the request, and then the parameter integrity check can be performed again.
[0107] S306. When the parameter integrity check subtask among multiple subtasks is executed, and the reasoning result of the parameter integrity check subtask indicates that the necessary parameters of the target interface to be called are complete, the controller 102 executes an interface call according to the necessary parameters of the target interface, obtains the interface call result, and presents the interface call result to the user.
[0108] The inference result of the parameter integrity check subtask indicates that the necessary parameters of the target interface to be called are complete, indicating that the complete parameters for the API call have been obtained. Controller 102 can provide these complete parameters to the API Center, such as the API name and complete API parameters, so that the API Center executes the interface call and obtains the interface call result returned by the API Center. The interface call result may include the call status, such as success. In some possible implementations, the interface call result may also include a return value. Controller 102 can present the interface call result to the user.
[0109] Based on the above description, it can be seen that this method splits the interface call task into multiple atomic subtasks, reducing the pressure on the LLM to perform logical thinking, reducing the difficulty of LLM reasoning, and improving the accuracy of LLM reasoning. Moreover, this method designs specific prompt templates and response templates for the subtasks, so that the LLM can reason and output reasoning results according to the templates, thereby reducing randomness and improving stability. Among them, this method supports the construction of corpus pairs that match the format of the above prompt templates and response templates, and inputs the corpus pairs into the LLM for supervised fine-tuning (SFT). In this way, the text understanding ability of the LLM can be utilized, and the model's understanding of the prompt and generation of fixed-format answers can be enhanced through SFT, thereby improving accuracy. In addition, the fixed-format template can be used to easily extract relevant information from the LLM's reasoning results, thereby improving post-processing efficiency.
[0110] In order to make the technical solution of this application clearer and easier to understand, the interface calling method of this application is introduced from the perspective of interaction in combination with a specific application scenario.
[0111] The following describes a specific process from request determination to actual API execution for a user request in the natural language interaction system 100. The method includes the following steps:
[0112] Step 1. Referring to the flowchart of the subtask execution shown in FIG4 , subtask 1 is first executed to judge the user input. Specifically, the user inputs "I want to create a code warehouse named ts_bot", as shown in FIG4 ①. The user input can be transmitted to the control system (i.e., the controller 102 mentioned above). The control system queries the prompt manager (i.e., the prompt manager 106 mentioned above) for the prompt corresponding to the subtask according to the specific subtask type, such as the subtask type shown in FIG4 ②. For example, as shown in FIG4 ③, the prompt manager returns the query result to the control system. The control system can splice the prompt, for example, splicing ① to the position of {question} in ③, and then pass the processed prompt, such as the information shown by character ④ in FIG4, to the LLM (i.e., the large language model 104 mentioned above). The LLM performs reasoning and passes the reasoning result, such as the information shown in FIG4 ⑤, to the control system for judgment of the next task.
[0113] In this example, the inference result is "request", so the next subtask may be subtask 2, which is to determine whether the user input requires calling an API.
[0114] Step 2. Referring to the flowchart of subtask execution shown in Figure 5, the control system determines the next subtask to be executed based on the inference result of the previous subtask, such as the information shown in ① in Figure 5, for example, [Request]. This subtask is subtask 2, which specifically determines whether the user input requires an API call, as shown in ② in Figure 5. The control system queries the prompt manager for the prompt corresponding to this subtask, as shown in ③ in Figure 5. The control system can splice the user input at the {question} position and pass the spliced prompt, such as the information shown in ④ in Figure 5, to the LLM. The LLM passes the inference result, such as the information shown in ⑤ in Figure 5, to the control system to make a judgment on the next task. The inference result may be that an API call is required.
[0115] Step 3. Referring to the subtask execution flow diagram shown in Figure 6, the control system determines the next subtask to be executed based on the inference result of the previous subtask, as shown in Figure 6 (①), specifically "Code Hosting" under "Cloud Service." As shown in Figure 6 (②), the next subtask to be executed is Subtask 3, which identifies the API. The control system can query the prompt manager for the prompt corresponding to the "Code Hosting" product line, as shown in Figure 6 (③). The prompt includes the names and descriptions of all APIs under "Code Hosting." The control system can concatenate the user input at the {user_intent} position and pass the concatenated prompt, as shown in Figure 6 (④), to the LLM. The LLM then passes the inference result, as shown in Figure 6 (⑤), to the control system.
[0116] Step 4. Referring to the subtask execution flow diagram shown in FIG7 , the control system determines the next subtask to be executed based on the inference result of the previous subtask, as shown in FIG7 ①. The subtask required after identifying the API is shown in FIG7 ②, specifically subtask 4, which is used to extract parameters from the user request. The control system queries the prompt manager for the prompt corresponding to subtask 4, as shown in FIG7 ③. Based on the inference result of the previous subtask ( FIG7 ①), the control system extracts the API name. The extracted API name is shown in FIG7 ④. The control system transmits it to the API database (i.e., interface center 200) and queries the API database for the required parameters corresponding to the API name. The query result is shown in FIG7 ⑤. The control system then concatenates the user-entered question with the API name and API parameter information, and transmits the concatenated prompt, as shown in FIG7 ⑥, to the LLM. The LLM transmits the inference result (parameter extraction result from the request), as shown in FIG7 ⑦, to the control system.
[0117] Step 5. Referring to the flowchart of subtask execution shown in FIG8 , the control system determines the next subtask to be executed based on the inference result of the previous subtask, as shown in FIG8 ①. After extracting the parameters, it is necessary to check whether the parameters are provided in full (complete). Based on this, the next subtask to be executed may be subtask 5, as shown in FIG8 2 . Subtask 5 is a parameter integrity check. Based on the extracted parameter dictionary, that is, the inference result of the previous subtask (as shown in FIG8 ①), the control system can find that the parameter project_uuid has no corresponding value and needs to be provided by the user, so it executes subtask 6 and interacts with the user to provide the parameter, as shown in FIG8 ③. The user sees the prompt returned to the front end, as shown in FIG8 ④, and can respond accordingly.
[0118] Step 6. Referring to the flowchart of the subtask execution shown in FIG9 , after the user responds, step 1 will be repeated to determine the user input type, and the model's judgment result is [Answer], as shown in ⑤ in FIG9 .
[0119] Step 7. Referring to the subtask execution flow diagram shown in Figure 10, the control system determines that the next subtask to be executed is subtask 7, as shown in Figure 10 (4), based on the inference result of the previous subtask. Subtask 7 involves extracting parameters from the user's answer. Based on subtask 7, the control system finds the corresponding prompt in the prompt manager, as shown in Figure 10 (5), and splices the previously extracted parameter dictionary (shown in Figure 10 (1), the parameter prompt returned to the user (shown in Figure 10 (2), and the user's answer (shown in Figure 10 (3)) into the prompt template. The spliced prompt (shown in Figure 10 (6)) is then passed to the LLM to obtain the inference result, which is the newly extracted parameter dictionary (shown in Figure 10 (7)).
[0120] Step 8. Referring to the subtask execution flow diagram shown in Figure 11, the control system repeats the parameter check in Step 5 based on the new parameter dictionary to verify that all necessary parameters have been provided. It then passes the API name and parameter dictionary information, as shown in Figure 11 (1), to the downstream API Center for the actual API call execution. After execution, the API returns the execution result, i.e., the API call result, as shown in Figure 11 (2), to the control system, which can present the result to the user.
[0121] The above Figures 4 to 11 illustrate the process in which the user needs to call the API. In other embodiments of the present application, the user may not need to call the API.
[0122] As shown in Figure 12, if the user enters the following natural language description: "What are the differences between the BFS and DFS algorithms?", the control system can perform the following steps:
[0123] Step 1. The control system determines the user's input type.
[0124] Step 2. Control the system and whether an API call is required.
[0125] In the embodiment of FIG12 , steps 1 and 2 are the same as steps 1 and 2 in the embodiments of FIG4 to FIG11 , but in this scenario, in step 2, the reasoning result of LLM may be {LEVEL1*general problem}.
[0126] Step 3. After the control system recognizes the "general question", it directly passes the question to the LLM. The LLM's reasoning result is directly returned to the user, ending this round of dialogue.
[0127] Based on the above description, it can be seen that the interface calling method of the present application adopts a unique subtask splitting method, such as splitting the interface calling task into input type identification subtask, interface calling requirement identification subtask, interface identification subtask, request parameter extraction subtask, parameter integrity check subtask, prompt subtask or answer parameter extraction subtask, ensuring that each subtask is atomic and only implements a separate function, thereby improving the accuracy of the subtask, thereby reducing the pressure on LLM to perform logical thinking and improving the accuracy of the system.
[0128] This method designs specific prompt and answer formats for each subtask, specifically the formats of the prompt template and answer template, and performs SFT on the LLM. Leveraging the LLM's text comprehension capabilities, SFT can enhance the LLM's understanding of prompts and the generation of fixed-format answers, improving accuracy. Furthermore, the fixed-format answers generated according to the answer template facilitate information extraction from the LLM's generated results, improving post-processing efficiency. This method designs a subtask concatenation method and logical reasoning, eliminating the need for the LLM to control the process and reducing the LLM's logical thinking capabilities. Furthermore, the next subtask to be executed is determined solely based on the execution results of the current subtask. Subtasks can be flexibly connected, effectively addressing various complex scenarios and improving the stability of the architecture.
[0129] During the API call process, this method increases the ability to interact with users without restricting the format of their responses. This allows users to provide required parameters, which can improve the success rate of API calls. Furthermore, users can provide parameters in a variety of natural language formats, increasing system flexibility.
[0130] Compared with related technologies, this method does not require manual annotation of large amounts of data, including complex multi-round dialogue scenarios. For example, the parameter extraction subtask does not need to cover all interfaces and parameter combinations, and only a small amount of data is needed to achieve generalization capabilities. This greatly reduces the difficulty and quantity requirements of training corpus construction. In classification judgment tasks, this method uses LLM as a classifier, rather than small models such as BERT that are used in traditional classification tasks. By constructing specific prompts for LLM to make judgments and perform SFT, the trained model has much higher generalization ability than small models and can achieve good results with only a relatively small amount of data.
[0131] It should be noted that the interface calling method of this application solves the problem of compatibility between ordinary chat and API calls, interaction during the call process, and ensuring service stability. Although this solution mainly implements API calls, it can actually be extended to call various tools beyond LLM. When the call needs to query the user for additional information, this technical solution can be used to improve service stability and enhance the user experience.
[0132] Based on the aforementioned interface calling method, the present application also provides a natural language interaction system. As shown in Figure 1, the system 100 includes a controller 102 and a large language model 104. Large language model 104 can be a built-in large language model or a third-party large language model. Furthermore, large language model 104 is only an example of a language model; in actual applications, large language model 104 can also be replaced by other language models.
[0133] Specifically, the controller 102 is configured to receive a natural language description input by a user, obtain a first prompt template corresponding to a first subtask among multiple subtasks, concatenate the first prompt template with the natural language description input by the user, input the concatenation result into the large language model 104, and obtain an inference result output by the large language model 104 according to the first answer template corresponding to the first subtask;
[0134] The controller 102 is also used to execute an interface call according to the necessary parameters of the target interface when executing a parameter integrity check subtask among multiple subtasks, and when the inference result of the parameter integrity check subtask indicates that the necessary parameters of the target interface to be called are complete, obtain the interface call result, and present the interface call result to the user.
[0135] For example, the controller 102 may be implemented by hardware or software, which will be described below.
[0136] When implemented via software, controller 102 can be an application running on a computing device, such as control system software or a computing engine. This application can be provided to users via virtualization services. Virtualization services can include virtual machine (VM) services, bare metal server (BMS) services, and container services. VM services can be services that use virtualization technology to create a virtual machine (VM) resource pool on multiple physical hosts to provide users with VMs on demand. BMS services are services that create a virtual BMS resource pool on multiple physical hosts to provide users with BMSs on demand. Container services are services that create a virtual container resource pool on multiple physical hosts to provide users with containers on demand. A VM is a simulated virtual computer, or logically a single computer. BMS is a scalable, high-performance computing service with computing performance comparable to traditional physical machines and secure physical isolation. Containers are a kernel virtualization technology that provides lightweight virtualization to isolate user space, processes, and resources. It should be understood that the VM service, BMS service and container service in the above-mentioned virtualization services are only specific examples. In actual applications, virtualization services can also be other lightweight or heavyweight virtualization services, which are not specifically limited here.
[0137] When implemented in hardware, the controller 102 may include at least one computing device, such as a server. Alternatively, the controller 102 may be implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0138] In some possible implementations, the controller 102 is further configured to:
[0139] Determine a second subtask to be performed based on the reasoning result of the first subtask;
[0140] Obtain a second prompt template corresponding to the second subtask, splice the second prompt template with the user's input information, input the splicing result into the large language model 104, and obtain the inference result output by the large language model 104 according to the second answer template corresponding to the second subtask.
[0141] Among them, the natural language interaction system 100 may also include a prompt manager 106. Accordingly, the controller 102 may obtain a second prompt template corresponding to the second subtask from the prompt manager 106. Similar to the controller 102, the prompt manager 106 may be implemented by software or by hardware. When implemented by software, the prompt manager 106 may be an application running on a computing device. The application may be provided to users through virtualization services, such as VM services, BMS services, and container services. When implemented by hardware, the prompt manager 106 may include at least one computing device, such as a server, etc. Alternatively, the prompt manager 106 may also be a device implemented using ASIC or PLD, etc.
[0142] In some possible implementations, when the first subtask is an interface identification subtask and the second subtask is a request parameter extraction subtask, the controller 102 is further configured to:
[0143] Obtain necessary parameter information of the target interface according to the interface identifier of the target interface in the reasoning result of the first subtask;
[0144] The controller 102 is specifically configured to:
[0145] The second prompt template is spliced with the natural language description input by the user and the necessary parameter information.
[0146] The natural language interaction system 100 may further include an interface database 108. The controller 102 may obtain necessary parameter information for the target interface from the interface database 108 based on the interface identifier of the target interface in the inference result of the first subtask. Similar to the large language model 104, the interface database 108 may be a database built into the natural language interaction system 100 or a third-party database, and this embodiment does not impose any restrictions thereto.
[0147] In some possible implementations, when the first subtask is a request parameter extraction subtask and the second subtask is a parameter integrity check subtask, the controller 102 is further configured to:
[0148] When the reasoning result of the parameter integrity check subtask indicates that the necessary parameters of the target interface are incomplete, a prompt subtask among the multiple subtasks is executed, where the prompt subtask is used to prompt the user to provide the missing necessary parameters.
[0149] In some possible implementations, the controller 102 is specifically configured to:
[0150] receiving a natural language description input by a user for the prompt subtask, and then performing an input type identification subtask;
[0151] The controller 102 is further configured to:
[0152] When the inference result of the input type identification subtask is an answer, the answer parameter extraction subtask is executed.
[0153] In some possible implementations, the controller 102 is specifically configured to:
[0154] A second subtask to be executed is determined based on the inference result of the first subtask and the association relationship between the multiple subtasks.
[0155] In some possible implementations, the controller 102 is further configured to:
[0156] Obtain a corpus pair corresponding to the prompt template and the answer template corresponding to the subtask, which is a question-answer pair;
[0157] The corpus is input into the language model for supervised fine-tuning SFT.
[0158] In some possible implementations, the plurality of subtasks includes a combination of the following subtasks:
[0159] Input type identification subtask, interface call requirement identification subtask, interface identification subtask, request parameter extraction subtask, parameter integrity check subtask, prompt subtask or answer parameter extraction subtask.
[0160] This application also provides a computing device 1300. As shown in Figure 13, computing device 1300 includes a bus 1302, a processor 1304, a memory 1306, and a communication interface 1308. Processor 1304, memory 1306, and communication interface 1308 communicate with each other via bus 1302. Computing device 1300 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in computing device 1300.
[0161] Bus 1302 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, among others. Buses may be classified as address buses, data buses, control buses, and the like. For ease of illustration, FIG13 shows a single line, but this does not imply a single bus or type of bus. Bus 1302 may include a path for transmitting information between various components of computing device 1300 (e.g., memory 1306, processor 1304, and communication interface 1308).
[0162] The processor 1304 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0163] The memory 1306 may include a volatile memory, such as a random access memory (RAM). The memory 1306 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD). The memory 1306 stores executable program code, and the processor 1304 executes the executable program code to implement the aforementioned interface calling method. Specifically, the memory 1306 stores instructions for the natural language interaction system 100 to execute the interface calling method.
[0164] The communication interface 1308 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 1300 and other devices or a communication network.
[0165] Embodiments of the present application also provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0166] As shown in Figure 14, the computing device cluster includes at least one computing device 1300. The memory 1306 of one or more computing devices 1300 in the computing device cluster may store the same instructions for executing the interface calling method of the natural language interaction system 100.
[0167] In some possible implementations, one or more computing devices 1300 in the computing device cluster may also be used to execute some of the instructions for executing the interface call method of the natural language interaction system 100. In other words, the combination of one or more computing devices 1300 may jointly execute the instructions for executing the interface call method of the natural language interaction system 100.
[0168] It should be noted that the memory 1306 in different computing devices 1300 in the computing device cluster may store different instructions for executing part of the functions of the natural language interaction system 100 .
[0169] Figure 15 shows a possible implementation. As shown in Figure 15, two computing devices 1300A and 1300B are connected via a communication interface 1308. The memory in the computing device 1300A stores instructions for executing the functions of the controller 102. The memory in the computing device 1300B stores instructions for executing the functions of the large language model 104. In other words, the memories 1306 of the computing devices 1300A and 1300B jointly store instructions for the natural language interaction system 100 to execute the interface call method. Furthermore, the memory of the computing device 1300A may also store instructions for executing the functions of the prompt manager 106, and the memory of the computing device 1300B may also store instructions for executing the functions of the interface database 108.
[0170] The connection method between the computing device clusters shown in Figure 15 can be considered to take into account that the interface calling method provided by this application requires a large amount of computing power for reasoning. Therefore, it is considered to transfer the functions implemented by the large language model 104 to computing device 1300B. Similarly, the interface calling method provided by this application requires a large amount of storage resources to store interface data. Therefore, it is considered to transfer the functions of the interface database 108 to computing device 1300B.
[0171] It should be understood that the functionality of the computing device 1300A shown in FIG15 may also be implemented by multiple computing devices 1300. Similarly, the functionality of the computing device 1300B may also be implemented by multiple computing devices 1300.
[0172] In some possible implementations, one or more computing devices in the computing device cluster can be connected via a network. The network can be a wide area network or a local area network, etc. Figure 16 shows a possible implementation. As shown in Figure 16, two computing devices 1300C and 1300D are connected via a network. Specifically, the connection to the network is made through the communication interface in each computing device. In this type of possible implementation, the memory 1306 in the computing device 1300C stores instructions for executing the functions of the controller 102. At the same time, the memory 1306 in the computing device 1300D stores instructions for executing the functions of the large language model 104.
[0173] The connection method between the computing device clusters shown in Figure 16 can be considered to consider that the interface calling method provided by this application requires a large amount of computing power for reasoning, so it is considered to delegate the functions implemented by the large language model 104 to the computing device 1300D. Similarly, the interface calling method provided by this application requires a large amount of storage resources to store interface data, so the functions implemented by the interface database 108 can be delegated to the computing device 1300D.
[0174] It should be understood that the functionality of the computing device 1300C shown in FIG16 may also be implemented by multiple computing devices 1300. Similarly, the functionality of the computing device 1300D may also be implemented by multiple computing devices 1300.
[0175] Based on the aforementioned interface calling method, the present application further provides a controller 102. When implemented via hardware, the controller 102 may include a processor and a memory. The memory stores computer-readable instructions, and the processor executes the computer-readable instructions accordingly, causing the controller 102 to perform the aforementioned interface calling method.
[0176] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center that contains one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute the above-mentioned method for executing the interface call applied to the natural language interaction system 100.
[0177] The present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored on any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the aforementioned interface calling method.
[0178] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the various embodiments of the present invention.
Claims
1. An interface calling method, characterized in that: Applied to a natural language interaction system, the natural language interaction system is used to execute multiple subtasks related to interface calling based on user input information to implement interface calling, the natural language interaction system includes a controller, and the method includes: The controller receives a natural language description input by a user; The controller obtains a first prompt template corresponding to a first subtask among the multiple subtasks, splices the first prompt template with the natural language description input by the user, inputs the splicing result into a language model, and obtains an inference result output by the language model according to a first answer template corresponding to the first subtask; When the parameter integrity check subtask among the multiple subtasks is executed, and the inference result of the parameter integrity check subtask indicates that the necessary parameters of the target interface to be called are complete, the controller executes an interface call according to the necessary parameters of the target interface, obtains an interface call result, and presents the interface call result to the user.
2. The method according to claim 1, characterized in that The method further comprises: The controller determines a second subtask to be executed according to the inference result of the first subtask; The controller obtains a second prompt template corresponding to the second subtask, splices the second prompt template with the user's input information, inputs the splicing result into the language model, and obtains an inference result output by the language model according to the second answer template corresponding to the second subtask.
3. The method according to claim 2, characterized in that When the first subtask is an interface identification subtask and the second subtask is a request parameter extraction subtask, the method further includes: The controller acquires necessary parameter information of the target interface according to the interface identifier of the target interface in the inference result of the first subtask; The controller splices the second prompt template with the natural language description input by the user, including: The controller splices the second prompt template with the natural language description input by the user and the necessary parameter information.
4. The method according to claim 2, characterized in that: When the first subtask is a request parameter extraction subtask, and the second subtask is a parameter integrity check subtask, the method further includes: When the reasoning result of the parameter integrity check subtask indicates that the necessary parameters of the target interface are incomplete, the controller executes a prompt subtask among the multiple subtasks, wherein the prompt subtask is used to prompt the user to provide the missing necessary parameters.
5. The method according to claim 4, characterized in that The controller receives a natural language description input by a user, including: The controller receives a natural language description input by the user for the prompt subtask, and then performs an input type identification subtask; When the inference result of the input type identification subtask is an answer, the answer parameter extraction subtask is executed.
6. The method according to any one of claims 2 to 5, characterized in that: The controller determines, according to the inference result of the first subtask, a second subtask to be executed, including: The controller determines a second subtask to be executed according to the inference result of the first subtask and the association relationship between the multiple subtasks.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: Obtaining a corpus pair corresponding to a prompt template and a reply template corresponding to the subtask, wherein the corpus pair is a question-answer pair; The corpus is input into the language model for supervised fine-tuning SFT.
8. The method according to any one of claims 1 to 7, characterized in that: The multiple subtasks include a combination of the following subtasks: Input type identification subtask, interface call requirement identification subtask, interface identification subtask, request parameter extraction subtask, parameter integrity check subtask, prompt subtask or answer parameter extraction subtask.
9. A natural language interaction system, characterized in that: The natural language interaction system is used to execute multiple subtasks related to the interface call based on the user's input information to realize the interface call, and the natural language interaction system includes a controller and a language model; The controller is configured to receive a natural language description input by a user, obtain a first prompt template corresponding to a first subtask among the multiple subtasks, concatenate the first prompt template with the natural language description input by the user, input the concatenation result into the language model, and obtain an inference result output by the language model according to a first answer template corresponding to the first subtask; The controller is further configured to execute a parameter integrity check subtask among the plurality of subtasks, and the parameter integrity check When the reasoning result of the subtask indicates that the necessary parameters of the target interface to be called are complete, an interface call is executed according to the necessary parameters of the target interface, an interface call result is obtained, and the interface call result is presented to the user.
10. The system according to claim 9, characterized in that The controller is also used for: Determining a second subtask to be performed according to the reasoning result of the first subtask; Obtain a second prompt template corresponding to the second subtask, splice the second prompt template with the user's input information, input the splicing result into the language model, and obtain the inference result output by the language model according to the second answer template corresponding to the second subtask.
11. The system according to claim 10, characterized in that When the first subtask is an interface identification subtask and the second subtask is a request parameter extraction subtask, the controller is further configured to: Acquire necessary parameter information of the target interface according to the interface identifier of the target interface in the reasoning result of the first subtask; The controller is specifically used for: The second prompt template is spliced with the natural language description input by the user and the necessary parameter information.
12. The system according to claim 10, characterized in that When the first subtask is a request parameter extraction subtask and the second subtask is a parameter integrity check subtask, the controller is further configured to: When the reasoning result of the parameter integrity check subtask indicates that the necessary parameters of the target interface are incomplete, a prompt subtask among the multiple subtasks is executed, and the prompt subtask is used to prompt the user to provide the missing necessary parameters.
13. The system according to claim 12, characterized in that The controller is specifically used for: receiving a natural language description input by the user for the prompt subtask, and then performing an input type identification subtask; The controller is also used for: When the inference result of the input type identification subtask is an answer, the answer parameter extraction subtask is executed.
14. The system according to any one of claims 10 to 13, characterized in that The controller is specifically used for: A second subtask to be executed is determined according to the inference result of the first subtask and the association relationship between the multiple subtasks.
15. The system according to any one of claims 9 to 14, characterized in that The controller is also used for: Obtaining a corpus pair corresponding to a prompt template and a reply template corresponding to the subtask, wherein the corpus pair is a question-answer pair; The corpus is input into the language model for supervised fine-tuning SFT.
16. The system according to any one of claims 9 to 15, characterized in that The multiple subtasks include a combination of the following subtasks: Input type identification subtask, interface call requirement identification subtask, interface identification subtask, request parameter extraction subtask, parameter integrity check subtask, prompt subtask or answer parameter extraction subtask.
17. A computing device cluster, characterized in that: The computing device cluster includes at least one computing device, and the at least one computing device includes at least one processor and at least one memory, wherein the at least one memory stores computer-readable instructions; the at least one processor executes the computer-readable instructions so that the computing device cluster executes the interface calling method as described in any one of claims 1 to 8.
18. A controller, characterized in that: The controller includes a processor and a memory, wherein the memory stores computer-readable instructions; the processor executes the computer-readable instructions so that the controller executes the interface calling method according to any one of claims 1 to 8.
19. A computer-readable storage medium, characterized in that: Comprising computer-readable instructions; the computer-readable instructions are used to implement the interface calling method described in any one of claims 1 to 8.
20. A computer program product, characterized in that Comprising computer-readable instructions; the computer-readable instructions are used to implement the interface calling method described in any one of claims 1 to 8.
Citation Information
Patent Citations
Generative large language model training method and model-based search method
CN116127020A
Robot task generation method and device based on pre-training language model and medium
CN116402164A
Knowledge question and answer method, device and equipment and storage medium
CN116561278A
Method and device for executing complex task by using large language model
CN116594757A
Computer implemented methods for the automated analysis or use of data, including use of a large language model
US20230274094A1
Cited By
Execution method and device of knowledge high-order program, storage medium and equipment
CN120540752A
Large language model assisted remote sensing index calculation method and device and medium
CN120706559A
Method and system for realizing AI processing capability of operating system
CN120821469A