A method for constructing multi-role intelligent agents based on large language models

By performing natural language text transformation and context modeling on sample data of different roles, fine-tuning the large language model, and integrating it into multi-role agents, the problem of insufficient construction methods for multi-role agents in the existing technology is solved, and the efficient interaction of agents in multiple scenarios is achieved.

CN118964549BActive Publication Date: 2025-04-22WEIJIE TECHNOLOGY (HANGZHOU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410953944.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-17
Publication Date
2025-04-22
Estimated Expiration
2044-07-17

AI Technical Summary

Technical Problem

The existing technology has insufficient research on the construction methods of multi-role agents, which has led to the inability to meet the actual needs of users.

Method used

By receiving sample data from different roles, using a sequence-to-sequence model to convert the data into natural language text, and establish topological relationships through context modeling, generating training data sets to fine-tune the large language model, and integrating it into a multivariate role agent.

Benefits of technology

The automatic and rapid construction of multi-character agents is realized, so that they can cope with the interaction needs of many different scenarios, and improve the interactive efficiency and user experience of the agents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118964549B_ABST
    Figure CN118964549B_ABST
Patent Text Reader

Abstract

A method for constructing a multi-role intelligent agent based on a large language model is provided, which includes: receiving several groups of sample data corresponding to different roles, each group of sample data contains interaction record data, professional terms, question answering data, and operation processing data; using a sequence-to-sequence model to convert each data element in each group of sample data into a natural language text, performing context modeling on all natural language texts to establish a topological relationship between each natural language text, and obtaining multiple training data groups according to the topological relationship; wherein each training data group contains several natural language texts with strong correlation; using each training data group to fine-tune the large language model, obtain a corresponding role model, and integrate each role model into a multi-role intelligent agent. The solution of the present invention realizes the automatic and rapid construction of a multi-role intelligent agent, so that the intelligent agent can cope with the interaction needs of a variety of different scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of psychological assessment technology, and in particular to a method for constructing a multi-role intelligent agent based on a large language model. Background Art

[0002] In the field of artificial intelligence, an agent is a system that can perceive its environment and make decisions based on the perceived information to achieve a specific goal. Agents can be simple, such as rule-based systems, or complex, such as intelligent systems with learning capabilities.

[0003] By fine-tuning the large language model for data of specific tasks (corresponding to specific roles) to improve its performance on specific tasks, an agent of the corresponding role can be obtained. Agents with multiple roles are also widely needed, such as agents used in service provision robots in business places such as banks and hospitals, agents used in intelligent customer service and game AI, etc. The agents in these application scenarios need to have the functions of multiple roles so that they can switch roles between multiple specific tasks, thereby providing users with a better user experience.

[0004] However, the existing technology does not have sufficient research on the construction method of multi-role intelligent agents, resulting in the multi-role intelligent agents being unable to meet the actual needs of users. Summary of the invention

[0005] In this regard, the present invention provides a method for constructing a multi-role intelligent agent based on a large language model to solve the above technical problems.

[0006] A method for constructing a multi-role intelligent agent based on a large language model, the method comprising the following steps:

[0007] Receiving a plurality of groups of sample data corresponding to different roles, each group of the sample data comprising interaction record data, professional terms, question answering data, and operation processing data;

[0008] Using a sequence-to-sequence model, each data element in each group of the sample data is converted into a natural language text, and context modeling is performed on all the natural language texts to establish a topological relationship between the natural language texts, and a plurality of training data groups are obtained according to the topological relationship; wherein each of the training data groups contains natural language texts with strong correlation;

[0009] The large language model is fine-tuned using each of the training data sets to obtain corresponding role models, and each role model is integrated into a multi-role intelligent agent.

[0010] In some embodiments, the large language model is a GPT model or a BERT model.

[0011] In some embodiments, fine-tuning the large language model using each of the training data sets includes:

[0012] Inputting each of the training data sets into the large language model, the large language model outputting a prediction feature vector;

[0013] The predicted feature vector is input into the LDA classifier to obtain a predicted result, a deviation value between the predicted result and the corresponding true value is calculated, and the parameters of the large language model are updated and adjusted according to the deviation value, and then the remaining training data groups are input in sequence until the deviation value converges.

[0014] In some embodiments, the step of integrating the role models into a multi-role intelligent agent includes:

[0015] Use the Resnet model to perform scene prediction on all natural language texts corresponding to each of the role models to obtain several prediction scenes;

[0016] Analyzing the correlation strength of each of the predicted scenarios between the role models, and constructing a scenario correlation network of each of the role agents based on the correlation strength;

[0017] The role models are integrated into the multi-role intelligent agent based on the scene association network.

[0018] In some embodiments, the multi-role agent works as follows:

[0019] The decision maker in the multi-role intelligent agent receives the interactive content input by the user, and performs semantic understanding on the interactive content to obtain the scene type and the corresponding confidence probability;

[0020] Based on the scene type, a matching calculation is performed on the predicted scenes corresponding to each of the role models, thereby matching and obtaining a plurality of role models and corresponding matching values, determining the one with the largest matching value as the target role model, and selecting a specified number of candidate role models from the remaining matched role models according to the confidence probability;

[0021] During the interaction with the user, both the target role model and the candidate role model respond to the user's interactive content, but only the response content of the target role model is used as output. When the response content of the target role model is empty, the response content of any candidate role model is used as output.

[0022] In some embodiments, matching calculations are performed on the predicted scenes corresponding to each of the role models based on the scene type, thereby matching and obtaining a plurality of role models and corresponding matching values, including:

[0023] Calculating the semantic matching degree between the scene type and a plurality of the predicted scenes corresponding to the role model, counting the number of the predicted scenes whose semantic matching degree is higher than a first threshold, and determining the number as the matching value of the role model;

[0024] The role models whose matching values ​​are lower than a second threshold are screened out, and the remaining role models are the several role models obtained by matching.

[0025] The beneficial effect of the present invention is that the solution of the present invention realizes the automatic and rapid construction of a multi-role intelligent agent, so that the intelligent agent can cope with the interaction needs of a variety of different scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0027] Figure 1 It is a flowchart of a method for constructing a multi-role intelligent agent based on a large language model disclosed in an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The following is a description of the implementation of the present application by specific specific embodiments. People familiar with the technology can easily understand other advantages and effects of the present application from the contents disclosed in this specification. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0029] In addition, the technical features involved in the different embodiments of the present application described below can be combined with each other as long as they do not conflict with each other.

