Interface calling method and related equipment
By splitting the API call task into multiple subtasks and designing specific prompt templates and answer templates, the complexity and stability of API call scenarios in the prior art are solved, and more efficient and accurate API calls are achieved.
Patent Information
- Application Number
- CN202410089511.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-10-24
- Filing Date
- 2024-01-22
- Publication Date
- 2025-04-25
AI Technical Summary
The prior art is difficult to support complex and diverse API call scenarios, and the stability and success rate of API calls using large language models are poor.
A unique subtask splitting method is adopted to split the task into multiple subtasks related to interface calls, which reduces the logical thinking pressure of the language model, and designs specific prompt templates and answer templates for each subtask to improve the model's understanding of prompts and generates fixed-format answers.
Supports more complex and diverse API call scenarios, improves the accuracy and stability of natural language interaction systems, and improves the success rate of API call.
Smart Images

Figure CN119883530A_ABST
Abstract
Description
[0001] This application claims the priority of 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”, all contents of which are incorporated by reference in 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, it has gradually become a trend to realize AI capabilities based on large language models (LLM). LLM is essentially a language model composed of an artificial neural network with many parameters (usually billions of weights or more), which can be trained on a large amount of unlabeled text using self-supervised learning or semi-supervised learning. Since LLM has achieved good results in a wide range of tasks, more and more users expect to apply LLM to a variety of services, using the capabilities of LLM to provide more efficient, more convenient, and better experience services, rather than being limited to being a question-and-answer assistant.
[0004] At present, the application of LLM for application programming interface (API) calls is a hot topic of current research and exploration. However, LLM can usually only implement limited functions in certain limited scenarios, which is not enough to support more complex and demanding API call scenarios. In addition, the stability and success rate of API calls using LLM are poor, making it difficult to meet business needs. Summary of the invention
[0005] The present application provides an interface calling method, which uses a unique subtask splitting method to split the task into multiple subtasks related to the interface call, reducing the pressure of language models such as LLM to perform logical thinking, so that it can support more complex and more demanding API calling scenarios, improve the accuracy of the natural language interaction system, and the method designs specific prompt templates and answer templates for each subtask to enhance the model's understanding of the prompt and generate fixed-format answers, reduce the randomness and instability of API calls, and further improve accuracy. The present 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.
[0006] In the 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 mini-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. 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, the interface calling method of the present application is executed.
[0007] 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 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.
[0008] This method splits the interface call task into multiple atomic subtasks, which reduces the pressure on the language model to perform logical thinking, reduces the difficulty of language model reasoning, and improves the accuracy of language model reasoning. In addition, this method designs specific prompt templates and reply templates for subtasks, so that the language model can reason and output reasoning results according to the template, thereby reducing randomness and improving stability. This method realizes the embedding of tool calls in natural language interaction systems such as chat dialogue systems, such as more than 8,000 or even more APIs, and users can interact with the system through natural language to realize API calls.
[0009] In some possible implementations, the controller may also 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, splices the second prompt template with the user's input information, inputs the splicing result into the language model, and obtains the inference result output by the language model according to the second answer template corresponding to the second subtask.
[0010] This method does not require a language model to control the process, reducing the logical thinking pressure of the language model. This method only needs to judge the next subtask to be executed based on the execution result of the current subtask. The subtasks can be flexibly connected. Through the above subtask series connection method and logical judgment, it can effectively cope with various complex scenarios and improve the stability of the architecture.
[0011] In some possible implementations, when the first subtask is an interface identification subtask, the second subtask is a request parameter extraction subtask. Accordingly, the controller can also obtain the necessary parameter information of the target interface according to 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.
[0012] In some possible implementations, when the first subtask is a request parameter extraction subtask, the second subtask is a parameter integrity check subtask. 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, and the prompt subtask is used to prompt the user to provide the missing necessary parameters.
[0013] This method increases the ability to interact with users during the interface calling process and guides users to provide necessary parameters, which can improve the success rate of calling the API.
[0014] In some possible implementations, the controller may receive a natural language description input by the user for the prompt subtask, and then execute the input type identification subtask. When the reasoning result of the input type identification subtask is an answer, the answer parameter extraction subtask is executed.
[0015] When guiding the user to provide necessary parameters, the method does not limit the format of the user's answer. The user can provide parameters in natural language in various formats, thereby improving the flexibility of the system.
[0016] In some possible implementations, the controller can determine the second subtask to be executed based on the reasoning result of the first subtask and the association between multiple subtasks. This method determines the next subtask to be executed based on the reasoning result of the current first subtask and the association between different subtasks at the logical level, thereby realizing flexible connection between subtasks. Process control does not require language model implementation, which reduces the pressure of language model logical thinking.
[0017] In some possible implementations, the controller may also obtain a corpus pair corresponding to a prompt template and a reply template corresponding to the subtask, where the corpus pair may be a question-answer pair, and then the controller may input the corpus pair into a language model for supervised fine-tuning SFT.
[0018] 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.
[0019] In some possible implementations, the multiple subtasks include a combination of the following subtasks:
[0020] 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.
[0021] This method reduces the pressure on the language model to perform logical thinking and improves the accuracy of the natural language interaction system through the unique sub-task splitting method mentioned above.
[0022] In some possible implementations, the language model can be a large language model LLM. By using LLM as a classifier in the classification judgment task, constructing a specific prompt for LLM to make judgments and perform SFT, the trained model has much higher generalization than a small model, and can achieve better results with only a relatively small amount of data, which can meet business needs.
[0023] 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;
[0024] 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;
[0025] The controller is also used to, when executing a parameter integrity check subtask among the 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, 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.
[0026] In some possible implementations, the controller is further configured to:
[0027] Determining a second subtask to be performed according to the reasoning result of the first subtask;
[0028] 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.
[0029] 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:
[0030] 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;
[0031] The controller is specifically used for:
[0032] The second prompt template is spliced with the natural language description input by the user and the necessary parameter information.
[0033] 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:
[0034] 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.
[0035] In some possible implementations, the controller is specifically configured to:
[0036] receiving a natural language description input by the user for the prompt subtask, and then performing an input type identification subtask;
[0037] The controller is also used for:
[0038] When the inference result of the input type identification subtask is an answer, the answer parameter extraction subtask is executed.
[0039] In some possible implementations, the controller is specifically configured to:
[0040] 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.
[0041] In some possible implementations, the controller is further configured to:
[0042] 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;
[0043] The corpus is input into the language model for supervised fine-tuning SFT.
[0044] In some possible implementations, the multiple subtasks include a combination of the following subtasks:
[0045] 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.
[0046] In a third aspect, the present application provides a computing device cluster. 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. The at least one processor and the at least one memory communicate with each other. The at least one processor is used to execute instructions stored in the at least one memory, so that the computing device or the computing device cluster executes the interface calling method described in the first aspect or any implementation of the first aspect.
[0047] 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 so that the controller executes the interface calling method described in the first aspect or any implementation of the first aspect.
[0048] 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.
[0049] In a sixth aspect, the present application provides a computer program product comprising instructions, which, when executed on a computing device or a computing device cluster, enables the computing device or the computing device cluster to execute the interface calling method described in the first aspect or any one of the implementations of the first aspect.
[0050] Based on the implementations provided in the above aspects, this application can also be further combined to provide more implementations. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical method of the embodiments of the present application, the drawings required for use in the embodiments are briefly introduced below.
[0052] Figure 1 A schematic diagram of the architecture of a natural language interaction system provided for this application;
[0053] Figure 2A schematic diagram of a disassembly to obtain multiple subtasks provided in this application;
[0054] Figure 3 A flowchart of an interface calling method provided for this application;
[0055] Figure 4 A schematic diagram of a subtask execution process provided for this application;
[0056] Figure 5 A schematic diagram of a subtask execution process provided for this application;
[0057] Figure 6 A schematic diagram of a subtask execution process provided for this application;
[0058] Figure 7 A schematic diagram of a subtask execution process provided for this application;
[0059] Figure 8 A schematic diagram of a subtask execution process provided for this application;
[0060] Fig. 9 A schematic diagram of a subtask execution process provided for this application;
[0061] Fig.10 A schematic diagram of a subtask execution process provided for this application;
[0062] Fig.11 A schematic diagram of a subtask execution process provided for this application;
[0063] Fig.12 A flowchart of a non-API call input type provided for this application;
[0064] Fig.13 A schematic diagram of the structure of a computing device provided for this application;
[0065] Fig.14 A schematic diagram of the structure of a computing device cluster provided for this application;
[0066] Fig.15 A schematic diagram of the structure of another computing device cluster provided for this application;
[0067] Fig.16 A schematic diagram of the structure of another computing device cluster provided in this application. DETAILED DESCRIPTION
[0068] The terms "first" and "second" in the embodiments of the present application are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features.
[0069] First, some technical terms involved in the embodiments of the present application are introduced.
[0070] A natural language interaction system, also known as a dialogue system, question-answering system, or chat system, is a system that can respond to natural language descriptions input by users, such as a system that answers questions from users. When a natural language interaction system responds to a user's natural language description, it can be implemented through an artificial intelligence (AI) model.
[0071] 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, if a word sequence w of length m is given 1 ,w 2 …w m , calculate the probability of these words: P(w 1 ,w 2 …w m ). Through language models, we can determine which word is more likely to appear, or predict the next most likely word based on several previous context words. Language models are often used in many natural language processing applications, such as speech recognition, machine translation, part-of-speech tagging, syntactic analysis, handwriting recognition, and information retrieval.
[0072] Language models can be divided into different types, such as n-gram language models and neural network-based language models. Language models can also be divided into small language models and large language models (LLM) based on parameter scale. LLM consists of an artificial neural network with many parameters (usually billions of weights or more), which is trained on a large amount of unlabeled text using self-supervised learning or semi-supervised learning. Due to its excellent performance in various tasks, LLM is currently widely used in the industry for natural language processing-related tasks. For ease of description, the following uses the language model as an example of LLM.
[0073] The natural application interaction system can be used in interface call scenarios. Among them, the interface can be an application programming interface (API), which is specifically a way for a program to interact with another program. Through API calls, different programs can interact and use the capabilities of different programs. Most API definitions have necessary parameters, also known as required parameters and mandatory parameters. When making API calls, the above necessary parameters are usually required to be provided. At present, API calls are manual input of necessary parameters by users, and the natural language interaction system based on LLM can assist users in completing API calls. For example, when a user enters a natural language description in the chat box, the natural language interaction system can identify whether to call the API and which API to call to achieve the user's intention. Considering that some API parameters are relatively complex and users do not understand the internal structure of the API, users expect the natural language interaction system to extract the API parameters from the user's natural language description, or when the parameters are incomplete, guide the user to provide the necessary parameters required to successfully call an API, so as to improve the success rate and efficiency of calling the API.
[0074] Currently, the industry provides a method for making API calls based on LLM and prompts. This method requires writing the prompt for the scenario in advance, including what kind of scenario it is, which behaviors can be selected, the basis for selection, and the format of the answer, etc., and then passing the prompt to LLM. LLM will autonomously analyze which behavior to choose next based on its understanding of the scenario and the user's current input, and post-process the results of LLM's answers to extract key information, and then automatically splice the generated results and user input into the original prompt, and then pass it to LLM.
[0075] This method mainly relies on the logical thinking ability of LLM and clear prompts, allowing LLM to control the entire dialogue and call process by itself and adapt to different scenarios. However, this method requires presetting the scenario in advance and clearly selecting the requirements for each behavior. But when the scenario requirements are more complex, the execution rules are complex, and LLM's logical understanding ability is poor, making it difficult to understand the prompt clearly. In addition, the results inferred by this method are very unstable and highly random. For complex scenarios, users expect higher API call success rates and efficiency.
[0076] 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 calling 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, and 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.
[0077] 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, deployed 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, the interface calling method of the present application is executed.
[0078] 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.
[0079] The method splits the interface call task into multiple atomic subtasks, which reduces the pressure of logical thinking of LLM, reduces the difficulty of LLM reasoning, and improves the accuracy of LLM reasoning. Moreover, the method designs specific prompt templates and reply templates for subtasks, so that LLM can 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 reply templates, and inputs the corpus pairs into LLM for supervised fine-tuning (SFT). In this way, the text understanding ability of LLM can be utilized, and the model's understanding of prompt and generation of fixed-format answers can be strengthened through SFT, which improves accuracy, and the relevant information in the reasoning results of LLM can be easily extracted through fixed-format templates, thereby improving post-processing efficiency.
[0080] Furthermore, the method designs subtask serialization and logical judgment, which can effectively cope with various complex scenarios and improve the stability of the architecture. In addition, through the design of some subtasks, the method can increase the ability to interact with users during the API call process, guide users to provide necessary parameters, and improve the success rate of API calls. Among them, the method does not limit the format of user answers, and users can use natural language in various formats to provide parameters, which improves the flexibility of the system.
[0081] It should be noted that the technical solution of the present application can be applied to other language models in addition to LLM. LLM is only an example of a language model and does not constitute a limitation on the technical solution of the present application. By splitting the interface call task into multiple subtasks related to the interface call, the pressure of the language model to perform logical thinking can be reduced, and the accuracy of language model reasoning can be improved.
[0082] In order to make the technical solution of the present application clearer and easier to understand, the system architecture of the present application is first introduced below with reference to the accompanying drawings.
[0083] join Figure 1 The natural language interaction system architecture diagram shown in FIG. 1 shows a natural language interaction system 100 for executing multiple subtasks related to an interface call based on user input information to implement an 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 may also be referred to as a control system. The large language model may be a built-in large language model or a third-party large language model. The present application does not limit the source or type of the large language model.
[0084] The controller 102 is a service system, including multiple subtasks. Figure 2 As shown, 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 the 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.
[0085] Specifically, the controller 102 is used to 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 to the large language model 104, and obtain the inference result output by the large language model 104 according to 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.
[0086] 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.
[0087] The natural language interaction system 100 may further include a prompt manager 106, i.e., a prompt manager. The prompt manager 106 stores a prompt template and a reply template corresponding to at least one of the multiple subtasks. For example, the prompt manager 106 stores a prompt template and a reply template corresponding to subtask 1, a prompt template and a reply template corresponding to subtask 2, and prompt templates and reply templates corresponding to other subtasks. The prompt manager 106 supports querying prompt templates or reply templates corresponding to subtasks. The prompt model may be regarded as a prompt that needs to be spliced.
[0088] 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 is used to store parameter information and API descriptions of the API. The parameter information of the API may include necessary parameter information of the API, such as parameter names of necessary parameters and parameter types of necessary parameters. When performing parameter extraction, the controller 102 may query the target interface, such as necessary parameter information of the target API, from the interface database 108, and perform parameter extraction based on the necessary parameter information.
[0089] Furthermore, the backend of the natural language interaction system 100 can be connected to an interface center 200, such as an APICenter, to connect to a callable API. The interface center 200 can include a variety of callable APIs, and can perform actual API calls based on the target API information provided by the natural language interaction system 100, such as the interface name and interface parameters of the target API.
[0090] 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 in conjunction with the accompanying drawings.
[0091] See also Figure 3 The flowchart of an interface calling method shown in FIG. 1 is applied to a natural language interaction system 100. The natural language interaction system 100 is used to perform multiple subtasks related to the interface calling based on the user's input information to realize the interface calling. The method includes the following steps:
[0092] S302: The controller 102 receives a natural language description input by a user.
[0093] 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 a natural language description input by a user through the interactive interface or the interactive interface.
[0094] 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.
[0095] In some possible implementations, the controller 102 may provide an interactive interface to the user, such as a voice interactive interface, through which the user may input a natural language description in the form of voice. In this case, the controller 102 may receive the natural language description voice. Further, the controller 102 may also convert the natural language description voice into natural language text through a speech to text algorithm or speech recognition.
[0096] S304, the controller 102 obtains a first prompt template corresponding to a 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 an inference result output by the large language model 104 according to the first answer template corresponding to the first subtask.
[0097] In this application, the interface call task can be split into multiple subtasks related to the interface call to implement the task call. The multiple subtasks can 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, such as Figure 2 As shown. The controller 102 can execute several subtasks among the multiple subtasks split out above to implement 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.
[0098] 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, and 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. Then the controller 102 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.
[0099] 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 data set, 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 data set, and this knowledge is also applicable to the target data set. The output layer of the source model is closely related to the label of the source data set, so it 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 data set is added to the target model, and the model parameters of the layer are randomly initialized. When training the target model on the target data set, 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 is 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 regarded as the target dataset, and 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 the layer are randomly initialized. Then, the large language model can be trained on the target dataset.
[0100] Among them, by performing SFT on the large language model 104, the large language model 104 can enhance its understanding of the prompt and generate answers in a fixed format, which can improve accuracy and facilitate the extraction of information in the LLM generation results.
[0101] 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 series connection mode 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.
[0102] When executing the second subtask, the controller 102 may adopt a method similar to that of executing the first subtask. Specifically, the controller 102 may 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 to 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.
[0103] 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 may also obtain 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. Among them, 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 may query the API database based on the interface identifier of the target interface to obtain the necessary parameter information of the target interface. Then the controller 102 may splice the second prompt template, the natural language description input by the user, and the above necessary parameter information to obtain a spliced prompt.
[0104] In some 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 among the multiple subtasks, and the prompt subtask is used to prompt the user to provide the missing necessary parameters.
[0105] Accordingly, the controller 102 may receive the natural language description input by the user for the prompt subtask, and then execute the input type identification subtask. When the inference result of the input type identification subtask is an answer, the controller 102 executes the answer parameter extraction subtask. Among them, executing the answer parameter extraction subtask may extract the missing parameters provided by the user. After extracting the parameters from the user's answer, they may be merged with the parameters extracted from the request, and then the parameter integrity check may be performed again.
[0106] 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.
[0107] The reasoning result of the parameter integrity check subtask characterizes 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. The controller 102 can provide the above complete parameters to the API Center, for example, providing 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, for example, the call is successful. In some possible implementations, the interface call result may also include a return value. The controller 102 may present the above interface call result to the user.
[0108] Based on the above description, it can be seen that this method splits the interface call task into multiple atomic subtasks, which reduces the pressure of LLM to perform logical thinking, reduces the difficulty of LLM reasoning, and improves the accuracy of LLM reasoning. Moreover, this method designs specific prompt templates and reply templates for subtasks, so that 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 reply templates, and inputs the corpus pairs into LLM for supervised fine-tuning (SFT). In this way, the text understanding ability of LLM can be utilized, and the model's understanding of prompts and generation of fixed-format answers can be strengthened through SFT, which improves accuracy, and the relevant information in the reasoning results of LLM can be easily extracted through fixed-format templates, thereby improving post-processing efficiency.
[0109] In order to make the technical solution of the present application clearer and easier to understand, the interface calling method of the present application is introduced from an interactive perspective in combination with a specific application scenario.
[0110] With respect to a request of a user in the natural language interaction system 100, the specific process from request determination to actual execution of the API is described below. The method includes the following steps:
[0111] Step 1. See Figure 4 The flowchart of the subtask execution shown in FIG. 1 is to first execute subtask 1 to judge the user's input. Specifically, the user inputs "I want to create a code warehouse named ts_bot", such as Figure 4 As shown in ①, the user input can be transmitted to the control system (i.e., the controller 102 above), and the control system can process the subtask according to the specific subtask type, such as Figure 4 The subtask type shown in ② is queried in the prompt manager (i.e., the prompt manager 106 mentioned above) for the prompt corresponding to the subtask, for example Figure 4 As shown in ③, the prompt manager returns the query result to the control system, and the control system can splice the prompt, for example, splicing ① to the position of {question} in ③, and then processing the prompt, for example Figure 4 The information shown by character ④ is passed to LLM (i.e., the large language model 104 mentioned above), and LLM performs reasoning. LLM generates the reasoning result, such as Figure 4The information shown in ⑤ is transmitted to the control system to determine the next task.
[0112] 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.
[0113] Step 2. See Figure 5 The flowchart of the subtask execution shown in the figure shows that the control system is based on the reasoning result of the previous subtask, such as Figure 5 The information shown in ①, for example, is [Request], which determines the subtask to be executed next. The subtask is subtask 2, which specifically determines whether the user input needs to call the API, such as Figure 5 As shown in ②. Controlsystem queries the prompt manager for the prompt corresponding to the subtask, such as Figure 5 As shown in ③. The control system can splice the user's input at the {question} position and put the spliced prompt, such as Figure 5 The information shown in ④ is passed to LLM, and LLM infers the results, such as Figure 5 The information shown in ⑤ is transmitted to the control system to determine the next task. The inference result may be that an API needs to be called.
[0114] Step 3. See Figure 6 The flowchart of the subtask execution shown in the figure shows that the control system is based on the reasoning result of the previous subtask, such as Figure 6 The information shown in ① is specifically 'Code Hosting' under 'Cloud Service', which determines the subtasks that need to be performed next, such as Figure 6 As shown in ②, the next subtask to be performed is subtask 3, which is used to identify the API. Among them, the control system can query the prompt corresponding to the 'code hosting' product line in the prompt manager, such as Figure 6 As shown in ③, the prompt specifically includes all API names and descriptions under 'Code Hosting'. The control system can splice the user's input at the {user_intent} position and send the spliced prompt, such as Figure 6 The content shown in ④ is passed to LLM, and LLM infers the results, such as Figure 6 The content shown by character ⑤ is transmitted to the control system.
[0115] Step 4. See Figure 7The flowchart of the subtask execution shown in the figure shows that the control system is based on the reasoning result of the previous subtask, such as Figure 7 The content shown in ① is used to determine the subtasks that need to be performed next. Among them, the subtasks that need to be performed after identifying the API can be as follows Figure 7 As shown in ②, it is subtask 4, which is used to extract parameters in the user request. The control system queries the prompt manager for the prompt corresponding to subtask 4, such as Figure 7 As shown in ③, the control system is based on the reasoning results of the previous subtask (such as Figure 7 ①) Extract the API name, where the extracted API name is as follows Figure 7 As shown in ④, the control system passes it to the APIDatabase (i.e., the interface center 200), and queries the APIDatabase for the required parameter information corresponding to the API name. The query result is as follows Figure 7 As shown in ⑤, the control system then concatenates the question entered by the user with the API name and API parameter information, and displays the concatenated prompt as Figure 7 The content shown in ⑥ is passed to LLM, and LLM infers the result (the result of parameter extraction in the request), such as Figure 7 The content shown in ⑦ is transmitted to the control system.
[0116] Step 5. See Figure 8 The flowchart of the subtask execution shown in the figure shows that the control system is based on the reasoning result of the previous subtask, such as Figure 8 The content shown in ① is used to determine the subtask to be executed next. After extracting the parameters, it is necessary to check whether the parameters are complete. Based on this, the subtask to be executed next may be subtask 5, such as Figure 8 As shown in character 2, subtask 5 is parameter integrity check. The control system can extract the parameter dictionary, that is, the reasoning result of the previous subtask (such as Figure 8 In the content shown in ①), it is found that the parameter project_uuid has no corresponding value and needs to be provided by the user, so subtask 6 is executed to interact with the user to provide parameters, such as Figure 8 As shown in ③. The user sees the prompt returned to the front end, such as Figure 8 You can make corresponding replies to the contents shown in ④.
[0117] Step 6. See Fig. 9The flowchart of the subtask execution shown in the figure shows that after the user replies, step 1 will be repeated to determine the user input type, and the judgment result of the model is [Answer]. Fig. 9 As shown in ⑤.
[0118] Step 7. See Fig.10 The control system determines that the next subtask to be executed is subtask 7 according to the reasoning result of the previous subtask, such as Fig.10 As shown in ④, subtask 7 is to extract the parameters in the user's answer. According to subtask 7, the control system finds the corresponding prompt in the prompt manager. Fig.10 As shown in ⑤, the previously extracted parameter dictionary is Fig.10 The system returns the content shown in ① to the user to provide parameter prompts, such as Fig.10 The content shown in ② and the user's answer, such as Fig.10 Add the content shown in ③ to the prompt template, and then add the prompt as shown in Fig.10 The content shown in ⑥ is passed to LLM to obtain the inference result, which is the re-extracted parameter dictionary, such as Fig.10 As shown in ⑦.
[0119] Step 8. See Fig.11 The control system repeats the parameter check in step 5 according to the new parameter dictionary to check whether all necessary parameters have been provided; then the API name and parameter dictionary information are sent to the control system. Fig.11 The content shown in ① is passed to the downstream API Center for actual API call execution. After execution, the API will return the execution result, that is, the API call result, such as Fig.11 The content shown in ② is given to the control system, and the control system can present the results to the user.
[0120] Above Figures 4 to 11 The process in which the user needs to call the API is explained. In other embodiments of the present application, the user may not need to call the API.
[0121] like Fig.12 As described above, the user inputs the following natural language description: "What is the difference between the BFS and DFS algorithms?", the control system can perform the following steps:
[0122] Step 1. The control system determines the user's input type.
[0123] Step 2. Control the system and whether an API call is required.
[0124] Fig.12 In the embodiment, steps 1, 2 and Figures 4 to 11 Steps 1 and 2 in the embodiment are the same, but in this scenario, in step 2, the reasoning result of LLM can be {LEVEL1*general problem}.
[0125] Step 3. After the control system recognizes the 'general question', it directly passes the question to the LLM, and the LLM's reasoning result is directly returned to the user, ending this round of dialogue.
[0126] 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, to ensure that each subtask is atomic and only implements a single 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.
[0127] This method designs a specific prompt and answer format for each subtask, specifically the format of the prompt template and the answer template, and performs SFT on the LLM. By utilizing the text comprehension ability of the LLM, SFT can enhance the LLM's understanding of the prompt and generate fixed-format answers, thereby improving accuracy. In addition, the fixed-format answers generated according to the answer template can facilitate the extraction of information from the LLM generation results, thereby improving post-processing efficiency. This method designs a subtask serial connection method and logical judgment, which does not require the LLM to control the process and reduces the LLM's logical thinking ability. Moreover, it is only necessary to judge the next subtask to be executed based on the execution result of the current subtask. The subtasks can be flexibly connected, which can effectively cope with various complex scenarios and improve the stability of the architecture.
[0128] During the API call process, this method increases the ability to interact with users and does not limit the format of user answers, thereby guiding users to provide required parameters to improve the success rate of API calls. In addition, users can provide parameters in natural languages of various formats, improving system flexibility.
[0129] 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. This method uses LLM as a classifier in classification judgment tasks, rather than small models such as BERT that are used in traditional classification tasks. By constructing a specific prompt for LLM to make judgments and perform SFT, the trained model has much higher generalization than the small model, and only a relatively small amount of data is needed to achieve better results.
[0130] It should be noted that the interface calling method of this application solves the problem of compatibility between ordinary chat and API calling, interaction during the calling process and ensuring service stability. Although this solution is mainly used to implement API calling, it can actually be extended to the calling of various tools other than LLM. When it is necessary to ask the user for additional information during the call, this technical solution can be used to solve the stability of the service and improve the user experience.
[0131] Based on the aforementioned interface calling method, the present application also provides a natural language interaction system. Figure 1 As shown, the system 100 includes a controller 102 and a large language model 104. The large language model 104 may be a built-in large language model or a third-party large language model. Moreover, the large language model 104 is an example of a language model. In actual application, the large language model 104 may also be replaced by other language models.
[0132] Specifically, the controller 102 is used to receive a natural language description input by a user, obtain a first prompt template corresponding to a first subtask among multiple subtasks, splice the first prompt template with the natural language description input by the user, input the splicing result to the large language model 104, and obtain the inference result output by the large language model 104 according to the first answer template corresponding to the first subtask;
[0133] The controller 102 is also used to execute an interface call according to the necessary parameters of the target interface when a parameter integrity check subtask among multiple subtasks is executed, 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.
[0134] Exemplarily, the controller 102 may be implemented by hardware or software, which will be described below respectively.
[0135] When implemented by software, the controller 102 may be an application running on a computing device, such as control system software, a computing engine, etc. The application may be provided to users through virtualization services. Virtualization services may include virtual machine (VM) services, bare metal server (BMS) services, and container services. Among them, the VM service may be a service that uses virtualization technology to virtualize a virtual machine (VM) resource pool on multiple physical hosts to provide users with VMs on demand for use. The BMS service is a service that virtualizes a BMS resource pool on multiple physical hosts to provide users with BMS on demand for use. The container service is a service that virtualizes a container resource pool on multiple physical hosts to provide users with containers on demand for use. VM is a simulated virtual computer, that is, a logical computer. BMS is a high-performance computing service that can be elastically scalable, and its computing performance is no different from that of a traditional physical machine, and it has the characteristics of secure physical isolation. Containers are a kernel virtualization technology that can provide lightweight virtualization to achieve the purpose of isolating 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.
[0136] When implemented by hardware, the controller 102 may include at least one computing device, such as a server, etc. Alternatively, the controller 102 may also be a device implemented by an application-specific integrated circuit (ASIC) or a programmable logic device (PLD), etc. 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.
[0137] In some possible implementations, the controller 102 is further configured to:
[0138] Determine a second subtask to be performed according to the reasoning result of the first subtask;
[0139] A second prompt template corresponding to the second subtask is obtained, the second prompt template is spliced with the user's input information, and the splicing result is input into the large language model 104 to obtain the inference result output by the large language model 104 according to the second answer template corresponding to the second subtask.
[0140] Among them, the natural language interaction system 100 may also include a prompt manager 106, and 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.
[0141] 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:
[0142] According to the interface identifier of the target interface in the reasoning result of the first subtask, obtain necessary parameter information of the target interface;
[0143] The controller 102 is specifically used for:
[0144] The second prompt template is spliced with the natural language description input by the user and the necessary parameter information.
[0145] The natural language interaction system 100 may further include an interface database 108. The controller 102 may obtain necessary parameter information of the target interface from the interface database 108 according to the interface identifier of the target interface in the inference result of the first subtask. The interface database 108 is similar to the large language model 104 and may be a database built into the natural language interaction system 100 or a third-party database, which is not limited in this embodiment.
[0146] 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:
[0147] 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.
[0148] In some possible implementations, the controller 102 is specifically configured to:
[0149] receiving a natural language description input by a user for the prompt subtask, and then performing an input type identification subtask;
[0150] The controller 102 is also used for:
[0151] When the inference result of the input type identification subtask is an answer, the answer parameter extraction subtask is executed.
[0152] In some possible implementations, the controller 102 is specifically configured to:
[0153] According to the reasoning result of the first subtask and the association relationship between the multiple subtasks, a second subtask to be executed is determined.
[0154] In some possible implementations, the controller 102 is further configured to:
[0155] Obtain a corpus pair corresponding to a prompt template and a reply template corresponding to the subtask, the corpus pair being a question-answer pair;
[0156] The corpus is input into the language model for supervised fine-tuning SFT.
[0157] In some possible implementations, the plurality of subtasks include a combination of the following subtasks:
[0158] 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.
[0159] The present application also provides a computing device 1300. Fig.13 As shown, the computing device 1300 includes: a bus 1302, a processor 1304, a memory 1306, and a communication interface 1308. The processor 1304, the memory 1306, and the communication interface 1308 communicate through the bus 1302. The computing device 1300 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 1300.
[0160] The bus 1302 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.13The bus 1302 may include a path for transmitting information between various components of the computing device 1300 (eg, the memory 1306, the processor 1304, and the communication interface 1308).
[0161] The processor 1304 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0162] 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.
[0163] 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 communication networks.
[0164] The embodiment of the present application also provides 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 smart phone.
[0165] like Fig.14 As shown, the computing device cluster includes at least one computing device 1300. The memory 1306 in 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.
[0166] In some possible implementations, one or more computing devices 1300 in the computing device cluster may also be used to execute some instructions of the natural language interaction system 100 for executing the interface calling method. In other words, a combination of one or more computing devices 1300 may jointly execute the instructions of the natural language interaction system 100 for executing the interface calling method.
[0167] It should be noted that the memory 1306 in different computing devices 1300 in the computing device cluster can store different instructions for executing partial functions of the natural language interaction system 100 .
[0168] Fig.15 A possible implementation is shown. Fig.15 As shown, 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.
[0169] Fig.15 The connection mode between the computing device clusters shown can be considered that the interface calling method provided by the present application requires a lot of computing power for reasoning. Therefore, it is considered that the functions implemented by the large language model 104 are handed over to the computing device 1300B for execution. Similarly, the interface calling method provided by the present application requires a lot of storage resources to store interface data, so it is considered that the functions of the interface database 108 are handed over to the computing device 1300B for execution.
[0170] It should be understood that Fig.15 The functions of the computing device 1300A shown in FIG. 1300A may also be completed by multiple computing devices 1300. Similarly, the functions of the computing device 1300B may also be completed by multiple computing devices 1300.
[0171] In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network. Fig.16 A possible implementation is shown. Fig.16As shown, two computing devices 1300C and 1300D are connected via a network. Specifically, the network is connected via a 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.
[0172] Fig.16 The connection mode between the computing device clusters shown can be that considering that the interface calling method provided by the present application requires a lot of computing power for reasoning, it is considered to hand over the functions implemented by the large language model 104 to the computing device 1300D for execution. Similarly, the interface calling method provided by the present application requires a lot of storage resources to store interface data, so the functions implemented by the interface database 108 can be handed over to the computing device 1300D for execution.
[0173] It should be understood that Fig.16 The functions of the computing device 1300C shown in FIG. 1300A may also be completed by multiple computing devices 1300. Similarly, the functions of the computing device 1300D may also be completed by multiple computing devices 1300.
[0174] Based on the aforementioned interface calling method, the present application also provides a controller 102. Wherein, when the controller 102 is implemented by hardware, the controller 102 may include a processor and a memory. The memory stores computer-readable instructions, and accordingly, the processor executes the above-mentioned computer-readable instructions so that the controller 102 executes the aforementioned interface calling method.
[0175] 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 the computing device or a data storage device such as a data center containing 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 hard disk). 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.
[0176] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be a software or program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computer device, the at least one computer device executes the above-mentioned interface calling method.
[0177] 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 cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the 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 also used to, when executing a parameter integrity check subtask among the 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, 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.
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.