Task planning method and device based on hybrid model, equipment, medium and product

By using hybrid models in task planning, including large language models, text embedding modules and graph neural networks, the problem that large language models in the prior art cannot explicitly reflect the task planning paths, and high accuracy and interpretability task planning is achieved.

CN119886322AActive Publication Date: 2025-04-25PEKING UNIV
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411637369.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-15
Publication Date
2025-04-25
Estimated Expiration
2044-11-15

AI Technical Summary

Technical Problem

In the prior art, the task planning path cannot be explicitly reflected when using large language models to plan tasks alone, resulting in inaccurate and interpretable task planning.

Method used

Using a task planning method based on a hybrid model, the user request is input to the first largest language model to obtain subtasks, and input directed text graphs to the text embedding module and graph neural network, node feature embedding and aggregation is performed, and the answer is finally generated from the second largest language model.

Benefits of technology

Accurate, high reliability and interpretable task planning are achieved, and subtasks can be output intuitively and answers that meet user requests are generated, avoiding the performance degradation of large language models when processing graph structure data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119886322A_ABST
    Figure CN119886322A_ABST
Patent Text Reader

Abstract

The invention provides a task planning method and device based on a hybrid model, equipment, a medium and a product, and the method comprises the steps: inputting a user request into a first large language model in the hybrid model, and obtaining a plurality of subtasks; the plurality of subtasks are output in the form of a directed text graph; inputting the directed text graph into a text embedding module, and converting the text feature of each node in the directed text graph into an embedded vector; inputting the embedded vector into a graph neural network to obtain an aggregation feature corresponding to each node; inputting the aggregation feature corresponding to each node into a second large language model to obtain an answer for the user request; wherein the answers comprise sub-answers for each sub-task. According to the method and the device, respective advantages of the graph neural network and the large language model are combined, so that the user request is explicitly disassembled into a plurality of sub-tasks, and accurate, high-reliability and interpretable task planning is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a task planning method, device, equipment, medium and product based on a hybrid model. Background Art

[0002] Task planning is a key research direction in artificial intelligence, which involves interpreting and breaking down complex user instructions into specific and solvable subtasks, and then satisfying the user's request by executing each subtask.

[0003] Large Language Models (LLMs) can be used for tasks such as natural language understanding and interactive knowledge query due to their rich knowledge reserves and powerful reasoning capabilities. With the application of the Chain-of-Thoughts (CoT) method, large language models have achieved remarkable success in logical reasoning and complex task analysis, and can decompose complex tasks into a series of subtasks. Although the Chain-of-Thoughts method can enable large language models to learn to handle problems step by step, this way of thinking of handling problems step by step is only reflected in LLMs, which only shows the step-by-step logical reasoning process. That is, LLMs output a step-by-step calculation process, answering step by step until the final result is obtained, but it does not output the problem to be solved in each step. In other words, LLM directly executes subtasks to obtain the results of each subtask, without decomposing user requests into different subrequests and outputting each subrequest.

[0004] It can be seen from this that when using a large language model for task planning, it cannot reflect the complete task decomposition process and cannot explicitly reflect the task planning path. Summary of the invention

[0005] The present invention provides a hybrid model-based task planning method, device, equipment, medium and product, which are used to solve the defect that the task planning path cannot be displayed when a large language model is used alone for task planning in the prior art, and realize accurate, highly reliable and explainable task planning, which can output subtasks intuitively and output answers that meet user requests.

[0006] The present invention provides a task planning method based on a hybrid model, wherein the hybrid model comprises a first large language model, a text embedding module, a graph neural network and a second large language model connected in sequence, and the method comprises the following steps.

[0007] Inputting the user request into the first language model in the hybrid model that has completed training, and obtaining a plurality of subtasks output by the first language model; wherein the plurality of subtasks and the dependency relationships between the subtasks are output in the form of a directed text graph; Inputting the directed text graph into the text embedding module in the hybrid model that has completed training, so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node; Inputting the embedding vectors and the dependency relationship between the embedding vectors into the graph neural network in the hybrid model that has been trained, and aggregating the embedding vectors according to the dependency relationship between the embedding vectors using the graph neural network to obtain the aggregated features corresponding to each node; Inputting the aggregated features corresponding to each node into the second largest language model in the hybrid model that has completed training, and obtaining an answer to the user request output by the second largest language model; wherein the answer includes a sub-answer to each subtask; Among them, the hybrid model that has completed training is obtained by pre-training the text embedding module and graph neural network in the pre-built hybrid model based on the preset graph structure data, and by fine-tuning the text embedding module and graph neural network in the pre-trained hybrid model based on the preset fine-tuning instruction set.

[0008] According to a hybrid model-based task planning method provided by the present invention, the text embedding module includes a pre-trained language representation model and a multi-layer perceptron; the directed text graph is input into the text embedding module in the hybrid model that has been trained so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node, including: Inputting the directed text graph into the pre-trained language representation model, using the pre-trained language representation model to initially encode the text of each node in the directed text graph to obtain an initial vector corresponding to each node; The initial vector corresponding to each node is input into the multi-layer perceptron to obtain the embedding vector corresponding to each node.

