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

By constructing a hybrid model, utilizing graph neural networks to process graph-structured data, and combining the knowledge reserves and reasoning capabilities of large language models, the problem of large language models being unable to explicitly represent paths in task planning is solved, thus achieving accurate and highly reliable task planning.

CN119886322BActive Publication Date: 2026-03-27PEKING UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-15
Publication Date
2026-03-27

Smart Images

  • Figure CN119886322B_ABST
    Figure CN119886322B_ABST
Patent Text Reader

Abstract

The application provides a task planning method and device based on a hybrid model, equipment, a medium and a product. The method comprises the following steps: inputting a user request into a first large language model in the hybrid model to obtain 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 to convert the text features of each node in the directed text graph into an embedding vector; inputting the embedding vector into a graph neural network to obtain an aggregated feature corresponding to each node; inputting the aggregated feature corresponding to each node into a second large language model to obtain an answer to the user request; wherein the answer comprises a subanswer to each subtask. The application combines the respective advantages of the graph neural network and the large language model, so that the user request is explicitly disassembled into a plurality of subtasks, and accurate, highly reliable and interpretable task planning is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

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

[0002] Task planning is a key research direction in the field of artificial intelligence, which involves interpreting and decomposing complex user instructions into specific and solvable subtasks, and then fulfilling user requests by executing each subtask.

[0003] Large language models (LLMs) can be used for natural language understanding and interactive knowledge queries due to their rich knowledge base and strong reasoning ability. 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 enables large language models to learn to process problems step by step, this step-by-step problem-solving approach only reflects the logical reasoning process of LLMs, i.e., LLMs output a step-by-step calculation process and gradually answer until the final result is obtained, but it does not output the problem to be solved at each step, i.e., LLMs directly execute subtasks to obtain the results of each subtask, without decomposing user requests into different subrequests and outputting each subrequest.

[0004] As can be seen, when using large language models for task planning, the complete task decomposition process cannot be fully reflected, and the task planning path cannot be explicitly reflected. SUMMARY

[0005] The present application provides a task planning method and device based on a hybrid model, equipment, medium and product to solve the defect that the task planning path cannot be explicitly reflected when using large language models alone for task planning in the prior art, and to achieve accurate, highly reliable and interpretable task planning, which can not only intuitively output subtasks but also output answers that meet user requests.

[0006] The present application provides a task planning method based on 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. The method includes the following steps.

[0007] The user request is input into the first large language model in the hybrid model that has been trained, and a plurality of subtasks output by the first large language model are obtained. The plurality of subtasks and the dependency relationship between each pair of subtasks are output in the form of a directed text graph.

[0008] inputting the directed text graph into a 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;

[0009] inputting the embedding vectors and the dependency relationships between the embedding vectors into a graph neural network in the trained hybrid model, and using the graph neural network to aggregate the embedding vectors according to the dependency relationships between the embedding vectors to obtain an aggregated feature corresponding to each node;

[0010] inputting the aggregated feature corresponding to each node into a second large language model in the trained hybrid model to obtain an answer to the user request output by the second large language model; wherein the answer includes a sub-answer for each sub-task.

[0011] The trained hybrid model is obtained by pre-training a text embedding module and a graph neural network in a pre-constructed hybrid model based on preset graph structure data, and then performing instruction fine-tuning on the pre-trained text embedding module and graph neural network based on a preset fine-tuning instruction set.

[0012] According to the task planning method based on the hybrid model provided by the application, the text embedding module includes a pre-trained language representation model and a multi-layer perception machine; the inputting of 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 includes:

[0013] inputting the directed text graph into the pre-trained language representation model, using the pre-trained language representation model to perform initial coding on the text of each node in the directed text graph to obtain an initial vector corresponding to each node;

[0014] inputting the initial vector corresponding to each node into the multi-layer perception machine to obtain the embedding vector corresponding to each node.

[0015] According to the task planning method based on the hybrid model provided by the application, the inputting of the embedding vectors and the dependency relationships between the embedding vectors into the graph neural network in the trained hybrid model, and the aggregation of the embedding vectors by the graph neural network according to the dependency relationships between the embedding vectors to obtain an aggregated feature corresponding to each node includes:

[0016] taking each node as a to-be-processed node, and randomly sampling a preset number of neighbor nodes from the neighbor nodes of the to-be-processed node.

[0017] characteristics of the preset number of neighbor nodes are aggregated to obtain aggregated neighbor characteristics;

[0018] The aggregated neighbor characteristics are spliced with the to-be-processed node to obtain the aggregated characteristics corresponding to the to-be-processed node.

[0019] According to the task planning method based on the hybrid model provided by the application, the characteristics of the neighbor nodes are aggregated to obtain aggregated neighbor characteristics, including:

[0020] The characteristics of the neighbor nodes of the to-be-processed node are aggregated by using a mean aggregator to obtain the aggregated neighbor characteristics.

