A method for automatic development of language models based on meta-agent technology

Through meta-agent technology, small language models are automatically developed, which solves the limited application and privacy issues of large language models in resource-limited environments, and achieves efficient model development and performance improvement.

CN118377481BActive Publication Date: 2024-09-03HAOSHEN TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410818181.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2024-09-03
Estimated Expiration
2044-06-24

AI Technical Summary

Technical Problem

Due to the huge model size and high computing requirements, the application of large language models is limited in resource-limited environments, such as mobile devices, and there are privacy issues in models running on the cloud. It is difficult for existing technologies to effectively solve these limitations.

Method used

Using meta-agent technology, large language models are used as meta-agent to adapt to the task scenarios of the model to be developed in advance, re-label training samples, develop small language models, and perform iterative optimization through performance evaluation to achieve automated development of small language models.

Benefits of technology

It realizes the automated development of small language models, and its performance is close to that of large models, saving labor costs, improving model development efficiency, being suitable for environments with limited resources, and solving privacy issues.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118377481B
    Figure CN118377481B
Patent Text Reader

Abstract

The invention discloses a method for automatic language model development based on meta-agent technology, which relates to the technical field of model development. The method comprises: using a large language model as a meta-agent to adapt to the task scenario of the model to be developed in advance; re-labeling the sample based on the confidence of each training sample by the meta-agent; the meta-agent uses the labeled training sample to develop a small language model; the meta-agent evaluates the performance of the developed small language model, and iterates the design of the small language model according to the evaluation result. The method realizes the automatic development of small and medium-sized language models, and the performance is close to that of large models, which saves labor costs and improves the efficiency of model development.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of model development, and in particular to a language model automatic development method based on meta-agent technology. Background Art

[0002] Large language models such as GPT-4 perform well on a variety of tasks, but due to their large model size and high computing requirements, their application is limited to resource-limited environments, such as mobile devices. In addition, models running in the cloud also have privacy issues. To address these limitations, this patent proposes a meta-agent technology. The large language model is used as a meta-agent (Meta-agent) that can automatically develop agents for small language models and achieve performance close to that of large models. This technology can save the human labor required to design agents and is very important for commercial applications. Summary of the invention

[0003] The present invention provides a method for automatic development of a language model based on meta-agent technology, characterized in that the method comprises:

[0004] Step 1: Use a large language model as a meta-agent to adapt to the task scenarios of the model to be developed in advance;

[0005] Step 2: Re-label the samples based on the meta-agent’s confidence in each training sample;

[0006] Step 3: The meta-agent uses the labeled training samples to develop a small language model.

[0007] Step 4: The meta-agent evaluates the performance of the developed small language model and iterates the design of the small language model based on the evaluation results.

[0008] As described above, a method for automatically developing a language model based on meta-agent technology, in which a large language model is used as a meta-agent to adapt in advance to the task scenario of the model to be developed, specifically includes the following sub-steps:

[0009] Create a new corpus based on the task scenario of the small language model to be developed;

[0010] Fine-tune large language models using corpora;

[0011] Verify the applicability of large language models to task scenarios.

[0012] As described above, a method for automatically developing a language model based on meta-agent technology, in which a new corpus is created according to the task scenario of a small language model to be developed, specifically includes the following sub-steps:

[0013] Collect relevant text data based on the task scenario;

[0014] Segment and annotate the collected data and process them into structured data;

[0015] The processed data are integrated into a new corpus.

[0016] The above-mentioned method for automatic language model development based on meta-agent technology, in which the samples are re-labeled based on the confidence of each training sample by the meta-agent, specifically includes the following sub-steps:

[0017] Get the meta-agent's confidence for each data sample;

[0018] Re-label the samples by using confidence instead of the original hard labels of the data samples.

[0019] As described above, a method for automatically developing a language model based on meta-agent technology, wherein the meta-agent uses annotated training samples to develop a small language model, specifically includes the following sub-steps:

