Fusion question and answer method, device and equipment of mixed expert large language model and medium

By introducing a routing model into the large language expert model to select suitable expert models for Q&A, and fusing and outputting the answers of these models, it solves the problems of long response time, low efficiency, poor generalization ability and low reliability of output results in cross-domain task applications, and achieves more efficient and reliable Q&A processing.

CN119692477APending Publication Date: 2025-03-25DATAGRAND TECH INC
View PDF 0 Cites 11 Cited by

Patent Information

Application Number
CN202411857662.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

The large language expert model has long response time, low efficiency, poor generalization ability and low output reliability in cross-domain task applications.

Method used

By inputting user input questions into the pre-trained routing model, we obtain k target expert models selected by the routing model among the N expert models for answering user input questions, and answering user input questions through these target expert models. Finally, the expert answers output by each target expert model are fused and output.

Benefits of technology

Reduce resource consumption, speed up response time, improve the efficiency of question-and-answer fusion, enhance the generalization ability of the model, and improve the reliability of the fusion question-and-answer fusion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119692477A_ABST
    Figure CN119692477A_ABST
Patent Text Reader

Abstract

The invention discloses a fusion question and answer method, device and equipment of a hybrid expert large language model and a medium, and relates to the technical field of artificial intelligence, and the method comprises the steps: inputting a question input by a user into a pre-trained routing model, obtaining k target expert models which are selected from the N expert models by the routing model and are used for answering the questions input by the user; and answering the question input by the user through the k target expert models, fusing expert answers output by the target expert models, and outputting the fused expert answers. The answers of the k target expert models are screened through the routing model and are fused and output, and the output of the model focuses on the results of the k expert models with relatively high task correlation, so that the resource consumption is reduced, the response time is shortened, and the question and answer fusion efficiency is improved. In addition, expert model outputs from different task fields are fused, so that the generalization ability of the model is enhanced, and the reliability of fused questions and answers is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a fusion question-answering method, device, equipment and medium for a hybrid expert large language model. Background Art

[0002] With the rapid development of big language expert models, their text generation capabilities have been significantly improved and have been widely used in many fields such as information retrieval, dialogue systems, and autonomous artificial intelligence agents.

[0003] In the prior art, large language expert models are usually constructed through pre-training, supervised fine-tuning, and reinforcement learning based on human feedback. However, the knowledge and skills learned by the model in the pre-training stage may not fully meet the needs of all downstream tasks. Even if the large language expert model can quickly adapt to specific downstream tasks through prompt learning, in actual applications, many downstream tasks involve multiple fields or topics, and the advantages of a single large language expert model in a certain field cannot be fully converted into efficient processing capabilities in other fields, thereby reducing the generalization ability of the large language expert model and the reliability of the output results. Although the generalization ability of the model can be enhanced by hybrid expert models and multi-layer projections, its structure is complex, and the parallel calculation of multiple expert models consumes a lot of computing resources, which reduces the speed and efficiency of response. Summary of the invention

[0004] The present invention provides a fusion question-answering method, device, equipment and medium of a hybrid expert large language model to solve the problems of long response time, low efficiency, poor generalization ability and low reliability of output results of the large language expert model in cross-domain task applications.

[0005] According to one aspect of an embodiment of the present invention, a multi-expert model fusion question answering method is provided, including:

[0006] Input the user input question into the pre-trained routing model, and obtain k target expert models selected by the routing model from N expert models for answering the user input question;

[0007] Among them, N>k; different expert models are suitable for input problems in different task fields;

[0008] The user input question is answered by k target expert models, and the expert answers output by each target expert model are fused and output.

[0009] According to another aspect of an embodiment of the present invention, a multi-expert model fusion question-answering device is provided, including:

[0010] The model screening module is used to input the user input question into the pre-trained routing model, and obtain the k target expert models selected by the routing model from the N expert models for answering the user input question; where N>k; different expert models are adapted to input questions in different task fields;

[0011] The answer output module is used to answer the user input question through k target expert models, and fuse the expert answers output by each target expert model and output them.

[0012] According to another aspect of an embodiment of the present invention, an electronic device is provided, the electronic device comprising:

[0013] at least one processor; and

[0014] a memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the multi-expert model fusion question and answer method described in any embodiment of the present invention.

[0016] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the multi-expert model fusion question-answering method described in any embodiment of the present invention when executed.

[0017] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program / instruction, wherein when the computer program / instruction is executed by a processor, the steps of the method described in any embodiment of the present invention are implemented.

[0018] The technical solution of the embodiment of the present invention inputs user input questions into a pre-trained routing model, obtains k target expert models selected by the routing model from N expert models for answering user input questions; wherein, N>k; different expert models are adapted to input questions in different task fields; the user input questions are answered by k target expert models, and the expert answers output by each target expert model are fused and output. The routing model filters the answers of the k target expert models and fuses the outputs, and the output of the model focuses on the results of the k expert models with higher task relevance, which reduces resource consumption, speeds up response time and improves the efficiency of question and answer fusion. In addition, fusing the outputs of expert models from different task fields not only enhances the generalization ability of the model, but also improves the reliability of fused questions and answers.

