Text processing method, device, electronic device and storage medium

By pre-planning the tool call path and combining the information and relationship information of candidate tools, the problem of incorrect order, high cost and time-consuming of large language models when calling external tools is solved, and more efficient and reliable tool call and execution results are achieved.

CN118227868BActive Publication Date: 2025-08-19BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410324534.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-20
Publication Date
2025-08-19
Estimated Expiration
2044-03-20

AI Technical Summary

Technical Problem

When calling external tools, the existing large language model has problems such as incorrect order of tool call, high cost, long time and lack of supervision mechanism, which leads to unreliable tool execution results.

Method used

By pre-planning the tool call path, using the large language model to call nodes in the tool call path in turn, combining the information and relationship information of the candidate tool, a logically coherent tool call sequence is generated, reducing the number of times the large language model is used, and replacing tool calls are made when necessary to ensure the accuracy of the output results.

Benefits of technology

It improves the accuracy and efficiency of the call order of the tool, reduces the cost and time of the use of large language models, and ensures the reliability and logical coherence of tool execution results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118227868B_ABST
    Figure CN118227868B_ABST
Patent Text Reader

Abstract

The present disclosure provides a text processing method, apparatus, electronic device, and storage medium, relating to the field of artificial intelligence, specifically to technical fields such as natural language processing (NLP), large models, language modeling (LLM), and deep learning. A specific implementation scheme comprises: obtaining a query text, tool information of multiple candidate tools in a tool set, and relationship information between the multiple candidate tools; generating a tool call path based on the query text, tool information, and relationship information; wherein the i-th node in the tool call path is used to indicate the target tool to be called for the i-th time by the large language model, where the target tool is determined from the candidate tools, and i is a positive integer; using the large language model to sequentially call the target tools indicated by the nodes in the tool call path to process the query text and obtain reply information; and replying to the query text based on the reply information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of AI (Artificial Intelligence), specifically to technical fields such as NLP (Natural Language Processing), large models, LLM (Large Language Model), and deep learning, and especially to text processing methods, devices, electronic devices, and storage media. Background Art

[0002] Currently, large language models can use external tools (such as APIs (Application Programming Interfaces), functions, search engines, etc.) to solve complex problems, enhance the capabilities of large language models, expand their practicality, and enhance their interactivity with real-world interfaces. For example, large language models can call APIs to retrieve information from online databases, perform data analysis, and even interact with social media platforms to accurately understand and respond to user needs. Summary of the Invention

[0003] The present disclosure provides a text processing method, apparatus, electronic device, and storage medium.

[0004] According to one aspect of the present disclosure, a text processing method is provided, comprising:

[0005] Obtaining a query text, tool information of multiple candidate tools in a toolset, and relationship information between the multiple candidate tools;

[0006] Generate a tool call path based on the query text, the tool information, and the relationship information; wherein the i-th node in the tool call path is used to indicate a target tool to be called for the i-th time by the large language model, the target tool being determined from the candidate tools, and i being a positive integer;

[0007] Using the large language model to sequentially call target tools indicated by nodes in the tool call path to process the query text and obtain reply information;

[0008] Reply to the query text according to the reply information.

[0009] According to another aspect of the present disclosure, there is provided a text processing apparatus, comprising:

[0010] An acquisition module, configured to acquire a query text, tool information of a plurality of candidate tools in a tool set, and relationship information between the plurality of candidate tools;

[0011] a generation module, configured to generate a tool call path based on the query text, the tool information, and the relationship information; wherein the i-th node in the tool call path is used to indicate a target tool to be called for the i-th time by the large language model, the target tool being determined from the candidate tools, and i being a positive integer;

[0012] a calling module, configured to use the large language model to sequentially call target tools indicated by the nodes in the tool calling path to process the query text and obtain reply information;

[0013] The reply module is used to reply to the query text according to the reply information.

[0014] According to another aspect of the present disclosure, there is provided an electronic device, comprising:

[0015] at least one processor; and

[0016] a memory communicatively connected to the at least one processor; wherein,

[0017] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the text processing method proposed in the above aspect of the present disclosure.

[0018] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium of computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the text processing method proposed in the above aspect of the present disclosure.

[0019] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, which implements the text processing method proposed in the above aspect of the present disclosure when executed by a processor.

[0020] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings are used to better understand the present invention and do not constitute a limitation of the present invention.

[0022] Figure 1 A flowchart of a text processing method provided in the first embodiment of the present disclosure;

[0023] Figure 2 A flowchart of a text processing method provided in the second embodiment of the present disclosure;

[0024] Figure 3 This is a flowchart of the text processing method provided in the third embodiment of the present disclosure;

[0025] Figure 4 A flowchart of a text processing method provided in the fourth embodiment of the present disclosure;

[0026] Figure 5 A flowchart of a text processing method provided in Embodiment 5 of the present disclosure;

[0027] Figure 6 A schematic diagram illustrating the implementation principle of text processing provided in the sixth embodiment of the present disclosure;

[0028] Figure 7 This is a structural diagram of a text processing device provided in Embodiment 7 of the present disclosure;

[0029] Figure 8 A schematic block diagram of an example electronic device that can be used to implement embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0030] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0031] Currently, research on large language models is mainly focused on enabling large language models to use external tools to enhance their capabilities. These studies enable large language models to use external tools (such as APIs, functions, etc.) to solve complex problems, expanding the practicality of large language models. Such integration not only improves the functionality of large language models, but also enhances the interactivity of large language models with real-world interfaces. For example, by calling APIs, large language models can directly retrieve information from online databases, perform data analysis, and even interact with social media platforms. In addition, by calling external tools for learning and adaptation, large language models can more accurately understand and respond to user needs.

[0032] With the further integration of technologies, the application scope of large language models has expanded from simple text generation to providing complex decision support. Currently, large language models can be used in areas such as project management, customer service, and online education, helping to improve work efficiency in these fields. For example, in project management, large language models can assist in developing workflows, optimizing resource allocation, and predicting project risks. In customer service, large language models can process customer inquiries in real time and provide personalized answers and suggestions. In online education, large language models can customize teaching plans and materials based on students' learning progress and style.

[0033] In related technologies, large language models mainly use deep search or step-by-step methods to call external tools.

[0034] Among them, the deep search method requires a large number of attempts, which has high time and space complexity and wastes a large number of calls to large language models.

[0035] Among them, the step-by-step approach requires deciding the next plan based on the output or execution result of the currently called external tool. This approach makes it difficult to ensure the correctness of the tool calling sequence and does not utilize the relationship information between tools.

[0036] In summary, the existing multi-round calling method of external tools has at least the following problems:

[0037] (1) The correctness of the tool calling sequence cannot be guaranteed;

[0038] (2) Using large language models too often results in high costs and excessive time consumption;

[0039] (3) There is a lack of supervision mechanism, which cannot guarantee the reliability of tool execution results or output results.

[0040] Therefore, in response to at least one of the above-mentioned problems, the present disclosure proposes a text processing method, device, electronic device and storage medium.

[0041] The following describes the text processing method, apparatus, electronic device, and storage medium of the embodiments of the present disclosure with reference to the accompanying drawings. Before describing the embodiments of the present disclosure in detail, for ease of understanding, the following common technical terms are first introduced:

[0042] Large models are machine learning models with large parameters and complex computational structures. They are typically built from deep neural networks and contain billions or even hundreds of billions of parameters. Large models are designed to improve their expressiveness and predictive performance, enabling them to handle more complex tasks and data. Large models are widely used in various fields, including natural language processing, computer vision, speech recognition, and recommendation systems.

[0043] The LLM in the large model is a type of natural language processing model based on deep learning. Its main features are huge model parameters and complex neural network structure, strong language understanding, context perception and language generation capabilities, and it can automatically learn useful feature representations from input data and generate relevant text.

[0044] Figure 1 This is a flowchart of the text processing method provided in the first embodiment of the present disclosure.

[0045] The embodiment of the present disclosure is illustrated by taking the text processing method as being configured in a text processing device. The text processing device can be applied to any electronic device so that the electronic device can perform a text processing function.