[0020] The meta-agent designs a small language model similar to itself based on the task scenario;

[0021] Use the training samples to train a small language model;

[0022] Adaptively tune small language models using labeled data for training examples.

[0023] The above-mentioned method for automatic language model development based on meta-agent technology, wherein the meta-agent performs performance evaluation on the developed small language model and iterates the design of the small language model according to the evaluation result, specifically includes the following sub-steps:

[0024] The meta-agent generates a set of workflows based on a small language model;

[0025] Use small language model-based workflows for task solving;

[0026] Automatically score small language models based on task solving results;

[0027] Automatically iterate on small language models based on scoring results.

[0028] The present invention also provides a language model automatic development system based on meta-agent technology, characterized in that the system comprises: a task scenario adaptation module, a training sample annotation module, a small language model development module, and a small language model iteration module;

[0029] The task scenario adaptation module is used to use a large language model as a meta-agent to adapt to the task scenario of the model to be developed in advance;

[0030] A training sample labeling module is used to relabel each training sample;

[0031] Small language model development module, used to develop small language models using labeled training samples;

[0032] The small language model iteration module is used to evaluate the performance of the developed small language model and iterate the design of the small language model based on the evaluation results.

[0033] A language model automatic development system based on meta-agent technology as described above, wherein the task scenario adaptation module includes a corpus building submodule and a large language model fine-tuning submodule;

[0034] The corpus building submodule is used to create a new corpus based on the task scenario of the small language model to be developed;

[0035] Large language model fine-tuning submodule for fine-tuning a large language model using a corpus.

[0036] A language model automatic development system based on meta-agent technology as described above, wherein the small language model development module includes a small language model design module and a small language model training submodule;

[0037] A small language model design module, which is used to design a small language model similar to the meta-agent based on the task scenario;

[0038] The small language model training submodule is used to train and adaptively tune the small language model using labeled training samples.

[0039] The beneficial effects achieved by the present invention are as follows: realizing the automated development of small and medium-sized language models with performance close to that of large models, saving labor costs and improving model development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0041] Figure 1 This is a flow chart of a method for automatic development of a language model based on meta-agent technology provided in the first embodiment of the present invention. DETAILED DESCRIPTION

[0042] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention. Embodiment 1

[0043] like Figure 1 As shown, the first embodiment of the present invention provides a method for automatic development of a language model based on meta-agent technology, including:

[0044] Step S10: Use a large language model as a meta-agent to adapt to the task scenario of the model to be developed in advance;

[0045] Determine the task types and fields to be performed based on the task scenarios of the small model to be developed, and let the large language model understand, define and parse them as the basis for the development of the small model. Specifically:

[0046] Step S11: Create a new corpus according to the task scenario of the small language model to be developed, which specifically includes the following sub-steps:

[0047] Step S111: collecting relevant text data according to the task scenario;

[0048] A task scenario refers to a model performing a specific type of task in a specific application field, such as medical question answering, language translation, text classification, etc.; relevant data sources include but are not limited to public data sets, professional literature, forums, social media, internal company documents, etc.

[0049] Step S112: segmenting and annotating the collected data to process them into structured data;

[0050] In this step, we should pay attention to pointing synonymous and near-synonymous terms to the same entity to improve the efficiency of subsequent retrieval work.

[0051] Step S113: The processed data is integrated into a new corpus.

[0052] Step S12: fine-tune the large language model using the corpus;

[0053] Add one or more layers on top of the original model specifically for training specific task scenarios, and fine-tune the model based on the data generated by the training. The fine-tuning parameters include: learning rate, batch size, and number of training rounds;