[0019] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0021] Figure 1 is a flowchart of a multi-expert model fusion question answering method provided according to the first embodiment of the present invention;

[0022] Figure 2 is a flowchart of another multi-expert model fusion question answering method provided according to the second embodiment of the present invention;

[0023] Figure 3 It is an offline module flow chart of a multi-expert model fusion question answering method applicable to an embodiment of the present invention;

[0024] Figure 4 is an example diagram of a prompt template of an expert model applicable to an embodiment of the present invention;

[0025] Figure 5 It is an online module flow chart of a multi-expert model fusion question answering method applicable to an embodiment of the present invention;

[0026] Figure 6 is a structural diagram of a multi-expert model fusion question-answering device provided according to Embodiment 3 of the present invention;

[0027] Figure 7 It is a structural schematic diagram of an electronic device for implementing the multi-expert model fusion question-answering method of an embodiment of the present invention. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] Embodiment 1

[0031] Figure 1 This is a flowchart of a multi-expert model fusion question-answering method provided in the first embodiment of the present invention. This embodiment can be applied to the application scenario of multi-domain question-answering tasks, where the first k most suitable expert models are selected for reasoning based on the feature evaluation input to the multi-expert models and the reasoning answers are integrated to output the question-answering results. This method can be executed by a multi-expert model fusion question-answering device, which can be implemented in the form of hardware and / or software and can generally be configured in an electronic device. Figure 1 As shown, the method includes:

[0032] S110 , inputting the user input question into the pre-trained routing model, and obtaining k target expert models selected by the routing model from N expert models for answering the user input question.

[0033] Among them, N>k; different expert models are adapted to input problems in different task fields.

[0034] In the embodiment of the present invention, the routing model can be specifically understood as: a model that selects one or more expert models for task processing by learning the characteristics of the user input question. The pre-trained routing model selects k target expert models for answering the user input question based on the characteristics of the user input question. Among them, the number k of the selected target expert models is less than the number N of the pre-built expert models, and the number k of the target expert models can take a fixed value, such as 1 or 2, which means that 1 or 2 expert models are selected as the target expert models from the N expert models.

[0035] The number of target expert models k can also be dynamically selected based on the characteristics of the input data or the system load. For example, for complex problems, a larger k value is set to use more expert models to process and ensure the accuracy of the output results. Considering the computing resources required by the model and the response speed of the model, in order to ensure that all expert models are used evenly and avoid some experts being overloaded while other experts are idle, the k value can be dynamically adjusted according to the model load. For example, when the target expert model matching the current user input problem is overloaded, the k value can be appropriately expanded and more expert models can be introduced to assist in processing. The use of a fixed k value optimizes the use of computing resources and reduces the additional overhead during the dynamic adjustment process. By using a dynamic k value, the model can flexibly adjust resource allocation according to the current load situation, achieve better load balancing, optimize resource utilization, and speed up the response time of the model.

[0036] Expert models can be specifically understood as: a large language model, which is a group of special neural networks, such as feedforward neural networks or other types of networks. Each model can focus on processing different types of user input problems or tasks, for example, according to the knowledge field, it can be divided into: law, medicine or finance and other fields.

[0037] The target expert model can be specifically understood as: the expert model selected to process the user input question according to the decision of the routing model. This selection is based on the characteristics of the user input question and the expertise type of the expert model. Specifically, it can be: extracting key features from the user input question, such as part-of-speech tagging, entity recognition, and topic modeling, to identify the main content and context of the input question. Then, the extracted features are converted into vector form, for example, using a bag-of-words model or word embedding to convert text features into numerical vectors. Then, the cosine similarity formula is used to calculate the similarity between the user input vector and each expert model expertise vector. The expert model expertise vector can be converted from the text features of the expertise field stored in the transfer model. The similarity calculation formula can be:

[0038]

[0039] Among them, A and B are the user input vector and the expert model expertise vector, and ||A|| and ||B|| are the modulus of the user input vector and the modulus of the expert model expertise vector. According to the calculated cosine similarity value, the top k expert models with the highest similarity are selected as the target expert models for answering the user input question.

[0040] S120, answering the user input question through k target expert models, and fusing the expert answers output by each target expert model and outputting them.

[0041] Specifically, the expert answers output by the k target expert models can be fused and outputted by simple averaging or voting, that is, regardless of the quality and expertise of each model, the answers of the k expert models can be fused by equal weight average, or the most frequently appearing answer can be selected as the final answer through a voting mechanism. When there are multiple most frequently appearing answers, they can be fused by simple averaging. By fusion output of answers, the advantages of each expert model can be fully utilized to generate high-quality answers.