[0046] Among them, the electronic device can be any device with computing capabilities, such as a personal computer, mobile terminal, server, etc. The mobile terminal can be, for example, a mobile phone, tablet computer, personal digital assistant, wearable device, etc., which are hardware devices with various operating systems, touch screens and / or display screens.

[0047] like Figure 1 As shown, the text processing method may include the following steps:

[0048] Step S101 : obtaining a query text, tool information of multiple candidate tools in a toolset, and relationship information between the multiple candidate tools.

[0049] In the embodiments of the present disclosure, there is no restriction on the method of obtaining the query text (query). For example, the query text can be text (or sentence, question, question) input by the user, or the query text can be text (or sentence, question, question) collected online. For example, web crawler technology can be used to collect the query text online, or the query text can be text obtained from an existing training set or test set, etc. The embodiments of the present disclosure do not impose any restrictions on this.

[0050] The input method of the query text may include but is not limited to touch input (such as sliding, clicking, etc.), keyboard input, voice input, etc.

[0051] In the embodiments of the present disclosure, candidate tools include but are not limited to: API, function, search engine, etc., wherein the candidate tools may be all tools in the tool set, or the candidate tools may also be part of the tools in the tool set, and the embodiments of the present disclosure do not limit this.

[0052] In the embodiment of the present disclosure, the tool information includes but is not limited to: identification information of the candidate tool (such as tool name, tool ID (Identity)), and function description information. The tool information of each candidate tool may be pre-set.

[0053] The functional description information includes but is not limited to at least one of the following:

[0054] The first item is the input requirements of the candidate tool.

[0055] Among them, input requirements include but are not limited to: data type (i.e., the input data type accepted by the candidate tool, such as text, images, numbers, files, etc.), format requirements (i.e., the format or specifications that the input data accepted by the candidate tool needs to follow, such as specific file extensions, encoding methods, text formats, etc.), content requirements (if the input data accepted by the candidate tool needs to contain certain specific information or meet specific conditions, the content requirements should also be listed in detail), etc.

[0056] The second item is the processing process of candidate tools.

[0057] The processing process is used to indicate how the candidate tool processes the input data, including the algorithms, techniques, or methods used. It should be noted that if the processing process involves multiple steps or stages, each step should be described separately.

[0058] The third item is the output requirements of the candidate tools.

[0059] Among them, output requirements include but are not limited to: data type (i.e., the output data type of the candidate tool), output format (i.e., the format or presentation method of the output data of the candidate tool, such as tables, charts, text reports, etc.), information content (listing in detail the specific information or indicators contained in the output data so that users can understand the structure and content of the output data), etc.

[0060] Fourth, restrictions on the use of candidate tools.

[0061] Among them, usage limitations are used to indicate limitations that may be encountered when using the candidate tool, such as processing speed, memory limitations, data size limitations, etc.

[0062] Fifth, precautions for using candidate tools.

[0063] The usage precautions are used to provide suggestions or tips on how to correctly use the candidate tool to avoid errors in calling the candidate tool or improve the efficiency of using the candidate tool.

[0064] In summary, the tool information includes multiple pieces of information associated with the candidate tool, which can improve the reliability and rationality of subsequent tool call path generation and improve the correctness of the calling order of each tool in the tool call path.

[0065] In the embodiment of the present disclosure, the relationship information (also referred to as connection relationship) includes but is not limited to: dependency relationship, parallel relationship. The relationship information between multiple candidate tools can be predicted in advance.

[0066] Among them, dependency: the input of one tool depends on the output of another tool.

[0067] Among them, the parallel relationship (or replacement relationship, substitution relationship) is that the tools can replace each other. For example, if a tool does not work properly, another tool can be used to replace it.

[0068] Step S102: Generate a tool calling path based on the query text, tool information and relationship information.

[0069] The i-th node in the tool call path is used to indicate the target tool that needs to be called for the i-th time by the large language model. The target tool is determined from the candidate tools, and i is a positive integer.

[0070] In an embodiment of the present disclosure, a tool call path can be generated based on the query text, tool information of each candidate tool, and relationship information between different candidate tools; wherein the tool call path can contain N (N is a positive integer) nodes, and the i-th (i is a positive integer not greater than N) node in the tool call path is used to indicate the target tool that the large language model needs to call for the i-th time, wherein the target tool is determined from the candidate tools.

[0071] Step S103 : Using the large language model, the target tools indicated by the nodes in the tool calling path are called in sequence to process the query text and obtain reply information.

[0072] In order to enhance the content richness of the reply information and meet the actual query needs of the user, the reply information may include at least one of the following:

[0073] The first item is text.

[0074] The second item is audio, or voice.

[0075] The third item is video.

[0076] Fourth item, image.

[0077] Fifth item, documentation.

[0078] The sixth item is the compressed package.

[0079] Item 7: A web link, such as a URL (Uniform Resource Locator). Users can click on the web link to access the corresponding response information for the query text. For example, if the query text is a user question, clicking on the web link will access the corresponding answer to the user's question.

[0080] In the embodiment of the present disclosure, a large language model may be used to sequentially call target tools indicated by nodes in a tool call path to process the query text and obtain reply information.

[0081] Step S104: reply to the query text according to the reply information.

[0082] In the disclosed embodiment, the query text may be replied to according to the reply information.

[0083] The text processing method of the embodiment of the present disclosure pre-plans (or pre-arranges) a tool calling path before the large language model calls the tool. The large language model calls the tool based on the pre-planned tool calling path, which can ensure that the number of times the large language model is used (or called) is at least the number of nodes in the tool calling path, thereby reducing the number of times the large language model is used. That is, the calling order of the tools is pre-arranged, which can reduce the number of times the large language model is used for thinking, improve text processing efficiency, and reduce costs. In addition, the tool calling path is determined not only based on the query text and the tool information of each candidate tool, but also based on the relationship information between different candidate tools (such as dependency relationships and parallel relationships), which can improve the logical coherence of the tool calling path and the effectiveness of tool execution, and improve the correctness of the tool calling order.

[0084] It should be noted that in the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision and disclosure of user personal information are all carried out with the user's consent, and are in compliance with relevant laws and regulations and do not violate public order and good morals.

[0085] In order to clearly illustrate how to determine candidate tools from a tool set in any embodiment of the present disclosure, the present disclosure also proposes a text processing method.

[0086] Figure 2 This is a flowchart of the text processing method provided in the second embodiment of the present disclosure.

[0087] like Figure 2As shown, the text processing method may include the following steps:

[0088] Step S201: Obtain query text.

[0089] For explanation of step S201, please refer to the relevant description in any embodiment of the present disclosure, and will not be repeated here.

[0090] Step S202: perform intent recognition on the query text to obtain the target intent.

[0091] The target intent includes but is not limited to the following intents: search queries, question-and-answer queries, etc.

[0092] In the embodiment of the present disclosure, the query text can be used to identify the intent based on NLP technology to obtain the target intent.

[0093] As an example, a method for identifying the target intent to which the query text belongs may be:

[0094] 1. Based on the query text, obtain at least one text intent pair (hereinafter referred to as the target text intent pair); wherein the target text intent pair includes candidate texts similar to the query text and the candidate intents to which the candidate texts belong.

[0095] Among them, the text intent pair is pre-generated. For example, a reference text can be collected from at least one data source in advance. After that, a text classification algorithm can be used to identify the reference intent to which the reference text belongs. Alternatively, manual annotation can be used to annotate the reference intent to which the reference text belongs, so that a text intent pair can be generated based on the reference text and the corresponding reference intent.

[0096] In the present disclosure, the similarity (such as text similarity, semantic similarity) between the query text and the reference text in each text intent pair can be calculated, and based on the similarity between the query text and the reference text in the text intent pair, the target text intent pair can be determined from the text intent pairs.

[0097] 2. Generate prompt information (prompt) based on at least one target text intention pair, which is recorded as second prompt information in this disclosure.