[0054] The adjustment function of the original model parameters is expressed as: ,in is the training output set, To verify the output set, is the expected output set, B is the output time, is the output value of the i-th sample in the training output set, is the expected output value of the i-th sample, is the output value of the i-th sample in the validation set, i ranges from 1 to n, and n is the number of samples. is the fluctuation detection threshold, is the gap detection threshold, t is the time-consuming detection threshold, C is the learning rate, the initial learning rate will be set to a minimum value, S is the batch size, the initial batch size is set to a maximum value, E is the number of training rounds, the initial number of training rounds is set to the minimum value, , , They are the adjustment steps of learning rate, batch size, and number of training rounds. When it is established, it means that the output of the model on the training sample fluctuates greatly and takes a long time, so execute To increase the learning rate and reduce the batch size, when If it is established, it means that the model is underfitting and needs to increase the number of training rounds. .

[0055] Step S13: verifying the applicability of the large language model to the task scenario;

[0056] Each time the model parameters are adjusted, the model output needs to be revalidated until the expected effect is achieved.

[0057] Step S20: re-labeling the samples based on the confidence of each training sample by the meta-agent;

[0058] The meta-agent is a large language model that has been fine-tuned. At this point, the meta-agent has the adaptability to the task scenario of the small model to be developed, and after repeated verification, it ensures good fit for different training samples in the task scenario. Under this premise, the training samples are re-labeled to provide data support for the subsequent training of the small model. Specifically:

[0059] Step S21: obtaining the confidence of the meta-agent for each data sample;

[0060] The meta-agent generates a probability distribution based on each training sample, which reflects the model's confidence in the sample.

[0061] Step S22: Re-label the sample by replacing the original hard label of the data sample with the confidence;

[0062] The original hard label of the data sample refers to the label of the data category. Replacing the original hard label with confidence allows the small model to better understand the training data during training.

[0063] Step S30: The meta-agent uses the labeled training samples to develop a small language model, which specifically includes the following sub-steps:

[0064] Step S31: The meta-agent designs a small language model similar to itself according to the task scenario;

[0065] The meta-agent has added one or more layers to itself specifically for adapting to the task scenario. Therefore, when designing a small model, we must first refer to the design parameters of the meta-agent, such as the number of layers, number of neurons, and attention mechanism newly added. However, considering the resource differences between the deployment environment of the small language model and the environment in which the meta-agent is located, some conversion is required to determine the preliminary design parameters of the small language model. The small language model established based on the converted basic parameters has a structure similar to that of the meta-agent, but with fewer parameters and a simpler structure. The design parameter conversion formula is expressed as:

[0066] ,in is the calculated k-th design parameter value of the small language model, is the amount of environmental resources owned by the meta-agent j, is the number of j environmental resources owned by the small language model production environment, is the influence weight of the jth environmental resource on the kth design parameter, is the kth design parameter value of the meta-agent, j ranges from 1 to m, m is the total number of environmental resources, and the influence weight of different environmental resources on the kth design parameter The estimation formula is expressed as: .

[0067] Step S32: using the training samples to perform model training on the small language model;

[0068] Step S33: the meta-agent uses the labeled data of the training samples to adaptively tune the small language model;

[0069] During the training process, the difference between the output of the small language model and the labeled data of the sample is compared, and the hyperparameters of the small language model are slowly adjusted to make the output value closer to the labeled data until the difference value reaches the minimum. The difference calculation formula between the output value and the labeled data is expressed as:

[0070] ,in is the output value of the small language model for the tth sample, is the labeled value of the tth sample, and t is the input sample subscript.

[0071] Step S40: the meta-agent performs a performance evaluation on the developed small language model, and iterates the design of the small language model according to the evaluation result;

[0072] During the development phase, the design of the small language model drew on some key parameters of the meta-agent to determine the preliminary model design parameters. In order to ensure that the design of the small language model is more suitable for the task scenario, the performance of the small language model is comprehensively evaluated, and the design parameters are iterated and optimized based on the performance evaluation results. Specifically:

[0073] Step S41: the meta-agent generates a set of workflows based on a small language model;

[0074]