[0009] According to a hybrid model-based task planning method provided by the present invention, the embedding vectors and the dependency relationship between the embedding vectors are input into the graph neural network in the hybrid model that has been trained, and the graph neural network is used to aggregate the embedding vectors according to the dependency relationship between the embedding vectors to obtain the aggregated features corresponding to each node, including: Take each node as a node to be processed, and randomly sample a preset number of neighboring nodes from the neighboring nodes of the node to be processed; Performing feature aggregation on the preset number of neighbor nodes to obtain aggregated neighbor features; The aggregated neighbor features are concatenated with the node to be processed to obtain the aggregated features corresponding to the node to be processed.

[0010] According to a hybrid model-based task planning method provided by the present invention, the feature aggregation of the neighbor nodes to obtain aggregated neighbor features includes: A mean aggregator is used to perform feature aggregation on neighbor nodes of the node to be processed to obtain the aggregated neighbor features.

[0011] According to a hybrid model-based task planning method provided by the present invention, the hybrid model that has been trained is obtained by training in the following manner, including: Using the preset graph structure data, pre-training the text embedding module and the graph neural network in the pre-built hybrid model to obtain a pre-trained hybrid model; wherein the parameters of the first language model and the parameters of the second language model in the hybrid model are frozen; Based on a preset fine-tuning instruction set, the text embedding module and the graph neural network in the pre-trained hybrid model are fine-tuned to obtain the hybrid model that has completed training; wherein the parameters of the first largest language model in the hybrid model are frozen; the preset fine-tuning instruction set includes task planning data represented by question-answer pairs, and the task planning data represented by question-answer pairs is graph structure data.

[0012] According to a hybrid model-based task planning method provided by the present invention, the text embedding module and the graph neural network in the pre-built hybrid model are pre-trained by using preset graph structure data to obtain a pre-trained hybrid model, including: Using the preset graph structure data, the text embedding module and graph neural network in the pre-built hybrid model are pre-trained with any one or more of node classification, graph understanding, path exploration, and node counting as the goal to obtain the pre-trained hybrid model.

[0013] The present invention also provides a task planning device based on a hybrid model, wherein the hybrid model includes a first large language model, a text embedding module, a graph neural network, and a second large language model connected in sequence, and the device includes: A task planning module, used for inputting a user request into a first language model in a hybrid model that has completed training, and obtaining a plurality of subtasks output by the first language model; wherein the plurality of subtasks and dependencies between the subtasks are output in the form of a directed text graph; A text embedding module, used for inputting the directed text graph into the text embedding module in the hybrid model that has been trained, so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node; A node feature aggregation module, used to input the embedding vectors and the dependency relationship between the embedding vectors into the graph neural network in the hybrid model that has been trained, and use the graph neural network to aggregate the embedding vectors according to the dependency relationship between the embedding vectors to obtain the aggregation feature corresponding to each node; An answer output module, used to input the aggregated features corresponding to each node into the second largest language model in the hybrid model that has completed training, and obtain an answer to the user request output by the second largest language model; wherein the answer includes a sub-answer to each subtask; Among them, the hybrid model that has completed training is obtained by pre-training the text embedding module and graph neural network in the pre-built hybrid model based on the preset graph structure data, and by fine-tuning the text embedding module and graph neural network in the pre-trained hybrid model based on the preset fine-tuning instruction set.