[0098] As an example, at least one question-answer pair can be generated based on at least one target text intent pair, wherein the question (Question, abbreviated as Q) in each question-answer pair is used to indicate the candidate text in the corresponding target text intent pair, and the answer (Answer, abbreviated as A) in each question-answer pair is used to indicate the candidate intent in the corresponding target text intent pair. In the present disclosure, the intent recognition scope can be determined based on the candidate intent in at least one target text intent pair, that is, the intent recognition scope includes each candidate intent, and the second prompt information is generated based on at least one question-answer pair and the intent recognition scope.

[0099] Therefore, the second prompt information can indicate each question-answer pair, which can serve as prior information or task information, indicating the information to be recognized by the large language model, which can improve the accuracy of intent recognition. Moreover, the second prompt information can also indicate the schematic recognition range, so that intent recognition can be performed only within the intent recognition range indicated by the second prompt information, without the need to perform intent recognition in all intentions, which can eliminate the intention recognition illusion and thus improve the reliability of the intent recognition result.

[0100] 3. Use a large language model to identify the intent of the query text based on the second prompt information to obtain the target intent of the query text.

[0101] It is understandable that the intents to which similar texts belong are also similar. Identifying the target intent to which the query text belongs based on candidate texts similar to the query text and the candidate intents to which the candidate texts belong can improve the accuracy and reliability of intent recognition.

[0102] Of course, other intent recognition algorithms may also be used to perform intent recognition on the query text, and the embodiments of the present disclosure do not limit this.

[0103] Step S203: Based on the target intent, determine candidate tools that match the target intent from the tool set.

[0104] In an embodiment of the present disclosure, the correspondence between different intents and tools can be pre-set. For example, search-type queries correspond to tool 1, tool 2, and tool 3, and question-and-answer-type queries correspond to tool 4, tool 5, and tool 6. In the present disclosure, the above correspondence can be queried based on the target intent to which the query text belongs to determine the candidate tool that matches the target intent from the tool set.

[0105] Still taking the above example, assuming that the target intent is a question-answering query, the candidate tools may be Tool 4, Tool 5, and Tool 6.

[0106] Step S204: Acquire tool information of multiple candidate tools and relationship information between the multiple candidate tools.

[0107] Step S205: Generate a tool calling path based on the query text, tool information and relationship information.

[0108] The i-th node in the tool call path is used to indicate the target tool that needs to be called for the i-th time by the large language model. The target tool is determined from the candidate tools, and i is a positive integer.

[0109] Step S206 : Using the large language model, the target tools indicated by the nodes in the tool calling path are called in sequence to process the query text and obtain reply information.

[0110] Step S207: reply to the query text according to the reply information.

[0111] For explanations of steps S204 to S207 , reference may be made to the relevant descriptions in any embodiment of the present disclosure, and no further details will be given here.

[0112] The text processing method of the embodiment of the present disclosure can improve the efficiency of generating tool call paths and thus improve text processing efficiency by screening candidate tools that match the target intent of the query text from the tool set, and performing path planning or arrangement only based on the screened candidate tools, without having to perform path planning or arrangement based on all tools in the tool set.

[0113] In order to clearly illustrate how to determine candidate tools from a tool set in any embodiment of the present disclosure, the present disclosure also proposes a text processing method.

[0114] Figure 3 This is a flowchart of the text processing method provided in the third embodiment of the present disclosure.

[0115] like Figure 3 As shown, the text processing method may include the following steps:

[0116] Step S301: Obtain query text.

[0117] For explanation of step S301, please refer to the relevant description in any embodiment of the present disclosure, and will not be repeated here.

[0118] Step S302: Identify the target domain to which the query text belongs.

[0119] As an example, semantic and grammatical analysis may be performed on the query text to obtain the target domain to which the query text belongs.

[0120] As another example, since texts in different fields have different language features, such as professional terms, expressions, sentence structures, etc., in this disclosure, the target field to which the query text belongs can also be identified by analyzing the professional terms, keywords, and sentence structures in the query text.

[0121] As another example, the target domain to which the query text belongs may be identified based on NLP technology and text classification algorithms.

[0122] It should be noted that the above target domain identification method is only an example description, but the present disclosure is not limited thereto. In actual application, other algorithms may also be used to identify the target domain to which the query text belongs.

[0123] Step S303: Based on the target domain, determine candidate tools matching the target domain from the tool set.

[0124] In an embodiment of the present disclosure, the correspondence between different fields and tools can be pre-set, so that in the present disclosure, the above correspondence can be queried based on the target field to which the query text belongs to determine the candidate tools matching the target field from the tool set.

[0125] Step S304: Obtain tool information of multiple candidate tools and relationship information between the multiple candidate tools.

[0126] For explanation of step S304, please refer to the relevant description in any embodiment of the present disclosure, and will not be repeated here.

[0127] In any embodiment of the present disclosure, a method for obtaining the relationship information between multiple candidate tools may be, for example, to process the tool information of the multiple candidate tools using a large language model to obtain structured information.

[0128] The structured information may include identification information (such as tool names) of any two candidate tools and relationship information between the two candidate tools; the relationship information includes dependency relationship and parallel relationship.

[0129] Therefore, using deep learning technology to predict the relationship information between different candidate tools can improve the accuracy and reliability of prediction results. Furthermore, providing this relationship information as structured data is not only clear and easy to understand, but also improves the efficiency, accuracy, and reliability of subsequent relationship information processing.

[0130] It should be noted that in order to improve the efficiency of text processing, a large language model can be used in advance to predict the relationship information between different tools based on the tool information of each tool in the tool set, and store the relationship information between different tools. Therefore, in this disclosure, it is only necessary to obtain the relationship information between multiple candidate tools through query. This is not only simple to operate and easy to implement, but also can improve the efficiency of obtaining relationship information.

[0131] In any embodiment of the present disclosure, the method for predicting the relationship information between multiple candidate tools may be, for example:

[0132] 1. Obtain a prompt template; the prompt template is used to indicate the output requirements of the large language model and the task information to be performed.

[0133] The prompt template can be pre-configured, or dynamically updated based on actual application needs, which is not a limitation of the present disclosure. The prompt template is used to indicate the task information and output requirements to be performed by the large language model. The output requirements may include, but are not limited to, output format and output data type.

[0134] 2. Tool information of multiple candidate tools may be used to fill in a prompt template to obtain prompt information (prompt), which is recorded as first prompt information in this disclosure.

[0135] 3. A large language model may be used to process the first prompt information to obtain structured information.

[0136] The structured information may include identification information (such as tool names) of any two candidate tools and relationship information between the two candidate tools; the relationship information includes dependency relationship and parallel relationship.

[0137] In summary, the first prompt information can serve as prior information or task information, indicating the task to be performed by the large language model. This can improve the prediction accuracy of the large language model, that is, improve the accuracy of structured information prediction. Furthermore, the first prompt information can also indicate the output requirements of the large language model, ensuring that the structured information output by the large language model meets the user's actual query requirements.

[0138] Step S305: Generate a tool calling path based on the query text, tool information and relationship information.

[0139] The i-th node in the tool call path is used to indicate the target tool that needs to be called for the i-th time by the large language model. The target tool is determined from the candidate tools, and i is a positive integer.

[0140] For explanation of step S305, please refer to the relevant description in any embodiment of the present disclosure, and will not be repeated here.

[0141] In any embodiment of the present disclosure, the tool call path may be generated in the following manner, for example:

[0142] 1. A large language model is used to determine the target tool to be called each time from multiple candidate tools based on the query text, tool information of multiple candidate tools, and relationship information between multiple candidate tools.

[0143] 2. Generate a tool calling path based on the target tool that needs to be called each time.

[0144] It is understandable that by analyzing the relationship information between candidate tools, such as dependency relationships and parallel relationships (or replacement relationships, substitution relationships), a more efficient path planning method can be provided for the large language model. This method takes into account the relationship between the input and output of the candidate tools, ensuring the logical consistency of the tool call path and the effectiveness of the tool execution. For example, if a candidate tool cannot produce the required output because it does not meet the execution conditions, other tools with parallel relationship information with the candidate tool can be used as replacement tools (or alternative tools) to ensure that the entire task process will not be interrupted due to the failure of a single tool. In addition, this method allows the large language model to maintain the continuity of task execution when faced with uncertainty and complexity, providing the large language model with a more flexible and dynamic tool calling capability, enabling it to better adapt to changing application scenarios and user needs.

