Task processing method and device
By converting task requests into task graphs and using the graph engine to execute task nodes, the complex problem of thread pool management is solved, and the task processing efficiency and response speed of large-scale model applications are improved.
Patent Information
- Application Number
- CN202510446912.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-09
- Publication Date
- 2025-07-11
AI Technical Summary
In the prior art, when parallel processing of user requests for large-model applications is performed through thread pools, the management is complex, resulting in waste of resources or occupancy, and reducing task processing efficiency.
Convert task requests into task graphs, use the graph engine to execute task nodes in the task graph, and avoid the management complexity of thread pool through the parallel processing capabilities of the graph engine.
It improves task processing efficiency, reduces task response time, simplifies thread pool management, and achieves clearer and more efficient task scheduling.
Smart Images

Figure CN120295734A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of artificial intelligence technology, and in particular, to a task processing method and an electronic device. Background Art
[0002] With the development of artificial intelligence technology, more and more users conduct various network activities through large model applications. How to efficiently process user requests for large model applications has become the focus of attention.
[0003] In related technical solutions, a thread pool is used to parallelize multiple tasks corresponding to user requests for large model applications. Taking the food delivery Agent in a large model application as an example, a food delivery query request initiated by a user usually involves multiple food item queries. The thread pool is used to parallelize multiple food item queries. For example, the query task corresponding to each food item is submitted to the thread pool, and the parallel processing ability of the thread pool is used to execute multiple food item query tasks simultaneously. However, in this technical solution, the management of the thread pool is relatively complex. For example, it is necessary to manually control the resources of the thread pool reasonably, otherwise it will cause waste of system resources or high resource occupancy, which will reduce the task processing efficiency.
[0004] The content in the background art section is only information known to the inventor personally, and does not represent that the above information has entered the public domain before the filing date of this specification, nor does it represent that it can become the prior art of this specification. Summary of the Invention
[0005] This specification provides a task processing method and an electronic device, which can use a graph engine to parallelize the execution of multiple tasks corresponding to large model applications, avoid the problem of complex thread pool management, improve the task processing efficiency, and reduce the task response time.
[0006] In a first aspect, this specification provides a task processing method, including:
[0007] In response to a task request for a large model application, determining multiple tasks corresponding to the task request, where the task includes at least one task operation, and the task operation includes calling an external interface of the large model application;
[0008] Converting the multiple tasks into a task graph, where the task graph includes multiple task nodes, and the task nodes represent the task operations corresponding to the tasks; and
[0009] Executing the task operations corresponding to each of the task nodes in the task graph through a graph engine.
[0010] In some example embodiments, based on the above solution, the task request corresponds to a plurality of task data elements, and the task data elements are data elements related to the task determined based on the task request. The converting the plurality of tasks into a task graph includes:
[0011] Determining at least one task operation corresponding to the task based on the task data element; and
[0012] Generating the task graph in a graph data format based on the task operations corresponding to each of the tasks, wherein each task operation corresponds to one task node.
[0013] In some example embodiments, based on the above solution, the determining at least one task operation corresponding to the task based on the task data element includes:
[0014] Generating task processing code corresponding to the task based on the task data element, where the task processing code is used to call at least one task operation corresponding to the task and obtain a task processing result;
[0015] Generating multi-task processing result code corresponding to the plurality of tasks based on the task processing results corresponding to each of the task processing codes, where the multi-task processing result code is used to summarize each of the task processing results,
[0016] The generating the task graph in a graph data format based on the task operations corresponding to each of the tasks includes:
[0017] Generating the task graph in a graph data format based on the task processing code and the multi-task processing result code.
[0018] In some example embodiments, based on the above solution, the task processing code includes a task call code and a result parsing code. The task call code is used to call a task operation corresponding to the task, and the result parsing code is used to parse the call result of the task call code. The generating multi-task processing result code corresponding to the plurality of tasks based on the task processing results corresponding to each of the task processing codes includes:
[0019] Generating multi-task processing result code corresponding to the plurality of tasks based on the parsing results corresponding to each of the result parsing codes.
[0020] In some example embodiments, based on the above solution, the generating the task graph in a graph data format based on the task processing code and the multi-task processing result code includes:
[0021] Convert each of the task processing codes and the multi-task processing result codes into task nodes of the task graph; and
[0022] Generate the dependency relationships between the task nodes in the task graph based on the dependency relationships between the tasks.
[0023] In some example embodiments, based on the above solution, the responding to a task request for a large model application and determining a plurality of tasks corresponding to the task request includes:
[0024] Respond to a task request for a large model application and determine a plurality of task data elements corresponding to the task request; and
[0025] Based on the plurality of task data elements, determine a plurality of tasks corresponding to the task request, where each task corresponds to at least one of the task operations.
[0026] In some example embodiments, based on the above solution, the responding to a task request for a large model application and determining a plurality of task data elements corresponding to the task request includes:
[0027] Respond to the task request for the large model application and determine the task intent corresponding to the task request and a plurality of task data elements corresponding to the task intent,
[0028] The determining a plurality of tasks corresponding to the task request based on the plurality of task data elements includes:
[0029] Based on the task intent and the plurality of task data elements, determine a plurality of tasks corresponding to the task request.
[0030] In some example embodiments, based on the above solution, the method further includes:
[0031] Perform dynamic data mapping on the data elements corresponding to the task nodes to generate unique identifiers for the data elements, where the data elements include the task data elements and the task result elements corresponding to the task data elements.
[0032] In some example embodiments, based on the above solution, the performing dynamic data mapping on the data elements corresponding to the task nodes to generate unique identifiers for the data elements includes:
[0033] Generate a unique index value for the data elements corresponding to the task nodes, and add the unique index value to the element name of the data elements.
[0034] In some example embodiments, based on the above solution, the task graph further includes the dependency relationships between the respective task nodes, and executing the task operations corresponding to the respective task nodes in the task graph through the graph engine includes:
[0035] Based on the dependency relationships between the respective task nodes, executing the task operations corresponding to the respective task nodes in the task graph through the graph engine.
[0036] In some example embodiments, based on the above solution, the executing the task operations corresponding to the respective task nodes in the task graph based on the dependency relationships between the respective task nodes includes:
[0037] Dividing the task graph into multiple parallel task nodes based on the dependency relationships between the respective task nodes;
[0038] Parallelly executing the task operations corresponding to the respective parallel task nodes through the graph engine.
[0039] In some example embodiments, based on the above solution, the executing the task operations corresponding to the respective task nodes in the task graph through the graph engine includes:
[0040] Dynamically adjusting the execution plans of the respective task nodes according to the resource requirements of the respective task nodes;
[0041] Based on the execution plans, executing the task operations corresponding to the respective task nodes in the task graph through the graph engine.
[0042] In some example embodiments, based on the above solution, the method further includes:
[0043] Obtaining the task processing results corresponding to the task operations of the respective tasks;
[0044] Storing the task processing results of the tasks in the contexts corresponding to the tasks in the graph engine.
[0045] In a second aspect, this specification further provides an electronic device, including: at least one storage medium storing at least one instruction set for task processing; and at least one processor communicatively connected to the at least one storage medium, wherein when the electronic device runs, the at least one processor reads the at least one instruction set and executes the task processing method described in the first aspect of this specification according to the instructions of the at least one instruction set.
[0046] As can be seen from the above technical solutions, for the task processing method and device provided in the embodiments of this specification, on the one hand, multiple tasks corresponding to a task request for a large model application are converted into a task graph. The task graph includes multiple task nodes, and a task node represents a task operation corresponding to the task. The task operation includes calling an external interface of the large model application, and it can convert multiple tasks into graph task nodes that can be executed in parallel by a graph engine. Due to the structural characteristics of the graph, the relationships and execution orders of the task nodes in the task graph become clear, and the scheduling of tasks becomes clearer and more efficient. Therefore, there is no need for manual explicit management of the threads and resource allocation of the thread pool. On the other hand, by executing the task operations corresponding to each task node in the task graph through the graph engine, since the graph engine has the ability of parallel processing, it can use the graph engine to execute multiple tasks corresponding to the task request in parallel, avoiding the problem of complex thread pool management, thereby improving the task processing efficiency of the large model application and reducing the task response time.
[0047] Other functions of the task processing method and device provided in this specification will be partially listed in the following description. According to the description, the content introduced by the following numbers and examples will be obvious to those of ordinary skill in the art. The creative aspects of the task processing method and device provided in this specification can be fully explained through practice or by using the methods, devices, and combinations described in the detailed examples below. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of this specification, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of this specification. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0049] Figure 1 FIG. shows a schematic diagram of an implementation environment of a task processing method provided in an embodiment of this specification;
[0050] Figure 2 FIG. shows a hardware structure diagram of an electronic device 200 provided in an embodiment of this specification;
[0051] Figure 3 FIG. shows a flowchart of a task processing method provided in some embodiments of this specification;
[0052] Figure 4 FIG. shows a schematic diagram of a human - machine interaction interface of a large model application provided in some embodiments of this specification;
[0053] Figure 5 FIG. shows a schematic diagram of a task graph provided in some embodiments of this specification;
[0054] Figure 6 shows a schematic diagram of a task graph provided according to some other embodiments of the present specification; and
[0055] Figure 7 shows a schematic flowchart of a task processing method provided according to some other embodiments of the present specification. Detailed implementation manners
[0056] The following description provides specific application scenarios and requirements of the present specification, aiming to enable those skilled in the art to manufacture and use the content in the present specification. For those skilled in the art, various partial modifications to the disclosed embodiments are obvious, and without departing from the spirit and scope of the present specification, the general principles defined here can be applied to other embodiments and applications. Therefore, the present specification is not limited to the illustrated embodiments, but has the broadest scope consistent with the claims.
[0057] The terms used here are only for the purpose of describing specific example embodiments and are not restrictive. For example, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" used here may also include the plural forms. When used in the present specification, the terms "comprising", "including" and / or "containing" mean that the associated integers, steps, operations, elements and / or components exist, but do not exclude the existence of one or more other features, integers, steps, operations, elements, components and / or groups, or the addition of other features, integers, steps, operations, elements, components and / or groups in the system / method.
[0058] In view of the following description, these features of the present specification and other features, as well as the operations and functions of the related elements of the structure, and the economy of the combination and manufacture of the components can be significantly improved. Referring to the accompanying drawings, all of these form a part of the present specification. However, it should be clearly understood that the drawings are only for the purpose of illustration and description and are not intended to limit the scope of the present specification. It should also be understood that the drawings are not drawn to scale.
[0059] The flowcharts used in the present specification show the operations implemented by the system according to some embodiments in the present specification. It should be clearly understood that the operations in the flowchart may not be implemented in sequence. On the contrary, the operations may be implemented in reverse order or simultaneously. In addition, one or more other operations may be added to the flowchart. One or more operations may be removed from the flowchart.
[0060] First, the noun terms related to one or more embodiments of the present specification are explained.
[0061] Large Language Model (LLM): That is, a large model. A large language model is a neural network model that can understand and generate natural language text obtained by training on a large amount of text data, such as a neural network model based on Transformer, the ChatGPT model, or the DeepSeek model, etc.
[0062] Large model application: Refers to an application program or service developed based on a large model, such as a food delivery agent or a travel assistant, etc.
[0063] Computational Graph: That is, a task graph, which is a data flow graph. Each node in the graph represents a computational operation, and the edges between the nodes represent data dependency relationships or data flows. Through the computational graph, a computational task can be split into multiple parallel computational nodes to ensure the computational order and dependency relationships.
[0064] Node: In a computational graph, a node is the basic unit representing a computational task. Each node usually performs an operation such as a function call, data processing, etc., and each node is connected to other nodes through edges, representing the transfer of data or computational results.
[0065] Data Flow: Refers to the way data is transferred between various computational tasks. In a computational graph, data flows from one node to another node, and after a node performs a computation, the result is passed as a data flow to the next node.
[0066] Graph Engine: A system used to execute a computational graph or a task graph. The graph engine represents a computational task as a graph and automatically manages the execution of nodes (computational tasks) in the graph. The graph engine usually has the capabilities of parallel computing, dynamic scheduling, and resource management, and can efficiently execute complex data processing tasks.
[0067] Parallelism: Refers to splitting the tasks in a task graph into multiple independent small tasks, and these small tasks can be executed simultaneously on multiple computing resources, thereby shortening the total execution time. Parallelism usually requires ensuring the independence between tasks or reasonable dependency management.
[0068] Task Scheduling: Refers to the process of determining the execution order of tasks and allocating computing resources in a computing system. The goal of task scheduling is to optimize the use of computing resources, ensure that tasks are executed in the order of dependency relationships, and perform parallelization if possible.
[0069] Thread Pool: A thread pool is a mechanism for managing and reusing thread resources. A thread pool can handle multiple tasks and distribute tasks to idle threads through a queue for execution.
[0070] Task Dependency: It refers to the situation where some computational tasks must wait for other tasks to complete before they can be executed. The dependency relationship between tasks is usually represented by data transfer or result sharing.
[0071] Asynchronous Execution: Asynchronous execution means that a task can start execution without waiting for other tasks to complete. In the asynchronous execution mode, tasks can be executed in parallel without blocking the execution of other tasks.
[0072] Context Management: It refers to maintaining the external state or data required by a task during task execution. In distributed or parallel computing, it is necessary to maintain the context information of tasks to ensure that tasks can access the correct data during execution.
[0073] In related technical solutions, a thread pool is used to parallelize multiple tasks corresponding to user requests for large model applications. However, in this technical solution, the management of the thread pool is relatively complex, and it is necessary to manually control the resources of the thread pool reasonably. For example, it is necessary to manually adjust the size of the thread pool. If there are too many threads in the thread pool, it will lead to resource competition, which may cause problems such as context switching, CPU, and memory overload; if there are too few threads in the thread pool, tasks cannot be efficiently processed concurrently, resulting in an increase in response time.
[0074] Based on the above, embodiments of this specification provide a task processing method and an electronic device. On the one hand, multiple tasks corresponding to a task request for a large model application are converted into a task graph. The task graph includes multiple task nodes, and a task node represents a task operation corresponding to the task. The task operation includes calling an external interface of the large model application, which can convert multiple tasks into graph task nodes that can be executed in parallel by a graph engine. Due to the structural characteristics of the graph, the relationship and execution order of the task nodes in the task graph become clear, and the scheduling of tasks becomes clearer and more efficient. Therefore, there is no need to manually manage the threads and resource allocation of the thread pool explicitly. On the other hand, the graph engine is used to execute the task operations corresponding to each task node in the task graph. Since the graph engine has the ability of parallel processing, it can use the graph engine to execute multiple tasks corresponding to the task request in parallel, avoiding the problem of complex thread pool management, thereby improving the task processing efficiency of the large model application and reducing the task response time.
[0075] Next, the technical solutions of the embodiments of this specification will be described in detail with reference to the accompanying drawings.
[0076] Figure 1 It shows a schematic diagram of an implementation environment of a task processing method provided by an embodiment of this specification.
[0077] See Figure 1 As shown, the implementation environment 100 may include a terminal 110, a server 130, and a database 140.
[0078] The terminal 110 is connected to the server 130 through a wireless network or a wired network 120. The terminal 110 may be a mobile phone, a tablet computer, a laptop computer, a desktop computer, etc., but is not limited thereto.
[0079] The terminal 110 may store data or instructions for executing the task processing method described in this specification. The terminal 110 may include a hardware device with data information processing capabilities and necessary programs for driving the hardware device to work.
[0080] The server 130 is an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms, etc. The server 130 provides background services for application programs running on the terminal 110.
[0081] An integrated development platform is installed on the server 130. The integrated development platform, also known as the Integrated Development Environment (IDE), is an application program used to provide a program development environment, generally including tools such as a code editor, a compiler, a debugger, and a graphical user interface. Developers can write program code (i.e., program development) on the integrated development platform. The integrated development platform server may be a computing device dedicated to implementing the task processing method by the integrated development platform. The server 130 can communicate with the terminal 110 and the database 140 respectively for data.
[0082] In addition, the server 130 may store data or instructions for executing the task processing method described in this specification. The server 130 may include a hardware device with data information processing capabilities and the necessary programs required to drive the operation of the hardware device. Of course, the server 130 may also be only a hardware device with data processing capabilities, or only a program running on the hardware device. In some embodiments, the server 130 may also be deployed as a plug-in on the terminal 110. At this time, the server 130 stores data or instructions for executing the task processing method corresponding to the terminal 110 described in this specification.
[0083] The database 140 may store data and / or instructions. In some embodiments, the database 140 may store task graphs and contexts corresponding to tasks, etc. In some embodiments, the database 140 may store data and / or instructions for the server 130 to execute or for use in executing the task processing method described in this specification. The terminal 110 and the server 130 have permissions to access the database 140, and the terminal 110 and the server 130 may access the data or instructions stored in the database 140 through a network. In some embodiments, the database 140 may be directly connected to the terminal 110 and the server 130. In some embodiments, the database 140 may be a part of the server 130. In some embodiments, the database 140 may include mass storage, removable storage, volatile read-write memory, read-only memory (ROM), or the like, or any combination thereof. Exemplary mass storage may include non-transitory storage media such as magnetic disks, optical disks, solid state drives, etc. Example removable storage may include flash drives, floppy disks, optical disks, memory cards, zip disks, magnetic tapes, etc. Typical volatile read-write memory may include random access memory (RAM). Example RAM may include dynamic RAM (DRAM), double data rate synchronous dynamic RAM (DDR SDRAM), static RAM (SRAM), thyristor RAM (T-RAM), and zero-capacitor RAM (Z-RAM), etc. Exemplary ROM may include masked ROM (MROM), programmable ROM (PROM), virtual programmable ROM (PEROM), electronically programmable ROM (EEPROM), optical disk (CD ROM), and digital versatile disk ROM, etc.
[0084] Those skilled in the art may be aware that the number of the above terminals may be more or less. For example, there may be only one of the above terminals, or there may be dozens or hundreds of the above terminals, or even more. In this case, other terminals are also included in the above implementation environment. The embodiments of this specification do not limit the number and device types of the terminals.
[0085] After introducing the implementation environment of the embodiments of this specification, the application scenarios of the embodiments of this specification will be introduced in combination with the above implementation environment. In the following description, the terminal is the terminal 110 in the above implementation environment, and the server is the server 130 in the above implementation environment. The technical solutions provided by the embodiments of this specification can be applied to the task processing scenarios of large language model applications, such as food delivery large model applications, travel assistant large model applications, and shopping assistant large model applications, etc.
[0086] Taking the technical solution provided by the embodiments of this specification being applied to the task processing scenario of a food delivery large model application as an example, the task request is a food delivery query request. The terminal 110 determines multiple food item query tasks corresponding to the food delivery query task request in response to the food delivery query request input on the human-computer interaction interface of the food delivery large model application; converts the multiple food item query tasks into a task graph, where the task graph includes multiple task nodes, and the task nodes represent food item query operations corresponding to the food item query tasks; and executes the food item query operations corresponding to each task node in the task graph through a graph engine.
[0087] It should be noted that the above is described by taking the technical solution provided by the embodiments of this specification being applied to the task processing scenario of a food delivery large model application as an example. The technical solutions provided by the embodiments of this specification can also be applied to other appropriate large model application scenarios, such as the task processing scenarios of a travel assistant large model or a shopping assistant large model. The implementation process belongs to the same inventive concept as the above description and will not be elaborated here.
[0088] It should be noted that in the task processing method in the exemplary embodiments of this specification, some steps can be executed by the terminal, some by the server, or all by the server or all by the client. This specification does not make any special limitations on this.
[0089] Based on Figure 1 the shown implementation environment, the task processing method and electronic device provided by the embodiments of this specification will be introduced in detail below in combination with Figures 2 - 7 . It should be noted that the above implementation environment is only shown for the convenience of understanding the spirit and principle of this specification, and the embodiments of this specification are not restricted in this regard. On the contrary, the embodiments of this specification can be applied to any applicable scenario.
[0090] Figure 2A schematic structural diagram of an electronic device 200 provided according to some embodiments of this specification. The above-mentioned electronic device 200 can execute the task processing method described in this specification. The above-mentioned task processing method is introduced in other parts of this specification. The above-mentioned electronic device 200 can be a general-purpose computer or a special-purpose computer. For example, the above-mentioned electronic device 200 can be a server, a personal computer, a portable computer (such as a notebook computer, a tablet computer, etc.), or other electronic devices with computing capabilities. Of course, the above-mentioned electronic device can be Figure 1 the terminal 110 and / or the server 130 in
[0091] The electronic device in this specification may include one or more of the following components: a processor 210, a memory 220, an input device 230, an output device 240, and a bus 250. The processor 210, the memory 220, the input device 230, and the output device 240 can be connected through the bus 250.
[0092] The processor 210 may include one or more processing cores. The processor 210 connects various parts within the entire electronic device through various interfaces and lines, and executes the task processing method described in this specification by running or executing instructions, programs, code sets, or instruction sets stored in the memory 220, and by calling data stored in the memory 220. Optionally, the processor 210 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 210 may integrate a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, the user interface, and application programs, etc.; the GPU is responsible for rendering and drawing the displayed content; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 210 and may be implemented separately through a communication chip.
[0093] The memory 220 may include a random access memory (RAM), and may also include a read-only memory (ROM). Optionally, the memory 220 includes a non-transitory computer-readable storage medium. The memory 220 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 220 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The operating system may be an Android system, including a system developed based on the Android system in depth, an IOS system, including a system developed based on the IOS system in depth, or other systems.
[0094] In order for the operating system to distinguish the specific application scenarios of third-party applications, it is necessary to establish data communication between the third-party applications and the operating system, so that the operating system can obtain the current scenario information of the third-party applications at any time, and then perform targeted system resource adaptation based on the current scenario.
[0095] Among them, the input device 230 is used to receive input instructions or data. The input device 230 includes, but is not limited to, a keyboard, a mouse, a camera, a microphone or a touch device. The output device 240 is used to output instructions or data. The output device 240 includes, but is not limited to, a display device, a speaker, etc. In one example, the input device 230 and the output device 240 can be integrated, and the input device 230 and the output device 240 are a touch display screen.
[0096] In addition, those skilled in the art can understand that the structure of the electronic device shown in the above figures does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figures, or combine some components, or have different component arrangements. For example, the electronic device further includes components such as a radio frequency circuit, an input unit, a sensor, an audio circuit, a Wireless Fidelity (WiFi) module, a power supply, a Bluetooth module, etc., which will not be elaborated here.
[0097] Figure 3The flowchart of a task processing method provided according to an embodiment of this specification is shown. As before, the electronic device 200 may execute the task processing method of the embodiment of this specification. Specifically, the processor 210 may read the instruction set stored in its local storage medium, and then execute the task processing method of the embodiment of this specification according to the provisions of the instruction set. Below, steps S310 to S330 in the task processing method will be described in detail with reference to the accompanying drawings.
[0098] Referring to Figure 3 As shown, in step S310, in response to a task request for a large model application, a plurality of tasks corresponding to the task request are determined.
[0099] In an example embodiment, the task request is a query request input by a user on the human-computer interaction interface of the large model application. The large model application refers to an application program or service developed based on a large model, such as a large model Agent. The tasks corresponding to the task request include at least one task operation, and the task operation includes invoking an external interface of the large model application. The external interface of the large model application includes an external tool interface or an external service interface. The external tool interface refers to an independent program or script, usually running in a local environment, to complete certain specific tasks such as data analysis or image processing. The external service interface refers to a service interface that provides specific functions for a software system running on a remote server, such as a weather query API (Application Programming Interface) or a meal query API of a food delivery application platform, etc. The electronic device 200 determines a plurality of task data elements corresponding to the task request in response to the task request for the large model application; and determines a plurality of tasks corresponding to the task request based on the plurality of task data elements, where each task corresponds to at least one task operation.
[0100] In some example embodiments, the large model application is a dedicated large model application for a specific scenario, such as a food delivery Agent or a shopping Agent, etc. The electronic device 200 obtains the query information input by the user on the human-computer interaction interface of the large model application in response to the task request for the large model application, extracts the corresponding task data elements from the query information, such as entity information, and determines a plurality of tasks corresponding to the task request according to the extracted task data elements.
[0101] For example, referring to Figure 4As shown in the left figure in the middle, the large model application can be a food delivery agent. The user inputs "I want to order Kung Pao Chicken, Yu-Shiang Shredded Pork, and Coke" on the human-computer interaction interface of the food delivery agent. In response to this task request for the food delivery agent, the electronic device 200 obtains the above query information input by the user on the human-computer interaction interface of the food delivery agent, extracts task data elements from the query information, such as "Kung Pao Chicken", "Yu-Shiang Shredded Pork", and "Coke", and determines multiple tasks corresponding to the task request based on the extracted task data elements. For example, Task 1 is to query Kung Pao Chicken, Task 2 is to query Yu-Shiang Shredded Pork, and Task 3 is to query Coke.
[0102] It should be noted that although the large model application is taken as an example of a food delivery agent for illustration, those of ordinary skill in the art should understand that the large model application can also be other appropriate applications, such as a travel assistant large model or a shopping assistant large model, etc., which are also within the scope of the embodiments of this specification.
[0103] Furthermore, in some other exemplary embodiments, the large model application is a general large model application, and intent recognition needs to be performed according to the user's task request. Therefore, in response to the task request for the large model application, the electronic device 200 determines the task intent corresponding to the task request and multiple task data elements corresponding to the task intent; based on the task intent and the above task data elements, it determines multiple tasks corresponding to the task request.
[0104] For example, suppose the user inputs "the weather of each city along the way from Shenzhen to Jiangmen by self-driving tomorrow" on the human-computer interaction interface of the large model application. In response to this task request, the electronic device 200 obtains the above query information input by the user on the human-computer interaction interface of the large model application, determines that the task intent corresponding to this task request is "query weather", determines that "each city along the way from Shenzhen to Jiangmen" includes task data elements such as "Shenzhen", "Guangzhou", "Foshan", and "Jiangmen", and determines multiple tasks corresponding to this task request based on the above task intent and the above task data elements. For example, Task 1 is to query the weather in Shenzhen, Task 2 is to query the weather in Guangzhou, Task 3 is to query the weather in Foshan, and Task 4 is to query the weather in Jiangmen.
[0105] In step S320, the multiple tasks are converted into a task graph. The task graph includes multiple task nodes, and the task nodes represent task operations corresponding to the tasks.
[0106] In an exemplary embodiment, a task graph is a structured data representation for showing the dependencies between tasks. Herein, each task node of the task graph represents a specific task operation, and the edges of the task graph represent the dependency or sequential relationship between the task operations of the task nodes. The task graph is a computational graph that can be executed by a graph engine. Through the task graph, multiple tasks corresponding to a task request can be split into multiple parallel computing nodes, and the computing order and dependency relationship between tasks can be ensured.
[0107] Furthermore, the task graph includes multiple task nodes, and the task nodes represent the task operations corresponding to the tasks. For example, the processing of each task (such as data query, data parsing, etc.) is represented as an independent task node or a FunctionCall node. The dependency relationship between task nodes is represented by edges. For example, if the result of a task node 1 is the input of another task node 2, this dependency relationship can be represented as "task node 1 -> task node 2". Taking the task request as an order query request for multiple food items as an example, the task request corresponds to multiple food item query tasks, and each food item query task (such as the food item query API call of the order platform) is represented as a task node in the task graph of the graph engine.
[0108] In an exemplary embodiment, the task request corresponds to multiple task data elements. The task data elements are data elements related to the task determined based on the task request. Each task data element corresponds to a task, and each task corresponds to at least one task operation. The task operations include calling the external interface of the large model application, such as the weather query API or the food item query API of the order application platform. The electronic device 200 determines at least one task operation corresponding to the task based on the task data element, such as FunctionCall; and generates a task graph in the graph data format based on the task operations corresponding to each task, wherein each task operation corresponds to a task node. For example, the electronic device 200 determines the function call model FunctionCallModel of the task operation corresponding to the task based on the task data element, converts the function call model of the task operation corresponding to the task into a task node of the task graph, and converts the dependency relationship between the task operations into the edges of the task graph. The function call model of the task operation can be an API call model. For example, if the task operation is to query the Y food item on the X order platform, the function call model corresponding to the task operation can be the food item query API call model corresponding to the X order platform.
[0109] Taking the large model application as the order Agent as an example, refer to Figure 5As shown, the multiple task data elements corresponding to the task request include "Kung Pao Chicken (Dish 1)", "Yu-Shiang Shredded Pork (Dish 2)", and "Coke (Dish 3)". The task data element "Dish 1" corresponds to the task of querying Dish 1; the task data element "Dish 2" corresponds to the task of querying Dish 2; the task data element "Dish 3" corresponds to the task of querying Dish 3. The electronic device 200 determines the task operations corresponding to the task based on the task data elements. For example, the task operation 1 corresponding to the task of querying Dish 1 is to call the function call model 1 for querying Dish 1, the task operation 2 corresponding to the task of querying Dish 2 is to call the function call model 2 for querying Dish 2, and the task operation 3 corresponding to the task of querying Dish 3 is to call the function call model 3 for querying Dish 3; the function call models of the task operations are converted into task nodes of the task graph. For example, the task operation 1 of querying Dish 1 is converted into task node 1; the task operation 2 of querying Dish 2 is converted into task node 2, and the task operation 3 of querying Dish 3 is converted into task node 3. Further, the task corresponding to the task request further includes a result summary task, and the electronic device 200 converts the dependency relationship between the task operations into the edges of the task graph. In Figure 5 In the task graph of
[0110] In some other exemplary embodiments, each task data element corresponds to a task, and each task corresponds to two task operations, such as a data query operation and a query result parsing operation. The electronic device 200 determines the data query operation and the query result parsing operation corresponding to the task based on the task data element; and generates a task graph in the graph data format based on the data query operation and the query result parsing operation corresponding to the task.
[0111] Taking the takeout query request for 3 dishes as an example, there are 3 task data elements, such as Dish 1, Dish 2, and Dish 3. The electronic device 200 determines the task operations corresponding to the task based on the task data elements. For example, the two task operations corresponding to the task of querying Dish 1 are to call the function call model for querying Dish 1 and to call the function call model for parsing the query result 1, the two task operations corresponding to the task of querying Dish 2 are to call the function call model for querying Dish 2 and to call the function call model for parsing the query result 2; and the two task operations corresponding to the task of querying Dish 3 are to call the function call model for querying Dish 3 and to call the function call model for parsing the query result 3; the function call models of each task operation are converted into task nodes of the task graph. For example, the two task operations of the task of querying Dish 1 are converted into task nodes 1 and 2; the two task operations of the task of querying Dish 2 are converted into task nodes 3 and 4; the two task operations of the task of querying Dish 3 are converted into task nodes 5 and 6.
[0112] Referring to Figure 6 As shown, the data query operation for querying Meal 1 task corresponds to Task Node 1, and the operation of parsing the query result corresponds to Task Node 2; the data query operation for querying Meal 2 task corresponds to Task Node 3, and the operation of parsing the query result corresponds to Task Node 4; the data query operation for querying Meal 3 task corresponds to Task Node 5, and the operation of parsing the query result corresponds to Task Node 6; the operation of summarizing the parsed results corresponds to Task Node 7.
[0113] In step S330, the task operations corresponding to each task node in the task graph are executed through the graph engine.
[0114] In the exemplary embodiment, the graph engine is a system for executing a computational graph such as the above-mentioned task graph. Through the graph engine, computational tasks can be represented as task nodes of the task graph, and the execution of task nodes (computational tasks) in the task graph can be automatically managed. The graph engine is responsible for scheduling the execution of each task node in the task graph and can execute the task operations of each task node in parallel on multiple computing units (such as each CPU in a multi-core CPU or each distributed node in a distributed system). For example, the graph engine allocates computing resources (such as threads or computing units) to each task node, schedules according to the dependency relationships between tasks, and ensures that the task operations corresponding to the tasks are executed as required. The graph engine also supports asynchronous execution of tasks. Taking the API calls of multiple meal query tasks as an example of task requests for multiple meals, the API calls of multiple meal query tasks can be executed simultaneously without waiting for the completion of other meal query tasks. After each meal query task completes the calculation, the result is transmitted to the next dependent task through a data stream without explicitly waiting for the completion of other tasks.
[0115] In the exemplary embodiment, the task graph further includes the dependency relationships between each task node. The dependency relationships between task nodes indicate that the output of one task node depends on the input of another task node. The graph engine is responsible for automatically scheduling the task nodes in the task graph to ensure that the task operations of the task nodes are executed according to the dependency relationships. For example, when the task nodes of multiple meal queries are executed in parallel, the graph engine generates a data stream based on the query results of each task node and dynamically schedules the execution order of the task operations of the task nodes.
[0116] The electronic device 200 executes the task operations corresponding to each task node in the task graph through the graph engine according to the dependency relationships between each task node. For example, the electronic device 200 schedules each task node in the task graph through the graph engine according to the dependency relationships between task nodes, and automatically arranges the execution order of the task operations of each task node. Through the graph engine, the dependency relationships and execution order between tasks can be automatically processed, avoiding the resource competition problems that may occur in the thread pool.
[0117] Taking the task request as an example of an takeaway query request for multiple food items, refer to Figure 5 As shown, the output of task node 4 depends on the inputs of task nodes 1 to 3. Based on the dependency relationship between task node 4 and task nodes 1 to 3, after obtaining the query results of task nodes 1 to 3, the electronic device 200 schedules task node 4 to perform the operation of summarizing the query results, that is, summarizing the query results of task nodes 1 to 3.
[0118] The graph engine usually has capabilities such as parallel computing, dynamic scheduling, and resource management, and can efficiently execute complex data processing tasks. In some exemplary embodiments, the electronic device 200 divides the task graph into multiple parallel task nodes based on the dependency relationship between each task node; and executes the task operations corresponding to each parallel task node in parallel through the graph engine. Taking the task request as an example of an takeaway query request for multiple food items, the electronic device 200 divides the multiple food item query task nodes corresponding to the task graph into multiple parallel task nodes based on the dependency relationship between each task node. For example, each food item query task corresponds to a parallel task node, and the parallel task nodes corresponding to each food item query task are executed in parallel. Since the graph engine has the ability of parallel processing, mutually independent task nodes (such as multiple food item queries) can be executed in parallel, thus significantly reducing the task response time.
[0119] For example, refer to Figure 5 As shown, the electronic device 200 divides the task graph into 3 parallel task nodes, namely task node 1, task node 2, and task node 3, through the graph engine, and performs parallel processing on the 3 parallel task nodes, that is, the 3 food item query API calls will be made simultaneously. Since the 3 food item query tasks will be processed in parallel by the graph engine, the task response time can be reduced.
[0120] Furthermore, the electronic device 200 obtains the task results of each task in the task graph executed by the graph engine, and displays the task results of each task on the human-computer interaction interface. Refer to the right figure of Figure 4 As shown, the large model application is the takeaway Agent. The task data elements are, for example, "Kung Pao Chicken", "Yu-Shiang Shredded Pork", and "Coke". Task 1 is to query Kung Pao Chicken, task 2 is to query Yu-Shiang Shredded Pork, and task 3 is to query Coke. The query result of task 1 corresponds to recommended merchants 1 to 3; the query result of task 2 corresponds to recommended merchants 4 to 6; the query result of task 3 corresponds to recommended merchants 7 to 9.
[0121] According to Figure 3In the technical solution of the exemplary embodiment, on the one hand, multiple tasks corresponding to a task request for a large model application are converted into a task graph. The task graph includes multiple task nodes, and a task node represents a task operation corresponding to the task, which can convert multiple tasks into task nodes of a computation graph that can be executed in parallel by a graph engine. Due to the structural characteristics of the graph, the relationships and execution order of the task nodes in the task graph become clear, and the scheduling of tasks becomes clearer and more efficient. Therefore, there is no need to manually manage the threads and resource allocation of the thread pool explicitly. On the other hand, the task operations corresponding to each task node in the task graph are executed by the graph engine. Since the graph engine has the ability of parallel processing, it can use the graph engine to execute multiple tasks corresponding to the task request in parallel, avoiding the complex problem of thread pool management, thereby improving the task processing efficiency of the large model application and reducing the task response time.
[0122] In addition, the task request input on the human-computer interaction interface of the large model application corresponds to multiple task data elements. A task data element is a data element related to the task determined based on the task request, and each task data element corresponds to at least one task. In the exemplary embodiment, the electronic device 200 generates a task code corresponding to the task based on the task data element, and the task code is used to execute the task operation corresponding to the task; and converts the task code into a graph data format, where each task code corresponds to a task node.
[0123] In some exemplary embodiments, each task data element may correspond to a data query task and a data parsing task, and multiple task data elements also correspond to a summary query result operation, which is used to summarize multiple result data elements corresponding to the data query operation. The data structure of multiple task data elements is a first linear structure, and the data structure of multiple result data elements is a second linear structure. The first linear structure and the second linear structure may be an array structure, or other appropriate data structures such as a linked list or a queue. Taking the data structure as an array as an example, the first linear structure and the second linear structure are a first array and a second array respectively, and the array elements of the first array are converted into the array elements of the second array by the graph engine.
[0124] The electronic device 200 generates a task processing code corresponding to the task based on the task data element, and the task processing code is used to call the task operation corresponding to the task and obtain a task processing result; based on the task processing results corresponding to each task processing code, generates a multi-task processing result code corresponding to multiple tasks, and the multi-task processing result code is used to summarize each task processing result; converts the task processing code and the multi-task processing result code into a task graph in graph data format.
[0125] Further, the task processing code includes a task call code and a result parsing code. The task call code is used to call a task operation corresponding to a task, and the result parsing code is used to parse the call result of the task call code. The electronic device 200 generates a multi-task processing result code corresponding to multiple tasks based on the parsing results corresponding to each result parsing code.
[0126] Taking the task request as an example of a takeout query request for 3 food items, there are 3 task data elements, such as food item 1, food item 2, and food item 3. Refer to Figure 6 As shown, querying food item 1 corresponds to task node 1, and parsing query result 1 corresponds to task node 2; querying food item 2 corresponds to task node 3, and parsing query result 2 corresponds to task node 4; querying food item 3 corresponds to task node 5, and parsing query result 3 corresponds to task node 6; summarizing the parsing results corresponds to task node 7. Then, the example task code 1 corresponding to each task generated is as follows:
[0127] 1.val strResult1=FunctionCall(callModel="@functionCallModel_1@")
[0128] 2.val jsonResult1=ParseJsonObject(json=strResult1)
[0129] 3.val strResult2=FunctionCall(callModel="@functionCallModel_2@")
[0130] 4.val jsonResult2=ParseJsonObject(json=strResult2)
[0131] 5.val strResult3=FunctionCall(callModel="@functionCallModel_3@")
[0132] 6.val jsonResult3=ParseJsonObject(json=strResult3)
[0133] 7.val finalSearchResult=Array(jsonResult1,jsonResult2,jsonResult3)
[0134] return finalSearchResult
[0135] The above task code 1 shows how to execute each query (FunctionCall) in parallel as an independent task and merge the results into an array. Among them, lines 1 to 6 represent the task processing code, and line 7 represents the multi-task processing result code. Taking the takeaway query request with 3 food items as an example, strResult1, strResult2, and strResult3 represent the query results of food item 1, food item 2, and food item 3 respectively, jsonResult1, jsonResult3, and jsonResult3 represent the Json parsing results of the query results of the 3 food items, and finalSearchResult represents the final query result to be returned to the user.
[0136] Further, the electronic device 200 converts each task processing code and the multi-task processing result code into task nodes of a task graph; and based on the dependency relationships between the tasks, generates the dependency relationships between the task nodes of the task graph. Taking the takeaway query request with 3 food items as an example, referring to Figure 6 as shown, task node 2 depends on the output of task node 1; task node 4 depends on the output of task node 3; task node 6 depends on the output of task node 5; task node 7 depends on the outputs of task node 2, task node 4, and task node 6. The generated task graph in the example graph data format 1 is as follows:
[0137] Digraph xxx{
[0138] Node_0001[label=”strResult1”,function=”Functioncall”,input=”@functionCallModel_1@”;
[0139] Node_0002[label=”jsonResult1”,function=”ParseJsonObject”,input=”strResult1”;
[0140] Node_0003[label=”strResult2”,function=”Functioncall”,input=”@functionCallModel_3@”;
[0141] Node_0004[label=”jsonResult2”,function=”ParseJsonObject”,input=”strResult2”;
[0142] Node_0005[label="strResult3", function="Functioncall", input="@functionCallModel_3@";
[0143] Node_0006[label="jsonResult3", function="ParseJsonObject", input="strResult3";
[0144] Node_0007[label="finalSearchResult", function="Array", input="jsonResult1,jsonResult2,jsonResult3"
[0145] Node_0001 -> Node_0002; Node_0003 -> Node_0004; Node_005 -> Node_0006;
[0146] Node_0002 -> Node_0007; Node_0004 -> Node_0007; Node_0006 -> Node_0007;}
[0147] Among them, Node_0001 to Node_0006 respectively represent the task nodes corresponding to task processing code 1 and task processing code 6, Node_0007 represents the task node corresponding to task processing code 7, and represents the summary of the parsing results corresponding to task node 2, task node 4, and task node 6. Task node 2 depends on task node 1, task node 4 depends on task node 3, task node 6 depends on task node 5, and task node 7 depends on task node 2, task node 4, and task node 6.
[0148] According to the technical solution in the above exemplary embodiment, by dynamically generating the task processing code of each task at runtime and converting the task processing code into a graph structure, and the graph engine processes the parallelization and scheduling of multiple tasks of the graph structure, the task processing efficiency can be improved and the task response time can be reduced.
[0149] Furthermore, to ensure correct data reference between different task nodes, the graph engine performs dynamic data mapping for each task node. In the exemplary embodiment, the electronic device 200 performs dynamic data mapping on the data elements corresponding to each task node to generate unique identifiers for the data elements, where the data elements include task data elements and task result elements corresponding to the task data elements. Data mapping refers to establishing a correspondence of fields or elements between different data models, formats, or systems to achieve data conversion, integration, or synchronization. Dynamic data mapping means that the unique identifier of the mapping is determined at runtime and can be automatically adjusted according to input data, external configuration, or conditions. For example, the task query result of a task node, i.e., the task result element, will be dynamically mapped (i.e., stored and referenced) as @functionCallModel_1@ and passed to subsequent nodes during execution.
[0150] According to the technical solution in the above exemplary embodiment, by performing dynamic data mapping on the data elements corresponding to each task node, it is possible to dynamically generate unique variable names for task data elements and task result elements, which can avoid the uniqueness of variable names in parallel execution and avoid variable conflicts.
[0151] Furthermore, the electronic device 200 generates a unique index value for the data elements corresponding to each task node and adds the unique index value to the element name of the data element. For example, the element name of the task data element, such as element, is dynamically mapped to the element name with an index, element_0, in the task processing code. By adding the index value to the variable name of the data element, it can be ensured that the variables used by each task do not conflict in the same context.
[0152] In addition, in some exemplary embodiments, the electronic device 200 dynamically adjusts the execution plan of each task node according to the resource requirements of each task node, such as computational complexity and task volume; and based on the execution plan, executes the task operations corresponding to each task node in the task graph through the graph engine. The graph engine can dynamically adjust the execution plan according to the computational complexity and data volume of the task, such as selecting whether to place some task nodes on different computing resources.
[0153] For example, the electronic device 200 can dynamically adjust the execution plan of tasks for each task node based on factors such as the execution time of the task and resource consumption. For example, the computing tasks can be distributed to multiple computing nodes through distributed computing to automatically perform load balancing, further optimizing the task response time of the system. Through distributed computing, the graph engine can distribute the computing tasks to multiple computing nodes and automatically perform load balancing, avoiding the expansion bottleneck of the thread pool in large-scale applications. Moreover, the graph engine has elastic scalability and can automatically adapt to the increased computing requirements. The electronic device 200 can increase the computing resources in response to the computing resource expansion requirement and dynamically adjust the execution plan and resource allocation of the task graph through the graph engine.
[0154] According to the technical solution in the above exemplary embodiment, the graph engine can dynamically adjust the execution plan according to the resource requirements of the task. For example, it can choose whether to place some task nodes on different computing resources for load balancing, avoiding the thread management bottleneck in the thread pool, reducing context switching, and improving the task processing efficiency.
[0155] In addition, in the graph engine, each parallel task (such as the takeout food query task) will access some context information (such as the parameters of the API request, response data, etc.). The graph engine will manage this context information to ensure that the task can correctly access the input data it needs. Therefore, in the exemplary embodiment, the electronic device 200 obtains the task execution results corresponding to the task operations of each task; stores the task execution results of the task in the context corresponding to the task in the graph engine. For example, the execution result of each task (such as the food information returned by the query) will be stored in the context of the graph engine (for example, PipelineContext#dataObjectMap), ensuring data consistency during the task execution process. The context data storage not only includes the task processing results of each task, but also can handle the reference relationship between data. For example, the output of a certain task can be used as the input of the next task, and the data transfer between tasks is realized through the context management of the graph engine.
[0156] According to the technical solution in the above exemplary embodiment, storing the task execution results of each task in the context corresponding to the task in the graph engine can isolate and store the data of each task, ensure the correct transfer of data between tasks, avoid data contamination between different tasks, and ensure the consistency and correctness of the data.
[0157] Figure 7 Shows a schematic flowchart of a task processing method provided according to some other embodiments of this specification.
[0158] Refer to Figure 7As shown, in step S710, in response to a task request for a large model application, a plurality of task data elements corresponding to the task request are determined.
[0159] In an exemplary embodiment, the task request is a query request input by a user on the human-machine interaction interface of the large model application. The large model application represents an application program or service developed based on a large model, such as a large model Agent. The electronic device 200 determines a plurality of task data elements corresponding to the task request in response to the task request of the large model application.
[0160] In some exemplary embodiments, the large model application is a dedicated large model application for a specific scenario, such as a food delivery Agent or a shopping Agent, etc. The electronic device 200 obtains the query information input by the user on the human-machine interaction interface of the large model application in response to the task request for the large model application, extracts corresponding task data elements such as entity information from the query information, and determines a plurality of tasks corresponding to the task request according to the extracted task data elements.
[0161] For example, referring to Figure 4 As shown in the left figure in, the large model application can be a food delivery Agent. The user inputs "I want to order Kung Pao Chicken, Yu-Shiang Shredded Pork and Coke" on the human-machine interaction interface of the food delivery Agent. The electronic device 200 obtains the above query information input by the user on the human-machine interaction interface of the food delivery Agent in response to the task request for the food delivery Agent, and extracts task data elements such as "Kung Pao Chicken", "Yu-Shiang Shredded Pork" and "Coke" from the query information.
[0162] In step S720, a task processing code corresponding to the task is generated based on the task data elements, and the task processing code is used to execute at least one task operation corresponding to the task.
[0163] In an exemplary embodiment, the electronic device 200 generates a task processing code corresponding to the task based on the task data elements. The task processing code is used to call the task operation corresponding to the task and obtain a task processing result; based on the task processing results corresponding to each task processing code, a multi-task processing result code corresponding to a plurality of tasks is generated. The multi-task processing result code is used to summarize each task processing result; the task processing code and the multi-task processing result code are converted into a task graph in a graph data format. For example, assuming that the data structure of a plurality of task data elements is an array, the electronic device 200 dynamically generates a corresponding task processing code for each array element. The task processing code is used to execute at least one task operation corresponding to the task. The task processing code includes a task call code and a result parsing code.
[0164] Taking the takeout query request with 3 food items as an example, there are 3 task data elements, such as food item 1, food item 2, and food item 3. Refer to Figure 6 As shown, query the task node 1 corresponding to food item 1, and parse the query result 1 corresponding to task node 2; query the task node 3 corresponding to food item 2, and parse the query result 2 corresponding to task node 4; query the task node 5 corresponding to food item 3, and parse the query result 3 corresponding to task node 6; summarize the parsed results corresponding to task node 7, then the generated task codes for the examples corresponding to each task are like the above task code 1.
[0165] Furthermore, in some exemplary embodiments, the processing process of each input data element is parallelized through the ArrayTransform operator, and an array containing multiple task processing results is output. The input of the ArrayTransform operator is an array array, which contains multiple task data elements that need to be processed independently. The electronic device 200 generates the task processing code corresponding to each array element through the ArrayTransform operator, and outputs an array containing multiple task processing results. For example, for the takeout food query, the input array can be multiple food query models (FunctionCallModel). The task processing code corresponding to each task data element needs to perform certain operations (such as food query API calls, result data parsing, etc.), and return the calculation result corresponding to the task processing code.
[0166] In step S730, the task processing code is converted into a task graph in graph data format.
[0167] In the exemplary embodiment, the processing of each task data element (such as takeout food query, result data parsing, etc.) is represented as an independent graph node (such as a FunctionCall node), that is, a task node. The dependency relationships between these graph nodes (such as the output of one task node may be used as the input of the next task node) will be processed by the graph engine. Multiple task nodes are connected by edges representing dependency relationships or data flows. In the graph engine, the task results of the task nodes are passed to the subsequent nodes in the form of data streams. The result of a certain task operation is the input of other task operations. For example, in the above task code 1, the result parsing variable jsonResult1 is the parsing result of the query result variable strResult1, and is passed through the data stream in the graph engine to ensure that the tasks are executed in the order of dependencies. Refer to Figure 6 As shown, taking the takeout query request with multiple food items as an example, the query result of food item 1 is passed to the parsing result node, that is, task node 2, and then continues to flow to task node 7 for result summarization.
[0168] According to the technical solutions of the above embodiments, parallelization is achieved through the computational graph and data flow of the graph engine, without explicitly managing the threads and resource allocation of the thread pool, thus avoiding the management complexity of the thread pool.
[0169] In an exemplary embodiment, the electronic device 200 converts each task processing code and the multi-task processing result code into task nodes of a task graph; and based on the dependency relationships between the tasks, generates the dependency relationships between the task nodes of the task graph. Taking the task request as a takeout query request for 3 meals as an example, referring to Figure 6 As shown, task node 2 depends on the output of task node 1; task node 4 depends on the output of task node 3; task node 6 depends on the output of task node 5; task node 7 depends on the outputs of task node 2, task node 4, and task node 6. The generated example is a task in the graph data format such as the above graph data format 1.
[0170] In step S740, the graph engine executes the task operations corresponding to the task nodes in the task graph.
[0171] In an exemplary embodiment, the graph engine is responsible for scheduling the execution of each node and can execute these tasks in parallel on multiple computing units (such as multi-core CPUs or distributed systems). The graph engine schedules according to the dependency relationships between tasks (for example, the output of some tasks depends on the result of the previous task), and automatically arranges the execution order of tasks. Due to the parallelization ability of the graph engine, multiple independent task nodes (such as multiple queries) can be executed in parallel, significantly reducing the task response time.
[0172] For example, when executing the task graph through the graph engine, each task of the generated code generates a corresponding task call FunctionCall according to the index of the array element, and parallelizes the task calls. Through the scheduling of these tasks, multiple tasks can be efficiently executed in parallel, significantly reducing the task response time.
[0173] For example, the electronic device 200 allocates computing resources (such as threads or computing units) to each task node through the graph engine, schedules each task node according to the dependency relationships between tasks, and ensures that each task node is executed as needed. The graph engine automatically manages the execution order and dependency relationships of tasks through the topological structure of the task graph, avoiding the synchronization waiting and blocking problems in the thread pool.
[0174] In addition, in some exemplary embodiments, the graph engine automatically optimizes the execution order of tasks according to the dependencies of the tasks, ensuring that the input of each task is ready before execution. For example, the electronic device 200 can dynamically adjust the execution plans of the tasks of each task node through the graph engine based on factors such as the execution time and resource consumption of the tasks. For example, the computing tasks can be distributed to multiple computing nodes through distributed computing to automatically perform load balancing and further optimize the task response time of the system.
[0175] According to the technical solutions in the above exemplary embodiments, on the one hand, by parallelizing the execution of multiple task nodes through the graph engine, the limitation of the thread pool size is not affected, and the throughput of the system is improved; on the other hand, since multiple tasks can be executed independently in parallel, the complexity of traditional thread pool management is reduced.
[0176] In step S750, the context data of the task is stored.
[0177] In the exemplary embodiment, in the graph engine, each parallel task (such as the takeaway food query task) will access some context information (such as the parameters of the API request, response data, etc.), and the graph engine will manage this context information to ensure that the task can correctly access the input data it needs. Therefore, in the exemplary embodiment, the electronic device 200 obtains the task execution results corresponding to the task operations of each task; stores the task execution results of the task in the context corresponding to the task in the graph engine. For example, the execution result of each task (such as the food information returned by the query) will be stored in the context of the graph engine (for example, PipelineContext#dataObjectMap) to ensure data consistency during the task execution process. The context data storage not only includes the task processing results of each task, but also can handle the reference relationships between data. For example, the output of a certain task can be used as the input of the next task, and the data transfer between tasks is realized through the context management of the graph engine.
[0178] Furthermore, in order to ensure the correct data reference between different task nodes, the graph engine will perform dynamic data mapping on each task node. In the exemplary embodiment, the electronic device 200 performs dynamic data mapping on the data elements corresponding to each task node to generate unique identifiers corresponding to the data elements, where the data elements include task data elements and task result elements corresponding to the task data elements. For example, the query result of the query task will be stored and referenced as @functionCallModel_0@ and passed to subsequent nodes during execution.
[0179] According to Figure 7In the technical solution of the exemplary embodiment, on the one hand, the graph engine performs parallel task scheduling on each task node of the task graph. For example, by converting the processing process of task data elements into graph nodes and using the parallel computing ability of the graph engine for task scheduling, the disadvantages of the traditional thread pool parallelization method are avoided. On the other hand, dynamic code generation and graph transformation are performed. For example, the task processing code for each task is dynamically generated at runtime and the task processing code is converted into a graph structure, and the graph engine processes the parallelization and scheduling of tasks, reducing the task response time. On the other hand, the graph engine automatically schedules according to the dependency relationships between tasks, ensuring the parallel execution between tasks, while optimizing data transfer and avoiding resource conflicts and scheduling bottlenecks in traditional parallel computing. On the other hand, context management and data transfer of tasks are performed. For example, the correct transfer of data between tasks is ensured through the context management of the graph engine, while simplifying the processing of dependency relationships between tasks.
[0180] In this specification, the Large Language Model (LLM) can also be abbreviated as the large model. The large language model is a natural language processing model based on deep learning technology, with the number of parameters usually reaching billions to hundreds of billions or even higher, and having powerful language understanding and generation capabilities. The large language model can adopt the Transformer architecture or its variants (such as GPT, BERT, etc.). This architecture uses the Attention Mechanism to achieve global modeling of sequence data, can efficiently process long-distance dependency relationships, and thus performs well in natural language tasks. The large language model learns the statistical features and semantic relevance of the language by pre-training on a large-scale corpus, enabling it to have good generalization ability. The core capabilities of the large language model include but are not limited to: understanding context semantics, generating coherent and grammatically correct text, performing logical reasoning, and handling multi-task scenarios. Its usage methods usually include two modes: direct inference and fine-tuning. In the direct inference mode, the user guides the large language model to generate specific outputs by designing prompts. The prompt can be a text-based task description or instruction, used to stimulate the semantic understanding and generation ability of the large language model. In the fine-tuning mode, the large language model is further trained on a small-scale dataset in a specific domain to optimize its performance on specific tasks. The powerful generalization ability and flexibility of the large language model make it an important tool in the field of artificial intelligence technology, providing an efficient and accurate solution for automated text generation and understanding.
[0181] In some embodiments, the large language model can also have the ability to understand and generate data of other modalities (such as vision, audio, etc.). In this case, the large language model can also be called a Multimodal Large Language Model (MLLMs). By integrating various types of inputs and outputs such as text, images, and sounds, MLLMs provide a richer and more natural interaction experience. The core advantage of MLLMs lies in their ability to process and understand information from different modalities and fuse this information to complete complex tasks. For example, MLLMs can analyze an image and generate descriptive text, or generate a corresponding image based on a text description. This cross-modal understanding and generation ability makes MLLMs have broad application prospects in multiple fields.
[0182] It should be noted that the key technologies of the large language model can be referred to the detailed description in the paper "A Survey of Large Language Models" (paper number: arXiv:2303.18223v16, publication time: March 11, 2025, public link: https: / / doi.org / 10.48550 / arXiv.2303.18223), and this specification will not elaborate here.
[0183] On the other hand, this specification provides a non-transitory storage medium storing at least one set of executable instructions for task processing. When the executable instructions are executed by a processor, the executable instructions direct the processor to implement the steps of the task processing method described in this specification. In some possible implementation manners, each aspect of this specification can also be implemented in the form of a program product, which includes program code. When the program product runs on an electronic device 200, the program code is used to cause the electronic device 200 to execute the steps of the task processing method described in this specification. The program product for implementing the above method can adopt a portable compact disc read-only memory (CD-ROM) including program code and can run on the electronic device 200. However, the program product of this specification is not limited thereto. In this specification, the readable storage medium can be any tangible medium that contains or stores a program, and the program can be used by or in combination with an instruction execution system. The above program product can adopt any combination of one or more readable media. The readable media can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. The above computer-readable storage medium can include a data signal propagated in a baseband or as a part of a carrier wave, in which the readable program code is carried. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable storage medium can also be any readable medium other than the readable storage medium, and the readable medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code included on the readable storage medium can be transmitted by any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above. The program code for executing the operations of this specification can be written in any combination of one or more programming languages, and the above programming languages include object-oriented programming languages - such as Java, C++, etc., and also include conventional procedural programming languages - such as the "C" language or similar programming languages. The program code can be executed entirely on the electronic device 200, partially on the electronic device 200, executed as an independent software package, partially on the electronic device 200 and partially on a remote computing device, or entirely on the remote computing device.
[0184] The above description has been made of specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the acts or steps recited in the claims can be performed in a different order than in the embodiments and still achieve the desired result. Additionally, the processes depicted in the figures do not necessarily require a particular order or a sequential order to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0185] In summary, after reading this detailed disclosure, those skilled in the art will appreciate that the foregoing detailed disclosure may be presented by way of example only and is not necessarily limiting. Although not explicitly stated herein, those skilled in the art will understand that this specification is intended to encompass various reasonable changes, improvements, and modifications to the embodiments. These changes, improvements, and modifications are intended to be proposed by this specification and are within the spirit and scope of the exemplary embodiments of this specification.
[0186] Furthermore, certain terms in this specification have been used to describe embodiments of this specification. For example, "one embodiment", "an embodiment", and / or "some embodiments" mean that the particular features, structures, or characteristics described in connection with that embodiment may be included in at least one embodiment of this specification. Thus, it should be emphasized and understood that two or more references to "an embodiment" or "one embodiment" or "alternative embodiments" in various parts of this specification do not necessarily all refer to the same embodiment. Additionally, the particular features, structures, or characteristics may be appropriately combined in one or more embodiments of this specification.
[0187] It should be understood that in the foregoing description of the embodiments of this specification, for the purpose of helping to understand a feature and for the purpose of simplifying this specification, this specification combines various features in a single embodiment, drawing, or its description. However, this does not mean that the combination of these features is necessary, and those skilled in the art may well mark out some of the devices as separate embodiments when reading this specification. That is to say, the embodiments in this specification can also be understood as the integration of multiple sub - embodiments. And it also holds when the content of each sub - embodiment contains less than all the features of a single foregoing disclosed embodiment.
[0188] Each patent, patent application, published patent application, and other materials cited herein, such as articles, books, specifications, publications, documents, items, etc., may be incorporated herein by reference, except for content that may be inconsistent with or in conflict with the present disclosure in the documents associated with the present disclosure, or any content that may have a limiting effect on the broadest scope of the claims. For example, in the event of any inconsistency or conflict between the description, definition, and / or use of terms associated with any of the incorporated materials and the terms, descriptions, definitions, and / or uses associated with the present disclosure, the terms of the present disclosure shall prevail.
[0189] Finally, it should be understood that the embodiments of the application disclosed herein are illustrative of the principles of the embodiments of this specification. Other modified embodiments are also within the scope of this specification. Therefore, the embodiments disclosed in this specification are merely examples and not limitations. Those skilled in the art can adopt alternative configurations based on the embodiments in this specification to implement the application in this specification. Therefore, the embodiments of this specification are not limited to the embodiments precisely described in the application.
Claims
1. A task processing method, comprising: Responding to a task request for a large model application, determining a plurality of tasks corresponding to the task request, the tasks including at least one task operation, and the task operation including invoking an external interface of the large model application; Converting the plurality of tasks into a task graph, the task graph including a plurality of task nodes, and the task nodes representing the task operations corresponding to the tasks; And Executing, by a graph engine, the task operations corresponding to the respective task nodes in the task graph.
2. The method according to claim 1, wherein, The task request corresponds to a plurality of task data elements, and the task data elements are data elements related to the tasks determined based on the task request. The converting the plurality of tasks into a task graph includes: Determining the at least one task operation corresponding to the task based on the task data elements; and Generating the task graph in a graph data format based on the task operations corresponding to the respective tasks, wherein each task operation corresponds to one task node.
3. The method according to claim 2, wherein, The determining the at least one task operation corresponding to the task based on the task data elements includes: Generating task processing code corresponding to the task based on the task data elements, the task processing code being used to invoke the at least one task operation corresponding to the task and obtain a task processing result; Generating multi-task processing result code corresponding to the plurality of tasks based on the task processing results corresponding to the respective task processing codes, the multi-task processing result code being used to summarize the respective task processing results, The generating the task graph in a graph data format based on the task operations corresponding to the respective tasks includes: Generating the task graph in a graph data format based on the task processing code and the multi-task processing result code.
4. The method according to claim 3, wherein The task processing code includes a task invocation code and a result parsing code. The task invocation code is used to invoke the task operation corresponding to the task, and the result parsing code is used to parse the invocation result of the task invocation code. The generating the multi-task processing result code corresponding to the plurality of tasks based on the task processing results corresponding to the respective task processing codes includes: Generating the multi-task processing result code corresponding to the plurality of tasks based on the parsing results corresponding to the respective result parsing codes.
5. The method according to claim 3, wherein The generating the task graph in a graph data format based on the task processing code and the multi-task processing result code includes: Converting the respective task processing codes and the multi-task processing result code into task nodes of the task graph; and Generating the dependency relationships between the respective task nodes in the task graph based on the dependency relationships between the respective tasks.
6. The method according to claim 1, wherein The responding to a task request for a large model application and determining a plurality of tasks corresponding to the task request includes: Responding to a task request for a large model application and determining a plurality of task data elements corresponding to the task request; and Determining a plurality of tasks corresponding to the task request based on the plurality of task data elements, wherein each task corresponds to at least one of the task operations.
7. The method according to claim 6, wherein In response to a task request for a large model application, determining a plurality of task data elements corresponding to the task request, including: In response to a task request for the large model application, determining a task intent corresponding to the task request and a plurality of task data elements corresponding to the task intent; Based on the plurality of task data elements, determining a plurality of tasks corresponding to the task request, including: Based on the task intent and the plurality of task data elements, determining a plurality of tasks corresponding to the task request.
8. The method according to claim 6, wherein The method further includes: Performing dynamic data mapping on the data elements corresponding to each of the task nodes to generate a unique identifier corresponding to the data element, where the data element includes the task data element and a task result element corresponding to the task data element.
9. The method according to claim 8, wherein, Performing dynamic data mapping on the data elements corresponding to each of the task nodes to generate a unique identifier corresponding to the data element, including: Generating a unique index value for the data element corresponding to each of the task nodes, and adding the unique index value to the element name of the data element.
10. The method according to claim 1, wherein The task graph further includes a dependency relationship between each of the task nodes. Executing the task operations corresponding to each of the task nodes in the task graph through a graph engine includes: Based on the dependency relationship between each of the task nodes, executing the task operations corresponding to each of the task nodes in the task graph through a graph engine.
11. The method according to claim 10, wherein, Based on the dependency relationship between each of the task nodes, executing the task operations corresponding to each of the task nodes in the task graph through a graph engine includes: Dividing the task graph into a plurality of parallel task nodes based on the dependency relationship between each of the task nodes; Parallelly executing the task operations corresponding to each of the parallel task nodes through the graph engine.
12. The method according to claim 10, wherein, Executing the task operations corresponding to each of the task nodes in the task graph through a graph engine includes: Dynamically adjusting the execution plan of each of the task nodes according to the resource requirements of each of the task nodes; Based on the execution plan, executing the task operations corresponding to each of the task nodes in the task graph through the graph engine.
13. The method according to claim 1, wherein, The method further includes: Obtaining a task processing result corresponding to the task operation of each of the tasks; Storing the task processing result of the task in the context corresponding to the task in the graph engine.
14. An electronic device, including: At least one storage medium storing at least one instruction set for task processing; And At least one processor communicatively connected to the at least one storage medium, wherein, when the electronic device runs, the at least one processor reads the at least one instruction set and executes the task processing method according to any one of claims 1-13 based on the indication of the at least one instruction set.