[0021] According to the task planning method based on the hybrid model provided by the application, the hybrid model that has completed training is obtained by training in the following manner, including:

[0022] The text embedding module and the graph neural network in the hybrid model constructed in advance are pre-trained by using preset graph structure data to obtain a pre-trained hybrid model, wherein the parameters of the first large language model and the parameters of the second large language model in the hybrid model are frozen.

[0023] The text embedding module and the graph neural network in the pre-trained hybrid model are instructed to fine-tune based on a preset fine-tuning instruction set to obtain the hybrid model that has completed training, wherein the parameters of the first large language model in the hybrid model are frozen, and the preset fine-tuning instruction set includes task planning data represented in the form of question and answer pairs, and the task planning data represented in the form of question and answer pairs is graph structure data.

[0024] According to the task planning method based on the hybrid model provided by the application, the text embedding module and the graph neural network in the hybrid model constructed in advance are pre-trained by using preset graph structure data to obtain a pre-trained hybrid model, including:

[0025] The text embedding module and the graph neural network in the hybrid model constructed in advance are pre-trained by using the preset graph structure data to obtain the pre-trained hybrid model, including any one or more of node classification, graph understanding, path exploration, and node counting.

[0026] The application further provides a task planning device based on a hybrid model, and 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:

[0027] The task planning module is configured to input a user request into a first large language model in a trained hybrid model to obtain a plurality of sub-tasks output by the first large language model; wherein the plurality of sub-tasks and the dependency relationship between each two of the sub-tasks are output in the form of a directed text graph.

[0028] The text embedding module is configured to input the directed text graph into a text embedding module in the trained hybrid model, so that the text embedding module converts a text feature of each node in the directed text graph into an embedding vector corresponding to the node.

[0029] The node feature aggregation module is configured to input the embedding vectors and the dependency relationship between the embedding vectors into a graph neural network in the trained hybrid model, and aggregate the embedding vectors according to the dependency relationship between the embedding vectors by using the graph neural network to obtain an aggregated feature corresponding to each node.

[0030] The answer output module is configured to input the aggregated feature corresponding to each node into a second large language model in the trained hybrid model to obtain an answer to the user request output by the second large language model; wherein the answer includes a sub-answer to each sub-task.

[0031] The trained hybrid model is obtained by pre-training a text embedding module and a graph neural network in a pre-constructed hybrid model based on preset graph structure data, and then performing instruction fine-tuning on the pre-trained text embedding module and graph neural network based on a preset fine-tuning instruction set.

[0032] The present application also provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any one of the above task planning methods based on a hybrid model.

[0033] The present application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program is executable by a processor to implement any one of the above task planning methods based on a hybrid model.

[0034] The present application also provides a computer program product comprising a computer program, wherein the computer program is executable by a processor to implement any one of the above task planning methods based on a hybrid model.

[0035] The present invention provides a task planning method, apparatus, device, medium, and product based on a hybrid model. This method constructs a hybrid model comprising a first large language model, a text embedding module, a graph neural network, and a second large language model connected sequentially. By inputting a user request into the first large language model within the pre-trained hybrid model, multiple sub-tasks are output by the first large language model. The multiple sub-tasks and their pairwise dependencies are output in the form of a directed text graph. The directed text graph is input into the text embedding module within the pre-trained hybrid model, causing the text embedding module to convert 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 them, are input into the graph neural network within the pre-trained hybrid model, and the graph neural network aggregates the embedding vectors to obtain aggregated features corresponding to each node. The aggregated features corresponding to each node are input into the second large language model within the pre-trained hybrid model to obtain the answer to the user request output by the second large language model. The answer includes sub-answers for each sub-task. This application first utilizes a large language model with frozen parameters to decompose user requests into multiple subtasks and represents their output as directed text graphs. Since existing large language models typically struggle to directly understand and process graph-structured data, processing such data requires compressing the two-dimensional graph structure into a one-dimensional natural language sequence before inputting it into the large language model, leading to performance degradation. To address this issue, this application leverages the strengths of graph neural networks in handling graph-structured data. It embeds node features from the directed text graph into a low-dimensional space and, through a series of feature aggregation and transfer operations, obtains node representations that integrate local and global information. This allows the original user request, after being decomposed into multiple subtasks, to be represented as graph-structured data. This enables the graph neural network to leverage its strengths, selecting the optimal path or subgraph as a reference, accurately exploring the logical dependencies between tasks, and finding the optimal path. This facilitates the subsequent efficient execution of each subtask by the large language model to obtain the sub-answers and ensures the accuracy of the final answer to the entire user request, preventing the large language model from falling into illusion. This application leverages the ability of graph neural networks to process graph data, compensating for the shortcomings of large language models in processing graph structures. It also fully utilizes the rich knowledge reserves and powerful reasoning capabilities of large language models, combining the advantages of both graph neural networks and large language models. This overcomes the deficiency of not being able to explicitly represent the task planning path when using large language models alone for task planning, enabling user requests to be decomposed into multiple sub-tasks, achieving accurate, highly reliable, and interpretable task planning. Attached Figure Description