[0145] Step S306 : Using the large language model, the target tools indicated by the nodes in the tool calling path are called in sequence to process the query text and obtain reply information.

[0146] Step S307: reply to the query text according to the reply information.

[0147] For explanations of steps S306 to S307, reference may be made to the relevant descriptions in any embodiment of the present disclosure, and no further details will be given here.

[0148] The text processing method of the embodiment of the present disclosure can improve the efficiency of generating tool call paths and thus improve text processing efficiency by screening candidate tools that match the target field to which the query text belongs from the tool set, and performing path planning only based on the screened candidate tools instead of performing path planning based on all tools in the tool set.

[0149] In order to clearly illustrate how any embodiment of the present disclosure uses a large language model to sequentially call the target tools indicated by the nodes in the tool call path to process the query text and obtain response information, the present disclosure also proposes a text processing method.

[0150] Figure 4 This is a flowchart of the text processing method provided in the fourth embodiment of the present disclosure.

[0151] like Figure 4 As shown, the text processing method may include the following steps:

[0152] Step S401 : obtaining a query text, tool information of multiple candidate tools in a toolset, and relationship information between the multiple candidate tools.

[0153] Step S402: Generate a tool calling path based on the query text, tool information and relationship information.

[0154] The i-th node in the tool call path is used to indicate the target tool that needs to be called for the i-th time by the large language model. The target tool is determined from the candidate tools, and i is a positive integer.

[0155] For explanations of steps S401 to S402 , reference may be made to the relevant descriptions in any embodiment of the present disclosure, and no further details will be given here.

[0156] Step S403 : Using the large language model, the target tools indicated by the nodes in the tool calling path are called in sequence to process the query text.

[0157] In the embodiment of the present disclosure, a large language model may be used to process the query text by sequentially or traversing the target tools indicated by each node in the tool calling path.

[0158] Step S404: Obtain the output result of the target tool currently called by the large language model.

[0159] In the embodiment of the present disclosure, the target tool currently called by the large language model can be monitored in real time to obtain the output result (or execution result, processing result) of the currently called target tool.

[0160] Step S405 , determining whether the output result meets the expected requirements for adapting to the currently called target tool, if so, executing step S406 , if not, executing steps S407 to S409 .

[0161] In any embodiment of the present disclosure, the expected requirements for adapting to the currently called target tool may include at least one of the following:

[0162] First, the output result of the currently called target tool is adapted to the input requirement of the target tool indicated by the next node after the current node in the tool call path.

[0163] The current node refers to the node where the currently called target tool is located in the tool calling path.

[0164] For example, the data type of the output result of the target tool indicated by the current node matches the data type in the input requirement of the target tool indicated by the next node.

[0165] For another example, the format of the output result of the currently called target tool matches the format requirement in the input requirement of the target tool indicated by the next node.

[0166] This can avoid the situation where the output result of the target tool indicated by the current node does not match the input requirement of the target tool indicated by the next node, resulting in the target tool indicated by the next node being unable to execute or failing to execute.

[0167] The second item is that the relevance between the output result of the currently called target tool and the query text is higher than the set threshold.

[0168] The set threshold is a pre-set correlation threshold.

[0169] This can avoid the situation where the output results of the target tool are irrelevant to the query text, resulting in the reply information being unable to meet the user's actual query needs, thereby improving the user experience.

[0170] It should be noted that step S406 and steps S407 to S409 are two parallel implementation methods. In actual application, only one needs to be executed.

[0171] Step S406 : Using the large language model and based on the output result of the currently called target tool, continue to call the target tool indicated by the next node to process the query text to obtain reply information.

[0172] The next node is the node next to the current node in the tool call path, and the current node is the node where the target tool currently being called is located.

[0173] In the embodiment of the present disclosure, when the output result of the target tool currently called by the large language model meets the expected requirements, the target tool indicated by the next node can be called to process the query text to obtain reply information.

[0174] Therefore, only when the output results (or execution results) of the target tool indicated by each node in the tool call path meet the expected requirements corresponding to each node, the target tool indicated by the subsequent node will be called to process the query text, which can ensure the accuracy and reliability of the reply information generation.

[0175] Step S407: Determine a replacement tool from the candidate nodes based on the relationship information.

[0176] In an embodiment of the present disclosure, when the output result of the target tool currently called by the large language model does not meet the above-mentioned expected requirements, a replacement tool can be determined from multiple candidate nodes based on the relationship information between the multiple candidate tools; wherein the relationship information between the replacement tool and the currently called target tool is a parallel relationship (or replacement relationship).

[0177] Step S408: Use the replacement tool to update the current node in the tool call path.

[0178] In an embodiment of the present disclosure, a replacement tool may be used to update a current node in a tool call path; wherein the current node is a node in the tool call path where a target tool currently being called is located.

[0179] Step S409: Use the large language model to call the updated replacement tool indicated by the current node to process the query text to obtain reply information.

[0180] In an embodiment of the present disclosure, the query text may be processed by using the replacement tool indicated by the updated current node in the tool call path of the large language model re-call tool.

[0181] In the embodiment of the present disclosure, the output result of the replacement tool can also be obtained, and it can be determined whether the output result of the replacement tool meets the expected requirements for adaptation to the replacement tool. If the output result of the replacement tool meets the expected requirements for adaptation to the replacement tool, the large language model can be further used to continue calling the target tool indicated by the next node to process the query text based on the output result of the replacement tool to obtain reply information.

[0182] In any embodiment of the present disclosure, a method of using a large language model to call a replacement tool to process a query text may be, for example:

[0183] 1. Determine the cause of the abnormal output of the currently called target tool based on the output result of the currently called target tool and the expected requirements for adaptation to the currently called target tool.

[0184] For example, when the data type of the output result of the target tool does not match the data type in the input requirement of the target tool indicated by the next node, the abnormal output reason is used to indicate that the data type of the output result is incorrect.

[0185] 2. Based on the abnormal output reason, the large language model is used to call the replacement tool indicated by the updated current node to process the query text.

[0186] In this way, it is possible to guide the output of the replacement tool called by the large language model based on the cause of the abnormal output, reduce the probability that the output result of the replacement tool does not match the input requirement of the target tool indicated by the next node, and / or reduce the probability that the output result of the replacement tool is irrelevant to the query text.

[0187] As an example, the cause of the abnormal output and the output result can be written into the historical conversation accordingly, so that a large language model can be used to process the query text based on the historical conversation and call the replacement tool indicated by the updated current node.

[0188] Therefore, by guiding the output of the replacement tool called by the large language model based on both the abnormal output cause and the abnormal output result, the probability that the output result of the replacement tool does not match the input requirements of the target tool indicated by the next node can be further reduced, and / or the probability that the output result of the replacement tool is irrelevant to the query text can be further reduced.

[0189] Step S410: reply to the query text according to the reply information.

[0190] For explanation of step S410, please refer to the relevant description in any embodiment of the present disclosure, and will not be repeated here.

[0191] The text processing method of the embodiment of the present disclosure monitors the output results of each target tool, and when the output results of each target tool do not meet the corresponding expected requirements, a replacement tool is used to replace the target tool. This not only can realize immediate correction of errors and avoid the accumulation and transmission of errors, thereby ensuring the smooth progress of the task process, that is, it can ensure that the entire task process will not be interrupted due to the failure of a single tool, but also can improve the effectiveness, efficiency and success rate of text processing.

[0192] In order to clearly illustrate how any embodiment of the present disclosure uses a large language model to sequentially call the target tools indicated by the nodes in the tool call path to process the query text and obtain response information, the present disclosure also proposes a text processing method.

[0193] Figure 5 This is a flowchart of the text processing method provided in Example 5 of the present disclosure.

[0194] like Figure 5 As shown, the text processing method may include the following steps:

[0195] Step S501 : obtaining a query text, tool information of multiple candidate tools in a toolset, and relationship information between the multiple candidate tools.