[0042] The technical solution of the embodiment of the present invention inputs user input questions into a pre-trained routing model, obtains k target expert models selected by the routing model from N expert models for answering user input questions; wherein, N>k; different expert models are adapted to input questions in different task fields; the user input questions are answered by k target expert models, and the expert answers output by each target expert model are fused and output. The routing model filters the answers of the k target expert models and fuses the outputs, and the output of the model focuses on the results of the k expert models with higher task relevance, which reduces resource consumption, speeds up response time and improves the efficiency of question and answer fusion. In addition, fusing the outputs of expert models from different task fields not only enhances the generalization ability of the model, but also improves the reliability of fused questions and answers.

[0043] Optionally, based on the above embodiments, obtaining k target expert models selected by the routing model from N expert models for answering the user input question may include:

[0044] Calculate the probability value of each expert model correctly answering the user input question according to the input user input question through the routing model to obtain a probability value sequence;

[0045] In descending order of probability values, retain the first k probability values ​​in the probability value sequence, and set the remaining probability values ​​to 0 to obtain an updated probability value sequence;

[0046] Normalize each non-zero probability value in the updated probability value sequence to obtain an integrated weight sequence;

[0047] Among them, the k non-zero weight values ​​in the integrated weight sequence correspond to k target expert models, and the sum of the k non-zero weight values ​​is 1.

[0048] Specifically, the routing model calculates the weights of k target expert models through a sparse activation mechanism, that is, according to the input user input question and the output answer of each expert model, the cosine similarity corresponding to each expert model is calculated as the probability value of correctly answering the question, and the probability values ​​are combined to obtain a probability value sequence. Then, the probability values ​​in the probability value sequence are arranged from large to small, the first k probability values ​​are retained and the remaining probability values ​​are set to 0 to obtain an updated probability value sequence. Each non-zero probability value in the updated probability value sequence is normalized, that is, through a softmax function, or, the sum of these non-zero probability values ​​is calculated, each non-zero probability value is divided by their sum, and the sum of all normalized probability values ​​is ensured to be equal to 1, so that each value can be regarded as a probability, thereby obtaining an integrated weight sequence, in which the k non-zero weight values ​​obtained after normalization in the sequence correspond to the weights of the k target expert models. By activating only a part of the expert models through a sparse activation mechanism, the use of computing resources is reduced, the response time is accelerated, the efficiency of question-answer fusion is improved, and the stability of the model output is ensured.

[0049] Optionally, based on the above embodiments, answering the user input question by k target expert models and fusing the expert answers output by each target expert model may include:

[0050] Inputting the user input questions into k target expert models respectively;

[0051] The probability distribution values ​​generated by each target expert model at each time step that match the target vocabulary are weighted and summed according to the integrated weight sequence, and the expert answer is output according to the probability distribution value obtained after the summation.

[0052] In the embodiment of the present invention, the time step can be specifically understood as: when generating the sentence content, the model gradually constructs the output result in a word-by-word input manner. For example, for the sentence "Today's weather is really good", the model will generate corresponding output results for each stage of input when receiving "today", "today" and "today", and so on. This method allows the model to take into account context information in each step, thereby gradually constructing a complete sentence.

[0053] The target vocabulary can be specifically understood as: the target expert model is a vocabulary set used when predicting the output answer at each time step. This set contains all the vocabulary that the model can select when predicting the next word, which limits the scope of the model output, allowing the model to focus more on learning the relationship between vocabulary and between vocabulary and context. Each target expert model predicts the next most likely word, word, phrase or sentence based on the current input (such as a character, a word, a phrase or a sentence) at each time step. This prediction is based on the probability distribution of all words in the target vocabulary. For example, for the sentence "The weather is so good today", after receiving "today", the model will generate a probability distribution to predict the next most likely word, word, phrase or sentence; after receiving "today", it will generate a new probability distribution to predict the next most likely word, word, phrase or sentence; and so on, until the entire sentence is generated.

[0054] Specifically, the probability distribution values ​​matching the target vocabulary generated by each target expert model at each time step are weighted and summed according to the integrated weight sequence, which can be specifically:

[0055]

[0056] Among them, x<t is the historical condition, X t is the event at the current time step t, P(X t |x<t), is the probability distribution of each time step generated by the model under the historical condition x<t, P(X t |x<t,E i ) is the i-th target expert model E i The probability distribution value generated for the input at this time step, w i is the weight corresponding to the i-th target expert model, that is, the corresponding weight value recorded in the integrated weight sequence. And so on, until the weighted sum calculation of all time steps is completed, the final expert answer obtained is the fusion output result. By using the target vocabulary to generate a probability distribution value that matches the context at each time step, the k target expert models gradually construct the output result, which enables the model to fully consider the previous context information when generating each word, thereby generating a text that is more in line with the context. At the same time, the target vocabulary enhances the adaptability and generalization ability of the model in a specific field, and also improves the ability to process unknown words, thereby improving the reliability of fusion question and answer.