[0075] here represents the initial small language model, Indicates the system prompt words used to build workflows. Represents a set of processing workflows based on a standardized description language, which is represented by a meta-agent, i.e., a large language model generate.

[0076] Step S42: solving the task using a workflow based on a small language model;

[0077]

[0078] here Represents the input of the test task, Represents the workflow generated in the previous step, Represents a workflow based on a small model The output obtained under the input.

[0079] Step S43: automatically scoring the small language model according to the task solution result;

[0080]

[0081] here Indicates the system prompt words used for scoring. They represent the task prediction value based on the small model workflow and the task label based on the large model, respectively. Represents a large model, represents the score of the i-th output, It represents the average value of all scores, and n is the number of input samples.

[0082] Step S44: automatically iterating the small language model according to the scoring result;

[0083]

[0084] here Indicates the system prompt word used to modify the task description. is the original small language model, It is a small language model modified from a large model. Embodiment 2

[0085] Embodiment 2 of the present invention provides a language model automatic development system based on meta-agent technology, including: a task scenario adaptation module, a training sample annotation module, a small language model development module, and a small language model iteration module;

[0086] (1) Task scenario adaptation module, which uses a large language model as a meta-agent to adapt to the task scenario of the model to be developed in advance;

[0087] Determine the task types and fields to be performed based on the task scenarios of the small model to be developed, and let the large language model understand, define and parse them as the basis for the development of the small model, including the corpus establishment submodule and the large language model fine-tuning submodule;

[0088] 1. Corpus establishment submodule, which is used to create a new corpus according to the task scenario of the small language model to be developed, including:

[0089] ① Collect relevant text data according to the task scenario;

[0090] A task scenario refers to a model performing a specific type of task in a specific application field, such as medical question answering, language translation, text classification, etc.; relevant data sources include but are not limited to public data sets, professional literature, forums, social media, internal company documents, etc.

[0091] ② Segment and annotate the collected data and process it into structured data;

[0092] In this step, we should pay attention to pointing synonymous and near-synonymous terms to the same entity to improve the efficiency of subsequent retrieval work.

[0093] ③The processed data is integrated into a new corpus.

[0094] 2. Large language model fine-tuning submodule, which is used to fine-tune the large language model using the corpus;

[0095] Add one or more layers on top of the original model specifically for training specific task scenarios, and fine-tune the model based on the data generated by the training. The fine-tuning parameters include: learning rate, batch size, and number of training rounds;

[0096] The adjustment function of the original model parameters is expressed as: ,in is the training output set, To verify the output set, is the expected output set, B is the output time, is the output value of the i-th sample in the training output set, is the expected output value of the i-th sample, is the output value of the i-th sample in the validation set, i ranges from 1 to n, and n is the number of samples. is the fluctuation detection threshold, is the gap detection threshold, t is the time-consuming detection threshold, C is the learning rate, and the initial learning rate will set a minimum value. For batch size, set a maximum value for the initial batch size, E for the number of training rounds, and set the initial number of training rounds to the minimum value. , , They are the adjustment steps of learning rate, batch size, and number of training rounds. When it is established, it means that the output of the model on the training sample fluctuates greatly and takes a long time, so execute To increase the learning rate and reduce the batch size, when If it is established, it means that the model is underfitting and needs to increase the number of training rounds. .

[0097] Each time the model parameters are adjusted, the model output needs to be revalidated until the expected effect is achieved.

[0098] (2) Training sample labeling module, used to re-label each training sample;

[0099] The meta-agent is a fine-tuned large language model. At this point, the meta-agent is already adaptable to the task scenario of the small model to be developed, and after repeated verification, it ensures good fit for different training samples in the task scenario. Under this premise, the training samples are re-labeled to provide data support for the subsequent training of the small model, including:

[0100] ① Obtain the meta-agent’s confidence in each data sample;

[0101] The meta-agent generates a probability distribution based on each training sample, which reflects the model's confidence in the sample.