[0196] For explanation of step S501, please refer to the relevant description in any embodiment of the present disclosure, and will not be repeated here.

[0197] In any embodiment of the present disclosure, after obtaining the query text, the query text may be preprocessed using a large language model.

[0198] Among them, preprocessing may include but is not limited to the following processing: deduplication processing, disambiguation processing, error correction processing (such as correction of spelling errors, grammatical errors, etc.), font conversion, font format conversion, removal of specified symbols, removal of missing sentences or filling in the blanks.

[0199] The designated symbols may include emoticons, special symbols, etc.

[0200] In this way, the query text can be cleaned and organized, improving the quality and reliability of subsequent text processing.

[0201] Step S502: Generate multiple tool call paths based on the query text, tool information and relationship information.

[0202] The i-th node in each tool calling path is used to indicate the target tool that needs to be called for the i-th time by the large language model. The target tool is determined from the candidate tools, and i is a positive integer.

[0203] Step S503 : Using the large language model, the target tools indicated by the nodes in the target tool calling path are called in sequence to process the query text.

[0204] The target tool calling path may be any one of multiple tool calling paths.

[0205] Step S504: Obtain the output result of the target tool currently called by the large language model.

[0206] Step S505 , determining whether the output result meets the expected requirements for adapting to the currently called target tool, if so, executing step S506 , if not, executing steps S507 to S509 .

[0207] It should be noted that step S506 and steps S507 to S509 are two parallel implementation methods. In actual application, only one needs to be executed.

[0208] Step S506 : Using the large language model and based on the output result of the currently called target tool, continue to call the target tool indicated by the next node to process the query text to obtain reply information.

[0209] The next node is the next node in the target tool calling path after the current node, and the current node is the node where the target tool currently being called is located.

[0210] For explanations of steps S502 to S506 , reference may be made to the relevant descriptions in any embodiment of the present disclosure, and no further details will be given here.

[0211] Step S507: stop calling the remaining nodes after the current node in the target tool calling path.

[0212] In an embodiment of the present disclosure, when the output result of the currently called target tool does not meet the expected requirements for adaptation to the currently called target tool, the calling of the remaining nodes after the current node in the target tool calling path may be stopped.

[0213] Step S508 : determining a replacement path from among the multiple tool calling paths except the target tool calling path.

[0214] In the embodiment of the present disclosure, a replacement path for replacing the target tool calling path may also be determined from other paths in the plurality of tool calling paths except the target tool calling path.

[0215] For example, a path can be randomly selected from other paths as a replacement path.

[0216] For another example, the path with the least number of nodes among other paths can be used as the replacement path.

[0217] Step S509: Use the large language model to call the target tools indicated by the nodes in the replacement path in sequence, process the query text, and obtain reply information.

[0218] In the embodiment of the present disclosure, a large language model can be used to sequentially call the target tools indicated by the nodes in the replacement path to process the query text and obtain the reply information. The implementation principle is similar to step S103 and will not be repeated here.

[0219] Step S510: reply to the query text according to the reply information.

[0220] For explanation of step S510, please refer to the relevant description in any embodiment of the present disclosure, and will not be repeated here.

[0221] The text processing method of the embodiment of the present disclosure can select an equivalent replacement path (or alternative path) when the output of a node in a path called by the large language model is abnormal. The large language model can continue to call the target tools indicated by each node in the replacement path to process the query text, which can ensure the smooth execution of the entire task process and improve the success rate and effectiveness of text processing.

[0222] It should be noted that for a known set of usable tools, effectively utilizing the relationship information between the tools in the toolset is crucial to ensuring the correctness of the tool calling sequence. At the same time, pre-arranging the tool calling sequence can reduce the number of times a large language model is used for thinking, reducing costs. Supervision of the tool's output results (or execution results) is also essential. In the event of an error in the tool execution (i.e., an abnormal output result of the tool), a mature supervision mechanism can help the system detect the cause of the error (recorded as the abnormal output cause in this disclosure) and make corrections.

[0223] In this context, the present disclosure provides a multi-round calling method for tools (such as APIs) pre-arranged based on a large language model. It utilizes the relationship information (or connection relationship) between tools and a pre-arrangement mechanism to ensure the correctness of the tool calling sequence and reduce the number of calls to the large language model. At the same time, a supervision mechanism is used to ensure the reliability of the tool output results (or execution results), providing a more effective way to combine the large language model with external tools.

[0224] That is, the large language model can complete specific tasks by invoking a series of tools, leveraging the relationship information between tools, pre-orchestration mechanisms, and supervision mechanisms to improve results. In this collaboration, the large language model provides planning and introspection capabilities, while external tools provide domain-specific knowledge. Users can communicate with the large language model using natural language. Once the user's intent is understood, the relevant tools can be used to perform the necessary tasks.

[0225] As an example, in order to overcome the problem of lack of information on the relationship between tools and lack of feedback mechanism for the output results of the tools, the present disclosure proposes the following Figure 6 Several mechanisms are shown:

[0226] 1. Tool relationship connection mechanism, or the generation mechanism of the relationship between tools.

[0227] Because traditional methods fail to utilize the relationship information (or connection relationship) between tools in a known tool set, it is difficult to ensure that the large language model fully understands how to use the tools. To solve this problem, this paper designs a tool relationship connection mechanism that divides the relationship information between tools into the following two types:

[0228] The first type is dependency: This relationship reflects the dependency between tools, where the input of one tool depends on the output of another tool.

[0229] The second type is a parallel relationship (or substitution relationship): This relationship reflects that the tools can be substituted for each other. This means that if the original tool fails to work properly, one tool can replace another.

[0230] Among them, the tool relationship connection mechanism can be described as the following formula:

[0231] T=L(t); (1)

[0232] Here, t represents the tool name and its functional description, L represents the large language model, and T represents the relationship information discovered by the tool relationship connection mechanism. Specifically, the tool names and functional descriptions of all tools in the tool set can be pre-inputted into the large language model, allowing the large language model to predict the relationship information (such as dependency and parallel relationships) between tools based on this input data.

[0233] The large language model can output relationship information between tools in a standard format, forming triples. Tool descriptions typically provide clear details about their inputs and outputs, helping the large language model predict the connections between them. Leveraging these predicted triples, pre-arrangement mechanisms can effectively overcome the hurdle of correctly ordering tools.

[0234] For example, the "XX Search" tool is often used for information retrieval. Before using the "XX Search" tool, you need to use the "Query Builder" tool to generate the relevant query text, which shows the dependency between the two tools. Similarly, when searching for a specific employee's employee information, you first need to use the "ID Query" tool to determine the employee's ID, and then you can use the ID to query the employee's information.

[0235] In these scenarios, a general large language model may face challenges in correctly arranging the calling order of tools. However, through the tool relationship connection mechanism, the large language model can easily identify the relationship information between tools, so that a pre-arrangement mechanism can be used to correctly arrange the calling order of tools based on this relationship information.

[0236] 2. Pre-arrangement mechanism.

[0237] In the tool call of the large language model, generating the correct tool call path is a major challenge. The traditional step-by-step method requires calling the large language model for reasoning multiple times in the process of forming the tool call path. In fact, once the large language model understands the user's intention and the available toolset, it can effectively plan the tool call path. In this process, it is not the step-by-step thinking that plays a role. What is crucial for the large language model is to recognize the relationship information between tools and handle situations where the tools cannot be completed. Therefore, the present disclosure combines the relationship information between tools and designs a pre-arrangement mechanism to enhance the ability of the large language model in generating tool call paths, and designs a tool replacement strategy for scenarios where the tools are invalid.

[0238] Among them, the pre-arrangement mechanism can be summarized as the following formula:

[0239] P=P(T,t,Q); (2)

[0240] Here, P represents the specific plan, t represents the tool name and function description, and Q represents the query text entered by the user. In this formula, P is the guidance provided by the large language model at each planning step, and T provides the large language model with information about the relationships between tools. Throughout the planning process, the large language model uses T to determine which tool to use next.