[0036] In order to make the technical solutions in the present application or the prior art clearer, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application, and other drawings can be obtained by a person of ordinary skill in the art without creative effort on the basis of these drawings.

[0037] Figure 1 is a schematic diagram of a module of the mixed model provided by the present application.

[0038] Figure 2 is one of the flow schematic diagrams of the task planning method based on the mixed model provided by the present application.

[0039] Figure 3 is another flow schematic diagram of the task planning method based on the mixed model provided by the present application.

[0040] Figure 4 is an example schematic diagram of a directed text graph provided by the present application.

[0041] Figure 5 is a schematic diagram of the final output model answer provided by the present application.

[0042] Figure 6 is a structural schematic diagram of the task planning device based on the mixed model provided by the present application.

[0043] Figure 7 is a structural schematic diagram of the electronic device provided by the present application. DETAILED DESCRIPTION

[0044] In order to make the technical solutions in the present application or the prior art clearer, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application, and other drawings can be obtained by a person of ordinary skill in the art without creative effort on the basis of these drawings.

[0045] The specific embodiments of the present application will be described below in combination with the drawings. Figures 1-7 The specific embodiments of the present application will be described below in combination with the drawings.

[0046] Figure 1 is a schematic diagram of a module of the mixed model provided by the present application, and the mixed model constructed by the present application comprises 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 can be different large language models.

[0047] Figure 2is one of the flowcharts of the task planning method based on a hybrid model provided by the present application, as shown in Figure 2 The method comprises the following.

[0048] In step 201, a user request is input into a first large language model in a hybrid model that has been trained, and a plurality of sub-tasks output by the first large language model are obtained; wherein the plurality of sub-tasks and the dependency relationship between each two of the sub-tasks are output in the form of a directed text graph.

[0049] The user request refers to a question input by a user into a system, for example, the user inputs: “Please help me solve the following mathematical problem: A conical container with a base radius of 5 cm and a height of 12 cm. If this container is inverted and exactly half of it is immersed in water, calculate the volume immersed in water (assuming π = 3.14 and the density of water is 1 g / cm³)”.

[0050] The above user request is first input into the first large language model, and the first large language model is a parameter-frozen large language model (for example, it can be Qwen2-7B-Instruct, which is an instruction fine-tuning model in the Qwen2-7B-Instruct series. It is based on Qwen2-7B and fine-tuned for instructions to improve the performance of the model on specific tasks), and the user request is decomposed into a plurality of specific sub-tasks by using the first large language model.

[0051] It should be noted that the plurality of sub-tasks output by the first large language model and the dependency relationship between each two of the sub-tasks are presented in the form of a directed text graph.

[0052] The directed text graph is a special data structure that combines the concepts of text data and graph theory. In this structure, text is represented as nodes in the graph, and directed edges between nodes represent some relationship or dependency between text segments. The directed text graph is composed of nodes and edges, each node represents a sub-task; each edge connects the nodes, representing some relationship between the nodes. In the directed text graph, the edges are directional, which means that the relationship is ordered. For example, an edge from node A to node B may represent a relationship such as “A is the premise of B” or “B depends on A”.

[0053] Specifically, still taking the above example, after passing the parameter frozen first large language model of the user input complex task request, the model is responsible for decomposing the user request into a plurality of specific subtasks, and generating a directed text graph containing these subtasks and their mutual dependency relationship. For example, the system provides the following prompt to the first large language model: "Please decompose the above problem into a series of interrelated subtasks and represent them in the form of a directed graph. Each node should represent a subtask or computational step, and edges represent the dependency relationship between tasks. Please ensure that all necessary computational steps are covered and consider the intermediate results that may be needed. Output format example: Node1: [step description]; Node2: [step description]… Relationship matrix (in Python list format, 1 indicates a dependency relationship, and 0 indicates no dependency relationship): [[0, 1, 1, 0, 0, 0], …, [0, 0, 0, 1, 0, 0]]". Then, the first large language model outputs the following task decomposition result.

[0054] Node1: Calculate the total volume of the cone;

[0055] Node2: Calculate the height midpoint of the cone;

[0056] Node3: Calculate the volume of the small cone with a base radius of 5 cm and a height of 6 cm;

[0057] Node4: Calculate the volume difference between the large cone (total cone) and the small cone;

[0058] Node5: Verify the reasonableness of the result;

[0059] Node6: Output the final answer, including units.

[0060] Node relationship matrix (also known as adjacency matrix):

[0061] [[0, 1, 1, 0, 0, 0],

[0062] [0, 0, 1, 0, 0, 0],

[0063] [0, 0, 0, 1, 0, 0],

[0064] [0, 0, 0, 0, 1, 1],

[0065] [0, 0, 0, 0, 0, 1],

[0066] [0, 0, 0, 0, 0, 0]].