[0057] Embodiment 2

[0058] Figure 2A flowchart of another multi-expert model fusion question-answering method provided in Embodiment 2 of the present invention. This embodiment is a refinement of the multi-expert model fusion question-answering method in the above embodiment, specifically: before inputting the user input question into the pre-trained routing model, it can also include: pre-constructing prompt word templates corresponding to different task fields; using a prompt learning method, generating N expert models for adapting to input questions in different task fields based on each prompt word template.

[0059] Correspondingly, such as Figure 2 As shown, the method includes:

[0060] S210: Pre-build prompt word templates corresponding to different task areas.

[0061] In the embodiment of the present invention, the prompt word template can be specifically understood as: a specific text template designed for the expert model construction method based on prompt learning, which may include some placeholders or text in a specific format to guide the language model to generate expected output or perform a specific task. Among them, the placeholders may include characters used to instruct the model to generate text at a specific location, recognize the beginning and end of the text, and recognize the problem, etc. <text> 、 <startoftext> 、 <endoftext>and <question>Etc. The text in a specific format may include text content used to provide context or guidance related to the task domain, such as examples. The examples may include one or more questions in the domain and the corresponding answers (Q1 and A1 and Q2 and A2 and so on to Qn and An). By providing specific questions and answers in the domain, the content generated by the model is ensured to be professional and accurate in the domain; as well as relevant domain knowledge, which can help the model better integrate and utilize domain data, improve its performance on specific tasks, and provide a basis for the model to continuously learn and adapt to new data, which helps to improve the reliability of fusion question and answer.

[0062] S220 , using a prompt learning method, generating N expert models based on each prompt word template for adapting to input problems in different task fields.

[0063] In the embodiment of the present invention, prompt learning refers to converting the downstream task into a pre-trained task by using a prompt word template designed according to the task domain, so that the model can understand the task and output the answer without a large amount of labeled data. It can allow each expert model to fully learn the knowledge and question and answer in the field without changing the parameter weights of the general expert model, and utilize the expertise of each expert model to reduce resource consumption, speed up response time, and improve the question and answer efficiency, professionalism and scalability of the model.

[0064] S230 , inputting the user input question into the pre-trained routing model, and obtaining k target expert models selected by the routing model from N expert models for answering the user input question.

[0065] Among them, N>k; different expert models are adapted to input problems in different task fields.

[0066] S240: answer the user input question through k target expert models, and fuse the expert answers output by each target expert model and output them.

[0067] In an embodiment of the present invention, by pre-constructing prompt word templates corresponding to different task fields, using a prompt learning method, N expert models for adapting to input questions in different task fields are generated based on each prompt word template, the user input question is input into a pre-trained routing model, and the routing model selects k target expert models for answering the user input question from the N expert models, and the user input question is answered by the k target expert models, and the expert answers output by each target expert model are fused and output. By constructing an expert model in a prompt learning method using a prompt word template, each expert model can deeply learn and master the knowledge and question-answering skills in a specific field without adjusting the parameter weights of the general expert model, effectively reducing resource consumption and speeding up the response time. The question-answering efficiency of the model is improved, the generalization ability of the model is enhanced, and the reliability of the fused question-answering is improved.

[0068] Further, based on the above embodiments, before inputting the user input question into the pre-trained routing model, the following steps may be further included:

[0069] Obtain a training sample set;

[0070] The training samples include question samples and the correctness indicators of the N expert models when answering the question samples. The correctness indicators include correct answers or incorrect answers. The correctness indicator of at least one expert model in the training samples for the question samples is a correct answer.

[0071] The training sample set is used to perform model training on the preset RoBERTa model using a multi-label classification method to obtain the routing model.

[0072] In an embodiment of the present invention, the training sample set may include samples of questions in different fields and the corresponding answers, which are used to determine whether the answers of N expert models are correct or wrong, and there is at least one correct answer in the sample, which ensures the integrity and practicality of the training data and enables the model to learn effective information from it. In addition, in multi-label classification problems, the same question may be adapted to different fields at the same time, and a sample may have multiple correct answers at the same time, such as "Technology company infringement case triggers economic compensation dispute", involving economics, technology and law. By learning correct and incorrect answers, the model's ability to distinguish between correct and incorrect responses is enhanced, and the generalization ability of the model is improved.

[0073] The RoBERTa model is a pre-trained language model based on the BERT model. In multi-label classification problems, each sample can belong to multiple categories at the same time, rather than the traditional single-label classification problem, that is, not each sample can only belong to one category. For example, an article can be about "technology", "economy" and "law" at the same time, so in the process of training the RoBERTa model, the model needs to be able to identify and mark all relevant labels or categories from the given data. The output layer of the RoBERTa model will output an output vector, each element in the vector corresponds to a possible label (such as setting multiple binary classification labels, each label indicates whether the corresponding expert model's answer to a given question is correct, if the expert's answer is correct, the label is 1, if the answer is wrong, the label is 0). The output of the model can be converted into the probability of each label through the activation function (such as sigmoid). Therefore, the trained RoBERTa model can be used as a routing model to realize the allocation, processing and result return of user input questions. In addition, during the training process of the RoBERTa model, the model can optimize the RoBERTa model by minimizing the loss function (such as binary cross entropy loss) through optimization algorithms (such as gradient descent), thereby improving the reliability of the model's question and answering.