[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the task planning method based on the hybrid model as described above is implemented.

[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the hybrid model-based task planning methods described above.

[0016] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the hybrid model-based task planning method described above is implemented.

[0017] The hybrid model-based task planning method, device, equipment, medium and product provided by the present invention are constructed by constructing a hybrid model, which includes a first large language model, a text embedding module, a graph neural network and a second large language model connected in sequence; and by inputting a user request into the first large language model in the hybrid model that has been trained, a plurality of subtasks output by the first large language model are obtained; wherein the plurality of subtasks and the dependency relationships between the subtasks are output in the form of a directed text graph; the directed text graph is input into the text embedding module in the hybrid model that has been trained, so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node; the embedding vectors and the dependency relationships between the embedding vectors are input into the graph neural network in the hybrid model that has been trained, and the graph neural network is used to aggregate the embedding vectors to obtain the aggregated features corresponding to each node; the aggregated features corresponding to each node are input into the second large language model in the hybrid model that has been trained, and the answer to the user request output by the second large language model is obtained; wherein the answer includes a sub-answer for each subtask. This application first uses a large language model with frozen parameters to decompose user requests into multiple subtasks, and represents its output as a directed text graph. Since existing large language models are usually difficult to directly understand and process graph structure data, when processing graph structure data, it is necessary to compress the two-dimensional graph structure into a one-dimensional natural language sequence and then input it into the large language model, which will cause the performance of the large language model to deteriorate. In dealing with this problem, this application uses the advantage of graph neural networks being good at processing graph structure data, embeds the node features in the directed text graph into a low-dimensional space, and obtains a node representation that integrates local and global information through a series of feature aggregation and transfer operations, so that the original user request is represented as graph structure data after being decomposed into multiple subtasks, which is conducive to the graph neural network to give full play to its own advantages and select the optimal path or subgraph as a reference, accurately explore the logical dependencies between tasks, find the optimal path, and facilitate the subsequent large language model to efficiently execute each subtask to obtain each sub-answer, and can ensure the accuracy of the final answer to the entire user request, avoiding the large language model from falling into hallucinations. This application utilizes the ability of graph neural networks to process graph data, making up for the shortcomings of large language models in processing graph structures, and fully utilizing the rich knowledge reserves and powerful reasoning capabilities of large language models. It combines the respective advantages of graph neural networks and large language models, and overcomes the defect that the task planning path cannot be explicitly reflected when using large language models alone for task planning, so that user requests can be decomposed into multiple subtasks, achieving accurate, highly reliable and explainable task planning. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 It is a module schematic diagram of the hybrid model provided by the present invention.

[0020] Figure 2 It is one of the flow charts of the task planning method based on the hybrid model provided by the present invention.

[0021] Figure 3 This is the second flow chart of the hybrid model-based task planning method provided by the present invention.

[0022] Figure 4 It is an example schematic diagram of the directed text graph provided by the present invention.

[0023] Figure 5 It is a schematic diagram of the model answer of the final output provided by the present invention.

[0024] Figure 6 It is a structural schematic diagram of a task planning device based on a hybrid model provided by the present invention.

[0025] Figure 7 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] Combine the following Figure 1-Figure 7 Specific embodiments of the present invention are described.

[0028] Figure 1 1 is a schematic diagram of a module of a hybrid model provided by the present invention. The hybrid model constructed in the present application includes a first large language model 101, a text embedding module 102, a graph neural network 103 and a second large language model 104 connected in sequence. The first large language model 101 and the second large language model can be the same model or different large language models.

[0029] Figure 2is one of the flow charts of the task planning method based on the hybrid model provided by the present invention, such as Figure 2 As shown, the method includes the following.

[0030] Step 201, input the user request into the first largest language model in the hybrid model that has completed training, and obtain multiple subtasks output by the first largest language model; wherein the multiple subtasks and the dependency relationships between the subtasks are output in the form of a directed text graph.

[0031] Here, a user request refers to a question that a user inputs into the system. For example, the user inputs: "Please help me solve the following math problem: a conical container has a bottom radius of 5 cm and a height of 12 cm. If this container is inverted and exactly half submerged in water, calculate the volume submerged in water (assuming π=3.14 and the density of water is 1g / cm³)".

[0032] The above user request is preferably input into the first largest language model, which is a large language model with frozen parameters (for example, it can be Qwen2-7B-Instruct, the open source model Qwen2-7B-Instruct is an instruction fine-tuning model in the Tongyi Qianwen series. It performs instruction fine-tuning based on Qwen2-7B to improve the performance of the model on specific tasks), and the first largest language model is used to decompose the user request into multiple specific sub-tasks.

[0033] It should be noted that the multiple subtasks output by the first language model and the dependencies between the subtasks are presented in the form of a directed text graph.

[0034] A directed text graph is a special data structure that combines concepts from text data and graph theory. In this structure, text is represented as nodes in a graph, and directed edges between nodes represent some kind of relationship or dependency between text fragments. A directed text graph consists of nodes and edges, where each node represents a subtask; each edge connects nodes and represents some kind of relationship between nodes. In a directed text graph, edges are directed, which means that the relationships are ordered. For example, an edge from node A to node B may represent a relationship such as "A is a prerequisite for B" or "B depends on A".

[0035] Specifically, still using the above example, after the complex task request input by the user is passed to the first language model with the parameter frozen, the model is responsible for decomposing the user request into multiple specific subtasks and generating a directed text graph containing these subtasks and their mutual dependencies. For example, the system provides the following prompt to the first language model: "Please decompose the above problem into a series of interrelated subtasks and represent these tasks in the form of a directed graph. Each node should represent a subtask or calculation step, and the edge represents the dependency between tasks. Please make sure to cover all necessary calculation steps and consider the intermediate results that may be required. Output format example: Node 1: [step description]; Node 2: [step description]... Relationship matrix (expressed in Python list format, 1 indicates dependency, 0 indicates no dependency): [[0, 1, 1, 0, 0, 0], ..., [0, 0, 0, 1, 0, 0]]". Then, the first language model outputs the following task decomposition results.

[0036] Node 1: Calculate the total volume of the cone; Node 2: Calculate the midpoint of the cone’s height; Node 3: Calculate the volume of a small cone with a base radius of 5 cm and a height of 6 cm; Node 4: Calculate the volume difference between the large cone (total cone) and the small cone; Node 5: Verify the rationality of the results; Node 6: Output the final answer, including the units.

[0037] Node relationship matrix (also called adjacency matrix): [[0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0]].

[0038] Figure 3 The second flowchart of the task planning method based on the hybrid model is shown as follows: Figure 3 As shown, the hybrid model-based task planning method in the present application can clearly divide user requests into two stages: task planning and task execution. By outputting subtasks represented as directed text graphs through the above-mentioned large language model, the subtasks can be output explicitly.

[0039] The directed text output by the first language model is as follows Figure 4 shown.

[0040] Step 202: input the directed text graph into a text embedding module in the hybrid model that has been trained, so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node.

[0041] Among them, the text embedding module is a core technical component in Natural Language Processing (NLP). Its core function is to convert text data (such as words, phrases, sentences or paragraphs) into fixed-size real number vectors that can capture the semantic information in the text. The text embedding module in this application is implemented by combining a pre-trained BERT (Bidirectional Encoder Representations from Transformers) model and a single-layer multi-layer perceptron (Multi Layer Perceptron, MLP). It can also be other network structures, which are not limited in this article.

[0042] The pre-trained encoder in the text embedding module is optional. This application selects BERT as the encoder. First, the pre-trained encoder BERT converts the text into an initial vector, and then a single-layer MLP maps the initial vector to an embedding vector, so that each input text can be richly represented with contextual information (refer to Figure 5 as shown).

[0043] Specifically, the text embedding module converts the text features of each subtask node in the directed text graph into an embedding vector.

[0044] Step 203: input the embedding vectors and the dependencies between the embedding vectors into the graph neural network in the hybrid model that has been trained, and use the graph neural network to aggregate the embedding vectors to obtain the aggregated features corresponding to each node.

[0045] Among them, Graph Neural Network (GNN) is a type of deep learning model used to process graph structured data. Entities in graph structured data are represented as nodes, and the relationships between entities are represented as edges. In this application, GraphSage is selected as the graph neural network. GraphSage is a graph neural network algorithm proposed in 2017. Other graph neural networks can also be used, and this article does not limit this.

[0046] The basic components of graph neural networks include: (1) Node feature matrix: used to represent the initial features of each node in the graph. (2) Adjacency matrix: used to represent the connection relationship between nodes in the graph. (3) Graph convolution layer: used to aggregate the information of neighbor nodes and update node features.

[0047] Specifically, the above embedding vectors and the dependencies between the embedding vectors (i.e., the above node relationship matrix) are input into the graph neural network. The core idea of ​​the graph neural network is to aggregate the neighbor information of the node through the message-passing mechanism, and concatenate its neighbor information with the node itself to update the feature representation of each node. This process usually goes through multiple rounds of iterations to capture information at a greater distance in the graph. Finally, the feature representation of each node (i.e., aggregated features) is output. At this point, the feature representation of each node (i.e., the aggregated features corresponding to each node) will contain information about its neighbors and more distant nodes.

[0048] Step 204, inputting the aggregated features corresponding to each node into the second largest language model in the hybrid model that has completed training, and obtaining an answer to the user request output by the second largest language model; wherein the answer includes a sub-answer for each subtask.

[0049] The second largest language model may be the same as or different from the first largest language model. In this embodiment, the same model as the second largest language model is used, that is, the open source model Qwen2-7B-Instruct.

[0050] Specifically, the node features processed by the above graph neural network GraphSage are input into the second largest language model (Qwen2-7B-Instruct) to generate the final reasoning results and answers. The second largest language model outputs detailed problem-solving steps (i.e., sub-answers for each subtask. The following paragraphs do not show the problem-solving steps. For details, see the attached Figure 5 ) and the final answer, including the following 6 nodes: (1) Calculate the total volume of the cone; (2) Calculate the midpoint of the cone’s height; (3) Calculate the volume of a small cone; (4) Calculate the volume difference; (5) Verify the rationality of the results; (6) Express the final answer.

[0051] In the above embodiment, a hybrid model is constructed, which includes a first large language model, a text embedding module, a graph neural network and a second large language model connected in sequence; and a user request is input into the first large language model in the hybrid model that has been trained to obtain multiple subtasks output by the first large language model; wherein the multiple subtasks and the dependencies between the subtasks are output in the form of a directed text graph; the directed text graph is input into the text embedding module in the hybrid model that has been trained, so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node; the embedding vectors and the dependencies between the embedding vectors are input into the graph neural network in the hybrid model that has been trained, and the graph neural network is used to aggregate the embedding vectors to obtain the aggregated features corresponding to each node; the aggregated features corresponding to each node are input into the second large language model in the hybrid model that has been trained to obtain the answer to the user request output by the second large language model; wherein the answer includes a sub-answer for each subtask. This application first uses a large language model with frozen parameters to decompose user requests into multiple subtasks, and represents its output as a directed text graph. Since existing large language models are usually difficult to directly understand and process graph structure data, when processing graph structure data, it is necessary to compress the two-dimensional graph structure into a one-dimensional natural language sequence and then input it into the large language model, which will cause the performance of the large language model to deteriorate. In dealing with this problem, this application uses the advantage of graph neural networks being good at processing graph structure data, embeds the node features in the directed text graph into a low-dimensional space, and obtains a node representation that integrates local and global information through a series of feature aggregation and transfer operations, so that the original user request is represented as graph structure data after being decomposed into multiple subtasks, which is conducive to the graph neural network to give full play to its own advantages and select the optimal path or subgraph as a reference, accurately explore the logical dependencies between tasks, find the optimal path, and facilitate the subsequent large language model to efficiently execute each subtask to obtain each sub-answer, and can ensure the accuracy of the final answer to the entire user request, avoiding the large language model from falling into hallucinations. This application utilizes the ability of graph neural networks to process graph data, making up for the shortcomings of large language models in processing graph structures, and fully utilizing the rich knowledge reserves and powerful reasoning capabilities of large language models. It combines the respective advantages of graph neural networks and large language models, and overcomes the defect that the task planning path cannot be explicitly reflected when using large language models alone for task planning, so that user requests can be decomposed into multiple subtasks, achieving accurate, highly reliable and explainable task planning.

[0052] In one embodiment, the text embedding module includes a pre-trained language representation model and a multi-layer perceptron; the step 202 includes: inputting the directed text graph into the pre-trained language representation model, using the pre-trained language representation model to initially encode the text of each node in the directed text graph to obtain an initial vector corresponding to each node; inputting the initial vector corresponding to each node into the multi-layer perceptron to obtain the embedding vector corresponding to each node.

[0053] The pre-trained language representation model may be a pre-trained BERT (Bidirectional Encoder Representations from Transformers) model. By using the encoder structure of the Transformer, the BERT model can simultaneously learn contextual information from both the left and right directions of the text, so that the model can better understand the semantics of each word in the sentence, learn to obtain rich contextual representations, and ultimately obtain a rich representation of each input text.

[0054] Specifically, the directed text graph is input into a pre-trained language representation model (i.e., BERT model), and the pre-trained BERT model is used to initially encode the text corresponding to each node to obtain an initial vector corresponding to each node, for example, each node corresponds to a 768-dimensional vector representation.

[0055] The initial vector corresponding to each node is input into a multi-layer perceptron (MLP) of one layer. The structure of the MLP includes an input layer and an output layer. The structures of the input layer and the output layer are exemplified as follows.

[0056] (1) Input layer: 768 neurons.

[0057] (2) Output layer: 4096 neurons, the output is the final embedding vector.

[0058] For the above 6 nodes, 6 embedding vectors are finally obtained, and the length of each embedding vector is 4096 dimensions.

[0059] The above embodiment, by using a pre-trained language representation model and a multi-layer perceptron to build a text embedding module, using the BERT model to convert the text into an initial vector, and a multi-layer perceptron (MLP) to convert the initial vector into an embedding vector, can accurately mine the semantic representation in the text and provide an effective and accurate data foundation for subsequent graph neural networks.

[0060] In one embodiment, the above step 203 includes: taking each node as a node to be processed, randomly sampling from the neighboring nodes of the node to be processed to obtain a preset number of neighboring nodes; performing feature aggregation on the preset number of neighboring nodes to obtain aggregated neighbor features; and splicing the aggregated neighbor features with the node to be processed to obtain the aggregated features corresponding to the node to be processed.

[0061] Specifically, the graph neural network GraphSage processes information through the following steps.

[0062] a. Initialization: Use the above embedding vector with a length of 4096 as the initial feature of each node, that is, the initial feature of the node to be processed.

[0063] b. Neighbor sampling: According to the dependency relationship between the embedded vectors, all neighbor nodes of the node to be processed are found, and a preset number of neighbor nodes are randomly sampled from the neighbor nodes of the node to be processed, for example, 10 neighbor nodes are sampled.

[0064] c. Information aggregation: Use the Mean Aggregator to aggregate the features of the 10 neighbor nodes obtained by sampling.

[0065] d. Feature update: Concatenate the aggregated neighbor features with the features of the node to be processed to obtain the aggregate features corresponding to each node, and output the updated aggregate features through a fully connected layer.

[0066] Repeat steps bd multiple times (for example, twice) to obtain the final node representation.

[0067] In the above-mentioned embodiment, by processing the graph structure data through the graph neural network, it is possible to obtain a node representation containing accurate logical association relationships, which is conducive to the subsequent large language model to obtain accurate answers.

[0068] In one embodiment, the hybrid model that has been trained is obtained by training in the following manner, including:

[0069] Using the preset graph structure data, pre-training the multi-layer perceptron and the graph neural network in the pre-built hybrid model to obtain a pre-trained hybrid model; wherein the parameters of the first language model and the parameters of the second language model in the hybrid model are frozen; Based on a preset fine-tuning instruction set, the multilayer perceptron and graph neural network in the pre-trained hybrid model are fine-tuned to obtain the hybrid model that has completed training; wherein the parameters of the first largest language model in the hybrid model are frozen; the preset fine-tuning instruction set includes task planning data represented by question-answer pairs, and the task planning data represented by question-answer pairs is graph structure data.

[0070] Optionally, the pre-training process adopts a multi-task learning strategy, and the task objectives can be any one or more of node classification, graph understanding, path exploration, and node counting.

[0071] Specifically, the present application adopts a two-stage training method to train the pre-built hybrid model.

[0072] Stage 1: Multi-task graph pre-training.

[0073] 1. Data preparation: Collect a variety of open source graph datasets, including but not limited to social network graphs, knowledge graphs, molecular graphs, etc., and preprocess these data to obtain training data suitable for different purposes, such as node classification, graph understanding, path exploration, and node counting.

[0074] 2. Task design: including node classification, graph understanding, path exploration and node counting. Among them: Node classification task: used to predict the category or attribute of nodes in the graph; Graph understanding task: used to generate a summary or description of the entire graph structure; Path exploration task: find the shortest path or all possible paths between two given nodes; Node counting task: Count the number of nodes that meet specific conditions.

[0075] 3. Optimize the objective function: Use the cross entropy loss function as the objective function.

[0076] 4. Pre-training process: adopt a multi-task learning strategy, randomly use any of the above four graph tasks in each batch of data; use the Adam optimizer to update parameters. In the pre-training stage, the parameters of the first and second language models are frozen. Since end-to-end training will increase the computational overhead of the entire hybrid model, and the first language model is mainly used for task decomposition, it has the ability to decompose tasks. Therefore, in order to save computational overhead, the parameters of the first language model are frozen; the second language model is used to perform logical reasoning on each subtask and output the answer. In order to align the graph neural network and the multi-layer perceptron, the parameters of the second language model need to be frozen to ensure the stability of the training. In addition, the parameters of the language representation model (BERT model) in the hybrid model are also kept frozen during the pre-training process.

[0077] 5. Evaluation and adjustment: Monitor the performance indicators of each task on the validation set; dynamically adjust the task weights and learning rates based on the validation results.

[0078] Phase 2: Fine-tuning instructions.

[0079] 1. Instruction set generation: Each instruction in the instruction set is represented in the form of a question-answer pair. Specifically, a generative pre-trained transformer (such as GPT-4) is used to generate a large number of diverse task planning problems, including mathematical problems, logical reasoning, complex decision-making, etc.; for each problem, a generative pre-trained transformer (such as GPT-4) is used to generate the corresponding task decomposition diagram and detailed answer.

[0080] 2. Data screening and enhancement: Manually review the data generated by GPT-4 to ensure quality and diversity; manually enhance the screened data to add more complex boundary cases and special considerations.

[0081] 3. Instruction fine-tuning settings: Use the filtered high-quality data set to fine-tune the pre-trained model; use a low learning rate (such as 5e-6) and a small batch size (such as 4 or 8) to prevent overfitting; use LoRA (Low-Rank Adaptation) technology to reduce the number of trainable parameters and improve efficiency. During the instruction fine-tuning stage, the parameters of the first language model are still frozen to save computing overhead, while the parameters of the second language model are not frozen. It is necessary to ensure that the parameters of the second language model are updated synchronously with the parameters of the graph neural network and the multi-layer perceptron. In addition, the parameters of the language representation model (BERT model) in the hybrid model also remain frozen during the instruction fine-tuning stage.

[0082] 4. Performance evaluation: Use a manually constructed test set to evaluate the model’s performance in task planning and answer generation; perform manual evaluation to determine the quality and rationality of the generated task planning diagrams and answers.

[0083] The above embodiment adopts a two-stage training method of pre-training + instruction fine-tuning, and adopts a multi-task training strategy. Different types of training data are used to pre-train the hybrid model, which can improve the hybrid model's ability to understand different tasks and improve the accuracy of the model's output answers.

[0084] The task planning device based on the hybrid model provided by the present invention is described below. The task planning device based on the hybrid model described below and the task planning method based on the hybrid model described above can be referred to each other.

[0085] like Figure 6 As shown, Figure 6 A structural schematic diagram of a task planning device based on a hybrid model provided in the present application is shown, wherein the hybrid model includes a first large language model, a text embedding module, a graph neural network and a second large language model connected in sequence, and the device includes.

[0086] The task planning module 601 is used to input the user request into the first language model in the hybrid model that has been trained, and obtain multiple subtasks output by the first language model; wherein the multiple subtasks and the dependency relationships between the subtasks are output in the form of a directed text graph; A text embedding module 602 is used to input the directed text graph into the text embedding module in the hybrid model that has been trained, so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node; A node feature aggregation module 603 is used to input the embedding vectors and the dependency relationship between the embedding vectors into the graph neural network in the hybrid model that has been trained, and use the graph neural network to aggregate the embedding vectors according to the dependency relationship between the embedding vectors to obtain the aggregation feature corresponding to each node; The answer output module 604 is used to input the aggregated features corresponding to each node into the second largest language model in the hybrid model that has been trained, and obtain the answer to the user request output by the second largest language model; wherein the answer includes a sub-answer for each subtask; Among them, the hybrid model that has completed training is obtained by pre-training the text embedding module and graph neural network in the pre-built hybrid model based on the preset graph structure data, and by fine-tuning the text embedding module and graph neural network in the pre-trained hybrid model based on the preset fine-tuning instruction set.

[0087] In one embodiment, the text embedding module includes a pre-trained language representation model and a multi-layer perceptron; the text embedding module 602 is further used to: The directed text graph is input into the pre-trained language representation model, and the pre-trained language representation model is used to initially encode the text of each node in the directed text graph to obtain an initial vector corresponding to each node; the initial vector corresponding to each node is input into the multi-layer perceptron to obtain the embedding vector corresponding to each node.

[0088] In one embodiment, the node feature aggregation module 603 is further used to: Each node is taken as a node to be processed, and a preset number of neighbor nodes are randomly sampled from the neighbor nodes of the node to be processed; features of the preset number of neighbor nodes are aggregated to obtain aggregated neighbor features; the aggregated neighbor features are spliced ​​with the node to be processed to obtain the aggregated features corresponding to the node to be processed.

[0089] In one embodiment, the node feature aggregation module 603 is further used to: A mean aggregator is used to perform feature aggregation on neighbor nodes of the node to be processed to obtain the aggregated neighbor features.

[0090] In one embodiment, a model training unit is further included, which is used to: Using preset graph structure data, the text embedding module and graph neural network in the pre-built hybrid model are pre-trained to obtain a pre-trained hybrid model; wherein the parameters of the first largest language model and the parameters of the second largest language model in the hybrid model are frozen; based on a preset fine-tuning instruction set, the text embedding module and the graph neural network in the pre-trained hybrid model are fine-tuned to obtain the hybrid model that has completed training; wherein the parameters of the first largest language model in the hybrid model are frozen; the preset fine-tuning instruction set includes task planning data represented by question-answer pairs, and the task planning data represented by question-answer pairs is graph structure data.

[0091] In one embodiment, the model training unit is further used to: Using the preset graph structure data, the text embedding module and graph neural network in the pre-built hybrid model are pre-trained with any one or more of node classification, graph understanding, path exploration, and node counting as the goal to obtain the pre-trained hybrid model.

[0092] Figure 7 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 7As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute a task planning method based on a hybrid model, the method comprising: inputting a user request into a first large language model in a hybrid model that has been trained, and obtaining a plurality of subtasks output by the first large language model; wherein the plurality of subtasks and the dependency relationships between the subtasks are output in the form of a directed text graph; inputting the directed text graph into a text embedding module in a hybrid model that has been trained, so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node; inputting the embedding vector and the dependency relationships between the embedding vectors into the hybrid model that has been trained. The graph neural network in the combined model utilizes the graph neural network to aggregate the embedding vectors according to the dependency relationship between the embedding vectors to obtain the aggregated features corresponding to each node; the aggregated features corresponding to each node are input into the second largest language model in the hybrid model that has been trained to obtain the answer to the user's request output by the second largest language model; wherein the answer includes a sub-answer for each subtask; wherein the hybrid model that has been trained is obtained by pre-training the text embedding module and the graph neural network in the pre-built hybrid model based on the preset graph structure data, and fine-tuning the text embedding module and the graph neural network in the pre-trained hybrid model based on the preset fine-tuning instruction set.

[0093] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0094] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the hybrid model-based task planning method provided by the above methods, the method comprising: inputting a user request into a first large language model in a hybrid model that has been trained to obtain multiple subtasks output by the first large language model; wherein the multiple subtasks and the dependencies between the subtasks are output in the form of a directed text graph; inputting the directed text graph into a text embedding module in the hybrid model that has been trained, so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node. ; Input the embedding vectors and the dependencies between the embedding vectors into the graph neural network in the hybrid model that has been trained, and use the graph neural network to aggregate the embedding vectors according to the dependencies between the embedding vectors to obtain the aggregated features corresponding to each node; Input the aggregated features corresponding to each node into the second largest language model in the hybrid model that has been trained to obtain the answer to the user's request output by the second largest language model; wherein the answer includes sub-answers for each subtask; wherein the hybrid model that has been trained is obtained by pre-training the text embedding module and the graph neural network in the pre-built hybrid model based on the preset graph structure data, and fine-tuning the text embedding module and the graph neural network in the pre-trained hybrid model based on the preset fine-tuning instruction set.