[0067] Figure 3 The second flowchart of the task planning method based on the hybrid model is shown in Figure 2. Figure 3As shown, the task planning method based on the hybrid model in the present application can clearly separate the user request into two stages of task planning and task execution, and through the above large language model outputting the subtasks represented as a directed text graph, the subtasks can be displayed and output.

[0068] The directed text graph output by the first large language model is as shown in Figure 4 .

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

[0070] The text embedding module is a core technical component in natural language processing (NLP), and its core function is to convert text data (such as words, phrases, sentences or paragraphs) into fixed-size real number vectors, which can capture the semantic information in the text. The text embedding module in the present application uses a combination of a pre-trained BERT (Bidirectional Encoder Representations from Transformers) model and a single-layer multi-layer perceptron (MLP) to achieve the conversion, and other network structures can also be used, which are not limited in the present application.

[0071] The pre-trained encoder in the text embedding module is optional, and the present 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, which can obtain a rich representation of each input text combined with context information (refer to Figure 5 ).

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

[0073] Step 203, input the embedding vectors and the dependency relationship between the embedding vectors into the graph neural network in the hybrid model which has been trained, and use the graph neural network to aggregate the embedding vectors to obtain the aggregated features corresponding to each node.

[0074] Among them, the graph neural network (Graph Neural Network, GNN) is a kind of deep learning model for processing graph structure data. The entities in the graph structure data are represented in the form of nodes, and the relationship between the entities is represented in the form of edges. In this application, GraphSage is selected as the graph neural network, which is a graph neural network algorithm proposed in 2017, and other graph neural networks can also be used, which is not limited in this paper.

[0075] The basic components of the graph neural network 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 neighbor node information and update node features.

