A Hybrid Expert Multi-Model Task Processing Method and System Based on AI Agent Scenario
By performing fine-grained division of user tasks and multi-model task processing in AI Agent scenarios, and constructing a RAG text knowledge base and a hybrid expert routing network, the problem of low collaborative efficiency of Agent tools in complex task scenarios is solved, and efficient task decomposition and answer generation are achieved.
Patent Information
- Application Number
- CN202511095717.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-06
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2045-08-06
AI Technical Summary
Existing agent tools are inflexible in terms of task scheduling and resource allocation to cope with complex and ever-changing user needs and task scenarios. The collaboration efficiency between models is low, especially when multiple tasks are concurrent and complex tasks are nested, the execution efficiency and resource utilization are difficult to meet the requirements.
A hybrid expert multi-model task processing method based on AI Agent scenario is adopted. Knowledge blocks are generated by semantic segmentation of unstructured and semi-structured data to build RAG text knowledge base. Vector representation is generated by using Embedding model. The similarity between user input and knowledge base is calculated. Task is decomposed into sub-tasks and dependency matrix is constructed. A multi-objective optimization strategy is used to train hybrid expert routing network for task allocation.
It enables fine-grained partitioning and dynamic decomposition of user tasks, improves the collaborative efficiency of multiple models, enhances the accuracy, diversity, and authenticity of answers, strengthens the stability and scalability of the system, and reduces task execution time latency.
Smart Images