[0030] like Figure 1 As shown, an embodiment of the present invention discloses a method for constructing a multi-role intelligent agent based on a large language model, and the method comprises the following steps:

[0031] Receiving a plurality of groups of sample data corresponding to different roles, each group of the sample data comprising interaction record data, professional terms, question answering data, and operation processing data;

[0032] Using a sequence-to-sequence model, each data element in each group of the sample data is converted into a natural language text, and context modeling is performed on all the natural language texts to establish a topological relationship between the natural language texts, and a plurality of training data groups are obtained according to the topological relationship; wherein each of the training data groups contains a plurality of natural language texts with strong correlation;

[0033] The large language model is fine-tuned using each of the training data sets to obtain corresponding role models, and each role model is integrated into a multi-role intelligent agent.

[0034] The present invention first collects multiple groups of sample data from different roles, which can be assistants / consultants, teachers, customer service, etc. Correspondingly, these sample data are, for example, the work data of bank / hospital guide assistants, the work data of virtual teachers in learning machines, and the work data of intelligent customer service in applications. The above sample data includes interactive record data (interactive dialogue records in text or voice form), professional terms, question answering data, and operation processing data (processing operations for specific problems involved in interactive dialogues, such as outputting answers to questions, turning on air conditioners, etc.), which include both unstructured text data, voice data, operation processing data, and structured professional terms, question answering data, etc. The present invention first converts these sample data into natural language texts using a large language model. Then, the context modeling mechanism is used to perform semantic association analysis on all natural language texts, thereby constructing a topological relationship network containing all natural language texts. The distance between natural language texts in the topological relationship network reflects the strength of their semantic association. The natural language texts are grouped and processed according to the strength of semantic association, and each natural language text in each group corresponds to a type of interaction, such as math knowledge questions and answers, English knowledge questions and answers, and geography knowledge questions and answers in the teacher role. At this point, we have obtained multiple training data groups, each of which corresponds to a role. We use the training data groups belonging to different roles to fine-tune the large language model, and thus obtain the corresponding role model. Finally, we integrate and package all the role models to construct a multi-role model.