[0076] Specifically, the embedding vectors and the dependency relationship between the embedding vectors (i.e. the 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 nodes through the message passing mechanism, and to concatenate the neighbor information with the node itself to update the feature representation of each node. This process usually iterates multiple times in order to capture the information of more distant nodes in the graph. Finally, the feature representation of each node (i.e. the aggregated feature) is output, at this time, the feature representation of each node (i.e. the aggregated feature corresponding to each node) will contain the information of its neighbors and more distant nodes.

[0077] Step 204, input the aggregated feature corresponding to each node into the second large language model in the mixed model which has been trained, to obtain the answer output by the second large language model for the user request; wherein the answer includes a sub-answer for each sub-task.

[0078] Among them, the second large language model can be the same as the first large language model, or it can be different. In this embodiment, the same model as the above-mentioned second large language model is used, that is, it can be an open source model Qwen2-7B-Instruct.

[0079] Specifically, the node features processed by the above-mentioned graph neural network GraphSage are input into the second large language model (Qwen2-7B-Instruct) to generate the final reasoning result and answer. The second large language model outputs detailed problem solving steps (i.e. sub-answers for each sub-task, which are not shown in the following paragraphs, see Appendix 2 for details) and the final answer, including the following 6 nodes: Figure 5

[0080] (1) Calculate the total volume of the cone;

[0081] (2) Calculate the height midpoint of the cone;​

[0082] (3) Calculate the volume of the small cone;

[0083] (4) Calculate the volume difference;

[0084] (5) Verify the reasonableness of the results;

[0085] (6) Express the final answer.

[0086] The above embodiment, by constructing a mixed model including 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 the user request into the first large language model in the mixed model which has been trained, obtaining a plurality of sub-tasks output by the first large language model; wherein the plurality of sub-tasks and the dependency relationship between the two sub-tasks are output in the form of a directed text graph; input the directed text graph into the text embedding module in the mixed model which 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 vector, and the dependency relationship between the embedding vectors, into the graph neural network in the mixed model which has been trained, aggregate the embedding vectors using the graph neural network to obtain an aggregated feature corresponding to each node; input the aggregated feature corresponding to each node into the second large language model in the mixed model which has been trained, to obtain an answer output by the second large language model for the user request; wherein the answer includes a sub-answer for each sub-task. First, the large language model with frozen parameters is used to disassemble the user request into a plurality of sub-tasks, and the output is represented as a directed text graph. Since existing large language models are generally 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 before inputting it into the large language model, which will cause the performance of the large language model to decline. In solving this problem, the graph neural network is used to take advantage of its ability to process graph structure data, embed the node features in the directed text graph into a low-dimensional space, and through a series of feature aggregation and transmission operations, obtain a node representation that fuses local and global information, so that the original user request, after being disassembled into a plurality of sub-tasks, is represented as graph structure data, which is beneficial to the graph neural network to exert its own advantages to select the optimal path or subgraph as a reference, accurately explore the logical dependency relationship between tasks, find the optimal path, and facilitate the subsequent large language model to efficiently perform each sub-task to obtain each sub-answer, and ensure the accuracy of the final answer of the entire user request, avoiding the large language model from falling into illusion. The application makes use of the ability of the graph neural network to process graph data, makes up for the shortcomings of the large language model in processing graph structure, and fully utilizes the rich knowledge reserve and powerful reasoning ability of the large language model, combines the advantages of the graph neural network and the large language model, overcomes the defect that the large language model alone cannot explicitly reflect the task planning path when planning tasks, so that the user request is disassembled into a plurality of sub-tasks, and accurate, high reliability and explainable task planning is achieved.

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

[0088] The pre-trained language representation model can be a pre-trained BERT (Bidirectional Encoder Representations from Transformers) model. The BERT model uses the encoder structure of the Transformer, and can learn the context information from both left and right directions of the text at the same time, so that the model can better understand the semantics of each word in the sentence, learn rich context representations, and finally obtain rich representations of each input text.

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

[0090] The initial vector corresponding to each node is input into a one-layer multi-layer perceptron (MLP), and the structure of the MLP comprises an input layer and an output layer. For example, the structure of the input layer and the output layer is as follows.

[0091] (1) The input layer comprises 768 neurons.

[0092] (2) The output layer comprises 4096 neurons, and the output is the final embedding vector.

[0093] For the above six nodes, six embedding vectors are finally obtained, and each embedding vector has a length of 4096 dimensions.

[0094] In the above embodiment, the text embedding module is constructed by using the pre-trained language representation model and the multi-layer perceptron. The BERT model is used to convert the text into an initial vector, and the multi-layer perceptron (MLP) is used to convert the initial vector into an embedding vector, so that the semantic representation in the text can be accurately mined, and an effective and accurate data basis can be provided for the subsequent graph neural network.

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

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

[0097] a, initialization: using the embedding vector with a length of 4096 dimensions as the initial feature of each node, that is, the initial feature of the to-be-processed node.

[0098] b, neighbor sampling: according to the dependency relationship between embedding vectors, finding all neighbor nodes of the to-be-processed node, and randomly sampling a preset number of neighbor nodes from the neighbor nodes of the to-be-processed node, for example, sampling 10 neighbor nodes.

[0099] c, information aggregation: using a mean aggregator to aggregate the features of the 10 sampled neighbor nodes.

[0100] d, feature update: splicing the aggregated neighbor features with the features of the to-be-processed node to obtain the aggregated features corresponding to each node, and outputting the updated aggregated features through a fully connected layer.

[0101] Repeating steps b-d multiple times (for example, twice) to obtain the final node representation.

[0102] The above embodiment can obtain node representation containing accurate logical association relationship by processing graph structure data through a graph neural network, which is beneficial to obtaining accurate answers by a subsequent large language model.

[0103] In an embodiment, the trained hybrid model is obtained by the following method, comprising.

[0104] Pre-training the multi-layer perceptron and the graph neural network in the pre-constructed hybrid model using preset graph structure data to obtain a pre-trained hybrid model; wherein the parameters of the first large language model and the parameters of the second large language model in the hybrid model are frozen.

[0105] Based on a preset fine-tuning instruction set, the multi-layer perceptron and the graph neural network in the pre-trained hybrid model are fine-tuned to obtain the trained hybrid model; wherein the parameters of the first large language model in the hybrid model are frozen; and the preset fine-tuning instruction set comprises task planning data represented in the form of question and answer pairs, and the task planning data represented in the form of question and answer pairs is graph structure data.

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

[0107] Specifically, the application adopts a two-stage training method to train the pre-constructed hybrid model.

[0108] First stage: multi-task graph pre-training.

[0109] 1. Data preparation: collect diversified open-source graph datasets, including but not limited to social network graphs, knowledge graphs, molecular graphs, etc. Preprocess these data to obtain training data suitable for different purposes, such as node classification, graph understanding, path exploration, and node counting.

[0110] 2. Task design: including node classification, graph understanding, path exploration, and node counting, etc. Among them:

[0111] Node classification task: used to predict the class or attribute of nodes in the graph;

[0112] Graph understanding task: used to generate a summary or description of the entire graph structure;

[0113] Path exploration task: find the shortest path or all possible paths between two given nodes;

[0114] Node counting task: count the number of nodes that meet certain conditions.

[0115] 3. Optimization objective function: use cross-entropy loss function as the objective function.

[0116] 4. Pre-training process: adopt multi-task learning strategy, randomly use any one of the above four graph tasks in each batch data; use Adam optimizer to update parameters. In the pre-training stage, the parameters of the first large language model and the second large language model are frozen. Since end-to-end training will increase the computational overhead of the entire hybrid model, and the first large language model is mainly used for task decomposition and has task decomposition capability itself, in order to save computational overhead, the parameters of the first large language model are frozen. The second large language model is used for logical reasoning of each sub-task and outputs the answer. In order to align the graph neural network and the multi-layer perceptron, the parameters of the second large language model need to be frozen, which can 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.

[0117] 5. Evaluation and adjustment: monitor the performance indicators of each task on the validation set; dynamically adjust the task weight and learning rate according to the validation results.

[0118] Phase Two: Fine-tuning of instructions.

[0119] 1. Instruction set generation: Each instruction in the instruction set is represented in the form of question-answer pairs. Specifically, a large number of diverse task planning problems are generated using a generative pre-trained converter (e.g., GPT-4), including mathematical problems, logical reasoning, and complex decision-making. For each problem, a corresponding task decomposition diagram and detailed solution are generated using a generative pre-trained converter (e.g., GPT-4).

[0120] 2. Data filtering and enhancement: The data generated by GPT-4 is manually reviewed to ensure quality and diversity; the filtered data is manually enhanced to add more complex boundary cases and special considerations.

[0121] 3. Instruction Fine-tuning Settings: Fine-tune the pre-trained model using a selected high-quality dataset; employ a low learning rate (e.g., 5e-6) and a small batch size (e.g., 4 or 8) to prevent overfitting; use LoRA (Low-Rank Adaptation) to reduce the number of trainable parameters and improve efficiency. During the instruction fine-tuning phase, the parameters of the first-largest language model are frozen to save computational costs, while the parameters of the second-largest language model are not frozen. It is necessary to ensure that the parameters of the second-largest language model are updated synchronously with the parameters of the graph neural network and the multilayer perceptron. Additionally, the parameters of the language representation model (BERT model) in the hybrid model are also kept frozen during the instruction fine-tuning phase.

[0122] 4. Performance Evaluation: Use a manually constructed test set to evaluate the model's performance in task planning and answer generation; conduct manual evaluation to determine the quality and reasonableness of the generated task planning diagrams and answers.

[0123] The above embodiments employ a two-stage training method of pre-training + instruction fine-tuning, and adopt a multi-task training strategy. By using different types of training data to pre-train the hybrid model, the hybrid model's ability to understand different tasks can be improved, thereby increasing the accuracy of the model's output answers.

[0124] The task planning device based on a hybrid model provided by the present invention is described below. The task planning device based on a hybrid model described below and the task planning method based on a hybrid model described above can be referred to in correspondence.

[0125] like Figure 6 As shown, Figure 6 A schematic diagram of the structure of the task planning device based on the hybrid model provided in this application is shown. 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. The device includes...

[0126] The task planning module 601 is configured to input a user request into a first large language model in a trained hybrid model to obtain a plurality of sub-tasks output by the first large language model; wherein the plurality of sub-tasks and the dependency relationship between each two of the sub-tasks are output in the form of a directed text graph.

[0127] The text embedding module 602 is configured to input the directed text graph into a 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.

[0128] The node feature aggregation module 603 is configured to input the embedding vectors and the dependency relationship between the embedding vectors into a graph neural network in the trained hybrid model, and aggregate the embedding vectors according to the dependency relationship between the embedding vectors by using the graph neural network to obtain an aggregated feature corresponding to each node.

[0129] The answer output module 604 is configured to input the aggregated feature corresponding to each node into a second large language model in the trained hybrid model to obtain an answer to the user request output by the second large language model; wherein the answer includes a sub-answer for each sub-task.

[0130] The trained hybrid model is obtained by pre-training a text embedding module and a graph neural network in a pre-constructed hybrid model based on preset graph structure data, and then performing instruction fine-tuning on the pre-trained text embedding module and graph neural network based on a preset fine-tuning instruction set.

[0131] In an embodiment, the text embedding module includes a pre-trained language representation model and a multi-layer perceptron; and the text embedding module 602 is further configured to:

[0132] input the directed text graph into the pre-trained language representation model, perform initial encoding on the text of each node in the directed text graph by using the pre-trained language representation model to obtain an initial vector corresponding to each node; and input the initial vector corresponding to each node into the multi-layer perceptron to obtain the embedding vector corresponding to each node.

[0133] In an embodiment, the node feature aggregation module 603 is further configured to:

[0134] Take each node as a to-be-processed node, randomly sample a preset number of neighbor nodes from neighbor nodes of the to-be-processed node, aggregate features of the preset number of neighbor nodes to obtain aggregated neighbor features, and concatenate the aggregated neighbor features with the to-be-processed node to obtain the aggregated features corresponding to the to-be-processed node.

[0135] In an embodiment, the node feature aggregation module 603 is further configured to:

[0136] The neighbor nodes of the to-be-processed node are aggregated by using a mean aggregator to obtain the aggregated neighbor features.

[0137] In an embodiment, the model training unit is further configured to:

[0138] The text embedding module and the graph neural network in the pre-constructed hybrid model are pre-trained by using the preset graph structure data to obtain a pre-trained hybrid model, wherein parameters of the first large language model and parameters of the second large language model in the hybrid model are frozen; and the text embedding module and the graph neural network in the pre-trained hybrid model are instructed to fine-tune based on a preset fine-tuning instruction set to obtain the trained hybrid model, wherein parameters of the first large language model in the hybrid model are frozen; and the preset fine-tuning instruction set includes task planning data represented in the form of question and answer pairs, and the task planning data represented in the form of question and answer pairs is graph structure data.

[0139] In an embodiment, the model training unit is further configured to:

[0140] The text embedding module and the graph neural network in the pre-constructed hybrid model are pre-trained by using the preset graph structure data to obtain a pre-trained hybrid model, wherein parameters of the first large language model and parameters of the second large language model in the hybrid model are frozen; and the text embedding module and the graph neural network in the pre-trained hybrid model are instructed to fine-tune based on a preset fine-tuning instruction set to obtain the trained hybrid model, wherein parameters of the first large language model in the hybrid model are frozen; and the preset fine-tuning instruction set includes task planning data represented in the form of question and answer pairs, and the task planning data represented in the form of question and answer pairs is graph structure data.

[0141] Figure 7 An example of an entity structure diagram of an electronic device is shown in FIG. 1. Figure 7As shown, the electronic device can include a processor 710, a communications interface 720, a memory 730, and a communications bus 740, wherein the processor 710, the communications interface 720, and the memory 730 complete mutual communication through the communications bus 740. The processor 710 can invoke a logic instruction in the memory 730 to execute a hybrid model-based task planning method, which includes inputting a user request into a first large language model in a hybrid model that has completed training to obtain a plurality of sub-tasks output by the first large language model; wherein the plurality of sub-tasks and the dependency relationship between two sub-tasks 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 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 a graph neural network in the hybrid model that has completed training, and using the graph neural network to aggregate the embedding vectors according to the dependency relationship between the embedding vectors to obtain an aggregated feature corresponding to each node; inputting the aggregated feature corresponding to each node into a second large language model in the hybrid model that has completed training to obtain an answer to the user request output by the second large language model; wherein the answer includes a sub-answer for each sub-task; wherein the hybrid model that has completed training is obtained by pre-training a text embedding module and a graph neural network in a pre-constructed hybrid model based on preset graph structure data, and performing instruction fine-tuning on the pre-trained text embedding module and the graph neural network based on a preset fine-tuning instruction set.

[0142] In addition, the logic instruction in the memory 730 described above can be implemented in the form of a software functional unit and sold or used as an independent product, which can be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present application or parts of the present application that essentially contribute to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the various embodiments of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0143] In another aspect, the present application also provides a computer program product, which comprises a computer program, the computer program being stored on a non-transitory computer readable storage medium, and the computer program being executable by a processor to cause a computer to perform the task planning method based on the hybrid model, the method comprising: inputting a user request into a first large language model in a hybrid model that has been trained to obtain a plurality of sub-tasks output by the first large language model; wherein the plurality of sub-tasks and the dependency relationship between each two of the sub-tasks 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 to cause the text embedding module to convert 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 a graph neural network in the hybrid model that has been trained, and using the graph neural network to aggregate the embedding vectors according to the dependency relationship between the embedding vectors to obtain an aggregated feature corresponding to each node; inputting the aggregated feature corresponding to each node into a second large language model in the hybrid model that has been trained to obtain an answer to the user request output by the second large language model; wherein the answer comprises a sub-answer for each sub-task; and wherein the hybrid model that has been trained is obtained by pre-training the text embedding module and the graph neural network in a pre-constructed hybrid model based on preset graph structure data, and performing instruction fine-tuning on the pre-trained text embedding module and the graph neural network in the hybrid model based on a preset fine-tuning instruction set.