[0241] The pre-orchestration mechanism provides a more efficient path planning method for large language models by analyzing the dependencies and substitution relationships between tools. This mechanism considers the relationship between tool inputs and outputs, ensuring the logical coherence of the tool call path and the effectiveness of tool execution. For example, if a specific tool cannot produce the required output because it does not meet the execution conditions, the pre-orchestration mechanism can identify an equivalent replacement tool (or alternative tool) to ensure that the entire task process is not interrupted by the failure of a single tool.

[0242] The tool substitution strategy further enhances the robustness of the system, allowing the large language model to maintain task continuity in the face of uncertainty and complexity. By building a knowledge base containing replacement tools (or alternative tools) and their applicable conditions, the tool substitution strategy enables the large language model to quickly switch to the most appropriate replacement tool when the original tool fails to work properly.

[0243] The combination of a pre-orchestrated mechanism and a tool replacement strategy not only improves the efficiency of large language models in handling complex tasks, but also increases the success rate of task execution. More importantly, it provides large language models with a more flexible and dynamic tool invocation capability, enabling them to better adapt to changing application scenarios and user needs.

[0244] In summary, by deeply understanding and applying the dependencies and parallel relationships between tools, and effectively managing tool replacement and failure situations, the present disclosure can greatly improve the performance of large language models in automated and intelligent task execution, providing users with more intelligent and efficient services.

[0245] 3. Supervision mechanism, or reflection mechanism.

[0246] Although large language models demonstrate powerful language understanding capabilities, they still have limitations in tool invocation capabilities. In the present disclosure, a supervision mechanism (or reflection mechanism) is crucial to ensuring the accuracy of subsequent execution. In the supervision mechanism, the relationship information between tools provided by the tool relationship connection mechanism provides the basis for supervision (or reflection). These relationships enable the supervision mechanism (or reflection mechanism) to determine whether the output of one tool meets the needs or expected requirements of the next tool. If the result obtained by the supervision mechanism (or reflection mechanism) is "correct", this indicates that the output meets the expected requirements, and the output of the tool can be directly added to the conversation history. If the result obtained by the supervision mechanism (or reflection mechanism) is "incorrect", this indicates that the tool failed to generate the expected output, or the output did not meet the standards. In addition, the supervision mechanism (or reflection mechanism) will generate feedback for the tool's output. If the output of the supervision mechanism (or reflection mechanism) is judged to be "incorrect", it will add the feedback and the incorrect tool's output to the conversation history to guide the tool to correct the incorrect output.

[0247] By introducing a supervision mechanism (or reflection mechanism), the reliability and efficiency of large language models in automated processing can be significantly improved. By monitoring and evaluating the correctness of tool outputs in real time, errors can be corrected immediately, preventing their accumulation and propagation, thereby ensuring the smooth progress of the task flow. Furthermore, incorporating erroneous outputs and feedback into the conversation history not only facilitates immediate correction but also provides valuable learning material for future task execution, enabling large language models to learn from past errors and continuously optimize their tool invocation and task processing strategies.

[0248] It's important to note that the effective implementation of a supervisory (or reflective) mechanism relies on a deep understanding and accurate description of the relationships between tools. This encompasses not only the direct input-output relationships between tools but also more complex scenarios, such as potential compatibility issues between tools and substitution relationships under specific conditions. Therefore, establishing a comprehensive and accurate knowledge base of tool relationships is key to achieving an effective supervisory (or reflective) mechanism.

[0249] In practice, the application of supervision (or reflection) mechanisms not only significantly improves the ability of large language models to handle multi-step, multi-tool tasks, but also enhances their adaptability, enabling them to better respond to various emergencies and complex needs, providing users with more precise and personalized services. Through continuous feedback and learning, large language models can gradually improve their ability to plan tool call paths, achieving more intelligent automated processing.

[0250] In short, the supervision mechanism (or reflection mechanism) provides important support for the tool-calling capabilities of large language models, ensuring the accuracy and efficiency of task execution. Through continuous learning and optimization, large language models will demonstrate even more outstanding performance in the future, bringing more innovations and breakthroughs to the field of automation.

[0251] In summary, this disclosure proposes a method for performing multiple rounds of tool calls using a large language model. The correctness of the tool call sequence can be ensured through a tool relationship connection mechanism and a pre-arrangement mechanism, and the accuracy of the tool output results can be ensured through a supervision mechanism.

[0252] With the above Figures 1 to 6 Corresponding to the text processing method provided in the embodiment, the present disclosure also provides a text processing device. Since the text processing device provided in the embodiment of the present disclosure is consistent with the above Figures 1 to 6 The text processing method provided in the embodiment corresponds to the text processing method, so the implementation of the text processing method is also applicable to the text processing device provided in the embodiment of the present disclosure, and will not be described in detail in the embodiment of the present disclosure.

[0253] Figure 7 This is a structural diagram of the text processing device provided in Example 7 of the present disclosure.

[0254] like Figure 7 As shown, the text processing device 700 may include: an acquisition module 710 , a generation module 720 , a calling module 730 and a reply module 740 .

[0255] The acquisition module 710 is configured to acquire the query text, tool information of multiple candidate tools in the tool set, and relationship information between the multiple candidate tools.

[0256] Generation module 720 is used to generate a tool call path based on the query text, tool information and relationship information; wherein the i-th node in the tool call path is used to indicate the target tool that needs to be called for the i-th time by the large language model, and the target tool is determined from the candidate tools, and i is a positive integer.

[0257] The calling module 730 is used to use the large language model to sequentially call the target tools indicated by the nodes in the tool calling path to process the query text and obtain reply information.

[0258] The reply module 740 is used to reply to the query text according to the reply information.

[0259] In a possible implementation of the embodiment of the present disclosure, the relationship information between multiple candidate tools is determined using the following modules:

[0260] A processing module, configured to process the tool information of multiple candidate tools using a large language model to obtain structured information;

[0261] The structured information includes identification information of any two candidate tools and relationship information between any two candidate tools; the relationship information includes dependency relationship and parallel relationship.

[0262] In a possible implementation of an embodiment of the present disclosure, the tool information includes identification information and functional description information of the candidate tool; wherein the functional description information includes at least one of the following: input requirements of the candidate tool; processing procedures of the candidate tool; output requirements of the candidate tool; usage restrictions of the candidate tool; and precautions for using the candidate tool.

[0263] In one possible implementation of the embodiment of the present disclosure, a processing module is configured to: obtain a prompt template; wherein the prompt template is configured to indicate output requirements of a large language model and information about tasks to be performed; fill the prompt template with tool information of multiple candidate tools to obtain first prompt information; and process the first prompt information using the large language model to obtain structured information.

[0264] In one possible implementation of the embodiment of the present disclosure, candidate tools are determined from a tool set using the following modules:

[0265] The first recognition module is used to perform intent recognition on the query text to obtain the target intent;

[0266] The first determination module is used to determine, based on the target intent, candidate tools that match the target intent from the toolset.

[0267] In a possible implementation of the embodiment of the present disclosure, the first recognition module is used to: obtain at least one text intent pair based on the query text; wherein the text intent pair includes candidate text similar to the query text and the candidate intent to which the candidate text belongs; generate second prompt information based on the at least one text intent pair; use a large language model to perform intent recognition on the query text based on the second prompt information to obtain the target intent.

[0268] In one possible implementation of the embodiment of the present disclosure, candidate tools are determined from a tool set using the following modules:

[0269] The second recognition module is used to identify the target domain to which the query text belongs;

[0270] The second determining module is used to determine, based on the target domain, candidate tools matching the target domain from the toolset.

[0271] In a possible implementation of the embodiment of the present disclosure, the generation module 720 is used to: use a large language model to determine the target tool that needs to be called each time from multiple candidate tools based on the query text, tool information and relationship information; and generate a tool call path according to the target tool that needs to be called each time.

[0272] In a possible implementation of the embodiment of the present disclosure, the calling module 730 is used to: use the large language model to sequentially call the target tool indicated by each node in the tool calling path to process the query text; obtain the output result of the target tool currently called by the large language model; determine whether the output result meets the expected requirements for adaptation to the currently called target tool; if the output result meets the expected requirements, use the large language model based on the output result of the currently called target tool, and continue to call the target tool indicated by the next node to process the query text to obtain reply information; wherein the next node is the node next to the current node in the tool calling path, and the current node is the node where the currently called target tool is located.