[0074] Optionally, based on the above embodiments, obtaining a training sample set may include:

[0075] Construct current question samples and correct answers that match the current question samples;

[0076] Input the current question samples into N expert models respectively to obtain N current expert answers;

[0077] Calculate the similarity between each expert model and the correct answer respectively, and perform an operation of obtaining an expert model whose similarity is greater than a preset similarity threshold;

[0078] If at least one matching expert model is successfully obtained, the correctness index of each matching expert model is set to a correct answer, and the correctness index of the remaining expert models is set to an incorrect answer, so as to construct a training sample;

[0079] If any matching expert model is not successfully obtained, the correctness index of the expert model with the greatest similarity is set to the correct answer, and the correctness indexes of the remaining expert models are set to the wrong answers, so as to construct a training sample.

[0080] In the embodiment of the present invention, based on the obtained N current expert answers and the correct answer matched by the current question sample, the similarity can be calculated in the following way: first, all the experts' answers and the correct answers are converted into high-dimensional vectors through a vector model (such as a RoBERTa model), and the cosine similarity is used to calculate the similarity between each current expert answer and the correct answer:

[0081]

[0082] Among them, A i is the current expert answer in the expert answer vector, G i is the correct answer in the correct answer vector corresponding to the current expert answer, ||A i || and ||G i || represents the model of the current expert answer and the correct answer respectively. Set the similarity threshold s. For each expert model answer A i , if S(A i , G i )>s, the answer is considered to be the correct answer and the expert model is the matching expert model; otherwise, the answer is considered to be the wrong answer and the expert model is the mismatching expert model. After obtaining at least one matching expert model, the correctness index of each matching expert model in the training sample is set to the correct answer, and the rest are set to wrong. If the similarity between the answers of all experts and the correct answer is lower than the threshold s, the correctness index of the expert model in the training sample corresponding to the answer with the greatest similarity is set to the correct answer, and the rest are set to wrong. By introducing similarity calculation and threshold strategy, the situation of missing labels can be effectively handled, the robustness and generalization ability of the multi-label classification model are enhanced, and the reliability of the routing model is improved.

[0083] Specific application scenarios

[0084] With the rapid development of large language models, the field of artificial intelligence has made significant progress. Through techniques such as pre-training, supervised fine-tuning, and reinforcement learning based on human feedback, large language models have demonstrated powerful text generation capabilities. However, when dealing with certain specific downstream tasks, the knowledge and skills learned by the model in the pre-training stage are often difficult to fully cover the diverse knowledge and capabilities required in all fields. The advantages of a single large language model trained by a prompt learning method in a certain field cannot be fully converted into efficient processing capabilities in other fields, reducing the reliability of the model's question and answer. The hybrid expert model, multi-layer projection, and parallel computing of multiple expert models also result in long model response time and low question and answer efficiency due to their complexity and high computational cost.

[0085] To solve the above problems, the embodiment of the present invention proposes a multi-expert model fusion question answering method, which aims to retain the advantages of each expert model while reducing the computing cost and communication overhead. The method includes an offline module and an online module. Figure 3 This is a flowchart of an offline module of a multi-expert model fusion question answering method applicable to an embodiment of the present invention. The technical solution involved in the offline module may specifically be:

[0086] 1. Collect question-answering datasets of different task types

[0087] Collect a series of question-answering datasets for different task types, each dataset corresponds to an expert model. Assume that the number of datasets is N.

[0088] 2. Build an expert model

[0089] For different question-answering dataset tasks, specialized expert models are built separately. Each expert model is based on prompt learning technology and aims to optimize its understanding and processing capabilities for a specific task. Figure 4 is an example diagram of a prompt template of an expert model applicable to an embodiment of the present invention, such as Figure 4 As shown, the prompt word template can include some placeholders or text in a specific format, such as an example, which can contain one or more questions in the field and the corresponding answers (question 1, answer 1 and question 2 and answer 2, and so on); it can also include relevant field knowledge, such as knowledge 1, knowledge 2, and so on, as well as the corresponding current answer. A special prompt word template is designed according to the problem characteristics of a specific task field, so as to guide the general expert model into a professional expert model. Through the prompt word template, the model can generate the best answer related to the field according to different task objectives or input data types.

[0090] 3. Construction of routing model training dataset