[0144] In yet another aspect, the present application also provides a non-transitory computer-readable storage medium having stored thereon a computer program, which, when executed by a processor, implements the hybrid model-based task planning method provided by any of the above methods, and the method comprises: inputting a user request into a first large language model in a hybrid model that has completed training, to obtain a plurality of sub-tasks output by the first large language model; wherein the plurality of sub-tasks and the dependency relationship between each two of the sub-tasks 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 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 a graph neural network in the hybrid model that has completed training, and using the graph neural network to aggregate the embedding vectors according to the dependency relationship between the embedding vectors to obtain an aggregated feature corresponding to each node; inputting the aggregated feature corresponding to each node into a second large language model in the hybrid model that has completed training, to obtain an answer to the user request output by the second large language model; wherein the answer comprises a sub-answer for each sub-task; and wherein the hybrid model that has completed training is obtained by pre-training the text embedding module and the graph neural network in a pre-constructed hybrid model based on preset graph structure data, and then performing instruction fine-tuning on the pre-trained text embedding module and the graph neural network based on a preset fine-tuning instruction set.

[0145] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, i.e., they can be located in one place or distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the present embodiment. Those skilled in the art can understand and implement without creative labor.

[0146] From the above description of the embodiments, those skilled in the art can clearly understand that the embodiments can be implemented by means of software plus necessary general hardware platforms, and of course can also be implemented by hardware. Based on such understanding, the above technical solutions, essentially or in terms of the contribution to the prior art, can be embodied in the form of a software product. The computer software product can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a plurality of instructions for causing 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.