[0035] In some embodiments, the large language model is a GPT model or a BERT model.

[0036] In this embodiment, the sample data is converted into natural language text, which is relatively simple and single in function, so the present invention preferably uses a sequence-to-sequence (Seq2Seq) model to reduce the amount of conversion calculation. This model uses an encoder-decoder architecture to convert the input non-natural language text into a series of symbols, and then decodes it to generate natural language text.

[0037] The large language model needs to be used as the basis for building the role model, and will be used for the analysis and calculation of various complex problems in the future, so it is preferred to use the GPT model or the BERT model. After the pre-training is completed, the large language model can be fine-tuned according to specific tasks to adapt to different downstream tasks, such as text classification, question answering, machine translation, etc.

[0038] In some embodiments, fine-tuning the large language model using each of the training data sets includes:

[0039] Inputting each of the training data sets into the large language model, the large language model outputting a prediction feature vector;

[0040] The predicted feature vector is input into the LDA classifier to obtain a predicted result, a deviation value between the predicted result and the corresponding true value is calculated, and the parameters of the large language model are updated and adjusted according to the deviation value, and then the remaining training data groups are input in sequence until the deviation value converges.

[0041] In this embodiment, the large language model first extracts the corresponding feature vector from each natural language text data in the training data group, performs semantic understanding and prediction processing based on the feature vector, and obtains the predicted feature vector, which is the output result of the large language model. Then, the LDA classifier is used to verify the above output result of the large language model. Specifically, the LDA classifier classifies and calculates the predicted feature vector output by the large language model to obtain the corresponding prediction result. Since the aforementioned training data group also contains the corresponding true value, that is, the label, the accuracy of the predicted feature vector of the large language model can be confirmed by calculating the deviation value between the predicted result and the corresponding true value label. Based on this, the parameters of the large language model can be updated and adjusted, and then the remaining training data groups are sequentially input to continue fine-tuning training until the deviation value converges.

[0042] In some embodiments, the step of integrating the role models into a multi-role intelligent agent includes:

[0043] Use the Resnet model to perform scene prediction on all natural language texts corresponding to each of the role models to obtain several prediction scenes;

[0044] Analyzing the correlation strength of each of the predicted scenarios between the role models, and constructing a scenario correlation network of each of the role agents based on the correlation strength;

[0045] The role models are integrated into the multi-role intelligent agent based on the scene association network.

[0046] In this embodiment, role models corresponding to different roles can be trained through the above-mentioned method, and each role model can handle various interactive processing services adapted to the role, such as problem solving in a specific field, equipment operation processing, etc. However, when a user interacts with a multi-role intelligent agent, it may involve multiple fields. For example, when a user interacts with a multi-role intelligent agent for mathematical knowledge, he switches or inserts an interaction with a medical problem, which requires the multi-role intelligent agent to switch the corresponding role model to interact. However, when the user switches the interactive field, the multi-role intelligent agent may not be given a switching prompt. Therefore, after the user enters the interactive content of the new field, the multi-role intelligent agent needs to spend a long time to analyze the field to which the interactive content belongs, or interact with the user multiple times to confirm the field to which it belongs, and then dispatch the corresponding role model to interact, which is obviously inefficient.

[0047] In response to the above technical problems, the present invention uses the Resnet model to perform scene analysis and prediction on all natural language texts corresponding to each role model, thereby obtaining multiple prediction scenes corresponding to each role model. The prediction scene refers to all possible usage scenes that the interactive capabilities of the role model can adapt to. For example, role model 1 has the ability to interact with geographical knowledge, and the role model 1 is adapted to scenes such as geographical teaching and navigation. Role model 2 has the ability to interact with multiple planning algorithms, and the role model 1 is adapted to scenes such as route planning in navigation. Therefore, role model 1 and role model 2 have the same usage scene, namely the navigation scene, and there is a correlation between the two. Based on this, a scene association network of each role agent can be gradually established. The scene association network should also involve association strength, and the association strength is the number of identical or related prediction scenes between role models. The larger the number, the greater the corresponding association strength.