[0091] Based on the collected question-answering dataset, training data of possible correct answers and incorrect answers of each expert model is constructed to train the routing model. First, some question-answering data are randomly sampled from the training set of the pre-prepared question-answering dataset. Then, these questions are input into the constructed expert model for reasoning to obtain the answers of the expert model. The answers A of all experts are recorded as:

[0092] A={A1,A2,…,A N }

[0093] Where N is the number of experts. i (i=1, 2, ..., N) and the correct answer G to the question q are transformed into high-dimensional vector representations through the vector model used to generate text vector representations:

[0094]

[0095] G vec =Embedding(G)

[0096] Among them, Embedding represents the vector model, A vec Represents the answer vector of the expert model, including And so on to G vec Represents the correct answer vector. For each question q, calculate the answer of each expert model With G vec The similarity between The embodiment of the present invention uses cosine similarity, and the similarity calculation formula is:

[0097]

[0098] Set the similarity threshold s. For each expert model answer A i , if S(A i , G)>s, then the answer is considered to be correct and its label label is set to 1, otherwise it is 0, that is:

[0099]

[0100] If at least one expert model with a similarity greater than a preset similarity threshold is successfully obtained, the correctness index of each matching expert model is set to a correct answer, and the correctness index of the remaining expert models is set to an incorrect answer to construct a training sample.

[0101] 4. Handling missing labels in routing model training

[0102] If the similarity between all experts’ answers and the correct answer is lower than the threshold s, that is, S(A i , G)≤s for all i, then choose the answer A with the greatest similarity j ,in:

[0103] j = argmax i S(A i , G)

[0104] And set the label of this answer to 1:

[0105] label(A i )=1,where j=argmax i S(A i , G)

[0106] Among them, argmax i (·) represents the value of the variable when the objective function reaches the maximum value.

[0107] That is, if any matching expert model is not successfully obtained, the correctness index of the expert model with the greatest similarity is set to the correct answer, and the correctness indexes of the remaining expert models are set to the wrong answers to construct a training sample.

[0108] The training data set constructed in this way will be used to train the routing selection model, enabling it to effectively determine which expert model is likely to give the correct answer to a given question, thereby improving the accuracy and efficiency of the overall system. By introducing similarity calculation and threshold strategies, the multi-label classification model is made more robust and generalizable, and can effectively deal with the situation of missing labels, improving the effect and applicability of the routing model.

[0109] 5. Routing model training

[0110] The routing model is based on the RoBERTa model and is trained using a multi-label classification method. The output layer of the model is set to multiple binary classification labels, each of which indicates whether the corresponding expert model's answer to a given question is correct. During the training process, the routing model learns how to determine whether each expert model can correctly answer the question based on the characteristics of each question by minimizing the loss function (such as the binary cross entropy loss function), and can optimize the model through optimization algorithms such as gradient descent.

[0111] The routing model trained in offline mode can automatically select the most suitable expert model according to the input task characteristics or content. It evaluates the fitness of each expert model by analyzing the input text characteristics or domain information and generates the corresponding activation probability. Through sparse selection, the top k expert models are selected to improve the overall reasoning efficiency of the model.

[0112] Figure 5 This is a flowchart of an online module of a multi-expert model fusion question-answering method applicable to an embodiment of the present invention. The technical solutions involved in the online module may specifically include:

[0113] 1. Sparse Activation Mechanism

[0114] Based on the expert model obtained by the offline module, the routing model is used to select the k expert models that are most suitable for answering the current question for any input. Given the integration weight W E ,

[0115] W E ={w1, w2, ..., w N }

[0116] w1,w2,...,w N is a non-negative weight that matches each expert model, where most weights are zero, indicating that the question will not be assigned to the expert model. During the reasoning process, for each test question, the routing model obtains the integrated weight of each expert model in the following way:

[0117] logits=router(x s )

[0118] W E =topk(softmax(logits))

[0119] Among them, router(·) is the routing model, x s is the incoming test context, and logits is the output of the last layer of the routing model. The softmax(·) function converts a vector or a set of real numbers into a probability distribution, so that the value of each element is between 0 and 1, and the sum of all elements is 1. Together with the topk function, it filters the output results of the top k expert models with larger probabilities and renormalizes their distributions so that the sum of the k probabilities corresponding to the expert models is 1.

[0120] 2. Expert model fusion

[0121] When the selected top k expert models produce outputs, the logits of these models are weighted summed. The weighting is based on the activation probability generated for them by the routing model. The probability distribution generated by the hybrid model at each time step is P(X t |x<t). Under the historical condition x<t, the probability distribution of the next step of the hybrid model is:

[0122]

[0123] Among them, P(X t |x<t,E i ) is the i-th expert model E i For the probability distribution value of the set vocabulary output, w i is the i-th expert model E i The corresponding weight.