[0273] In a possible implementation of the embodiment of the present disclosure, the calling module 730 is further used to: determine a replacement tool from candidate nodes based on relationship information when the output result does not meet the expected requirements; wherein the relationship information between the replacement tool and the currently called target tool is a parallel relationship; use the replacement tool to update the current node in the tool calling path; use the large language model to call the replacement tool indicated by the updated current node to process the query text to obtain reply information.

[0274] In a possible implementation of the embodiment of the present disclosure, the calling module 730 is used to: determine the abnormal output reason of the currently called target tool based on the output result and expected requirements; use a large language model to call the updated replacement tool indicated by the current node based on the abnormal output reason to process the query text.

[0275] In a possible implementation of the embodiment of the present disclosure, the calling module 730 is used to: write the abnormal output cause and the output result into the historical conversation accordingly; use the large language model based on the historical conversation to call the replacement tool indicated by the updated current node to process the query text.

[0276] In a possible implementation of the embodiment of the present disclosure, there are multiple tool call paths; the calling module 730 is further used to: stop calling the remaining nodes located after the current node in the tool call path when the output result does not meet the expected requirements; determine a replacement path from other paths in the multiple tool call paths except the tool call path; use a large language model to call the target tools indicated by the nodes in the replacement path in sequence to process the query text and obtain reply information.

[0277] In a possible implementation of an embodiment of the present disclosure, the expected requirements include at least one of the following: the output result is adapted to the input requirements of the target tool indicated by the next node located after the current node in the tool call path; the correlation between the output result and the query text is higher than a set threshold.

[0278] In a possible implementation of the embodiment of the present disclosure, the text processing apparatus 700 may further include:

[0279] A preprocessing module, used to preprocess the query text using a large language model;

[0280] Among them, the preprocessing includes at least one of the following: deduplication processing, disambiguation processing, error correction processing, font conversion, font format conversion, removal of specified symbols, removal of missing sentences or filling in the blanks.

[0281] The text processing device of the embodiment of the present disclosure pre-plans (or pre-arranges) a tool calling path before the large language model calls the tool. The large language model calls the tool based on the pre-planned tool calling path, which can ensure that the number of times the large language model is used (or called) is at least the number of nodes in the tool calling path, thereby reducing the number of times the large language model is used. That is, the calling sequence of the tools is pre-arranged, which can reduce the number of times the large language model is used for thinking, improve text processing efficiency, and reduce costs. In addition, the tool calling path is determined not only based on the query text and the tool information of each candidate tool, but also based on the relationship information between different candidate tools (such as dependency relationships and parallel relationships), which can improve the logical coherence of the tool calling path and the effectiveness of tool execution, and improve the correctness of the tool calling sequence.

[0282] In order to implement the above embodiments, the present disclosure also provides an electronic device, which may include at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the text processing method proposed in any of the above embodiments of the present disclosure.

[0283] In order to implement the above embodiments, the present disclosure further provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the text processing method proposed in any of the above embodiments of the present disclosure.

[0284] In order to implement the above embodiments, the present disclosure further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the text processing method proposed in any of the above embodiments of the present disclosure.

[0285] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0286] Figure 8 A schematic block diagram of an example electronic device that can be used to implement embodiments of the present disclosure is shown.

[0287] Among them, the electronic device may include the server and client in the above-mentioned embodiments. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0288] like Figure 8 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a ROM (Read-Only Memory) 802 or a computer program loaded from a storage unit 807 into a RAM (Random Access Memory) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An I / O (Input / Output) interface 805 is also connected to the bus 804.

[0289] Various components in device 800 are connected to I / O interface 805, including an input unit 806, such as a keyboard, mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a magnetic disk, optical disk, etc.; and a communication unit 809, such as a network card, modem, wireless communication transceiver, etc. The communication unit 809 allows device 800 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0290] The computing unit 801 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a CPU (Central Processing Unit), a GPU (Graphic Processing Unit), various specialized AI (Artificial Intelligence) computing chips, various computing units that run machine learning model algorithms, a DSP (Digital Signal Processor), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as the text processing method described above. For example, in some embodiments, the text processing method described above can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the text processing method described above can be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to execute the above text processing method in any other appropriate manner (for example, by means of firmware).

[0291] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application-Specific Standard Products), SOCs (System on Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0292] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0293] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or apparatus. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include an electrical connection based on one or more wires, a portable computer disk, a hard disk, RAM, ROM, EPROM (Electrically Programmable Read-Only-Memory) or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0294] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0295] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: LAN (Local Area Network), WAN (Wide Area Network), the Internet, and blockchain networks.

[0296] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact via a communication network. The client-server relationship is established by computer programs running on the respective computers and establishing a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, a host product within the cloud computing service ecosystem that addresses the management difficulties and poor scalability of traditional physical hosts and VPS services. The server may also be a server in a distributed system or a server integrated with blockchain.

[0297] It's important to note that artificial intelligence (AI) is the study of how computers can simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, and planning). This encompasses both hardware and software technologies. AI hardware technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, and big data processing. AI software technologies primarily encompass computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graphs.

[0298] According to the technical solution of the embodiment of the present disclosure, before the large language model calls the tool, the tool calling path is pre-planned (or pre-arranged). The large language model calls the tool based on the pre-planned tool calling path, which can ensure that the number of times the large language model is used (or called) is at least the number of nodes in the tool calling path, thereby reducing the number of times the large language model is used. That is, the calling sequence of the tools is pre-arranged, which can reduce the number of times the large language model is used for thinking, improve text processing efficiency, and reduce costs. In addition, the tool calling path is determined not only based on the query text and the tool information of each candidate tool, but also based on the relationship information between different candidate tools (such as dependency relationships and parallel relationships), which can improve the logical coherence of the tool calling path and the effectiveness of tool execution, and improve the correctness of the tool calling sequence.

[0299] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not a limitation herein.

[0300] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.

Claims

1. A text processing method, comprising: Obtaining a query text, tool information of multiple candidate tools in a toolset, and relationship information between the multiple candidate tools; Generate a tool call path based on the query text, the tool information, and the relationship information; wherein the i-th node in the tool call path is used to indicate a target tool to be called for the i-th time by the large language model, the target tool being determined from the candidate tools, and i being a positive integer; Using the large language model to sequentially call target tools indicated by nodes in the tool call path to process the query text and obtain reply information; Reply to the query text according to the reply information; The step of using the large language model to sequentially call target tools indicated by nodes in the tool call path to process the query text and obtain reply information includes: Using the large language model to sequentially call the target tools indicated by the nodes in the tool calling path to process the query text; Obtaining an output result of a target tool currently called by the large language model; Determining whether the output result meets the expected requirements for adapting to the currently called target tool, the expected requirements including whether the output result is adapted to the input requirements of the target tool indicated by the next node; In the case that the output result does not meet the expected requirement, determining a replacement tool from the candidate nodes based on the relationship information; wherein the relationship information between the replacement tool and the currently called target tool is a parallel relationship; Using the replacement tool to update the current node in the tool call path; Determining the cause of the abnormal output of the currently called target tool according to the output result and the expected requirement; The large language model is used to process the query text based on the abnormal output reason, and the replacement tool indicated by the updated current node is called to obtain the reply information.

2. The method according to claim 1, wherein The relationship information between the multiple candidate tools is determined by the following steps: Processing the tool information of the plurality of candidate tools using the large language model to obtain structured information; The structured information includes identification information of any two candidate tools and relationship information between the two candidate tools; The relationship information includes dependency relationship and parallel relationship.

3. The method according to claim 1 or 2, wherein: The tool information includes identification information and function description information of the candidate tool; The function description information includes at least one of the following: the input requirements of the candidate tool; the processing of the candidate tool; the output requirements of the candidate tool; limitations on the use of the candidate tool; Considerations for use of the candidate tool.