[0048] In some embodiments, the multi-role agent works as follows:

[0049] The decision maker in the multi-role intelligent agent receives the interactive content input by the user, and performs semantic understanding on the interactive content to obtain the scene type and the corresponding confidence probability;

[0050] Based on the scene type, a matching calculation is performed on the predicted scenes corresponding to each of the role models, thereby matching and obtaining a plurality of role models and corresponding matching values, determining the one with the largest matching value as the target role model, and selecting a specified number of candidate role models from the remaining matched role models according to the confidence probability;

[0051] During the interaction with the user, both the target role model and the candidate role model respond to the user's interactive content, but only the response content of the target role model is used as output. When the response content of the target role model is empty, the response content of any candidate role model is used as output.

[0052] In this embodiment, when the role models are integrated into a multi-role intelligent agent, a decision maker should be added to the multi-role intelligent agent, and the decision maker is used to schedule the corresponding role model to deal with the interaction with the user. The "user" involved in the present invention includes not only human users, but also various machines or electronic devices, and even other intelligent agents, and the present invention is not limited to this.

[0053] The user first inputs a piece of interactive content to the multi-role intelligent agent, and the decision maker in the multi-role intelligent agent performs semantic understanding of the interactive content to analyze the scene type and the corresponding confidence probability. Then, the matching calculation is performed based on the scene type and the several predicted scenes corresponding to each role model, so as to screen out several matching role models and the corresponding matching values. The one with the largest matching value is determined as the target role model, and the others are determined as candidate role models. These screened role models respond to the interactive content input by the user at the same time and give their own response content, but the decision maker only outputs the response content of the target role model to the user, and only when the response content of the target role model is empty will it select one from the response content of the candidate role model for output. That is, the user has newly switched or inserted interactive content belonging to a new field, and the target role model does not have the interactive ability for the new field and cannot output the response content. At this time, other candidate role models are switched to interact. Although the multi-role intelligent agent has switched the role model, since the candidate role model also calculates the response content at the same time, the interaction process is still timely and smooth, and the user will not perceive the interaction jam.

[0054] Among them, the number of candidate role models to be screened is determined based on the confidence probability obtained above. Specifically, when the confidence probability of the scene type predicted by the decision maker is higher, it means that the decision maker has a higher accuracy in analyzing the field to which the user's interactive content belongs at this time, and only a small number of candidate role models need to be set; and when the confidence probability of the scene type predicted by the decision maker is lower, it means that the decision maker has a lower accuracy in analyzing the field to which the user's interactive content belongs at this time, and more candidate role models need to be set at this time. By responding to the user's interactive content through more candidate role models, the candidate role models can respond in succession when the target role model cannot respond. Obviously, the more candidate role models there are, the higher the success rate of the successive response.

[0055] In some embodiments, matching calculations are performed on the predicted scenes corresponding to each of the role models based on the scene type, thereby matching and obtaining a plurality of role models and corresponding matching values, including:

[0056] Calculating the semantic matching degree between the scene type and a plurality of the predicted scenes corresponding to the role model, counting the number of the predicted scenes whose semantic matching degree is higher than a first threshold, and determining the number as the matching value of the role model;

[0057] The role models whose matching values ​​are lower than a second threshold are screened out, and the remaining role models are the several role models obtained by matching.

[0058] In this embodiment, the semantic matching degree of the scene type predicted by the decision maker and the several predicted scenes corresponding to the role model predicted by the Resnet model is calculated respectively. For example, if the scene type is a navigation scene, the several predicted scenes corresponding to role model 1 include navigation scenes, entertainment question-and-answer scenes, and video screening scenes, the several predicted scenes corresponding to role model 2 include weather broadcast scenes and geography teaching scenes, and the several predicted scenes corresponding to role model 3 include primary school knowledge teaching scenes and banking business guidance scenes. Obviously, the scene type has a high semantic matching degree with the navigation scene and entertainment question-and-answer scene (music recommendation, food recommendation, etc.) in role model 1, and also has a high semantic matching degree with the weather broadcast scene in role model 2, but has a very low semantic matching degree with the geography teaching scene, and has a very low semantic matching degree with the primary school knowledge teaching scene and banking business guidance scene in role model 3. Therefore, the matching value of role model 1 is 2, the matching value of role model 2 is 1, and the matching value of role model 3 is 0, and role model 3 is screened out because its matching value is lower than the second threshold, and the remaining role model 1 and role model 2 are the role models obtained by matching.