[0124] In the inference phase of the online module, the routing model evaluates the adaptability of the expert model based on the input features and only selects the first k most suitable expert models for inference. Through the sparse activation mechanism, the redundant calculation of activating all expert models at the same time is avoided, which greatly reduces the computational overhead. When the selected expert model generates output, the system will perform a weighted sum of the logits of these models. The weighting method is based on the activation probability generated by the routing model for it, thereby ensuring that the final generated answer is more accurate and reasonable. In addition, since the expert model is obtained through prompt learning, only one model parameter needs to be loaded during inference, which effectively reduces the computational and communication costs.

[0125] The technical solution of the embodiment of the present invention implements a domain expert model for each specific task through a prompt learning method; trains a routing model according to the current task domain to automatically assign an expert model to a given input; during the reasoning process, an offline routing rather than an online load balancing method is used to assign a given input to the top k expert models, so as to sparsely activate a subset of the expert models through the routing model to reduce the computing cost, speed up the response time and improve the efficiency of question-answer fusion; and generates an answer by weighted summing the outputs of the selected expert models, thereby enhancing the generalization ability of the model and improving the reliability of the fused question-answer.

[0126] Embodiment 3

[0127] Figure 6 This is a schematic diagram of the structure of a multi-expert model fusion question answering device provided in the third embodiment of the present invention. Figure 6 As shown, the device includes: a model screening module 610 and an answer output module 620.

[0128] The model screening module 610 is used to input the user input question into the pre-trained routing model, and obtain k target expert models selected by the routing model from N expert models for answering the user input question; wherein N>k; different expert models are adapted to input questions in different task fields;

[0129] The answer output module 620 is used to answer the user input question through k target expert models, and fuse the expert answers output by each target expert model and output them.

[0130] The technical solution of the embodiment of the present invention inputs user input questions into a pre-trained routing model, obtains k target expert models selected by the routing model from N expert models for answering user input questions; wherein, N>k; different expert models are adapted to input questions in different task fields; the user input questions are answered by k target expert models, and the expert answers output by each target expert model are fused and output. The routing model filters the answers of the k target expert models and fuses the outputs, and the output of the model focuses on the results of the k expert models with higher task relevance, which reduces resource consumption, speeds up response time and improves the efficiency of question and answer fusion. In addition, fusing the outputs of expert models from different task fields not only enhances the generalization ability of the model, but also improves the reliability of fused questions and answers.

[0131] Based on the above embodiments, the model screening module 610 is specifically used for:

[0132] Calculate the probability value of each expert model correctly answering the user input question according to the input user input question through the routing model to obtain a probability value sequence;

[0133] In descending order of probability values, retain the first k probability values ​​in the probability value sequence, and set the remaining probability values ​​to 0 to obtain an updated probability value sequence;

[0134] Normalize each non-zero probability value in the updated probability value sequence to obtain an integrated weight sequence;

[0135] Among them, the k non-zero weight values ​​in the integrated weight sequence correspond to k target expert models, and the sum of the k non-zero weight values ​​is 1.

[0136] Based on the above embodiments, the answer output module 620 is specifically used for:

[0137] Inputting the user input questions into k target expert models respectively;

[0138] The probability distribution values ​​generated by each target expert model at each time step that match the target vocabulary are weighted and summed according to the integrated weight sequence, and the expert answer is output according to the probability distribution value obtained after the summation.

[0139] Furthermore, based on the above embodiments, the multi-expert model fusion question-answering device may also include: a template construction module and a model generation module.

[0140] A template construction module, used to pre-construct prompt word templates corresponding to different task fields before inputting user input questions into the pre-trained routing model;

[0141] The model generation module is used to generate N expert models for adapting to input problems in different task fields based on each prompt word template by adopting a prompt learning method.

[0142] Furthermore, based on the above embodiments, the multi-expert model fusion question-answering device may further include: a sample set acquisition module and a routing model construction module.

[0143] A sample set acquisition module is used to acquire a training sample set before inputting a user input question into a pre-trained routing model; wherein the training sample includes a question sample and a correctness index when N expert models answer the question sample, the correctness index includes a correct answer or an incorrect answer, and the correctness index of at least one expert model in the training sample for the question sample is a correct answer;

[0144] The routing model construction module is used to perform model training on a preset RoBERTa model using the training sample set and a multi-label classification method to obtain the routing model.

[0145] Based on the above embodiments, the sample set acquisition module is specifically used to:

[0146] Construct current question samples and correct answers that match the current question samples;

[0147] Input the current question samples into N expert models respectively to obtain N current expert answers;

[0148] Calculate the similarity between each expert model and the correct answer respectively, and perform an operation of obtaining an expert model whose similarity is greater than a preset similarity threshold;

[0149] If at least one matching expert model is successfully obtained, the correctness index of each matching expert model is set to a correct answer, and the correctness index of the remaining expert models is set to an incorrect answer, so as to construct a training sample;

[0150] If any matching expert model is not successfully obtained, the correctness index of the expert model with the greatest similarity is set to the correct answer, and the correctness indexes of the remaining expert models are set to the wrong answers, so as to construct a training sample.