[0147] It should be pointed out finally that the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit the same; and although the present application has been described in detail with reference to the foregoing embodiments, it should be appreciated by those skilled in the art that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features thereof can be replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for task planning based on a hybrid model, characterized in that, 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: inputting a user request into the first large language model in the hybrid model which has been trained, to obtain a plurality of sub-tasks output by the first large language model; wherein the plurality of sub-tasks and the dependency relationship between each two sub-tasks are output in the form of a directed text graph; inputting the directed text graph into the text embedding module in the hybrid model which 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 vectors and the dependency relationship between the embedding vectors into the graph neural network in the hybrid model which has been trained, and using the graph neural network to aggregate the embedding vectors according to the dependency relationship between the embedding vectors to obtain an aggregated feature corresponding to each node; inputting the aggregated feature corresponding to each node into the second large language model in the hybrid model which has been trained, to obtain an answer to the user request output by the second large language model; wherein the answer comprises a sub-answer to each sub-task. The hybrid model which has been trained is obtained by pre-training the text embedding module and the graph neural network in a pre-constructed hybrid model based on preset graph structure data, and then performing instruction fine-tuning on the pre-trained text embedding module and the graph neural network based on a preset fine-tuning instruction set.

2. The method of claim 1, wherein, The text embedding module comprises a pre-trained language representation model and a multi-layer perceptron; and the inputting of the directed text graph into the text embedding module in the hybrid model which 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, comprises: inputting the directed text graph into the pre-trained language representation model, and using the pre-trained language representation model to perform initial coding on 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.