[0095] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the hybrid model-based task planning method provided by the above-mentioned methods, the method comprising: inputting a user request into a first large language model in a hybrid model that has been trained, and obtaining a plurality of subtasks output by the first large language model; wherein the plurality of subtasks and the dependency relationships between the subtasks are output in the form of a directed text graph; inputting the directed text graph into a text embedding module in the hybrid model that has been trained, so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node; converting the embedding vector, and the embedding vectors The dependencies between the two subtasks are input into the graph neural network in the hybrid model that has been trained, and the graph neural network is used to aggregate the embedding vectors according to the dependencies between the embedding vectors to obtain the aggregated features corresponding to each node; the aggregated features corresponding to each node are input into the second largest language model in the hybrid model that has been trained to obtain the answer to the user's request output by the second largest language model; wherein the answer includes a sub-answer for each subtask; wherein the hybrid model that has been trained is obtained by pre-training the text embedding module and the graph neural network in the pre-built hybrid model based on the preset graph structure data, and fine-tuning the text embedding module and the graph neural network in the pre-trained hybrid model based on the preset fine-tuning instruction set.

[0096] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0097] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0098] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A task planning method based on a hybrid model, characterized in that: The hybrid model includes a first large language model, a text embedding module, a graph neural network, and a second large language model connected in sequence, and the method includes: Inputting the user request into the first language model in the hybrid model that has completed training, and obtaining a plurality of subtasks output by the first language model; wherein the plurality of subtasks and the dependency relationships between the subtasks are output in the form of a directed text graph; Inputting the directed text graph into the text embedding module in the hybrid model that has completed training, so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node; Inputting the embedding vectors and the dependency relationship between the embedding vectors into the graph neural network in the hybrid model that has been trained, and aggregating the embedding vectors according to the dependency relationship between the embedding vectors using the graph neural network to obtain the aggregated features corresponding to each node; Inputting the aggregated features corresponding to each node into the second largest language model in the hybrid model that has completed training, and obtaining an answer to the user request output by the second largest language model; wherein the answer includes a sub-answer to each subtask; Among them, the hybrid model that has completed training is obtained by pre-training the text embedding module and graph neural network in the pre-built hybrid model based on the preset graph structure data, and by fine-tuning the text embedding module and graph neural network in the pre-trained hybrid model based on the preset fine-tuning instruction set.