[0151] The fusion question-answering device of multiple expert models provided in the embodiment of the present invention can execute the fusion question-answering method of multiple expert models provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0152] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0153] Embodiment 4

[0154] Figure 7 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0155] like Figure 7 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0156] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0157] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, such as the fusion question-answering method of multiple expert models, that is:

[0158] Input the user input question into the pre-trained routing model, and obtain k target expert models selected by the routing model from N expert models for answering the user input question;

[0159] Among them, N>k; different expert models are suitable for input problems in different task fields;

[0160] The user input question is answered by k target expert models, and the expert answers output by each target expert model are fused and output.

[0161] In some embodiments, the fusion question-answering method of multiple expert models may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the fusion question-answering method of the multiple expert models described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the fusion question-answering method of the multiple expert models in any other appropriate manner (e.g., by means of firmware).

[0162] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0163] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0164] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0165] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0166] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0167] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0168] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0169] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.< / question> < / endoftext> < / startoftext> < / text>

Claims

1. A multi-expert model fusion question answering method, characterized in that: include: Input the user input question into the pre-trained routing model, and obtain k target expert models selected by the routing model from N expert models for answering the user input question; Among them, N>k; different expert models are suitable for input problems in different task fields; The user input question is answered by k target expert models, and the expert answers output by each target expert model are fused and output.

2. The method according to claim 1, characterized in that Obtain k target expert models selected by the routing model from N expert models for answering user input questions, including: Calculate the probability value of each expert model correctly answering the user input question according to the input user input question through the routing model to obtain a probability value sequence; In descending order of probability values, retain the first k probability values ​​in the probability value sequence, and set the remaining probability values ​​to 0 to obtain an updated probability value sequence; Normalize each non-zero probability value in the updated probability value sequence to obtain an integrated weight sequence; Among them, the k non-zero weight values ​​in the integrated weight sequence correspond to k target expert models, and the sum of the k non-zero weight values ​​is 1.

3. The method according to claim 2, characterized in that The user input question is answered by k target expert models, and the expert answers output by each target expert model are merged and output, including: Inputting the user input questions into k target expert models respectively; The probability distribution values ​​generated by each target expert model at each time step that match the target vocabulary are weighted and summed according to the integrated weight sequence, and the expert answer is output according to the probability distribution value obtained after the summation.

4. The method according to claim 1, characterized in that: Before feeding the user input question into the pre-trained routing model, it also includes: Pre-build prompt word templates corresponding to different task areas; Using the prompt learning method, N expert models are generated based on each prompt word template to adapt to input problems in different task fields.

5. The method according to any one of claims 1 to 4, characterized in that: Before feeding the user input question into the pre-trained routing model, it also includes: Obtain a training sample set; The training samples include question samples and the correctness indicators of the N expert models when answering the question samples. The correctness indicators include correct answers or incorrect answers. The correctness indicator of at least one expert model in the training samples for the question samples is a correct answer. The training sample set is used to perform model training on the preset RoBERTa model using a multi-label classification method to obtain the routing model.

6. The method according to claim 5, characterized in that Get the training sample set, including: Construct current question samples and correct answers that match the current question samples; Input the current question samples into N expert models respectively to obtain N current expert answers; Calculate the similarity between each expert model and the correct answer respectively, and perform an operation of obtaining an expert model whose similarity is greater than a preset similarity threshold; If at least one matching expert model is successfully obtained, the correctness index of each matching expert model is set to a correct answer, and the correctness index of the remaining expert models is set to an incorrect answer, so as to construct a training sample; If any matching expert model is not successfully obtained, the correctness index of the expert model with the greatest similarity is set to the correct answer, and the correctness indexes of the remaining expert models are set to the wrong answers, so as to construct a training sample.

7. A multi-expert model fusion question-answering device, characterized in that: include: A model screening module is used to input the user input question into the pre-trained routing model, and obtain k target expert models selected by the routing model from N expert models for answering the user input question; Among them, N>k; different expert models are suitable for input problems in different task fields; The answer output module is used to answer the user input question through k target expert models, and fuse the expert answers output by each target expert model and output them.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the multi-expert model fusion question-answering method described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the multi-expert model fusion question-answering method according to any one of claims 1 to 6 when executed.

10. A computer program product, characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the fusion question-answering method of the multi-expert model according to any one of claims 1-6.

Citation Information

Cited By

  • Interactive question answering system and question answering method based on multi-model parallel reasoning

    CN120144724A

  • An interactive question-answering system and question-answering method based on multi-model parallel reasoning

    CN120144724B

  • Question and answer model cluster collaborative question and answer method, system and device based on dual reinforcement learning and medium

    CN120338123A

  • Question and answer model cluster collaborative question and answer method, system, device and medium based on double reinforcement learning

    CN120338123B

  • Service request processing method and device, storage medium and electronic equipment

    CN120455551A