Figure CN120653404B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of LLM multi-model task allocation technology, and in particular to a hybrid expert multi-model task processing method and system based on AI Agent scenarios. Background Technology
[0002] The development of AI technology has given rise to agent tools that integrate large models. Existing agent technologies generate a series of workflows based on user-defined needs using the LLM (Learning by Modeling) approach, ultimately calling different large models to generate an aggregated answer according to the workflow steps. While workflows allow the dominant model to clearly execute tasks sequentially, improving the efficiency and applicability of large models remains a pressing issue.
[0003] Traditional agent tools often employ fixed patterns in task scheduling and resource allocation, making it difficult to flexibly respond to complex and ever-changing user needs and task scenarios. Furthermore, significant differences in functionality and performance exist between different large models, leading to low collaboration efficiency between models and further limiting the overall performance of agent tools. Especially when facing multi-task concurrency and complex task nesting, the execution efficiency and resource utilization of existing methods are often unsatisfactory, and there is still considerable room for improvement in stability and scalability. Summary of the Invention
[0004] In view of this, the purpose of this invention is to provide a method and system for processing hybrid expert multi-model tasks in AI Agent scenarios. This method and system perform fine-grained division of user tasks and routing selection of model pools, which can effectively improve the accuracy, diversity and authenticity of user demand answers and enhance the multi-model parallel utilization of the Agent system.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: a hybrid expert multi-model task processing method based on AI Agent scenarios, comprising the following steps:
[0006] Step S1: Process unstructured data and semi-structured data Perform semantic segmentation to generate a set of knowledge blocks. Generate vector representation sets through the Embedding model. And store it in the FAISS vector database to build a RAG text knowledge base;
[0007] Step S2: For user-input text Construct query vectors Calculate the similarity between user input and the RAG text knowledge base. Select those with high similarity Each knowledge block constitutes a related document vector set. ;
[0008] Step S3: Concatenate the user input with the inversely decoded document and input it into the Large Language Model (LLM). Divide the user task to obtain a set of subtasks. And generate a subtask dependency matrix. Construct a directed acyclic graph ;
[0009] Step S4: Based on the scoring model and expert model pool Build a task assignment dataset ;
[0010] Step S5: Based on the task allocation dataset constructed in step S4 A multi-objective optimization strategy is used to jointly train a hybrid expert routing network;
[0011] Step S6: For a given user task, following the methods of steps S1-S5, the subtasks are assigned to multiple experts based on dependencies, and the answer for each subtask is obtained by weighting the results using a hybrid expert routing network. Dependency aggregation for generating subtask answers Finally, the aggregated answer of each subtask is used as the user task result.
[0012] In a preferred embodiment, step S1 specifically includes the following steps:
[0013] Step S11: For unstructured data and semi-structured data Each should be standardized separately;
[0014] Unstructured text extraction function Extracting text from unstructured data ;
[0015]
[0016] Semi-structured text conversion function Extracting text from semi-structured data ;
[0017]
[0018] in, Indicates the file type;
[0019] Step S12: Generate a knowledge block set using a semantic block segmentation algorithm. ,in, Indicates the first A knowledge block, Indicates the first A knowledge block, Indicates the first A knowledge block, This indicates the number of knowledge blocks in the set;
[0020]
[0021] Generative Algorithm Defined as;
[0022]
[0023] in, Indicates the first The segmented block to the first A collection of documents divided into blocks. To adjust the sliding window size, The step size of the sliding window. Indicates the total number of documents;
[0024] Step S13: Use the pre-trained BERT model as the vector encoding generator, denoted as the embedding model f. emb Generate the embedding vector representation set corresponding to each knowledge block. ,in, Indicates the first Each knowledge block corresponds to a vector. Indicates the first Each knowledge block corresponds to a vector. Indicates the first Each knowledge block corresponds to a vector. This represents the number of knowledge block vectors in the set;
[0025]
[0026] in, Vectors corresponding to knowledge blocks The vector dimension;
[0027] Step S14: Input a vector into the FAISS database using an inverted index function. Building a knowledge base index:
[0028]
[0029] in, This indicates the number of cluster centers in the inverted list. This indicates the number of product-quantized subspace partitions. This represents the number of encoded bits for each subspace.
[0030] In a preferred embodiment, step S2 specifically includes the following steps:
[0031] Step S21: User inputs text By embedding model Convert to query vector ;
[0032]
[0033] Step S22: Normalize the query vector and knowledge block vector, and calculate the cosine similarity between the query vector and all vectors in the RAG knowledge base:
[0034]
[0035] in, L2 normalization is represented by T, which represents the transpose of a vector. The calculation formula is:
[0036]
[0037] Step S23: Sort by similarity in descending order and select the one with the highest similarity. Each knowledge block constitutes a related document vector set, represented as follows:
[0038]
[0039] Where topN represents the N optimal values, V topN express Knowledge blocks constitute a set of related document vectors. This represents a vector of knowledge blocks that meet the criteria. This represents the minimum similarity threshold.
[0040] In a preferred embodiment, step S3 specifically includes the following steps:
[0041] Step S31: Reverse decode the top N knowledge block vectors to obtain the original text and aggregate the user input text. :
[0042]
[0043]
[0044] in, This is the reverse decoding result of the first top-N vector. This is the reverse decoding result of the second top-N vector. For the first The reverse decoding result of the top N vectors This is the reverse decoding result of the Nth vector that matches the top N vectors. This is the aggregated document obtained by reverse decoding of the top N vector sets. Indicates a splicing operation;
[0045] Step S32: Decompose the task based on the Large Language Model (LLM). The input includes user-input text. The aggregated document after reverse decoding of the top N vector set Output subtasks Subtask Description Subtask dependencies , represented as:
[0046]
[0047] in, This refers to prompt words that are combined with user input and a set of relevant documents and inputted into the Large Language Model (LLM).
[0048] Step S33: For the extracted subtask set ,in, Indicates the first Sub-tasks Indicates the first Sub-tasks Indicates the first Sub-tasks Represent the total number of subtasks and establish the dependency matrix. Construct a directed acyclic graph of subtask dependencies. :
[0049]
[0050]
[0051]
[0052] Among them, sub-task set As a diagram The vertex, For the image The directed edge, This represents the set of other subtasks that depend on the subtask.
[0053] In a preferred embodiment, step S4 specifically includes the following steps:
[0054] Step S41, for the expert pool ,in It is the first in the model pool An expert model, It is the first in the model pool An expert model, It is the first in the model pool An expert model, This represents the total number of models in the model pool; assign simple tasks to all expert models. Using a scoring model The matching degree is calculated for the generated results of each expert model. Smoothness and credibility Multidimensional scoring, scoring model Represented as:
[0055]
[0056] Matching degree measures the similarity between the questions and answers generated by the model. Defined as:
[0057]
[0058] Fluency measures the logical coherence between sentences generated by the model. Defined as:
[0059]
[0060] Credibility measures the consistency between the model-generated results and real-world content. Defined as:
[0061]
[0062]
[0063] in, Representation Model For the task The rating matrix For the first The output of each model For the first The output of the model is the first One sentence. Calculate the logical relationship between two sentences. This indicates that the output sentence is consistent with the facts. Indicates the first The total number of sentences output by each model;
[0064] Step S42: Perform a weighted summation of the multidimensional scores to calculate the final score for each model. :
[0065]
[0066]
[0067] in, The weights for matching degree, fluency, and credibility are respectively.
[0068] Based on the comprehensive score, all models and outputs are re-sorted to obtain the sorted set representation of the models: ,in , These represent the rankings. Overall score These represent the rankings. The model corresponding to the comprehensive score, These represent the rankings. The combined scores of the models' responses, along with the two highest-scoring models and their corresponding task inputs, are added to the task-model assignment dataset. :
[0069]
[0070] Step S43: Select a simple task again. Repeat steps S41 and S42 to construct the complete dataset.
[0071] In a preferred embodiment, step S5 specifically includes the following steps:
[0072] Step S51: Generate task feature vectors from simple tasks. Each model constructs a model feature vector based on the task's output. express:
[0073]
[0074]
[0075] in, This represents the task feature vector generated by the MLP model from a simple task. This represents the model feature vector constructed by each model in the MLP model based on the task output. Subtasks The number of tokens contained in it. This represents the number of tokens in the output text of each model. The dimension of the task feature vector. Indicates the dimension of the model's feature vectors;
[0076] Step S52: Concatenate and fuse the task feature vector with the model feature vector and map them together. At the same time, perform global pooling on the features to obtain the corresponding feature representations.
[0077]
[0078]
[0079] in, The first MLP model represents the... layer, Indicates the first The model feature vector representation is obtained by concatenating and mapping the two types of vector features in the layer. and They represent the first The weight matrix and bias weights of the layer model. express vector dimension, It is the number of neurons in the current hidden layer. It is the feature vector after global pooling;
[0080] Step S53: After adopting MLP multi-layer mapping, the hybrid routing expert model performs Softmax normalization to output the probability of each expert being elected. , represented as:
[0081]
[0082] in, Indicates task processing The number of expert models, and This indicates the original prediction of the MLP model. The expert and the first The probability value of an expert being selected. It is the transpose of the weighted matrix of the original output. express The dimension;
[0083] Step S54: Calculate the loss function of the model score for hybrid expert route assignment. Defined as:
[0084]
[0085] in, This represents the total number of subtasks. This is the current subtask. In subtask The optimal model obtained from the training and The two models that perform best on the dataset. Indicates hybrid expert routing in the task The model score obtained by Softmax during training. Indicates in the task Below, dataset The optimal model score for the medium task.
[0086] In a preferred embodiment, step S6 specifically includes the following steps:
[0087] Step S61: Based on step S3, process the user-input text. After constructing the subtask graph, for each subtask... Calculate its vertex in-degree :
[0088]
[0089] If and only if hour The execution, and the dependency values corresponding to the executed task. All updated to 0;
[0090] Step S62: Each time the remaining task nodes are traversed, a set of executable tasks is obtained. The probability that an executable task will pass through the routing model output:
[0091]
[0092] in, Representing model y The probability vector of each subtask. Indicates the network to be selected for routing. for The vector dimension;
[0093] exist The model corresponding to the two largest probability values is represented as follows:
[0094]
[0095]
[0096] in, ( The function implements the output probability vector. The two models with the largest median and , and These respectively represent subtasks The election probability values output by the suboptimal and second-best models. These are probability and threshold;
[0097] Step S63: Input the subtask results into the post-processing model T5 to generate the best answer for the subtask. Independent subtasks are input into the expert model in parallel for processing, resulting in feedback results from the multi-expert model:
[0098]
[0099]
[0100]
[0101] in, This indicates that the top-1 model processes subtasks. Output results Indicates top2 model processing Subtask output results Indicates processing subtasks The optimal result obtained express The maximum number of tokens in the processed output. Indicates Use a lightweight model for input weights. For content Perform weighted fusion output;
[0102] Step S64: Based on the directed acyclic task graph, aggregate the best results of the sub-tasks generated by the expert model to generate dependency aggregation of the sub-task answers. , represented as:
[0103]
[0104] in, Represents each user task The total number of subtasks in the breakdown.
[0105] This invention also provides a hybrid expert multi-model task processing system based on AI Agent scenarios, characterized by including a knowledge base construction module, a task parsing and construction module, a hybrid expert routing network, and a sub-task parallel execution strategy. The modules work together to achieve the hybrid expert multi-model task processing based on AI Agent scenarios as described above.
[0106] Compared with the prior art, the present invention has the following beneficial effects:
[0107] (1) This invention performs fine-grained partitioning of user tasks and constructs a directed acyclic graph from the subtask dependency matrix to achieve dynamic decomposition and parallel scheduling of tasks. Compared with the traditional Agent fixed workflow mode, this invention can intelligently identify the logical dependencies between subtasks, support the parallel execution of subtasks, significantly improve the collaborative efficiency of multiple models, and reduce the time delay of task execution.
[0108] (2) This invention proposes a multi-objective optimization routing strategy based on a scoring model, which dynamically selects the optimal expert model through multi-dimensional scoring of matching degree, fluency, and credibility. Compared with existing static allocation methods, this invention can adaptively adjust network weights and improve the accuracy, diversity, and realism of the Agent system by combining task characteristics and model capabilities.
[0109] (3) This invention integrates the RAG knowledge base into knowledge retrieval, achieving efficient knowledge retrieval through semantic block segmentation and embedding. Compared with existing keyword matching methods, this invention can enhance the correlation between user input and knowledge base content, alleviate the LLM illusion problem, and improve the credibility of generated results.
[0110] (4) This invention supports dynamically expanding the expert model pool and achieves model capability re-evaluation and adaptation through joint training of the routing network, which has a small number of training parameters. Compared with agent systems with fixed model combinations, this invention can flexibly cope with complex task scenarios and improve the stability and scalability of the system.
[0111] (5) This invention introduces a lightweight T5 model to perform weighted fusion of multiple expert outputs, avoiding redundancy and conflicts caused by direct splicing. Compared with traditional aggregation methods, this invention ensures the coherence and information density of the output through dynamic weight allocation and token length limitation, while reducing computational overhead. Attached Figure Description
[0112] Figure 1 This is a flowchart of a preferred embodiment of the present invention;
[0113] Figure 2 This is a schematic diagram of the training process of the expert routing network in a preferred embodiment of the present invention. Detailed Implementation
[0114] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0115] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.
[0116] It should be noted that the terminology used herein is for the purpose of describing particular implementations only and is not intended to limit the exemplary implementations according to this application; as used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise; furthermore, it should be understood that when the terms “comprising” and / or “including” are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or combinations thereof.
[0117] like Figure 1 As shown, this embodiment provides a hybrid expert multi-model task processing system based on an AI Agent scenario, including the following steps:
[0118] Step S1: Process unstructured data and semi-structured data Perform semantic segmentation to generate a set of knowledge blocks. Generate vector representation sets through the Embedding model. The data is then stored in the FAISS vector database to construct the RAG text knowledge base.
[0119] In this embodiment, step S1 specifically includes the following steps:
[0120] Step S11: For unstructured data and semi-structured data Each should be standardized separately;
[0121] Unstructured text extraction function Extracting text from unstructured data ;
[0122]
[0123] Semi-structured text conversion function Extracting text from semi-structured data ;
[0124]
[0125] in, Indicates the file type;
[0126] Step S12: Generate a knowledge block set using a semantic block segmentation algorithm. ,in, Indicates the first A knowledge block, This indicates the number of knowledge blocks in the set;
[0127]
[0128] Generative Algorithm Defined as;
[0129]
[0130] in, Indicates the first The segmented block to the first A collection of documents divided into blocks. To adjust the sliding window size, The step size of the sliding window. Indicates the total number of documents;
[0131] Step S13: Use the pre-trained BERT model as the vector encoding generator, denoted as... Generate a set of embedding vector representations for each knowledge block. ,in, Indicates the first Each knowledge block corresponds to a vector. Indicates the first Each knowledge block corresponds to a vector. Indicates the first Each knowledge block corresponds to a vector. This represents the number of knowledge block vectors in the set;
[0132]
[0133] in, The vector dimension;
[0134] Step S14: Input a vector into the FAISS database using an inverted index function. Building a knowledge base index:
[0135]
[0136] in, This indicates the number of cluster centers in the inverted list. This indicates the number of product-quantized subspace partitions. This represents the number of encoded bits for each subspace.
[0137] Step S2: For the text entered by the user Construct query vectors Calculate the similarity between user input and RAG knowledge blocks. Select the one with the highest similarity Each knowledge block constitutes a related document vector set. ;
[0138] In this embodiment, step S2 specifically includes the following steps:
[0139] Step S21: User inputs text Through the embedding model described in step 13 Convert into a query vector;
[0140]
[0141] in, It is a vector formed by transforming text through an embedding model. Word vectors The dimension;
[0142] Step S22: Normalize the query vector and knowledge block vector, and calculate the cosine similarity between the query vector and all vectors in the RAG knowledge base:
[0143]
[0144] in, This indicates L2 normalization for vectors. The calculation formula is:
[0145]
[0146] Step S23: Sort by similarity in descending order and select the one with the highest similarity. Each knowledge block constitutes a related document vector set, represented as follows:
[0147]
[0148] Where topN represents the N optimal values, V topN This indicates that the top N knowledge blocks constitute a related set of document vectors. This represents a vector of knowledge blocks that meet the criteria. This represents the minimum similarity threshold.
[0149] Step S3: Concatenate the user input with the reverse-decoded document and input it into the LLM. Divide the user task to obtain a set of subtasks. And generate a subtask dependency matrix. Construct a directed acyclic graph .
[0150] In the original embodiment, step S3 specifically includes the following steps:
[0151] Step S31: Reverse decode the top N knowledge block vectors to obtain the original text and aggregate user input. :
[0152]
[0153]
[0154] in, This is the result of the reverse decoding of the first top-N vector. For the first The reverse decoding result of the top N vectors This is the reverse decoding result of the Nth vector that matches the top N vectors. This is the aggregated document obtained by reverse decoding of the top N vector sets. Indicates a splicing operation;
[0155] Step S32: Decompose the task based on LLM, with input including the user-given task. Related knowledge base data Output subtasks Subtask Description Subtask dependencies , can be represented as:
[0156]
[0157] in, This refers to prompts that are combined with user input and a set of relevant documents and inputted into the LLM.
[0158] Step S33: For the extracted subtask set ,in, Indicates the first Sub-tasks Represent the total number of subtasks and establish the dependency matrix. Construct a directed acyclic graph of subtask dependencies. :
[0159]
[0160]
[0161]
[0162] Among them, sub-task set As a diagram The vertex, For the image The directed edge, Indicates dependency on subtasks Other sub-task sets.
[0163] Step S4: Based on the scoring model and expert model pool Build a task assignment dataset .
[0164] In this embodiment, step S4 specifically includes the following steps:
[0165] Step S41, for the expert pool ,in It is the first in the model pool One model, It represents the total number of models in the model pool; it is used to represent all expert models. Assign simple tasks Using a scoring model Calculate the matching degree of the generated results for each model. Smoothness and credibility Multidimensional scoring, scoring model Represented as:
[0166]
[0167] Matching score measures the similarity between the questions and answers generated by the model, and is defined as:
[0168]
[0169] Fluency measures the logical relevance of sentences generated by the model, and is defined as:
[0170]
[0171] Credibility measures the consistency between the model-generated results and real content, and is defined as:
[0172]
[0173]
[0174] in, For the first The output of each model For the first The output of the model is the first One sentence. Calculate the logical relationship between two sentences. This indicates that the output sentence is consistent with the facts. Indicates the first The total number of sentences output by each model;
[0175] Step S42: Perform a weighted summation of the multidimensional scores to calculate the final score for each model. :
[0176]
[0177]
[0178] in, The weights for matching degree, fluency, and credibility are respectively.
[0179] Based on the comprehensive score, all models and outputs are re-sorted to obtain the sorted set representation of the models: ,in , These represent the rankings. Overall score These represent the rankings. The model corresponding to the comprehensive score, These represent the rankings. The combined scores of the models' responses, along with the two highest-scoring models and their corresponding task inputs, are added to the task-model assignment dataset. :
[0180]
[0181] Step S43: Select a simple task again. Repeat steps S41 and S42 to construct the complete dataset.
[0182] Step S5: Based on the task allocation dataset constructed in step S4, a hybrid expert routing network is jointly trained using a multi-objective optimization strategy.
[0183] In this embodiment, step S5 specifically includes the following steps:
[0184] Step S51: Generate task feature vectors from simple tasks. Each model constructs a model feature vector based on the task's output. express:
[0185]
[0186]
[0187] in, MLP model The task feature vector, In the MLP model The output results are used to construct the model feature vector. Indicates task This represents the number of tokens in the output text of each model. The dimension of the task feature vector. Indicates the dimension of the model's feature vectors;
[0188] Step S52: Concatenate and fuse the task feature vector with the model feature vector and map them together. At the same time, perform global pooling on the features to obtain the corresponding feature representations.
[0189]
[0190]
[0191] in, The first MLP model represents the... layer, Indicates the first The model feature vector representation is obtained by concatenating and mapping the two types of vector features in the layer. and They represent the first The weight matrix and bias weights of the layer model. express vector dimension, It is the number of neurons in the current hidden layer. It is the feature vector after global pooling;
[0192] Step S53: After applying MLP multi-layer mapping, the hybrid routing expert model performs Softmax normalization to output the probability of each expert being elected, expressed as:
[0193]
[0194] in, Indicates task processing The number of expert models, and These represent the original predictions of the MLP model. The expert and the first The probability value of an expert being selected It is the transpose of the weighted matrix of the original output. The dimension;
[0195] Step S54: Calculate the loss function of the model score for hybrid expert route assignment. Defined as:
[0196]
[0197] in, This represents the total number of subtasks. This is the current subtask. In subtask The optimal model obtained from the training and The two models that perform best on the dataset. Indicates hybrid expert routing in the task The model score obtained by Softmax during training. Indicates in the task Below, dataset The optimal model score for the medium task.
[0198] In this embodiment, the training process of the expert routing network is as follows: Figure 2 As shown.
[0199] Step S6: For a given user task, following the methods in steps S1-S5, assign subtasks to multiple experts based on dependencies, and use a hybrid expert routing network to weight the subtasks to obtain the best answer for each subtask. Dependency aggregation for generating subtask answers Finally, the aggregated answer of each subtask is used as the user task result.
[0200] In this embodiment, step S6 specifically includes the following steps:
[0201] Step S61: Based on step S3, process the user's input. After constructing the subtask graph, for each subtask... Calculate its vertex in-degree:
[0202]
[0203] If and only if hour The execution, and the dependency values corresponding to the executed task. All updated to 0;
[0204] Step S62: Each time the remaining task nodes are traversed, a set of executable tasks is obtained. The probability that an executable task will pass through the routing model output:
[0205]
[0206] in, Representing model y Sub-tasks vector, Indicates the network to be selected for routing. for The vector dimension;
[0207] exist Find the two largest The corresponding model is represented as:
[0208]
[0209]
[0210] in, ( The function implements the output probability vector. The two models with the largest median and , and These respectively represent subtasks The election probability values output by the suboptimal and second-best models. These are probability and threshold;
[0211] Step S63: Input the subtask results into the post-processing model T5 to generate the best answer for the subtask. Independent subtasks are input into the expert model in parallel for processing, resulting in feedback results from the multi-expert model:
[0212]
[0213]
[0214]
[0215] in, This indicates that the top-1 model processes subtasks. Output results Indicates top2 model processing Subtask output results Indicates processing subtasks The optimal result obtained express The maximum number of tokens in the processed output. Indicates Use a lightweight model for input weights. For content Perform weighted fusion output;
[0216] Step S64: Based on the directed acyclic task graph, aggregate the best results of the sub-tasks generated by the expert model to generate dependency aggregation of the sub-task answers. , can be represented as:
[0217]
[0218] in, Represents each user task The total number of subtasks in the decomposition;
[0219] This embodiment also provides a hybrid expert multi-model task processing system based on AI Agent scenarios, including a knowledge base construction module, a task parsing and construction module, a hybrid expert routing network, and a sub-task parallel execution strategy. The collaborative operation of these modules can realize the above-mentioned task processing method based on a hybrid expert architecture.
[0220] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0221] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0222] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0223] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0224] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.
Claims
1. A hybrid expert multi-model task processing method based on AI Agent scenarios, characterized in that, Includes the following steps: Step S1: Process unstructured data and semi-structured data Perform semantic segmentation to generate a set of knowledge blocks. Generate vector representation sets through the Embedding model. And store it in the FAISS vector database to build a RAG text knowledge base; Step S2: For user-input text Construct query vectors Calculate the similarity between user input and the RAG text knowledge base. Select those with high similarity Each knowledge block constitutes a related document vector set. ; Step S3: Concatenate the user input with the inversely decoded document and input it into the Large Language Model (LLM). Divide the user task into subtask sets. And generate a subtask dependency matrix. Construct a directed acyclic graph ; Step S4: Based on the scoring model and expert model pool Build a task assignment dataset ; Step S5: Based on the task allocation dataset constructed in step S4 A multi-objective optimization strategy is used to jointly train a hybrid expert routing network; Step S6: For a given user task, following the methods of steps S1-S5, the subtasks are assigned to multiple experts based on dependencies, and the answer for each subtask is obtained by weighting the results using a hybrid expert routing network. Dependency aggregation for generating subtask answers Finally, the aggregated answer of each subtask is used as the user task result.
2. The hybrid expert multi-model task processing method based on AI Agent scenario according to claim 1, characterized in that, Step S1 specifically includes the following steps: Step S11: For unstructured data and semi-structured data Each should be standardized separately; Unstructured text extraction function Extracting text from unstructured data ; Semi-structured text conversion function Extracting text from semi-structured data ; in, Indicates the file type; Step S12: Generate a knowledge block set using a semantic block segmentation algorithm. ,in, Indicates the first A knowledge block, Indicates the first A knowledge block, Indicates the first A knowledge block, This indicates the number of knowledge blocks in the set; Generative Algorithm Defined as; in, Indicates the first The segmented block to the first A collection of documents divided into blocks. To adjust the sliding window size, The step size of the sliding window. Indicates the total number of documents; Step S13: Using the pre-trained BERT model as a vector encoder, embed the model f emb Generate the embedding vector representation set corresponding to each knowledge block. ,in, Indicates the first Each knowledge block corresponds to a vector. Indicates the first Each knowledge block corresponds to a vector. Indicates the first Each knowledge block corresponds to a vector. This represents the number of knowledge block vectors in the set; in, Vectors corresponding to knowledge blocks The vector dimension; Step S14: Input a vector into the FAISS database using an inverted index function. Building a knowledge base index: in, This indicates the number of cluster centers in the inverted list. This indicates the number of product-quantized subspace partitions. This represents the number of encoded bits for each subspace.
3. The hybrid expert multi-model task processing method based on AI Agent scenario according to claim 1, characterized in that, Step S2 specifically includes the following steps: Step S21: User inputs text By embedding model Convert to query vector ; Step S22: Normalize the query vector and knowledge block vector, and calculate the cosine similarity between the query vector and all vectors in the RAG knowledge base: in, L2 normalization is represented by T, which represents the transpose of a vector. The calculation formula is: Step S23: Sort by similarity in descending order and select the one with the highest similarity. Each knowledge block constitutes a related document vector set, represented as follows: Where topN represents the N optimal values, V topN express Knowledge blocks constitute a set of related document vectors. This represents a vector of knowledge blocks that meet the criteria. This represents the minimum similarity threshold.
4. The hybrid expert multi-model task processing method based on AI Agent scenario according to claim 1, characterized in that, Step S3 specifically includes the following steps: Step S31: Reverse decode the top N knowledge block vectors to obtain the original text and aggregate the user input text. : in, This is the result of the reverse decoding of the first top-N vector. This is the result of the reverse decoding of the second top-N vector. For the first The reverse decoding result of the top N vectors This is the reverse decoding result of the Nth vector that matches the top N vectors. This is the aggregated document obtained by reverse decoding of the top N vector sets. Indicates a splicing operation; Step S32: Decompose the task based on the Large Language Model (LLM). The input includes user-input text. The aggregated document after reverse decoding of the top N vector set Output subtasks Subtask Description Subtask dependencies , represented as: in, This refers to prompt words that are combined with user input and a set of relevant documents and inputted into the Large Language Model (LLM). Step S33: For the extracted subtask set ,in, Indicates the first Sub-tasks Indicates the first Sub-tasks Indicates the first Sub-tasks Represent the total number of subtasks and establish the dependency matrix. Construct a directed acyclic graph of subtask dependencies. : Among them, sub-task set As a diagram The vertex, For the image The directed edge, This represents the set of other subtasks that depend on the subtask.
5. The hybrid expert multi-model task processing method based on AI Agent scenario according to claim 1, characterized in that, Step S4 specifically includes the following steps: Step S41, for the expert pool ,in It is the first in the model pool An expert model, It is the first in the model pool An expert model, It is the first in the model pool An expert model, This represents the total number of models in the model pool; assign simple tasks to all expert models. Using a scoring model Calculate the matching degree of the generated results for each expert model. Smoothness and credibility Multidimensional scoring, scoring model Represented as: Matching degree measures the similarity between the questions and answers generated by the model. Defined as: Fluency measures the logical coherence of sentences generated by the model. Defined as: Credibility measures the consistency between the model-generated results and real-world content. Defined as: in, Representation Model For the task The rating matrix For the first The output of each model For the first The output of the model is the first One sentence. Calculate the logical relationship between two sentences. This indicates that the output sentence is consistent with the facts. Indicates the first The total number of sentences output by each model; Step S42: Perform a weighted summation of the multidimensional scores to calculate the final score for each model. : in, The weights for matching degree, fluency, and credibility are respectively. Based on the comprehensive score, all models and outputs are re-sorted to obtain the sorted set representation of the models: ,in , These represent the rankings. Overall score These represent the rankings. The model corresponding to the comprehensive score, These represent the rankings. The combined scores of the models' responses, along with the two highest-scoring models and their corresponding task inputs, are added to the task-model assignment dataset. : Step S43: Select a simple task again. Repeat steps S41 and S42 to construct the complete dataset.
6. The hybrid expert multi-model task processing method based on AI Agent scenario according to claim 1, characterized in that, Step S5 specifically includes the following steps: Step S51: Generate task feature vectors from simple tasks. Each model constructs a model feature vector based on the task's output. express: in, This represents the task feature vector generated by the MLP model from a simple task. This represents the model feature vector constructed by each model in the MLP model based on the task output. Subtasks The number of tokens contained in it. This represents the number of tokens in the output text of each model. The dimension of the task feature vector. Indicates the dimension of the model's feature vectors; Step S52: Concatenate and fuse the task feature vector with the model feature vector and map them together. At the same time, perform global pooling on the features to obtain the corresponding feature representations. in, The first MLP model represents the... layer, Indicates the first The model feature vector representation is obtained by concatenating and mapping the two types of vector features in the layer. and They represent the first The weight matrix and bias weights of the layer model. express vector dimension, It is the number of neurons in the current hidden layer. It is the feature vector after global pooling; Step S53: After adopting MLP multi-layer mapping, the hybrid routing expert model performs Softmax normalization to output the probability of each expert being elected. , represented as: in, Indicates task processing The number of expert models, and This indicates the original prediction of the MLP model. The expert and the first The probability value of an expert being selected. It is the transpose of the weighted matrix of the original output. express The dimension; Step S54: Calculate the loss function of the model score for hybrid expert route assignment. Defined as: in, This represents the total number of subtasks. This is the current subtask. In subtask The optimal model obtained from the training and The two models that perform best on the dataset. Indicates hybrid expert routing in the task The model score obtained by Softmax during training. Indicates in the task Below, dataset The optimal model score for the medium task.
7. The hybrid expert multi-model task processing method based on AI Agent scenario according to claim 1, characterized in that, Step S6 specifically includes the following steps: Step S61: Based on step S3, process the user-input text. After constructing the subtask graph, for each subtask... Calculate its vertex in-degree : If and only if hour The execution of the task and the dependency values corresponding to the executed task. All updated to 0; Step S62: Each time the remaining task nodes are traversed, a set of executable tasks is obtained. The probability that an executable task will pass through the routing model output: in, Representing model y The probability vector of each subtask. Indicates the network to be selected for routing. for The vector dimension; exist The model corresponding to the two largest probability values is represented as follows: in, ( The function implements the output probability vector. The two models with the largest median and , and These respectively represent subtasks The election probability values output by the suboptimal and second-best models. These are probability and threshold; Step S63: Input the subtask results into the post-processing model T5 to generate the best answer for the subtask. Independent subtasks are input into the expert model in parallel for processing, resulting in feedback results from the multi-expert model: in, This indicates that the top-1 model processes subtasks. Output results Indicates top2 model processing Subtask output results Indicates processing subtasks The optimal result obtained express The maximum number of tokens in the processed output. Indicated by Use a lightweight model for input weights. For content Perform weighted fusion output; Step S64: Based on the directed acyclic task graph, aggregate the best results of the sub-tasks generated by the expert model to generate dependency aggregation of the sub-task answers. , represented as: in, Represents each user task The total number of subtasks in the decomposition.
8. A hybrid expert multi-model task processing system based on AI Agent scenarios, characterized in that, The system includes a knowledge base construction module, a task parsing and construction module, a hybrid expert routing network, and a subtask parallel execution strategy. The system runs the hybrid expert multi-model task processing method based on AI Agent scenario as described in any one of claims 1-7.
Citation Information
Patent Citations
Method and device for reducing multi-model task queuing time delay
CN115686776A
Method and device for dynamically generating multi-modal hybrid expert model
CN118865409A