2. The hybrid model-based task planning method according to claim 1, characterized in that: The text embedding module includes a pre-trained language representation model and a multi-layer perceptron; the step of inputting the directed text graph into the text embedding module in the trained hybrid model so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node, including: Inputting the directed text graph into the pre-trained language representation model, using the pre-trained language representation model to initially encode the text of each node in the directed text graph to obtain an initial vector corresponding to each node; The initial vector corresponding to each node is input into the multi-layer perceptron to obtain the embedding vector corresponding to each node.

3. The hybrid model-based task planning method according to claim 2, characterized in that: The embedding vectors and the dependencies between the embedding vectors are input into the graph neural network in the hybrid model that has been trained, and the graph neural network is used to aggregate the embedding vectors according to the dependencies between the embedding vectors to obtain the aggregated features corresponding to each node, including: Take each node as a node to be processed, and randomly sample a preset number of neighboring nodes from the neighboring nodes of the node to be processed; Performing feature aggregation on the preset number of neighbor nodes to obtain aggregated neighbor features; The aggregated neighbor features are concatenated with the node to be processed to obtain the aggregated features corresponding to the node to be processed.

4. The hybrid model-based task planning method according to claim 3, characterized in that: The performing feature aggregation on the neighbor nodes to obtain aggregated neighbor features includes: A mean aggregator is used to perform feature aggregation on neighbor nodes of the node to be processed to obtain the aggregated neighbor features.

