Automatic task execution method and device fusing large language model and finite-state machine
By integrating large language models and finite state machines, combined with natural language instructions and multi-round dialogue memory, it solves the shortcomings of RPA robots in scene adaptation and large task processing, achieving more efficient human-computer interaction and automatic task execution.
Patent Information
- Application Number
- CN202410491215.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-23
- Publication Date
- 2024-08-23
AI Technical Summary
Existing RPA robots have deficiencies in scene adaptation, exception handling, and process expansion. AI based on large language models is difficult to provide accurate and interpretable results in complex tasks, and single-round dialogue voice assistants cannot handle large tasks.
Integrating large language models and finite state machines, through scene analysis of natural language instructions, keyword extraction and multi-round dialogue memory, assembling entry parameter messages, cyclically executing finite state machine tasks, using API mode to achieve automatic task execution, and in the absence of Re-ask the user for data or instructions.
It improves the interactive experience and stability of large-scale automatic task execution systems, solves complex task processing problems, achieves better human-computer interaction, and enhances the efficiency, unity, and interactive experience of the system.
Smart Images

Figure CN118535251A
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of process management and quality management in software development, and in particular to an automatic task execution method and device integrating a large language model and a finite state machine. Background Art
[0002] Computer systems or software systems all belong to the category of automatic task execution systems, and their cores are all extremely large finite state machine systems. The fundamental function of programs and functions is to realize parameter processing and conversion, and to convert a bunch of parameters into another bunch of parameters through calculation. In order to simplify the construction of computing system functions, many low-code tools such as RPA robots (Robotic Process Automation) have emerged to assist in completing various functions. In addition, in terms of natural language processing, question-and-answer or auxiliary operating systems based on natural language processing, such as Xiao Ai, Siri, and ChatGPT, are all task execution systems based on natural language question-and-answer.
[0003] RPA robot is a productivity tool that allows users to configure one or more scripts, which are often called robots, and can simulate specific operations or entire businesses. This preset state machine model and the expected specific input and output methods that comply with the rules constitute the entire structure of the PRA robot. The established judgment and process relationship is the performance of the state machine model on the RPA robot. The significant advantage of the RPA robot is that it uses low-code framework development to achieve task universalization. But this is also its biggest disadvantage. Under the multi-scenario conditions of the old system, because it needs to encapsulate the original system with an RPA robot, and use the API interface structure and message exclusive to the RPA robot to embed the API interface of the original system, it requires various adaptation work. This also leads to poor scene adaptation, poor exception handling, and poor process expansion of the RPA robot. This also makes it difficult to integrate the natural language quick interaction into the RPA robot compared to integrating the original system.
[0004] At the same time, because low-code development belongs to a completely different development language or a unique way of expression belonging to RPA, its learning cost is high, and the entry interface requires proficiency in operation to master various functions. At the same time, due to various problems such as encapsulation, functional non-freedom, and freedom, its various costs are too high.
[0005] For example, multi-round conversation AI language models such as ChatGPT3.5 and Wenxinyiyan can complete contextual communication and answer questions raised by users. They can also complete specific tasks such as text classification, logical reasoning, text information extraction, mathematical reasoning, etc. in multi-round conversations according to instructions. Voice assistant solutions such as Xiaoai classmate Siri briefly parse user instructions in a single round of conversation, extract the corresponding data, convert the data format into the input parameters required to execute the Agent, and then interact with software or hardware through the Agent.
[0006] However, large language models based on probability models, such as ChatGPT, have unstable outputs based on probability, and their results contain a lot of phantom writing and unconventional expressions caused by probability bias. Usually, they cannot directly complete professional tasks and can only generate content such as text and pictures that lack quantitative subjective evaluation. They cannot generate accurate, explainable, and robust results.
[0007] The main problem with voice assistant solutions such as Xiao Ai and Siri is that they cannot currently solve large-scale tasks. There are two main reasons for this. First, there is no automatic task execution system built in the background to perform large-scale tasks. Second, large-scale tasks often require more data resources and a better understanding of user intentions, but a single round of user dialogue often cannot provide sufficient data resources, and traditional solutions do not have the ability to communicate with users over multiple rounds to confirm intentions, or to remind users to supplement data resources. Summary of the invention
[0008] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide an automatic task execution method and device integrating a large language model and a finite state machine.
[0009] The purpose of the present invention can be achieved by the following technical solutions:
[0010] As a first aspect of the present application, there is provided an automatic task execution method integrating a large language model and a finite state machine, the steps comprising:
[0011] Get natural language instructions;
[0012] Perform scenario analysis on natural language instructions through the first language model to obtain the process nodes corresponding to the natural language instructions in the finite state machine model;
[0013] Based on the results of the scenario analysis, the second language model is used to extract relevant keywords for the scenario in the multi-round dialogue memory data according to the input parameter message requirements;
[0014] Assemble the extracted keyword information into an entry parameter message corresponding to an existing function, and output a single-step automatic task execution;
[0015] The finite state machine task execution unit that works in a cyclic API mode obtains the automatic task execution result and automatically executes it according to the finite state machine pipeline.
[0016] As a preferred technical solution, the task execution unit includes an analysis engine of a finite state machine model, an automatic execution engine, an execution process recording engine, an entry adapter and an exit adapter.
[0017] As a preferred technical solution, the analysis engine is used to judge the state and conditions, and is composed of a corresponding finite state machine model database, which is composed of a quaternary group of many states, conditions, data operation functions and the next state;
[0018] The automatic execution engine is a data operation function, which is an accessible API interface composed of functional interfaces, takes given data as input parameters, and then returns the content after the relevant operation;
[0019] The execution process recording engine records the execution results during the automatic execution process and converts them into natural language or vector expressions, which are used to guide the large language model to complete scene analysis and information extraction tasks together with the user's natural language instructions in multiple rounds of dialogue;
[0020] The entry adapter is used to assemble entry messages for the API interfaces provided by the background management system in different scenes and steps, so that the content extracted by the large language model enters the entry adapter with the same standard. The entry adapter matches the content with the API of the corresponding scene and step through assembly and adaptation;
[0021] The export adapter is used to organize the return messages of the API in different scenarios and steps, remove invalid content, save valid field data to the parameter set during the finite state machine model link process, and assemble it into the form required by the foreground interactive interface at the end of the finite state machine model link.
[0022] As a preferred technical solution, the finite state machine model analyzes user instructions in real time during operation, and when there is a lack of data resources or further instructions, fills in the inquiry information according to a preset specific template and re-asks the user to obtain the data or further instructions filled in by the user.
[0023] As a preferred technical solution, when the task execution unit lacks data resources or further instructions, it re-asks the user for commands, as follows:
[0024] Send natural language queries after language beautification through a large language model;
[0025] Receive natural language responses from users;
[0026] Combined with historical records, the first language model is used to perform scenario analysis on the natural language instructions replied by the user;
[0027] Based on the user's instructions, the finite state machine enters the corresponding next state;
[0028] The second largest language model is used to extract the required scene-related information from the multi-round dialogue memory;
[0029] Assembling the extracted information into an entry parameter message corresponding to an existing function;
[0030] The task execution unit enters the next processing node.
[0031] As a preferred technical solution, the method in multiple rounds of question and answer:
[0032] In the process of performing scenario analysis on the natural language instruction by the first language model, the first language model generates prompt words for serving the second language model to extract required information based on the record of historical interactions and the execution process record engine;
[0033] In the process of extracting the required scene-related information from the multi-round dialogue memory through the second largest language model, the entry parameters are generated in combination with the long-term memory of the large language model.
[0034] As an optimal technical solution, the finite state model adopts a construction solution based on parameter transformation and state transformation, and adopts incremental construction. During the construction process, it only needs to declare the state, conditions and execution functions. Based on the state sample library and the execution function sample library, the state is recorded through the finite state machine model, and the corresponding execution function records the parameter conversion solution, thereby realizing the construction.
[0035] As a preferred technical solution, the first largest language model and the second largest language model are:
[0036] A general large language model is adopted, which is trained after fine-tuning and prompt word engineering on different data sets to form the first large language model for scene analysis and designation of the full finite state machine scene set and the second large language model for information extraction in the corresponding scenes and steps.
[0037] As a second aspect of the present application, there is provided an automatic task execution device integrating a large language model and a finite state machine, comprising:
[0038] one or more processors;
[0039] A memory for storing one or more programs;
[0040] When the one or more programs are executed by the one or more processors, the one or more processors implement the automatic task execution method integrating the large language model and the finite state machine as described in the previous item.
[0041] As a third aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the automatic task execution method integrating a large language model and a finite state machine as described in any one of the above items are implemented.
[0042] Compared with the prior art, the present invention has the following beneficial effects:
[0043] 1) The main goal of the present invention is to integrate the large language model with the traditional large-scale automatic task execution system, and to use the four capabilities of the large language model, namely, scene analysis, keyword extraction, model memory, and language beautification, to empower the interactive experience of the traditional large-scale automatic task execution system based on a finite state machine. The automatic task execution system can solve complex problems and output stable and explainable results to enable the large language AI model to solve more problems "logically". The integration solution of the large model and the finite state machine proposed in the present invention takes the best of both methods. Finite state machines are used to solve the problem that large language models are difficult to handle complex tasks, and large language models are used to achieve better human-computer interaction.
[0044] 2) The present invention can integrate almost all systems with software data objects with clear states. The more states of data objects, the more complex the processing and jump, and the more obvious the advantages of the present invention. In most complex scenarios, especially non-single system real-time tasks that need to wait for a large number of background systems to process, it is a very necessary function to store the state and keep it active during the period to accept user instructions.
[0045] 3) Due to the existence of the scene analysis model, the present invention can make the large language AI model a unified entrance for human-computer interaction operations, thereby realizing the unified integration of any number of related systems and unifying the human-computer interaction logic, thereby greatly increasing efficiency, unity, stability and interactive experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a flow chart of the automatic task execution method integrating a large language model and a finite state machine of the present invention;
[0047] Figure 2 A complete flow chart of multiple rounds of operation of the automatic task execution method integrating a large language model and a finite state machine according to the present invention;
[0048] Figure 3 The flowchart is one of the implementation examples of the automatic task execution method integrating a large language model and a finite state machine of the present invention. DETAILED DESCRIPTION
[0049] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0050] Example 1
[0051] The present invention proposes a method for integrating a large language model with a finite state machine. The integration scheme of the large model and the finite state machine proposed by the present invention takes the advantages of both methods. The finite state machine is used to solve the problem that the large language model is difficult to handle complex tasks, and the large language model is used to achieve better human-computer interaction. It realizes more accurate scene recognition and positioning and realizes related automatic tasks.
[0052] like Figure 1 The schematic diagram of the general process of the method of the present invention is shown as follows: first, the natural language instruction input by the user is obtained; the natural language instruction is analyzed by the first language model to obtain the process node corresponding to the natural language instruction in the finite state machine model, that is, the state of the finite state machine; based on the scene analysis results, the second language model is used to extract relevant keywords for the scene in the multi-round dialogue memory data according to the entry parameter message needs, that is, the conditions and data of the finite state machine; the scene analysis and keyword extraction results are assembled into the entry parameter message corresponding to the existing function, and the single-step automatic task execution is output; the finite state machine task execution unit working in the API mode in a cycle obtains the automatic task execution result, and automatically executes according to the finite state machine pipeline. Among them, in the multi-round question and answer, the first language model is used to record the historical interaction and the prompt words generated by the execution process recording engine, so that the large model can better understand the additional derivative steps generated when the task is "rolled back" due to the risk control factors of software development process management and quality management in the multi-round dialogue, so that the instruction input can select a more correct node in the scene analysis. After keyword extraction in the second largest language model, the processing combined with the long-term memory of the large language model, such as the entry adapter, is finally converted into the entry parameters of the execution unit.
[0053] The finite state model of the present invention realizes a fast construction scheme based on parameter conversion and state conversion when incrementally building. The finite state machine model records the state, and the corresponding execution function records the parameter conversion scheme. In the case of a sufficiently large state sample library and execution function sample library, fast construction is achieved. The construction process only needs to declare the state, condition, and execution function.
[0054] The present invention innovatively integrates the large language model and automatic task execution in the system operation scheme, and uses the scene analysis and keyword extraction capabilities of the large language model to realize the analysis of natural language instructions. Determine the software development control process node (scene analysis) corresponding to the natural language instruction in the finite state machine model, and then extract the required information related to the scene and subsequent scenes in the multi-round dialogue memory (information extraction), and then output the automatic task execution to assemble the corresponding information into an entry message corresponding to the existing function, obtain the result through the execution tool of the stable API mode, and automatically execute according to the finite state machine pipeline. When there is a lack of resources or instructions, fill in the query information according to the preset specific template, and re-question the user to obtain the data filled by the user or further instructions.
[0055] The large language model mentioned in the present invention adopts a general large language model, which is trained after fine-tuning different data sets and prompt word engineering to perform scene analysis and specification in the full set of finite state machine scenes and information extraction in corresponding scenes and steps. The data set and related prompt words used in the present invention to train the large language model, as well as the related training methods and prompt word organization methods, do not belong to the content of this patent.
[0056] The present invention does not involve a specific finite state machine model and related scenarios. The necessity of using a finite state machine model in this invention is reflected in the need to analyze user instructions in real time during operation, or to directly ask the user when instructions are missing. Although the execution plan of the task is based on a fully automatic streaming process in most cases, and there is no node waiting for condition updates, the finite state machine model is indispensable.
[0057] The finite state machine processing node mentioned in the present invention corresponds to a task execution unit composed of five main parts: an analysis engine of a finite state machine model, an automatic execution engine, an execution process recording engine, an entry adapter, and an exit adapter. It is the main occurrence unit of automatic task execution.
[0058] The finite state machine model analysis engine refers to the judgment of the state and condition of the basic finite state model. It is composed of the corresponding finite state machine model database, which consists of a number of states, conditions, data operation functions, and four tuples of the next state.
[0059] The automatic execution engine refers to the data operation function, but its essence is an accessible API interface composed of functional interfaces. It takes the specified data as input parameters and then returns the content after the relevant operation.
[0060] The execution process recording engine records the execution results during the automatic execution process and converts them into natural language expressions. In multiple rounds of conversations, it guides the large language model together with the user's natural language instructions to complete scene analysis and information extraction tasks.
[0061] The purpose of the entry adapter is to assemble entry messages for the API interfaces provided by the background management system in different scenarios and steps, so that the content extracted by the large language model through information can enter the entry adapter with the same standard. The entry adapter assembles and adapts the content to match the API of the corresponding scenario and step.
[0062] The export adapter organizes the return messages of the API in different scenarios and steps, removes invalid content, saves valid field data to the parameter set during the finite state machine model link process, and assembles it into the form required by the front-end interactive interface at the end of the finite state machine model link.
[0063] like Figure 2 As shown, the above-mentioned automatic task execution method integrating the large language model and the finite state machine specifically processes each processing node, especially when the data resources are lacking or the user commands are asked again when further instructions are needed, and the specific process is as follows:
[0064] The finite state machine processing node obtains the data processing result;
[0065] Under normal circumstances, the configured linear process continues to execute to obtain new conditions and data of the finite state machine;
[0066] When the user is asked again for commands due to lack of data resources or further instructions, the large language model is first used to beautify the language and then send natural language to ask the user again for commands; after receiving the natural language reply from the user, the execution history and the execution process record engine are used to generate prompt words for the second language model to extract the required information for the natural language reply from the user, and the scene analysis is performed through the first language model, and the finite state machine enters the corresponding next state according to the user's instructions; the second language model is used to extract keywords, and then the entry parameters, i.e., the new conditions and data of the finite state machine, are generated in combination with the long-term memory function of the large language model;
[0067] Based on the new conditions and data of the finite state machine, the finite state machine enters the next processing node.
[0068] Example 2
[0069] In this embodiment, a case of software development quality control is provided, and the common situation in the above method flow chart is described in detail through the case. Figure 3 As shown:
[0070] Get Material 1: Natural language instruction: "Promote the testing of the ABCD system's production code this week";
[0071] System step 1: Perform scenario analysis through the first language model.
[0072] Get material 2: Work scenario: "Code testing";
[0073] System step 2: {version, test tool}, and the subsequent scenario {release date, operator}. After analysis, {release date, operator} can be obtained through another scenario A through step B by inputting {system, code version}, so it is not required.
[0074] System step 3: Prompt library generated by the engine based on the historical interaction records and execution process records;
[0075] Material 4: Prompt words for the fields {system, code version, test tool} obtained from natural language sequences.
[0076] System steps System 4: The second largest language model performs information extraction: (using material 1 and material 4);
[0077] Material 5: {ABCD, production version-123, full test before launch};
[0078] System step 5: Entry configurator to which the step scenario belongs: test scenario.
[0079] Material 6: Multiple APIs corresponding to different test requirement fields are packaged and different interface address lookup tables are used: {ABCD, production version-123, test 1, test related fields}, {ABCD, production version-123, test 2, test related fields}, {ABCD, production version-123, test related fields};
[0080] System step 6: Automatic execution engine: push the corresponding API to the corresponding interface to obtain the return value.
[0081] Material 7: Return message {success}{success}{success};
[0082] System step 7: Export configurator: Add scene A to the work sequence via step B, update the state machine node status, and add the next node to the work sequence. (Cooperate with the background management system to push related tasks).
[0083] Material 8: Full field library {ABCD, production version-123, full test before launch};
[0084] Repeat system steps 5-7 in different scenarios and steps until the message is completed.
[0085] Example 3
[0086] As a second aspect of the present invention, the present application also provides an electronic device, comprising: one or more processors; a memory for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the automatic task execution method integrating the large language model and the finite state machine as described above. In addition to the above-mentioned processor, memory and interface, any device with data processing capability in which the device in the embodiment is located may also include other hardware according to the actual function of the device with data processing capability, which will not be described in detail.
[0087] Example 4
[0088] As a third aspect of the present invention, the present application also provides a computer-readable storage medium on which computer instructions are stored, and when the instructions are executed by the processor, the automatic task execution method of integrating the large language model and the finite state machine as described above is implemented. The computer-readable storage medium can be an internal storage unit of any device with data processing capabilities described in any of the aforementioned embodiments, such as a hard disk or a memory. The computer-readable storage medium can also be an external storage device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), an SD card, a flash card (Flash Card), etc. equipped on the device. Further, the computer-readable storage medium can also include both an internal storage unit of any device with data processing capabilities and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by any device with data processing capabilities, and can also be used to temporarily store data that has been output or is to be output.
[0089] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. An automatic task execution method integrating large language model and finite state machine, It is characterized in that the steps include: Get natural language instructions; Perform scenario analysis on natural language instructions through the first language model to obtain the process nodes corresponding to the natural language instructions in the finite state machine model; Based on the results of the scenario analysis, the second largest language model is used to extract relevant keywords from the multi-round dialogue memory data according to the input parameter message needs; Assemble the extracted keyword information into an entry parameter message corresponding to an existing function, and output a single-step automatic task execution; The finite state machine task execution unit that works in a cyclic API mode obtains the automatic task execution result and automatically executes it according to the finite state machine pipeline.
2. According to claim 1, an automatic task execution method integrating a large language model and a finite state machine, It is characterized in that The task execution unit includes an analysis engine of a finite state machine model, an automatic execution engine, an execution process recording engine, an entry adapter and an exit adapter.
3. The automatic task execution method integrating a large language model and a finite state machine according to claim 2, It is characterized in that The analysis engine is used to judge the state and conditions, and is composed of a corresponding finite state machine model database, which is composed of a quaternary group of many states, conditions, data operation functions and the next state; The automatic execution engine is a data operation function, which is an accessible API interface composed of functional interfaces, takes given data as input parameters, and then returns the content after the relevant operation; The execution process recording engine records the execution results during the automatic execution process and converts them into natural language or vector expressions, which are used to guide the large language model to complete scene analysis and information extraction tasks together with the user's natural language instructions in multiple rounds of dialogue; The entry adapter is used to assemble entry messages for the API interfaces provided by the background management system in different scenes and steps, so that the content extracted by the large language model enters the entry adapter with the same standard. The entry adapter matches the content with the API of the corresponding scene and step through assembly and adaptation; The export adapter is used to organize the return messages of the API in different scenarios and steps, remove invalid content, save valid field data to the parameter set during the finite state machine model link process, and assemble it into the form required by the foreground interactive interface at the end of the finite state machine model link.
4. The automatic task execution method integrating a large language model and a finite state machine according to claim 3, It is characterized in that The finite state machine model analyzes user instructions in real time during operation, and when data resources or further instructions are missing, fills in inquiry information according to a preset specific template and re-asks the user to obtain the data or further instructions filled in by the user.
5. The automatic task execution method integrating a large language model and a finite state machine according to claim 4, It is characterized in that When the task execution unit lacks data resources or further instructions, it will re-ask the user for commands, as follows: Send natural language queries after language beautification through a large language model; Receive natural language responses from users; Combined with historical records, the first language model is used to perform scenario analysis on the natural language instructions replied by the user; Based on the user's instructions, the finite state machine enters the corresponding next state; The second largest language model is used to extract the required scene-related information from the multi-round dialogue memory; Assembling the extracted information into an entry parameter message corresponding to an existing function; The task execution unit enters the next processing node.
6. The automatic task execution method integrating a large language model and a finite state machine according to claim 5, It is characterized in that The method is in multiple rounds of question answering: In the process of performing scenario analysis on the natural language instruction by the first language model, the first language model generates prompt words for the second language model to extract required information based on the historical interaction record and the execution process record engine; In the process of extracting the required scene-related information from the multi-round dialogue memory through the second largest language model, the entry parameters are generated in combination with the long-term memory of the large language model.
7. The automatic task execution method integrating a large language model and a finite state machine according to claim 1, It is characterized in that The finite state model adopts a construction scheme based on parameter transformation and state transformation, and adopts incremental construction. During the construction process, it only needs to declare the state, conditions and execution functions. Based on the state sample library and the execution function sample library, the state is recorded through the finite state machine model, and the corresponding execution function records the parameter conversion scheme, thereby realizing the construction.
8. The automatic task execution method integrating a large language model and a finite state machine according to claim 1, It is characterized in that The first largest language model and the second largest language model are: A general large language model is adopted, which is trained after fine-tuning and prompt word engineering on different data sets to form the first large language model for scene analysis and designation of the full finite state machine scene set and the second large language model for information extraction in the corresponding scenes and steps.
9. An automatic task execution device integrating a large language model and a finite state machine, It is characterized in that include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the automatic task execution method integrating a large language model and a finite state machine as described in any one of claims 1 to 8.
10. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the steps of the automatic task execution method integrating a large language model and a finite state machine as described in any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Network protocol specification automatic extraction method based on large language model
CN119583663A
Three-dimensional scene logic skeleton generation method and device, electronic equipment and medium
CN121600226A