3. The method of claim 2, wherein, The inputting of the embedding vectors and the dependency relationship between the embedding vectors into the graph neural network in the hybrid model which has been trained, and the aggregation of the embedding vectors by the graph neural network according to the dependency relationship between the embedding vectors to obtain an aggregated feature corresponding to each node, comprises: taking each node as a to-be-processed node, and randomly sampling a preset number of neighbor nodes from the neighbor nodes of the to-be-processed node; performing feature aggregation on the preset number of neighbor nodes to obtain aggregated neighbor features; concatenating the aggregated neighbor features with the to-be-processed node to obtain the aggregated feature corresponding to the to-be-processed node.

4. The method of claim 3, wherein, The feature aggregation on the neighbor nodes to obtain aggregated neighbor features comprises: The mean aggregator is used to aggregate features of neighbor nodes of the to-be-processed node, to obtain the aggregated neighbor features.

5. The method of claim 1, wherein, The trained hybrid model is trained by the following method, comprising: The text embedding module and the graph neural network in the pre-constructed hybrid model are pre-trained using the preset graph structure data, to obtain a pre-trained hybrid model; wherein the parameters of the first large language model and the parameters of the second large language model in the hybrid model are frozen; The text embedding module and the graph neural network in the pre-trained hybrid model are instructed to fine-tune based on a preset fine-tuning instruction set, to obtain the trained hybrid model; wherein the parameters of the first large language model in the hybrid model are frozen; the preset fine-tuning instruction set includes task planning data represented in the form of question and answer pairs, and the task planning data represented in the form of question and answer pairs is graph structure data.

6. The method of claim 5, wherein, The text embedding module and the graph neural network in the pre-constructed hybrid model are pre-trained using the preset graph structure data, to obtain a pre-trained hybrid model; wherein the parameters of the first large language model and the parameters of the second large language model in the hybrid model are frozen; The text embedding module and the graph neural network in the pre-constructed hybrid model are pre-trained using the preset graph structure data, to obtain a pre-trained hybrid model; wherein the parameters of the first large language model and the parameters of the second large language model in the hybrid model are frozen; 7. A hybrid model based task planning apparatus, characterized by, 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 device comprises: The task planning module is configured to input a user request into the first large language model in the trained hybrid model, to obtain a plurality of sub-tasks output by the first large language model; wherein the plurality of sub-tasks and the dependency relationship between each two sub-tasks are output in the form of a directed text graph; The text embedding module is configured to input 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; The node feature aggregation module is configured to input the embedding vectors and the dependency relationship between the embedding vectors into the graph neural network in the trained hybrid model, and aggregate the embedding vectors according to the dependency relationship between the embedding vectors by using the graph neural network, to obtain an aggregated feature corresponding to each node; The answer output module is configured to input the aggregated feature corresponding to each node into the second large language model in the trained hybrid model, to obtain an answer to the user request output by the second large language model; wherein the answer includes a sub-answer to each sub-task. The trained hybrid model is obtained based on the pre-training of the text embedding module and the graph neural network in the pre-constructed hybrid model using the preset graph structure data, and the instruction fine-tuning of the text embedding module and the graph neural network in the pre-trained hybrid model using the preset fine-tuning instruction set.

8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The computer program is executed by the processor to implement the task planning method based on the hybrid model according to any one of claims 1 to 6. 9.A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the task planning method based on the hybrid model according to any one of claims 1 to 6.

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

Citation Information

Patent Citations

  • Knowledge reasoning method based on multi-modal knowledge graph

    CN112288091A

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

    CN118839720A