[0102] ②Re-label the samples using confidence instead of the original hard labels of the data samples;

[0103] The original hard label of the data sample refers to the label of the data category. Replacing the original hard label with confidence allows the small model to better understand the training data during training.

[0104] (3) A small language model development module, which is used to develop a small language model using labeled training samples, including a small language model design module and a small language model training submodule;

[0105] 1. Small language model design module, which is used to design a small language model similar to the meta-agent according to the task scenario;

[0106] The meta-agent has added one or more layers to itself to adapt to the task scenario. Therefore, when designing a small model, we must first refer to the model basic parameters such as the number of layers, number of neurons, and attention mechanism newly added by the meta-agent. However, considering the resource differences between the deployment environment of the small language model and the environment in which the meta-agent is located, some conversion is required to determine the initial model basic parameters of the small language model. The small language model established based on the converted basic parameters has a structure similar to that of the meta-agent, but with fewer parameters and a simpler structure. The basic parameter conversion formula is expressed as:

[0107] ,in is the kth base parameter value of the calculated small language model, is the amount of environmental resources owned by the meta-agent j, is the number of j environmental resources owned by the small language model production environment, is the impact weight of the jth environmental resource on the kth basic parameter, is the kth basic parameter value of the meta-agent, j ranges from 1 to m, m is the total number of environmental resources, and the influence weight of different environmental resources on the kth basic parameter The estimation formula is expressed as: .

[0108] 2. Small language model training submodule, used to train and adaptively tune the small language model using labeled training samples;

[0109] During the training process, the difference between the output of the small language model and the labeled data of the sample is compared, and the hyperparameters of the small language model are slowly adjusted to make the output value closer to the labeled data until the difference value reaches the minimum. The difference calculation formula between the output value and the labeled data is expressed as:

[0110] ,in is the output value of the small language model for the tth sample, is the labeled value of the tth sample, and t is the input sample subscript.

[0111] (4) Small language model iteration module, which is used to evaluate the performance of the developed small language model and iterate the design of the small language model based on the evaluation results;

[0112] During the development phase, the design of the small language model drew on some key parameters of the meta-agent to determine the preliminary model design parameters. In order to ensure that the design of the small language model is more suitable for the task scenario, the performance of the small language model is comprehensively evaluated, and the design parameters are iterated and optimized based on the performance evaluation results. Specifically:

[0113] ① The meta-agent generates a workflow based on a small language model;

[0114]

[0115] here represents the initial small language model, Indicates the system prompt words used to build workflows. Represents a set of processing workflows based on a standardized description language, which is represented by a meta-agent, i.e., a large language model generate.

[0116] ② Use a workflow based on a small language model to solve tasks;

[0117]

[0118] here Represents the input of the test task, Represents the workflow generated in the previous step, Represents a workflow based on a small model The output obtained under the input.

[0119] ③ Automatically score the small language model based on the task solution results;

[0120]

[0121] here Indicates the system prompt words used for scoring. They represent the task prediction value based on the small model workflow and the task label based on the large model, respectively. Represents a large model, represents the score of the i-th output, It represents the average value of all scores, and n is the number of input samples.

[0122] ④Automatically iterate the small language model based on the scoring results;

[0123]

[0124] here Indicates the system prompt word used to modify the task description. is the original small language model, It is a small language model modified from a large model.