4. The method according to claim 2, wherein: The using the large language model to process the tool information of the plurality of candidate tools to obtain structured information includes: Obtaining a prompt template; wherein the prompt template is used to indicate the output requirements of the large language model and information about tasks to be performed; Filling the prompt template with the tool information of the plurality of candidate tools to obtain first prompt information; The first prompt information is processed using the large language model to obtain the structured information.

5. The method according to claim 1, wherein The candidate tools are identified from the toolset using the following steps: Performing intent recognition on the query text to obtain a target intent; Based on the target intent, candidate tools matching the target intent are determined from the toolset.

6. The method according to claim 5, wherein: The performing intent recognition on the query text to obtain the target intent includes: Obtain at least one text-intent pair according to the query text; wherein the text-intent pair includes a candidate text similar to the query text and a candidate intent to which the candidate text belongs; generating second prompt information according to at least one text-intent pair; The large language model is used to perform intent recognition on the query text based on the second prompt information to obtain the target intent.

7. The method according to claim 1, wherein The candidate tools are identified from the toolset using the following steps: Identifying the target domain to which the query text belongs; Based on the target domain, candidate tools matching the target domain are determined from the toolset.

8. The method according to claim 1, wherein Generating a tool calling path according to the query text, the tool information, and the relationship information includes: Using the large language model, based on the query text, the tool information, and the relationship information, sequentially determine a target tool to be called each time from the plurality of candidate tools; The tool calling path is generated according to the target tool that needs to be called each time.

9. The method according to claim 1, wherein The method further comprises: If the output result meets the expected requirement, the large language model is used to process the query text based on the output result of the currently called target tool, and the target tool indicated by the next node is continued to be called to obtain the reply information; The next node is the next node of the tool calling path after the current node, and the current node is the node where the target tool of the current call is located.

10. The method according to claim 1, wherein The using the large language model to process the query text based on the abnormal output cause and calling the updated replacement tool indicated by the current node includes: Write the abnormal output reason and the output result into the historical conversation accordingly; The large language model is used to process the query text based on the historical conversation and the replacement tool indicated by the updated current node is called.

11. The method according to claim 9, wherein There are multiple tool calling paths; After determining whether the output result meets the expected requirements for adapting to the currently called target tool, the method further includes: If the output result does not meet the expected requirement, stop calling the remaining nodes after the current node in the tool calling path; Determine a replacement path from other paths among the plurality of tool calling paths except the tool calling path; The target tools indicated by the nodes in the replacement path are called in sequence using the large language model to process the query text and obtain reply information.

12. The method according to any one of claims 9 to 11, wherein: The expected requirements also include: The relevance between the output result and the query text is higher than a set threshold.

13. The method according to claim 1, wherein After obtaining the query text, the method further includes: Preprocessing the query text using the large language model; The preprocessing includes at least one of the following: deduplication processing, disambiguation processing, error correction processing, font conversion, font format conversion, removal of specified symbols, removal of missing sentences or filling in blanks.

14. A text processing device comprising: An acquisition module, configured to acquire a query text, tool information of a plurality of candidate tools in a tool set, and relationship information between the plurality of candidate tools; a generation module, configured to generate a tool call path based on the query text, the tool information, and the relationship information; wherein the i-th node in the tool call path is used to indicate a target tool to be called for the i-th time by the large language model, the target tool being determined from the candidate tools, and i being a positive integer; a calling module, configured to use the large language model to sequentially call target tools indicated by the nodes in the tool calling path to process the query text and obtain reply information; A reply module, configured to reply to the query text according to the reply information; The calling module is used to: Using the large language model to sequentially call the target tools indicated by the nodes in the tool calling path to process the query text; Obtaining an output result of a target tool currently called by the large language model; Determining whether the output result meets the expected requirements for adapting to the currently called target tool, the expected requirements including whether the output result is adapted to the input requirements of the target tool indicated by the next node; In the case that the output result does not meet the expected requirement, determining a replacement tool from the candidate nodes based on the relationship information; wherein the relationship information between the replacement tool and the currently called target tool is a parallel relationship; Using the replacement tool to update the current node in the tool call path; Determining the cause of the abnormal output of the currently called target tool according to the output result and the expected requirement; The large language model is used to process the query text based on the abnormal output reason, and the replacement tool indicated by the updated current node is called to obtain the reply information.

15. The device according to claim 14, wherein The relationship information between the multiple candidate tools is determined using the following modules: a processing module, configured to process the tool information of the plurality of candidate tools using the large language model to obtain structured information; The structured information includes identification information of any two candidate tools and relationship information between the two candidate tools; The relationship information includes dependency relationship and parallel relationship.

16. The device according to claim 14 or 15, wherein The tool information includes identification information and function description information of the candidate tool; The function description information includes at least one of the following: the input requirements of the candidate tool; the processing of the candidate tool; the output requirements of the candidate tool; limitations on the use of the candidate tool; Considerations for use of the candidate tool.

17. The device according to claim 15, wherein The processing module is used to: Obtaining a prompt template; wherein the prompt template is used to indicate the output requirements of the large language model and information about tasks to be performed; Filling the prompt template with the tool information of the plurality of candidate tools to obtain first prompt information; The first prompt information is processed using the large language model to obtain the structured information.

18. The device according to claim 14, wherein The candidate tools are identified from the toolset using the following modules: A first recognition module is used to perform intent recognition on the query text to obtain a target intent; The first determination module is configured to determine, based on the target intent, candidate tools matching the target intent from the toolset.

19. The device according to claim 18, wherein The first identification module is configured to: Obtain at least one text-intent pair according to the query text; wherein the text-intent pair includes a candidate text similar to the query text and a candidate intent to which the candidate text belongs; generating second prompt information according to at least one text-intent pair; The large language model is used to perform intent recognition on the query text based on the second prompt information to obtain the target intent.

20. The apparatus according to claim 14, wherein The candidate tools are identified from the toolset using the following modules: A second recognition module is used to identify the target domain to which the query text belongs; The second determining module is configured to determine, based on the target domain, candidate tools matching the target domain from the toolset.

21. The apparatus according to claim 14, wherein The generating module is used to: Using the large language model, based on the query text, the tool information, and the relationship information, sequentially determine a target tool to be called each time from the plurality of candidate tools; The tool calling path is generated according to the target tool that needs to be called each time.

22. The apparatus according to claim 14, wherein The calling module is further used to: If the output result meets the expected requirement, the large language model is used to process the query text based on the output result of the currently called target tool, and the target tool indicated by the next node is continued to be called to obtain the reply information; The next node is the next node of the tool calling path after the current node, and the current node is the node where the target tool of the current call is located.

23. The apparatus according to claim 14, wherein The calling module is used to: Write the abnormal output reason and the output result into the historical conversation accordingly; The large language model is used to process the query text based on the historical conversation and the replacement tool indicated by the updated current node is called.

24. The apparatus according to claim 22, wherein There are multiple tool calling paths; The calling module is further used to: If the output result does not meet the expected requirement, stop calling the remaining nodes after the current node in the tool calling path; Determine a replacement path from other paths among the plurality of tool calling paths except the tool calling path; The target tools indicated by the nodes in the replacement path are called in sequence using the large language model to process the query text and obtain reply information.

25. The device according to any one of claims 22 to 24, wherein The expected requirements also include: The relevance between the output result and the query text is higher than a set threshold.

26. The apparatus according to claim 14, wherein The device further comprises: A preprocessing module, configured to preprocess the query text using the large language model; The preprocessing includes at least one of the following: deduplication processing, disambiguation processing, error correction processing, font conversion, font format conversion, removal of specified symbols, removal of missing sentences or filling in blanks.

27. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to perform the text processing method according to any one of claims 1 to 13.

28. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to enable the computer to execute the text processing method according to any one of claims 1 to 13.

29. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the steps of the text processing method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • API relation reasoning method and system based on large pre-training language model

    CN116776981A

  • Heating and ventilation system data processing method, device and equipment based on large language model

    CN117235223A

  • Large model-based intention recognition method and device, electronic equipment and storage medium

    CN117688946A

  • Automatic application program interface (API) selector for unsupervised natural language processing (NLP) intent classification

    US20210089375A1