Tool calling method and device based on large language model
By filtering and designing adaptive tools, the problem of poor adaptability when calling tools with large language models is solved, and more efficient task processing is achieved.
Patent Information
- Application Number
- CN202411874280.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-05-06
AI Technical Summary
When the tool is called in the prior art, the tool has poor adaptability to the task to be processed, resulting in low processing efficiency.
By receiving task scenarios, medical information and medical rules for pending tasks, filter out relevant basic atomic tools, and use large language models to design adaptive tools to improve the adaptability of tools and tasks.
It improves the adaptability of tools and pending tasks, enhances the tool matching effect of large language model calls, and improves the efficiency of task processing.
Smart Images

Figure CN119938178A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a tool calling method, device, electronic device, computer storage medium and computer program product based on a large language model. Background Art
[0002] In recent years, the rapid development of big models has brought about tremendous changes in various fields and promoted the development of many applications. For example, in the medical field, big language models have demonstrated their functions in scenarios such as analysis and processing of medical texts and medical images, personal health assistants, and clinical auxiliary diagnosis and treatment decisions. In addition, thanks to the excellent understanding, reasoning, and long text capabilities of big models, big models can not only rely on training knowledge to complete various tasks, but also call external tools or obtain external knowledge through tool calls, enabling them to perform specific tasks or access specific information, further breaking the limitations of big models.
[0003] In the existing technology, when a large language model is used to call a tool for task processing, most of the tools that can be called are pre-defined tools. Therefore, when the tool is called, the adaptability of the tool to the task to be processed is poor. Summary of the invention
[0004] The main purpose of the present invention is to solve the technical problem in the prior art that when a large language model is used to call a tool for task processing, the called tool and the task to be processed are not well adapted to each other.
[0005] A first aspect of the present invention provides a tool calling method based on a large language model, comprising:
[0006] Receiving a task to be processed, and obtaining a task scenario, medical information, and medical rules of the task to be processed;
[0007] Based on the task scenario, at least one relevant basic atomic tool is selected from the basic atomic tool set;
[0008] Calling the large language model to design an adaptation tool for the task to be processed based on the screened basic atomic tools according to the medical information and the medical rules;
[0009] The adaptation tool is called to process the task to be processed.
[0010] Optionally, in a first implementation of the first aspect of the present invention, before receiving a task to be processed in a task scenario lacking an adaptation tool, the method further includes:
[0011] Define basic atomic tools and clarify tool information of the basic atomic tools;
[0012] Based on the defined basic atomic tools and the tool information, a basic atomic toolset is constructed.
[0013] Optionally, in a second implementation of the first aspect of the present invention, the selecting at least one relevant basic atomic tool from the basic atomic tool set based on the task scenario includes:
[0014] According to the task scenario and the tool information in the basic atomic tool set, at least one basic atomic tool related to the task scenario of the task to be processed is retrieved and screened.
[0015] Optionally, in a third implementation of the first aspect of the present invention, after designing the adaptation tool for the task to be processed based on the screened basic atomic tool, the method further includes:
[0016] According to the tool information of each basic atomic tool, the workflow of the task to be processed is optimized and planned to obtain an optimized workflow;
[0017] Adjusting the calling process of the adaptation tool based on the optimized workflow;
[0018] The calling of the adaptation tool to process the task to be processed includes:
[0019] Based on the adjusted calling process, the adaptation tool is called to process the task to be processed.
[0020] Optionally, in a fourth implementation of the first aspect of the present invention, after constructing the adaptation tool of the task to be processed based on the relevant basic atomic tool, the method further includes:
[0021] The medical information, the medical rules and the tool information of each of the basic atomic tools in the adaptation tool are used as the input of the model, and the large language model is called to generate the executable code of the adaptation tool;
[0022] The calling of the adaptation tool to process the task to be processed based on the adjusted calling process includes:
[0023] The adapter tool is called by the executable code based on the adjusted calling process to process the task to be processed.
[0024] Optionally, in a fifth implementation of the first aspect of the present invention, before receiving a task to be processed in a task scenario lacking an adaptation tool, the method further includes:
[0025] Define the application programming interface corresponding to the basic atomic tools;
[0026] The executable code for calling the large language model to generate the adaptation tool includes:
[0027] Calling the large language model to generate executable code corresponding to the adaptation tool based on the application program interface;
[0028] The calling of the adapter tool based on the adjusted calling process by the executable code to process the task to be processed includes:
[0029] Based on the executable code, the application program interface corresponding to each basic atomic tool in the adaptation tool is called to process the task to be processed.
[0030] Optionally, in a sixth implementation of the first aspect of the present invention, generating the executable code of the adaptation tool also includes:
[0031] Flag characters are set before and after the segments of the executable code.
[0032] Optionally, in a sixth implementation of the first aspect of the present invention, after calling the adaptation tool based on the executable code to process the task to be processed, the method further includes:
[0033] Performing external verification on the executable code to determine whether the feasibility of the executable code meets feasibility requirements;
[0034] If the feasibility requirements are met, construct test set data to iteratively optimize the adaptation tool;
[0035] The adaptation tool after iterative optimization is used as the adaptation tool corresponding to the task scenario of the task to be processed, and is added to the candidate tool pool.
[0036] A second aspect of the present invention provides a tool calling device based on a large language model, comprising:
[0037] An acquisition module, used for receiving a task to be processed in a task scenario lacking an adaptation tool, and acquiring medical information and medical rules of the task to be processed;
[0038] A screening module, used in the task scenario, to screen out at least one relevant basic atomic tool from the basic atomic tool set;
[0039] A generation module, used for calling a large language model to design an adaptation tool for the task to be processed based on the screened basic atomic tools according to the medical information and the medical rules;
[0040] The calling module is used to call the adaptation tool to process the task to be processed.
[0041] The third aspect of the present invention provides a tool calling device based on a large language model, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the tool calling device based on the large language model executes the steps of the above-mentioned tool calling method based on the large language model.
[0042] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the steps of the above-mentioned tool calling method based on a large language model.
[0043] A fifth aspect of the present invention provides a computer program product, comprising a computer program / instruction, characterized in that when the computer program / instruction is executed by a processor, the steps of the above-mentioned tool calling method based on a large language model are implemented.
[0044] In the technical solution provided by the present invention, a task to be processed is received, and the task scenario, medical information and medical rules of the task to be processed are obtained; based on the task scenario, at least one relevant basic atomic tool is screened out from the basic atomic tool set; the large language model is called to design an adaptation tool for the task to be processed based on the medical information and medical rules and based on the screened basic atomic tools; the adaptation tool is called to process the task to be processed. The method can design an adaptation tool by calling the basic atomic tools related to the task to be processed through the large language model, and call the adaptation tool to process the task to be processed, which can improve the adaptability of the tool and the task to be processed, and improve the matching effect of the tool called by the large language model when processing the task. A device, an electronic device, a computer-readable storage medium and a computer program product provided by the present invention also solve the corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0046] Figure 1 It is a flowchart of a first embodiment of a tool calling method based on a large language model in an embodiment of the present invention;
[0047] Figure 2 It is a flowchart diagram of a second embodiment of a tool calling method based on a large language model in an embodiment of the present invention;
[0048] Figure 3 It is a flowchart diagram of a third embodiment of a tool calling method based on a large language model in an embodiment of the present invention;
[0049] Figure 4 A schematic diagram of an embodiment of a tool calling device based on a large language model in an embodiment of the present invention;
[0050] Figure 5 A schematic diagram of an embodiment of a tool calling device based on a large language model in an embodiment of the present invention;
[0051] Figure 6 The figure is a schematic diagram of a computer-readable medium in an embodiment of the present invention. DETAILED DESCRIPTION
[0052] Exemplary embodiments of the present invention will now be described more fully with reference to the accompanying drawings. However, exemplary embodiments can be implemented in a variety of forms, and should not be construed as limiting the present invention to the embodiments set forth herein. On the contrary, providing these exemplary embodiments enables the present invention to be more comprehensive and complete, and is more convenient for fully conveying the inventive concept to those skilled in the art. The same reference numerals in the figures represent the same or similar elements, components or parts, and thus their repeated description will be omitted.
[0053] Under the premise of being consistent with the technical concept of the present invention, the features, structures, characteristics or other details described in a specific embodiment do not exclude that they can be combined in one or more other embodiments in a suitable manner.
[0054] In the description of specific embodiments, the features, structures, characteristics or other details described in the present invention are intended to enable those skilled in the art to fully understand the embodiments. However, it does not exclude that those skilled in the art can practice the technical solutions of the present invention without one or more of the specific features, structures, characteristics or other details.
[0055] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0056] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0057] The term "and / or" or "and / or" includes all combinations of any one or more of the associated listed items.
[0058] See also Figure 1The first embodiment of the tool calling method based on the large language model in the embodiment of the present invention includes:
[0059] S101, receiving a task to be processed, and obtaining a task scenario, medical information, and medical rules of the task to be processed;
[0060] It is understandable that the execution subject of the present invention may be a tool calling device, or a terminal or a server, which is not limited here. The embodiment of the present invention is described by taking a server as the execution subject as an example.
[0061] In this embodiment, firstly, the pending task that needs to be processed by calling the Large Language Model (LLM) is obtained, and the task scenario to which the pending task belongs is obtained; when there is an adapter tool corresponding to the task scenario in the tool pool, the large language model searches and calls the adapter tool corresponding to this task scenario in the tool pool; when the tool pool lacks the adapter tool corresponding to this task scenario, the medical information and medical rules of the pending task are obtained. Among them, the task scenario can be a medical task scenario; the medical information refers to the basic information, report data and other information of the current pending task; the medical rules refer to the standardized and normalized rules, protocols, clinical pathways and algorithms and other rule information related to the current pending task for guiding the diagnosis, treatment, prevention and management of diseases.
[0062] The large language model described in this embodiment is a language model composed 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 and can perform well in a wide range of tasks.
[0063] S102, based on the task scenario, selecting at least one relevant basic atomic tool from the basic atomic tool set;
[0064] In this embodiment, a basic atomic tool set is preconfigured and constructed, and the basic atomic tool set includes multiple basic atomic tools, wherein the basic atomic tool refers to a preconfigured tool that can complete certain tasks, such as a calculator, a knowledge base searcher, an Internet searcher, an image encoder, and various classifiers, etc. According to the type of basic atomic tool that may be required for the task scenario of the task to be processed, at least one relevant basic atomic tool is screened out from the basic atomic tool set.
[0065] S103, calling the large language model to design an adaptation tool for the task to be processed based on the medical information and medical rules and the selected basic atomic tools;
[0066] In this embodiment, after the basic atomic tools are screened out, the large language model can be called to process the pending tasks based on these basic atomic tools. Specifically, the large language model can understand and analyze the medical information and specific medical rules of the pending tasks, and design and construct an adaptation tool that can process the pending tasks based on the tool information of the screened basic atomic tools.
[0067] S104: Call an adapter tool to process the task to be processed.
[0068] After obtaining the adapter tool, the large language model calls the adapter tool to execute a specific processing flow for the task to be processed.
[0069] The embodiment of the present invention can design an adaptation tool by calling the tool based on the large language model and the basic atomic tool structure related to the task to be processed, and call the adaptation tool to process the task to be processed, which can improve the adaptability of the tool and the task to be processed and improve the matching effect of the tool called by the large language model when processing the task.
[0070] Please see Figure 2 The second embodiment of the tool calling method based on the large language model in the embodiment of the present invention includes:
[0071] S201, define basic atomic tools, and clarify tool information of the basic atomic tools, and build a basic atomic tool set based on the defined basic atomic tools and tool information;
[0072] In this embodiment, a plurality of basic atomic tools are first constructed, and the constructed basic atomic tools are defined, and a basic atomic tool set is constructed based on the defined basic atomic tools. Defining a tool means clarifying the components and main functions of the tool. Specifically, the tool definition can divide each basic atomic tool into multiple types, such as general types of basic atomic tools that can perform numerical calculations and analysis; and types such as special tools for specific application tasks that can call a drug knowledge base to obtain drug instructions.
[0073] In a specific implementation, the constructed basic atomic tools may include calculators, knowledge base searchers, Internet searchers, image encoders, and various classifiers, etc. During definition, the tool information of the basic atomic tools is clarified, wherein the tool information may include the coverage of the tool, tool description, model prompt words corresponding to the tool, input content and format of the tool, output content and format of the tool, and other information.
[0074] S202, receiving the task to be processed, and obtaining the task scenario, medical information and medical rules of the task to be processed;
[0075] It is understandable that the execution subject of the present invention may be a tool calling device, or a terminal or a server, which is not limited here. The embodiment of the present invention is described by taking a server as the execution subject as an example.
[0076] In this embodiment, first, the pending task that needs to be processed by calling the large language model is obtained, and the task scenario to which the pending task belongs is obtained, wherein the task scenario can be a medical task scenario; when there is an adaptation tool corresponding to the task scenario in the tool pool, the large language model searches for and calls the adaptation tool corresponding to this task scenario in the tool pool; when the tool pool lacks the corresponding adaptation tool under this task scenario, the medical information and medical rules of the pending task are obtained.
[0077] In a specific implementation, in some medical scenarios, multiple tools may be called, and the trigger of the call may be automatically triggered or manually triggered during the user's interaction with the model. Therefore, in order to improve the efficiency of model tool calls, for different medical task scenarios, a large language model can be used to predict the tools that may be used based on scenario characteristics. For example, in the pre-consultation scenario of a disease, symptom consultation, medication consultation, guidance, medical recommendations, etc. are all common user demands. Based on this, the large language model can predict the tools that may be used in the pre-consultation scenario, such as knowledge base retrieval tools and Internet search tools, as well as related document retrieval tools, paragraph rearrangement tools, etc.
[0078] Therefore, before executing a specific call, it is necessary to obtain the medical information and medical rules of the task to be processed.
[0079] S203, according to the task scenario and the tool information in the basic atomic tool set, retrieve and filter out at least one basic atomic tool related to the task scenario;
[0080] In the case where there is a lack of adaptation tools for the task to be processed, this embodiment can combine the description of the task scenario and medical information and rules to match the basic atoms to construct an adaptation tool; specifically, the task scenario of the task to be processed and the tool information of each tool in the basic atomic tool set are obtained, and at least one basic atomic tool related to the current task scenario is retrieved as an available tool group based on the tool description.
[0081] In a specific implementation, if the current pending task is a medical task scenario, such as a diagnosis and treatment decision scenario for cancer, the task usually includes analysis of data such as the patient's basic information, pathology report, imaging report, and ultrasound report. Therefore, the solution process for the diagnosis and treatment decision includes the call of analysis tools for various reports, such as the current stage of the disease, the current treatment progress, and the report summary; therefore, when searching, the relevant basic atomic tools can be retrieved from the basic atomic tool set. In another specific example, when executing a similar pending task for diagnosis and treatment decision, the solution tools required may be basic atomic tools of various report analysis types and basic atomic tools of decision maker types.
[0082] S204, calling the large language model to build an adaptation tool for the task to be processed based on the screened basic atomic tools according to the medical information and medical rules;
[0083] After obtaining various candidate basic atomic tools in the above steps, the basic atomic tools are designed and matched in combination with the medical information and medical rules of the task to be processed to obtain the adapter tool corresponding to the task to be processed. The medical information refers to basic information, report data and other information, such as the patient's basic information, clinical data information, treatment records and other management information; medical rules refer to the standardized and normalized rules, protocols, clinical pathways and algorithms related to the current task to be processed for guiding the diagnosis, treatment, prevention and management of diseases.
[0084] In a specific implementation, if the current task to be processed belongs to the diagnosis and treatment decision scenario of cancer, after screening various basic atomic tools, various tools will be combined and implemented according to the specific required content; taking the calculation of cancer symptom staging as a specific example, when the task to be processed includes the task step of staging the symptom, the medical information that needs to be obtained from the pathology report first includes the T staging related to the primary tumor, the N staging related to regional lymph node metastasis, and the M staging information related to cancer cell metastasis; the medical rules include the TNM calculation rules for pathological staging. The constructed adaptive tool can be a pathological staging tool. Specifically, the pathological staging tool can be designed and constructed by combining the three basic atomic tools of T staging, N staging and M staging with the TNM calculation tool for pathological staging. Similarly, the analysis tools of imaging reports and ultrasound reports can also be implemented by combining tools such as TNM staging classifiers and subtype classifiers; the specific combination method is obtained by calling a large language model to perform task analysis and planning on medical information and medical rules.
[0085] S205, optimizing and planning the workflow of the task to be processed according to the tool information of each basic atomic tool to obtain an optimized workflow, and adjusting the calling process of the adaptation tool based on the optimized workflow;
[0086] S206: Based on the adjusted calling process, call the adapter tool to process the task to be processed.
[0087] As described in step S202 in this embodiment, in some specific application scenarios in this embodiment, there may be multiple calls to a variety of basic atomic tools, and the triggering of the calls may be automatic, or manually triggered during the user's interaction with the model. Some atomic tools are actually decoupled from each other during execution, so they can be completed in parallel, for example, knowledge base retrieval can be performed concurrently with Internet search; some atomic tools have a fixed order when they are implemented, for example, document retrieval and paragraph rearrangement tools should be performed step by step after the search results are obtained. Therefore, in this embodiment, the workflow information of each basic atomic tool when executing the task to be processed can also be determined according to the tool information of each basic atomic tool, the specific workflow of the task to be processed can be optimized and planned, the calling and execution process of each tool can be adjusted, and based on the adjusted calling process, the adapter tool is called to process the task to be processed based on the optimized and adjusted workflow.
[0088] In a preferred embodiment, the possibility of using each basic atomic tool can also be predicted to improve the efficiency of the pre-consultation dialogue; for example, when a user asks about the disease corresponding to the symptoms, it is usually necessary to search the knowledge base or the Internet to obtain relevant disease knowledge, and at the same time, the tool call prediction can be executed to search and obtain the relevant knowledge of the medicine and medical treatment corresponding to the symptoms. Since multiple types of search tools can be completed in parallel, when the user asks about the disease corresponding to the symptoms, not only the search tool is called to search for possible disease types, but also the search tool is called to search for possible disease types. Related drugs and medical recommendations that may be used as preparation. When the user subsequently asks about related drugs and medical recommendations, the relevant drugs and medical recommendations that may be used can be directly output, instead of calling the search tool to search for possible disease types. Related drugs and medical recommendations that may be used when the user triggers a request to ask about related drugs and medical recommendations. This can reduce the steps of calling the search tool and improve interaction efficiency.
[0089] The embodiment of the present invention can design an adaptation tool through tool calls based on a large language model and basic atomic tools related to the task to be processed, and call the adaptation tool to process the task to be processed, which can improve the adaptability of the tool and the task to be processed and improve the matching effect of the tool called by the large language model when processing the task; and in this embodiment, when designing the adaptation tool, the calling process of each basic atomic tool will be optimized according to the relevant medical task information and medical rules of the task to be processed, thereby improving the parallel efficiency of multiple tool calls, reducing the number of model inferences, saving computing resources and improving the efficiency of interaction.
[0090] Please see Figure 3The third embodiment of the tool calling method based on the large language model in the embodiment of the present invention includes:
[0091] The tool calling method based on the large language model described in this embodiment can be used in various models and products with medical knowledge question and answer, medical background dialogue, medical follow-up, auxiliary diagnosis and treatment capabilities and involving external tool calling or tool design. The specific application scenarios in this embodiment are only examples and should not be regarded as limitations on the application scenarios of this application.
[0092] S301, define basic atomic tools, clarify tool information of basic atomic tools, define application programming interfaces corresponding to basic atomic tools, and build a basic atomic tool set based on the tool information and application programming interfaces of basic atomic tools;
[0093] In this embodiment, first, multiple basic atomic tools are constructed, and the constructed basic atomic tools are defined. Defining the tools means clarifying the components and main functions of the tools, including clarifying the tool information of the basic atomic tools, wherein the tool information may include the coverage of the tool, tool description, model prompt words corresponding to the tool, input content and format of the tool, output content and format of the tool, and other information. And a basic atomic tool set is constructed based on the defined basic atomic tools.
[0094] In this embodiment, when constructing and defining the basic atomic tool, it can also include defining the application programming interface (API) corresponding to the basic atomic tool. The application programming interface refers to the code provided by the computer operating system or program function library for application program to call and use, and its main purpose is to allow application developers to call a set of routine functions without considering the underlying source code or understanding the details of its internal working mechanism. When the basic atomic tool is implemented by means of an application programming interface, the function of the basic atomic tool can be called by the application programming interface when the subsequent large language model calls the corresponding basic atomic tool.
[0095] S302, receiving a task to be processed, and obtaining a task scenario, medical information, and medical rules of the task to be processed;
[0096] S303, based on the task scenario and the tool information in the basic atomic tool set, retrieve and filter out at least one basic atomic tool related to the task scenario of the task to be processed;
[0097] S304, calling the large language model to design an adaptation tool for the task to be processed based on the medical information and medical rules and the selected basic atomic tools;
[0098] S305, optimizing and planning the workflow according to the tool information of each basic atomic tool to obtain an optimized workflow, and adjusting the calling process of the adaptation tool based on the optimized workflow;
[0099] The contents of step S302 to step S305 in this embodiment are substantially the same as those of step S202 to step S205 in the aforementioned embodiment, and thus will not be described in detail herein.
[0100] S306, using medical information, medical rules, and tool information of each basic atomic tool in the adaptation tool as input to the model, calling the large language model to generate executable code corresponding to the adaptation tool;
[0101] After obtaining various candidate basic atomic tools in the above steps, the basic atomic tools are designed and matched in combination with the medical information and medical rules of the task to be processed to obtain the adapter tool corresponding to the task to be processed. The medical information refers to basic information, report data and other information, such as the patient's basic information, clinical data information, treatment records and other management information; medical rules refer to the standardized and normalized rules, protocols, clinical pathways and algorithms related to the current task to be processed for guiding the diagnosis, treatment, prevention and management of diseases.
[0102] In a specific implementation, if the current task to be processed belongs to the diagnosis and treatment decision scenario of cancer, after screening various basic atomic tools, various tools will be combined and implemented according to the specific required content; taking the calculation of cancer symptom staging as a specific example, when the task to be processed includes the task step of staging the symptom, the medical information that needs to be obtained from the pathology report first includes the T staging related to the primary tumor, the N staging related to regional lymph node metastasis, and the M staging information related to cancer cell metastasis; the medical rules include the TNM calculation rules for pathological staging. The constructed adaptive tool can be a pathological staging tool. Specifically, the pathological staging tool can be designed and constructed by combining the three basic atomic tools of T staging, N staging and M staging with the TNM calculation tool for pathological staging. Similarly, the analysis tools of imaging reports and ultrasound reports can also be implemented by combining tools such as TNM staging classifiers and subtype classifiers; the specific combination method is obtained by calling a large language model to perform task analysis and planning on medical information and medical rules.
[0103] In this embodiment, after obtaining the possible tool combinations, the application program interface information of the basic atomic tools corresponding to each tool combination and the optimized specific calling process of each basic atomic tool are also obtained to generate the executable code corresponding to the possible adaptation tool. This is because this embodiment is different from the traditional model tool calling method. The traditional model outputs the function name and corresponding parameters of the tool when the tool needs to be called. Since there are many combinations between multiple tools, the model usually calls one tool at a time according to the current needs, which will lead to low tool calling efficiency. In this embodiment, in order to improve the tool calling efficiency, multiple tools are integrated together for execution by generating executable code through a large model, thereby reducing the number of interactions between the model and the tool, and improving the degree of concurrent calling of the tool, which is convenient for designing the simultaneous calling of multiple tools. At the same time, combined with the optimized calling process obtained in the above steps, the calling order of multiple tools is considered to greatly save the time consumption of tool calling and reduce the number of reasoning times and computing costs of the model.
[0104] To illustrate with a specific example, when generating the executable code corresponding to the adaptation tool, this step can take the current user or medical task description and the tool description of the callable basic atomic tool as input, use the prompt word of the atomic tool to indicate the model analysis task requirements, and generate executable Python code under appropriate operating conditions. The code can include the tool to be called and the predicted function name and parameters that may need to be called in the future.
[0105] Furthermore, a flag character may be set before and after the generated executable code segment. An example of the flag character may be " <startofcode>"and" <endofcode>", the generated executable code is located in the code output by the model. Special marker characters" <startofcode>"and" <endofcode>" to facilitate parsing and positioning.
[0106] S307 , calling the application program interface corresponding to each basic atomic tool in the adapter tool based on the adjusted calling process through the executable code to process the task to be processed.
[0107] Based on the external programming environment, the code segments generated by the large language model are parsed, and the compilation and execution software is called to run the code. Based on the executable code, the application programming interfaces corresponding to the basic atomic tools in the adaptation tool are called to process the tasks to be processed, and the execution results are returned to the large language model.
[0108] Among them, the large language model described in this embodiment needs to have code generation capabilities. In a specific implementation, before step S301 of this embodiment, it also includes fine-tuning the model by using corresponding code generation data to obtain a large language model with code generation capabilities.
[0109] Furthermore, in a preferred embodiment, it also includes: externally verifying the generated executable code to determine whether the feasibility of the executable code meets the feasibility requirements; if the feasibility requirements are met, constructing test set data to iteratively optimize the adaptation tool; using the iteratively optimized adaptation tool as the adaptation tool corresponding to the task scenario of the task to be processed, and adding it to the alternative tool pool.
[0110] Furthermore, in a preferred embodiment, it also includes: receiving the task to be processed and obtaining the task scenario of the task to be processed, searching for the corresponding adapter tool in the alternative tool pool according to the task scenario, and if the adapter tool is found, calling the adapter tool to process the task to be processed.
[0111] Specifically, you can set an external code environment to run the code and give correct feedback to tell the model whether it needs to modify the generated code or continue to the next step. Through a perfect code generation and feedback mechanism, you can improve the parallel efficiency of multiple tool calls, while minimizing the number of model inferences and saving computing resources.
[0112] The embodiment of the present invention can design and build an adaptation tool through tool calls based on a large language model and basic atomic tools related to the task to be processed, and call the adaptation tool to process the task to be processed, which can improve the adaptability of the tool and the task to be processed, solve the problems of limited tool categories and insufficient application scope when calling tools for task processing in the prior art, and improve the matching effect of tools called by large language models; and in this embodiment, when designing the adaptation tool, the calling process of each basic atomic tool will be optimized according to the relevant medical task information and medical rules of the task to be processed, so as to improve the parallel efficiency of multiple tool calls and reduce the number of model inferences; in addition, in this embodiment, when calling the tool to perform a task, the task is processed by generating an executable code for the adaptation tool, which avoids the problem of increasing the response time when calling an external tool, saves computing resource costs and improves the efficiency of interaction.
[0113] The above describes the tool calling method based on the large language model in the embodiment of the present invention. The following describes the tool calling device based on the large language model in the embodiment of the present invention. Figure 4 , an embodiment of a tool calling device based on a large language model in an embodiment of the present invention includes:
[0114] The acquisition module 401 is used to receive the task to be processed, and obtain the task scenario, medical information and medical rules of the task to be processed;
[0115] A screening module 402 is used to screen out at least one relevant basic atomic tool from the basic atomic tool set based on the task scenario;
[0116] A generation module 403 is used to call a large language model to design an adaptation tool for the task to be processed based on the medical information and the medical rules and the screened basic atomic tools;
[0117] The calling module 404 is used to call the adaptation tool to process the task to be processed.
[0118] The embodiment of the present invention can design an adaptation tool by calling the tool based on the large language model and the basic atomic tool related to the task to be processed, and calling the adaptation tool to process the task to be processed, which can improve the adaptability of the tool and the task to be processed and improve the matching effect of the tool called by the large language model when processing the task.
[0119] In another embodiment of the present application, the tool calling device based on the large language model also includes a toolset construction module, which is specifically used to: define basic atomic tools and clarify tool information of the basic atomic tools; and construct a basic atomic toolset based on the defined basic atomic tools and the tool information.
[0120] In another embodiment of the present application, the screening module 402 is specifically used to retrieve and screen out at least one basic atomic tool related to the task scenario of the task to be processed according to the task scenario and the tool information in the basic atomic tool set.
[0121] In another embodiment of the present application, the tool calling device based on the large language model also includes an adjustment module, which is specifically used to: optimize the workflow of the task to be processed according to the tool information of each basic atomic tool to obtain an optimized workflow; adjust the calling process of the adaptation tool based on the optimized workflow; the calling module 404 is specifically used to: based on the adjusted calling process, call the adaptation tool to process the task to be processed.
[0122] In another embodiment of the present application, the tool calling device based on the large language model also includes a code generation module, which is specifically used to: use the medical information, the medical rules and the tool information of each of the basic atomic tools in the adaptation tool as the input of the model, and call the large language model to generate the executable code of the adaptation tool; the calling module 404 is also specifically used to call the adaptation tool based on the adjusted calling process through the executable code to process the task to be processed.
[0123] In another embodiment of the present application, the toolset construction module is further specifically used to define the application program interface corresponding to the basic atomic tool; the code generation module is further specifically used to call the large language model to generate the executable code corresponding to the adaptation tool based on the application program interface; the calling module 404 is further specifically used to call the application program interface corresponding to each basic atomic tool in the adaptation tool based on the adjusted calling process through the executable code to process the task to be processed.
[0124] In another embodiment of the present application, the code generation module is further configured to set flag characters before and after a segment of the executable code.
[0125] In another embodiment of the present application, the tool calling device based on the large language model also includes a tool backup module, which is specifically used to: perform external verification on the executable code to determine whether the feasibility of the executable code meets the feasibility requirements; if the feasibility requirements are met, construct test set data to iteratively optimize the adaptation tool; use the iteratively optimized adaptation tool as the adaptation tool corresponding to the task scenario of the task to be processed, and add it to the alternative tool pool.
[0126] In addition, in another embodiment of the present application, the method executable in the tool calling device of the large language model can refer to the embodiment of the tool calling method of the large language model mentioned above, which will not be repeated here.
[0127] The embodiment of the present invention can design an adaptation tool through tool calls based on a large language model and basic atomic tools related to the task to be processed, and call the adaptation tool to process the task to be processed, which can improve the adaptability of the tool and the task to be processed, solve the problems of limited tool categories and insufficient application scope when calling tools for task processing in the prior art, and improve the matching effect of tools called by large language models; and in this embodiment, when designing the adaptation tool, the calling process of each basic atomic tool will be optimized according to the relevant medical task information and medical rules of the task to be processed, so as to improve the parallel efficiency of multiple tool calls and reduce the number of model inferences; in addition, in this embodiment, when calling the tool to perform a task, the task is processed by generating an executable code for the adaptation tool, which avoids the problem of increasing the response time when calling an external tool, saves computing resource costs and improves the efficiency of interaction.
[0128] Based on the same inventive concept, an embodiment of this specification also provides an electronic device for tool calling based on a large language model. The electronic device for tool calling based on a large language model in an embodiment of the present invention is described in detail below from the perspective of hardware processing.
[0129] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this specification. Figure 5 The electronic device 500 according to this embodiment of the present invention is described. Figure 5 The electronic device 500 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0130] like Figure 5 As shown, the electronic device 500 is in the form of a general computing device. The components of the electronic device 500 may include, but are not limited to: at least one processing unit 510, at least one storage unit 520, a bus 530 connecting different system components (including the storage unit 520 and the processing unit 510), a display unit 540, etc.
[0131] The storage unit stores program codes, which can be executed by the processing unit 510, so that the processing unit 510 performs the steps according to various exemplary embodiments of the present invention described in the above processing method section of this specification. For example, the processing unit 510 can perform the following steps: Figure 1 Steps shown.
[0132] The storage unit 520 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 5201 and / or a cache memory unit 5202 , and may further include a read-only memory unit (ROM) 5203 .
[0133] The storage unit 520 may also include a program / utility 5204 having a set (at least one) of program modules 5205, such program modules 5205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include the implementation of a network environment.
[0134] Bus 530 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0135] The electronic device 500 may also communicate with one or more external devices 100 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device 500, and / or any device that enables the electronic device 500 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 550. Furthermore, the electronic device 500 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 560. The network adapter 560 may communicate with other modules of the electronic device 500 through the bus 530. It should be understood that although Figure 5 Not shown, other hardware and / or software modules may be used in conjunction with electronic device 500, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0136] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the exemplary embodiments described in the present invention can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation method of the present invention can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.) or on a network, including a number of instructions to enable a computing device (which can be a personal computer, server, or network device, etc.) to execute the above method according to the present invention. When the computer program is executed by a data processing device, the computer-readable medium can implement the above method of the present invention, that is: Figure 1-3 The method shown.
[0137] Figure 6 A schematic diagram of a computer-readable medium provided for an embodiment of this specification.
[0138] accomplish Figure 1-3 The computer program of the method shown can be stored on one or more computer readable media. The computer readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0139] The computer readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by an instruction execution system, an apparatus, or a device or used in combination with it. The program code contained on the readable storage medium may be transmitted with any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0140] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0141] In summary, the present invention can be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that general data processing devices such as microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0142] In addition, the present invention also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the tool calling method based on a large language model as described in any of the above embodiments.
[0143] The specific embodiments described above further describe the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the present invention is not inherently related to any specific computer, virtual device or electronic device, and various general devices can also implement the present invention. The above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
[0144] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0145] If the technical solution of this application involves personal information, the product using the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing personal information. If the technical solution of this application involves sensitive personal information, the product using the technical solution of this application has obtained the individual's separate consent before processing sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to the collection of his or her personal information; or on the device that processes personal information, the personal information processing rules are notified by obvious signs / information, and the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; among them, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.
[0146] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.< / endofcode> < / startofcode> < / endofcode> < / startofcode>
Claims
1. A tool calling method based on a large language model, characterized in that: include: Receiving a task to be processed, and obtaining a task scenario, medical information, and medical rules of the task to be processed; Based on the task scenario, at least one relevant basic atomic tool is selected from the basic atomic tool set; Calling the large language model to design an adaptation tool for the task to be processed based on the screened basic atomic tools according to the medical information and the medical rules; The adaptation tool is called to process the task to be processed.
2. The tool calling method based on a large language model according to claim 1, characterized in that: Before receiving the task to be processed, the method further includes: Define basic atomic tools and clarify tool information of the basic atomic tools; Based on the defined basic atomic tools and the tool information, a basic atomic toolset is constructed.
3. The tool calling method based on a large language model according to claim 2, characterized in that: The step of selecting at least one relevant basic atomic tool from the basic atomic tool set based on the task scenario includes: According to the task scenario and the tool information in the basic atomic tool set, at least one basic atomic tool related to the task scenario is retrieved and screened.
4. The tool calling method based on a large language model according to claim 3, characterized in that: After designing the adaptation tool for the task to be processed based on the screened basic atomic tool, the method further includes: According to the tool information of each basic atomic tool, the workflow of the task to be processed is optimized and planned to obtain an optimized workflow; Adjusting the calling process of the adaptation tool based on the optimized workflow; The calling of the adaptation tool to process the task to be processed includes: Based on the adjusted calling process, the adaptation tool is called to process the task to be processed.
5. The tool calling method based on a large language model according to claim 4, characterized in that: After constructing the adaptation tool for the task to be processed based on the relevant basic atomic tools, it also includes: The medical information, the medical rules and the tool information of each of the basic atomic tools in the adaptation tool are used as inputs of the model, and the large language model is called to generate executable code of the adaptation tool; The calling of the adaptation tool to process the task to be processed based on the adjusted calling process includes: The adapter tool is called by the executable code based on the adjusted calling process to process the task to be processed.
6. The tool calling method based on a large language model according to claim 5, characterized in that: Before receiving the task to be processed, the method further includes: Define the application programming interface corresponding to the basic atomic tools; The executable code for calling the large language model to generate the adaptation tool includes: Calling the large language model to generate executable code corresponding to the adaptation tool based on the application program interface; The calling of the adapter tool based on the adjusted calling process by the executable code to process the task to be processed includes: The executable code calls the application program interface corresponding to each basic atomic tool in the adaptation tool based on the adjusted calling process to process the task to be processed.
7. The tool calling method based on a large language model according to claim 5, characterized in that: Also includes: Flag characters are set before and after the segments of the executable code.
8. The tool calling method based on a large language model according to claim 5, characterized in that: After the executable code calls the adaptation tool based on the adjusted calling process to process the task to be processed, the method further includes: Performing external verification on the executable code to determine whether the feasibility of the executable code meets feasibility requirements; If the feasibility requirements are met, construct test set data to iteratively optimize the adaptation tool; The adaptation tool after iterative optimization is used as the adaptation tool corresponding to the task scenario of the task to be processed, and is added to the candidate tool pool.
9. A tool calling device based on a large language model, characterized in that: The tool calling device based on the large language model includes: An acquisition module, used for receiving a task to be processed, and acquiring a task scenario, medical information and medical rules of the task to be processed; A screening module, used in the task scenario, to screen out at least one relevant basic atomic tool from the basic atomic tool set; A generation module, used for calling a large language model to design an adaptation tool for the task to be processed based on the screened basic atomic tools according to the medical information and the medical rules; The calling module is used to call the adaptation tool to process the task to be processed.
10. A tool calling device based on a large language model, characterized in that: The tool calling device based on the large language model includes: a memory and at least one processor, wherein the memory stores instructions; The at least one processor calls the instructions in the memory to enable the large language model-based tool calling device to perform the steps of the large language model-based tool calling method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the program / instructions are executed by a processor, the steps of the tool calling method based on a large language model as described in any one of claims 1 to 8 are implemented.
12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the tool calling method based on a large language model as described in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Task construction method and device, electronic equipment and storage medium
CN115951877A
Large-model-oriented universal tool collaboration and refined learning system and method
CN116594768A
Task processing method, device, system and equipment and readable storage medium
CN117094376A
Financial analysis task reasoning method based on large language model, terminal and medium
CN117744804A
System and method for analyzing high content images based on AI agents
CN118552953A
Cited By
Hierarchical decision architecture model and training reasoning system and method thereof
CN120875023A
Information query method and device, medium and electronic equipment
CN121350117A