[0125] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for automatic development of language models based on meta-agent technology, characterized in that: The method comprises: Step 1: Use a large language model as a meta-agent to adapt to the task scenarios of the model to be developed in advance; Step 2: Re-label the samples based on the meta-agent’s confidence in each training sample; Step 3: The meta-agent uses the labeled training samples to develop a small language model and puts the developed small language model into the production environment; The meta-agent designs a small language model similar to itself based on the task scenario; The basic parameter conversion formula is expressed as: ,in is the kth base parameter value of the calculated small language model, is the amount of environmental resources owned by the meta-agent j, is the number of j environmental resources owned by the small language model production environment, is the impact weight of the jth environmental resource on the kth basic parameter, is the kth basic parameter value of the meta-agent, j ranges from 1 to m, m is the total number of environmental resources, and the influence weight of different environmental resources on the kth basic parameter The estimation formula is expressed as: ; Use the training samples to train a small language model; Use the labeled data of training samples to adaptively tune the small language model and put it into the production environment after it meets the application standards; Step 4: The meta-agent monitors the performance of the small language model in the production environment and regularly iterates and optimizes the small language model.

2. The method for automatic language model development based on meta-agent technology according to claim 1, characterized in that: Using a large language model as a meta-agent to adapt to the task scenario of the model to be developed in advance includes the following sub-steps: Create a new corpus based on the task scenario of the small language model to be developed; Fine-tune large language models using corpora; Verify the applicability of large language models to task scenarios.

3. The method for automatic language model development based on meta-agent technology according to claim 2, characterized in that: Create a new corpus based on the small language model task scenario to be developed, which includes the following sub-steps: Collect relevant text data based on the task scenario; Segment and annotate the collected data and process them into structured data; The processed data are integrated into a new corpus.

4. The method for automatic language model development based on meta-agent technology according to claim 1, characterized in that: Re-label the samples based on the meta-agent's confidence in each training sample, which includes the following sub-steps: Get the meta-agent's confidence for each data sample; Re-label the samples by using confidence instead of the original hard labels of the data samples.

5. The method for automatic language model development based on meta-agent technology according to claim 1, characterized in that: The meta-agent monitors the performance of the small language model in the production environment and regularly iterates and optimizes the small language model, including the following sub-steps: The meta-agent sets up performance monitoring points in the production environment to obtain performance feedback data of the small language model; Extract the context of feedback data into new training samples and use the meta-agent to annotate the new samples; Further train the small language model based on the new training samples, and tune the parameters of the small language model during the training process; Replace the old model of the current production environment with the tuned small language model.

6. A language model automatic development system based on meta-agent technology, characterized in that: The system includes: a task scenario adaptation module, a training sample annotation module, a small language model development module, and a small language model iteration module; The task scenario adaptation module is used to use a large language model as a meta-agent to adapt to the task scenario of the model to be developed in advance; A training sample labeling module is used to relabel each training sample; Small language model development module, which is used to develop small language models using labeled training samples and put the developed small language models into production environments; The meta-agent designs a small language model similar to itself based on the task scenario; The basic parameter conversion formula is expressed as: ,in is the kth base parameter value of the calculated small language model, is the amount of environmental resources owned by the meta-agent j, is the number of j environmental resources owned by the small language model production environment, is the impact weight of the jth environmental resource on the kth basic parameter, is the kth basic parameter value of the meta-agent, j ranges from 1 to m, m is the total number of environmental resources, and the influence weight of different environmental resources on the kth basic parameter The estimation formula is expressed as: ; Use the training samples to train a small language model; Use the labeled data of training samples to adaptively tune the small language model and put it into the production environment after it meets the application standards; The small language model iteration module is used to monitor the performance of the small language model in the production environment and regularly iterate and optimize the small language model.

7. The language model automatic development system based on meta-agent technology according to claim 6, characterized in that: The task scenario adaptation module includes a corpus building submodule and a large language model fine-tuning submodule; The corpus building submodule is used to create a new corpus based on the task scenario of the small language model to be developed; Large language model fine-tuning submodule for fine-tuning a large language model using a corpus.

8. The language model automatic development system based on meta-agent technology according to claim 6, characterized in that: The small language model development module includes a small language model design module and a small language model training submodule; A small language model design module, which is used to design a small language model similar to the meta-agent based on the task scenario; The small language model training submodule is used to train and adaptively tune the small language model using labeled training samples.