[0059] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment, or a part of a code, and the module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0060] In general, various example embodiments of the present disclosure may be implemented in hardware or dedicated circuits, software, firmware, logic, or any combination thereof. Certain aspects may be implemented in hardware, while other aspects may be implemented in firmware or software that may be executed by a controller, microprocessor, or other computing device. When aspects of some embodiments of the present disclosure are illustrated or described as block diagrams, flow charts, or using certain other graphical representations, it will be understood that the blocks, devices, systems, techniques, or methods described herein may be implemented as non-limiting examples in hardware, software, firmware, dedicated circuits or logic, general hardware or controllers P0781- or other computing devices, or some combination thereof.

[0061] The exemplary embodiments of the present disclosure described in detail above are merely illustrative and not restrictive. It should be understood by those skilled in the art that various modifications and combinations may be made to these embodiments or their features without departing from the principles and spirit of the present disclosure, and such modifications should fall within the scope of the present disclosure.

Claims

1. A method for constructing a multi-role intelligent agent based on a large language model, characterized in that: Receive several groups of sample data corresponding to different roles, each group of sample data includes interaction record data, professional terms, question answering data, and operation processing data; A sequence-to-sequence model is used to convert each data element in each set of sample data into a natural language text, and context modeling is performed on all the natural language texts to establish a topological relationship between the natural language texts, and multiple training data groups are obtained based on the topological relationship; each training data group contains a number of natural language texts with strong correlations; Using each training data group to fine-tune the large language model to obtain the corresponding role model, and integrating each role model into a multi-role intelligent agent, including: using the Resnet model to perform scene prediction on all natural language texts corresponding to each role model to obtain a number of prediction scenes; analyzing the correlation strength of each prediction scene between the role models, and constructing a scene association network of each role intelligent agent based on the correlation strength; integrating each role model into a multi-role intelligent agent based on the scene association network; The decision maker in the multi-role intelligent agent receives the interactive content input by the user, performs semantic understanding, and obtains the corresponding scene type and the corresponding confidence probability; based on the scene type, it performs matching calculations on several predicted scenes corresponding to each role model, matches and obtains several role models and corresponding matching values, and determines the one with the largest matching value as the target role model, and selects a specified number of candidate role models from the remaining matched role models according to the confidence probability; in the process of interaction with the user, both the target role model and the candidate role model respond to the user's interactive content, and only the response content of the target role model is used as output. When the response content of the target role model is empty, the response content of any candidate role model is used as output.

2. The method for constructing a multi-role intelligent agent based on a large language model according to claim 1, characterized in that: The large language model is a GPT model or a BERT model.

3. The method for constructing a multi-role intelligent agent based on a large language model according to claim 2, characterized in that: The fine-tuning of the large language model using each of the training data sets includes: Inputting each of the training data sets into the large language model, the large language model outputting a prediction feature vector; The predicted feature vector is input into the LDA classifier to obtain a predicted result, a deviation value between the predicted result and the corresponding true value is calculated, and the parameters of the large language model are updated and adjusted according to the deviation value, and then the remaining training data groups are input in sequence until the deviation value converges.

4. The method for constructing a multi-role intelligent agent based on a large language model according to claim 1, characterized in that: Based on the scene type, a matching calculation is performed on a plurality of the predicted scenes corresponding to each of the role models, thereby matching and obtaining a plurality of role models and corresponding matching values, including: Calculating the semantic matching degree between the scene type and a plurality of the predicted scenes corresponding to the role model, counting the number of the predicted scenes whose semantic matching degree is higher than a first threshold, and determining the number as the matching value of the role model; The role models whose matching values ​​are lower than a second threshold are screened out, and the remaining role models are the several role models obtained by matching.