5. The hybrid model-based task planning method according to claim 1, characterized in that: The hybrid model that has been trained is obtained by training in the following manner, including: Using the preset graph structure data, pre-training the text embedding module and the graph neural network in the pre-built hybrid model to obtain a pre-trained hybrid model; wherein the parameters of the first language model and the parameters of the second language model in the hybrid model are frozen; Based on a preset fine-tuning instruction set, the text embedding module and the graph neural network in the pre-trained hybrid model are fine-tuned to obtain the hybrid model that has completed training; wherein the parameters of the first largest language model in the hybrid model are frozen; the preset fine-tuning instruction set includes task planning data represented by question-answer pairs, and the task planning data represented by question-answer pairs is graph structure data.

6. The hybrid model-based task planning method according to claim 5, characterized in that: The method uses the preset graph structure data to pre-train the text embedding module and the graph neural network in the pre-built hybrid model to obtain the pre-trained hybrid model, including: Using the preset graph structure data, the text embedding module and graph neural network in the pre-built hybrid model are pre-trained with any one or more of node classification, graph understanding, path exploration, and node counting as the goal to obtain the pre-trained hybrid model.

7. A task planning device based on a hybrid model, characterized in that: The hybrid model includes a first large language model, a text embedding module, a graph neural network, and a second large language model connected in sequence, and the device includes: A task planning module, used for inputting a user request into a first language model in a hybrid model that has completed training, and obtaining a plurality of subtasks output by the first language model; wherein the plurality of subtasks and dependencies between the subtasks are output in the form of a directed text graph; A text embedding module, used for inputting the directed text graph into the text embedding module in the hybrid model that has been trained, so that the text embedding module converts the text features of each node in the directed text graph into an embedding vector corresponding to each node; A node feature aggregation module, used to input the embedding vectors and the dependency relationship between the embedding vectors into the graph neural network in the hybrid model that has been trained, and use the graph neural network to aggregate the embedding vectors according to the dependency relationship between the embedding vectors to obtain the aggregation feature corresponding to each node; An answer output module, used to input the aggregated features corresponding to each node into the second largest language model in the hybrid model that has completed training, and obtain an answer to the user request output by the second largest language model; wherein the answer includes a sub-answer to each subtask; Among them, the hybrid model that has completed training is obtained by pre-training the text embedding module and graph neural network in the pre-built hybrid model based on the preset graph structure data, and by fine-tuning the text embedding module and graph neural network in the pre-trained hybrid model based on the preset fine-tuning instruction set.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the hybrid model-based task planning method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the hybrid model-based task planning method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the hybrid model-based task planning method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Knowledge reasoning method based on multi-modal knowledge graph

    CN112288091A

  • Standards planning intention recognition method for pre-training large language model tuning

    CN117076661A

  • Network architecture searching method and device, equipment and storage medium

    CN118839720A

  • Intelligent SQL query generation method and system based on large language model

    CN118861081A

  • Agent trajectory planning using neural networks

    US20230040006A1