Continuous learning method of text instruction fine tuning scene
By using the Wasserstein distance and InsInfo value-guided playback strategy in the large language model to dynamically adjust the amount of old task data and sample selection, the forgetting problem of the large language model in text multi-task learning is solved, and efficient knowledge retention and new tasks are achieved. Adaptation significantly improves the model’s generalization ability and computational efficiency.
Patent Information
- Application Number
- CN202410704921.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-08-30
AI Technical Summary
Large language models are prone to catastrophic forgetting in the process of continuous text multi-task learning, and it is difficult to retain the knowledge of old tasks when incrementally learning new tasks. Especially in the training scenario of large language models, existing continuous learning methods have high The problem of computational overhead and parameter volume growth.
It uses a continuous learning method of text instruction fine-tuning scenarios, calculates the distribution distance between old and new task instruction embeddings through Wasserstein distance, dynamically determines the amount of playback data, and introduces InsInfo value to quantify instruction diversity and complexity, guides the selection of playback samples, and optimizes the model in increments. Anti-forgetting ability in formal learning.
It effectively alleviates the problem of catastrophic forgetting, improves the fine-tuning effect of the model on new text data, while retaining the memory of old text tasks, reducing computational overhead, suitable for large language models of different architectures, and improving generalization capabilities and Practicality.
Smart Images

Figure CN118569242A
Abstract
Description
Technical Field
[0001] The invention relates to a continuous learning method for a text instruction fine-tuning scenario. Background Art
[0002] Humans have the ability to continuously reuse and expand knowledge from experience. This ability to continuously learn and generalize knowledge is an important feature of strong artificial intelligence, which is difficult for artificial intelligence represented by deep learning to possess. Continuous learning, also known as life-long learning, is a research direction to solve such problems. Continuous learning is different from the currently known transfer learning: transfer learning emphasizes the use of knowledge learned from the source distribution to help handle new tasks, without considering the performance of the modified model on the old tasks; continuous learning focuses on expanding the adaptability of the model, integrating multi-task learning, online learning and transfer learning, and requires obtaining new data and updating model parameters at different times, and the model has relatively ideal performance on all distributions.
[0003] The main goal of continuous learning is to alleviate the catastrophic forgetting problem that is inherent in the design of neural networks. Catastrophic forgetting refers to the situation where a neural network almost completely forgets what it has learned before after learning new knowledge. In today's big data era, the emergence of new data will frequently change the paradigm of tasks, which requires neural networks to have the ability to adapt to new tasks while also retaining what they have learned on old tasks. Traditional continuous learning methods can be divided into three categories: regularization-based methods, dynamic architecture-based methods, and replay-based methods.
[0004] Regularization-based methods constrain the parameter updates of the model by introducing regularization terms. The most representative of these is the Elastic Weight Consolidation (EWC) method proposed by the Google DeepMind team in 2017. According to the memory characteristics of the mammalian brain, when some synapses are critical in previously learned tasks, they are less likely to be changed. Neural networks are composed of many connections, which are similar to the connections between neurons in the brain. Corresponding to neural networks, it is reflected in the selection of important weight parameters. The EWC algorithm therefore proposes to calculate the importance of parameters in neural networks through the Fisher information matrix, and to allocate greater protection mechanisms to more important parameters. In addition to the EWC method, traditional L1 and L2 regularization can also be used to constrain parameter updates to prevent the model from overfitting on new tasks to achieve the effect of alleviating catastrophic forgetting. The dynamic architecture-based method separates new and old tasks by introducing additional training parameters, reducing the impact of the model on old tasks when updating parameters when learning new tasks. In 2019, Google proposed Adapter-Bert, adding an Adapter structure in the middle of the pre-trained model and freezing the pre-trained parameters. During the fine-tuning stage of downstream tasks, only the parameters of the Adapter are updated, and a small number of training parameters are used to achieve a training effect close to that of the full parameters. On this basis, the AdapterCL proposed in 2020 adds an additional linear layer as a trainable parameter after each layer of the network, and constructs an independent trainable Adapter module for each task. When performing prediction tasks, the semantic perplexity is used to select the optimal module to generate the final output. The playback-based method helps the model recall previous knowledge in the form of data by replaying part of the old task data when training new tasks. When selecting old task data, a small amount of representative data is usually selected through clustering and other methods. In addition, in addition to directly sampling old task data, LAMOL uses the characteristics of the generative language model to generate pseudo samples related to the old tasks for playback, but the quality of the pseudo samples is generally not guaranteed.
[0005] Since large language models naturally have high computational overhead and large GPU storage usage, some of the existing traditional continuous learning methods cannot be directly applied to the training scenarios of large language models. Regularization-based methods will bring additional computational workloads, which will bring expensive computational overheads in the training of large language models. Dynamic architecture-based methods require setting independent additional training parameters for each task, so the number of model parameters will show a linear growth trend as the number of tasks increases. The playback-based method only needs to select a small amount of old data for training, so the additional computational workload is small and there is no need to make major changes to the model architecture. It is the most widely used method in the industry in the current era of large models.
[0006] In 2022, MetaAI proposed Continual-T0, which proved that by randomly sampling a small amount of old task data for playback, the large language model can better resist catastrophic forgetting. Instruction tuning can stimulate the knowledge acquired by the language model in the pre-training stage, and efficiently align it with various downstream task forms. It is currently the most widely used supervised fine-tuning paradigm for large language models. Therefore, in order to avoid catastrophic forgetting when incrementally learning large language models, it is of great significance to design a playback sample selection strategy for the instruction fine-tuning scenario of large language models. At present, the exploration of playback methods for instruction fine-tuning scenarios of large language models is still in its early stages. In 2023, UCLA and Peking University conducted a preliminary discussion on the playback method of instruction fine-tuning, and proposed that selecting playback data based on instructions will bring better performance. However, the above work did not conduct a detailed analysis of the playback strategy, and there is still a lot of room for exploration of the playback method in the instruction fine-tuning scenario.
[0007] In specific application scenarios, large language models have demonstrated strong capabilities in text processing tasks such as natural language understanding, text generation, and machine translation. However, these models face the problem of catastrophic forgetting in the process of text-oriented multi-task continuous learning, which is manifested in forgetting some knowledge of old tasks when incrementally learning new tasks. For text tasks, this means that while understanding new language patterns, better learning effects can be achieved without losing memory of old language structures. Therefore, continuous learning has important practical application needs in multi-task incremental learning scenarios of text.
[0008] It should be noted that the information disclosed in the above background technology section is only used for understanding the background of the present application, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the invention
[0009] The main purpose of the present invention is to overcome the defects of the above-mentioned background technology and provide a continuous learning method for text instruction fine-tuning scenarios.
[0010] To achieve the above object, the present invention adopts the following technical solutions:
[0011] A continuous learning method for a text instruction fine-tuning scenario includes the following steps:
[0012] Before or at the beginning of model training:
[0013] A1. For text task instructions, they are converted into embedded representations through a large language model to facilitate subsequent similarity calculations;
[0014] A2. For text tasks, the Wasserstein distance in optimal transfer theory is used to calculate the distribution distance between the embeddings of new and old task instructions, which is used as a measure of task similarity.
[0015] A3. For old tasks in text tasks, use a large language model to generate intent labels for all instructions of the old tasks;
[0016] A4. De-noise and normalize the generated intent labels to improve their accuracy and consistency.
[0017] A5. Based on the number and frequency of labels corresponding to each text task instruction, the InsInfo value is calculated as a quantitative indicator to measure the diversity and complexity of instructions;
[0018] During model training:
[0019] B1. Based on the calculation result of Wasserstein distance, dynamically determine the amount of replay data for each old task, and allocate more replay data to old tasks that are more different from new tasks;
[0020] B2. Use the InsInfo value to guide the selection of high-quality instruction data for playback, giving priority to text instruction data with high diversity and complexity;
[0021] B3. For text tasks, continuously evaluate the performance of the model on new and old tasks to ensure that the model can effectively retain old task knowledge and learn new tasks in incremental learning.
[0022] Further:
[0023] Step A2 includes:
[0024] The cost metric is defined by calculating the cosine distance between the new and old task instruction embeddings;
[0025] The instruction count ratio is used as the probability distribution to calculate the Wasserstein distance between tasks.
[0026] Step A3 includes:
[0027] Use a large language model to generate intent labels for instructions based on predefined prompt templates;
[0028] Unify word forms;
[0029] Get the semantic embedding of each tag;
[0030] Tags are clustered and deduplicated based on cosine similarity, and a deduplication threshold is set.
[0031] Step A5 includes:
[0032] The InsInfo metric that quantifies the amount of information about a single instruction has the following definition:
[0033]
[0034] When tasks are input into the model in the form of sequences, the previously seen instructions will be stored in the instruction pool, where N is the sum of the number of instructions of all old tasks; for each instruction, T is the number of labels corresponding to the instruction, f t For the frequency of the tth label appearing in all instructions.
[0035] Step B1 includes:
[0036] The amount of replay data for each old task is allocated according to the ratio of the calculated Wasserstein distance between the old task and the current task to the sum of the Wasserstein distances of all old tasks.
[0037] Step B2 includes:
[0038] Using the intent labels generated by A3, we use the InsInfo metric to quantify the diversity and complexity of instructions;
[0039] The generated intent labels are denoised and normalized, including the replacement of special characters, unification of word forms, and clustering and deduplication of semantic embeddings.
[0040] In step B2, the playback sample sampling process guided by InsInfo includes:
[0041] Step 1: Initialize an empty playback dataset and a list S for storing InsInfo values j ;
[0042] Step 2: From the instruction pool I i Extract the instruction set I of task j from j ;
[0043] Step 3: For Instruction Set I j Each query instruction I j,k :
[0044] a. Calculation query instruction I j,k InsInfo value S j,k ;
[0045] b. The calculated InsInfo value S j,k Add to ListS j middle;
[0046] Step 4: Traverse Instruction Set I j For each instruction Ij,k :
[0047] a. According to the InsInfo value S j,k And the sum of all InsInfo values, calculate the sampling ratio β;
[0048] b. From dataset D j Select and command I j,k Related data D j,k ;
[0049] c. According to the sampling ratio β, from the data D j,k Randomly extract β data from to form a subset;
[0050] Step 5: Add each subset extracted in step 4 to the playback dataset;
[0051] Step 6: Return the constructed playback dataset.
[0052] Sampling ratio β = (S j,k / sum(S j ))×α; where sum(S j ) is the instruction set I j The sum of the InsInfo values of all instructions in , and α is the total amount of predetermined playback data.
[0053] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the continuous learning method of the text instruction fine-tuning scenario as described above.
[0054] A computer program product, which, when executed by a processor, implements the continuous learning method for the text instruction fine-tuning scenario.
[0055] The present invention has the following beneficial effects:
[0056] The present invention proposes a continuous learning method for text instruction fine-tuning scenarios, which regards the instructions of text tasks as high-quality descriptions of tasks, designs a data-efficient method, and screens high-quality old task data for playback when training new tasks. The effect of alleviating catastrophic forgetting is better than other existing methods of the same type. In the present invention, a dynamic playback strategy based on the similarity of new and old text tasks is used, and the Wasserstein distance in the optimal transmission theory is used as a measurement method for the similarity of different distributions, so that more playback data is allocated to old task data with large differences. A measurement index InsInfo (Instruction Information Metric) for the amount of instruction information is further proposed. This index can quantify the diversity and complexity of instructions, thereby helping to select high-quality text instruction data.
[0057] The technology of the present invention is aimed at large language models. The core lies in dynamically replaying previous data through instructions, data-efficient continuous learning, to optimize the anti-forgetting ability in incremental fine-tuning scenarios. By introducing task similarity dynamic replay and instruction information measurement-guided sampling, the present invention can design the optimal replay strategy for the current training stage, help large language models more efficiently recall old task knowledge, and alleviate the catastrophic forgetting problem that occurs during incremental fine-tuning.
[0058] The present invention applies the above technology to the incremental instruction fine-tuning scenario of a large language model for text tasks, and proposes a continuous learning method for text instruction fine-tuning scenarios. In text tasks, this method optimizes the fine-tuning process of the model on new text data through dynamic playback and InsInfo-guided sampling, while retaining the memory of old text tasks, thereby effectively alleviating the problem of catastrophic forgetting. In addition, the method of the present invention takes into account the optimization of computational efficiency and model parameters during design, so that it does not require major changes to the model architecture or the introduction of additional computing overhead, and can be applied to large language models of different architectures, with strong portability. In this way, large language models can better adapt to new tasks in the continuous learning process while maintaining their adaptability to old tasks, significantly improving the generalization ability and practicality of the model.
[0059] Other beneficial effects of the embodiments of the present invention will be further described below. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 This is a framework diagram of the InsCL method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0061] The following is a detailed description of the embodiments of the present invention. It should be emphasized that the following description is only exemplary and is not intended to limit the scope and application of the present invention.
[0062] An embodiment of the present invention provides a continuous learning method for a text instruction fine-tuning scenario, comprising the following steps:
[0063] Before or at the beginning of model training:
[0064] A1. For text task instructions, they are converted into embedded representations through a large language model to facilitate subsequent similarity calculations;
[0065] A2. For text tasks, the Wasserstein distance in optimal transfer theory is used to calculate the distribution distance between the embeddings of new and old task instructions, which is used as a measure of task similarity.
[0066] A3. For old tasks in text tasks, use a large language model to generate intent labels for all instructions of the old tasks;
[0067] A4. De-noise and normalize the generated intent labels to improve their accuracy and consistency.
[0068] A5. Based on the number and frequency of labels corresponding to each text task instruction, the InsInfo value is calculated as a quantitative indicator to measure the diversity and complexity of instructions;
[0069] During model training:
[0070] B1. Based on the calculation result of Wasserstein distance, dynamically determine the amount of replay data for each old task, and allocate more replay data to old tasks that are more different from new tasks;
[0071] B2. Use the InsInfo value to guide the selection of high-quality instruction data for playback, giving priority to text instruction data with high diversity and complexity;
[0072] B3. For text tasks, continuously evaluate the performance of the model on new and old tasks to ensure that the model can effectively retain old task knowledge and learn new tasks in incremental learning.
[0073] The core technical point of the continuous learning method for the text instruction fine-tuning scenario of the present invention is to dynamically replay previous data through instructions, and to achieve data-efficient continuous learning to optimize the anti-forgetting ability in the incremental fine-tuning scenario. By introducing task similarity dynamic replay and sampling guided by instruction information measurement, the optimal replay strategy can be designed for the current training stage, helping large language models to recall old task knowledge more efficiently and alleviating the catastrophic forgetting problem that occurs during incremental fine-tuning.
[0074] The method of the present invention applies the above technology to the incremental instruction fine-tuning scenario of a large language model for text tasks, and proposes a continuous learning method for text instruction fine-tuning scenarios. In text tasks, the method optimizes the fine-tuning process of the model on new text data through dynamic playback and InsInfo-guided sampling, while retaining the memory of old text tasks, thereby effectively alleviating the problem of catastrophic forgetting. In addition, the method of the present invention takes into account the optimization of computational efficiency and model parameters during design, so that it does not require major changes to the model architecture or the introduction of additional computational overhead, and can be applied to large language models of different architectures, with strong portability. In this way, large language models can better adapt to new tasks in the continuous learning process while maintaining their adaptability to old tasks, significantly improving the generalization ability and practicality of the model.
[0075] Specifically, the present invention proposes the following two technical solutions:
[0076] Dynamic playback of task similarity: By analyzing the similarity of tasks, the present invention uses Wasserstein distance to measure the distance between different tasks, and dynamically selects the amount of playback data based on this metric, thereby allocating a larger amount of playback data to old tasks with larger differences.
[0077] Sampling guided by information metric of textual task instructions: Since complex and diverse instructions will bring better instruction fine-tuning effects, the present invention introduces a new metric called instruction information metric (InsInfo) to quantify the complexity and diversity of textual task instructions. In order to further analyze the fine-grained information contained in the textual task instructions, the present invention uses LLM to label each textual task instruction with intent. After obtaining the fine-grained label corresponding to each instruction, the number and frequency of occurrence of the label can be used as indicators to quantify the diversity and complexity of the instruction. On this basis, the InsInfo value is calculated to guide the sampling process to be more inclined to diverse and complex instruction data.
[0078] In some embodiments, the Wasserstein distance is calculated as the task similarity through the distribution of the embedded new and old text task instructions, and the amount of playback data corresponding to each old task is dynamically allocated according to the similarity with the new task, and a larger amount of playback is allocated to the old task with a larger difference;
[0079] A large language model with strong performance (such as GPT-4) can be used to label all instructions of the old task with intent, and the labels can be denoised and normalized.
[0080] On this basis, the InsInfo value is calculated by combining the number of tags and the frequency of occurrence corresponding to each instruction as a measure of the complexity and diversity of instructions. In each old task data, a larger playback sampling ratio is allocated to high-quality instructions.
[0081] In some embodiments, the dynamic playback method based on Wasserstein distance calculates the difference between two distributions according to the optimal transmission theory, and in this way, the instruction embedding distribution distance between different tasks can be obtained as the similarity.
[0082] In some embodiments, the sampling process guided by InsInfo refers to the inverse document frequency widely used in the field of information retrieval. When the instruction has more or more unique intent tags, a larger InsInfo value will be obtained, which can represent the diversity and complexity of the instruction to a certain extent. By sampling diverse and complex old task instructions, the playback effect can be optimized to alleviate catastrophic forgetting.
[0083] The specific embodiments of the present invention are further described below.
[0084] In incremental training, n text tasks can be defined as a sequence D = {D 1 ,…,D n}, the model is continuously trained in the specified order, simulating the multi-stage learning process. When the model is trained on the i-th task, the replay-based continuous learning method samples the corresponding replay data from the j-th task Where j∈[1,j-1], α is the amount of sampled data. Therefore, after using data playback, the current training data can be expressed in the following form:
[0085]
[0086] The embodiment of the present invention proposes a data-efficient continuous learning method for incremental text task instruction fine-tuning scenarios, called InsCL (Instruction-based Continual Learning) method, and uses a large number of experimental results to prove that this method can effectively alleviate the catastrophic forgetting problem in incremental learning. The instruction fine-tuning dataset usually has a specific data format consisting of three parts: {instructions, input, output}, where the instructions generally contain a high-quality natural language description of the current task. The specific data format is shown in the following table:
[0087] Table 1 Example of data template for instruction fine-tuning
[0088]
[0089] The data-efficient continuous learning method for incremental instruction fine-tuning scenarios of the present invention fully utilizes the task-related information provided by the instructions. The main execution process of InsCL is as follows: Figure 1 As shown. The subscripts of all characters are the corresponding task ids. i Represents the dataset of the i-th new task. R represents the replayed data, that is, the data sampled from the old task, which is used to help the model recall the knowledge of the old task when training the new task. W represents the Wasserstein distance between the j-th old task and the i-th new task. This distance measures the distribution difference of the embedding of the instructions of the two tasks and is used to determine the similarity between tasks. In the dynamic replay strategy, this value is used to calculate the proportion of the amount of data replayed from the old task j to the new task i. Figure 1 As shown, when the new task D i When it arrives, InsCL samples the replayed data R from all previous old tasks, with the superscript α *The area of the color block corresponds to the total amount of sampled data. The dots on the left represent the instructions contained in the task data set. InsCL first uses the Wasserstein distance in the optimal transmission to calculate the distance between the new and old tasks based on the data distribution of the instructions, and uses this as a measure of task similarity. When the difference between the new and old tasks is large, InsCL will allocate a larger amount of sampled data (corresponding to a wider color block).
[0090] After determining the amount of playback data for each old task, a metric for measuring the amount of instruction information is proposed, called InsInfo (Instruction Information Metric). Under the guidance of InsInfo, InsCL is more inclined to select data related to instructions that are both complex and diverse for playback (corresponding to longer color blocks).
[0091] Next, we will introduce the dynamic playback in InsCL and the sampling process guided by InsInfo in more detail.
[0092] Dynamic playback
[0093] Previous work on continuous learning optimized the method by calculating the similarity between new and old text tasks, and proved that the model is more likely to retain knowledge of old tasks that are more similar to the current task. Based on this idea, a dynamic replay method is proposed to allocate more replay data to old task data with large differences. Task similarity is widely discussed in many machine learning paradigms, among which the optimal transfer theory provides a method for calculating the minimum cost of changing from one distribution to another. The Wasserstein distance, as a representative method in the optimal transfer theory, is widely used to calculate the similarity between different distributions. Its definition is as follows:
[0094]
[0095] where π∈Π(μ A ,μ B ) is expressed as the marginal distribution μ A and μ B The joint probability distribution of , d is the method for calculating the cost metric, which is defined as the cosine distance here. For the instruction fine-tuning scenario, since all tasks can be described by instructions in natural language, the instruction embedding of the new and old tasks is used as x A and x B, and calculate the proportion of instructions in each task as a probability distribution. The Wasserstein distance calculated by instructions is representative and avoids the large amount of computational overhead caused by calculating with full data. The present invention uses the Wasserstein distance between new and old tasks as a representation of task similarity. When the large language model is fine-tuned on the current i-th task, the amount of sampled data for the j-th task in dynamic playback can be expressed as:
[0096]
[0097] Where W j,i Indicates old mission D j and current task D i The dynamic replay dynamically allocates the amount of data for replaying old tasks according to the similarity between new and old tasks, helping large language models to selectively recall old task knowledge.
[0098] InsInfo Guided Sampling
[0099] Many previous works have proved that by screening high-quality data, the training effect of the model on a small amount of data can be close to the effect of training with full data. Since complex and diverse instructions will bring better instruction fine-tuning effects, the instruction information quantity metric InsInfo is proposed to quantify the diversity and complexity of instructions.
[0100] In order to find diverse and complex instructions, it is necessary to further analyze the fine-grained information they contain. Models with strong instruction following capabilities have been proven to have the ability to annotate data, and the consistency and accuracy of their annotations have been manually verified. Therefore, a large language model such as GPT-4 is used to label each instruction with intent, and the input prompt template is shown in Table 2. The obtained labels are then denoised and normalized, which is mainly divided into the following two steps: (1) All special characters in the original tag are replaced with spaces, and the word forms are unified using NLTK; (2) The semantic embedding corresponding to each label is obtained through PHRASEBERT, and then the DBSCAN algorithm is used to cluster and remove duplicate semantics. Cosine similarity is used for clustering here, and the deduplication threshold is set to 0.1.
[0101] Table 2 Prompt templates for generating intent labels using GPT-4
[0102]
[0103] After obtaining the fine-grained labels corresponding to each instruction, the number and frequency of labels can be used as indicators to quantify the diversity and complexity of instructions. Inspired by the Inverse Document Frequency (IDF) widely used in the field of information retrieval, the InsInfo indicator for quantifying the amount of information in a single instruction is proposed with the following definition:
[0104]
[0105] When tasks are input into the model in the form of sequences, previously seen instructions will be stored in the instruction pool, where N represents the sum of the number of instructions of all old tasks. For each instruction, T represents the number of labels corresponding to the instruction, and f t Indicates the frequency of the tth tag appearing in all instructions. Therefore, when an instruction has more or more unique tags, it will get a larger InsInfo value, which can represent the diversity and complexity of instructions to a certain extent. Under the guidance of InsInfo information, the sampling process of playback samples can be represented by the algorithm shown in the following pseudo code:
[0106]
[0107] The playback sample sampling process guided by InsInfo includes:
[0108] Step 1: Initialize an empty playback dataset and a list S for storing InsInfo values j ;
[0109] Step 2: From the instruction pool I i Extract the instruction set I of task j from j ;
[0110] Step 3: For Instruction Set I j Each query instruction I j,k :
[0111] a. Calculation query instruction I j,k InsInfo value S j,k ;
[0112] b. The calculated InsInfo value S j,k Add to ListS j middle;
[0113] Step 4: Traverse Instruction Set I j For each instruction I j,k :
[0114] a. According to the InsInfo value S j,kand the sum of all InsInfo values to calculate the sampling ratio β; sampling ratio β = (S j,k / sum(S j ))×α; where sum(S j ) is the instruction set I j The sum of the InsInfo values of all instructions in , α is the total amount of playback data
[0115] b. From dataset D j Select and command I j,k Related data D j,k ;
[0116] c. According to the sampling ratio β, from the data D j,k Randomly extract β data from to form a subset;
[0117] Step 5: Add each subset extracted in step 4 to the playback dataset;
[0118] Step 6: Return the constructed playback dataset.
[0119] With the guidance of InsInfo, the sampling process can be made more focused on data with complex and diverse instructions. The total number of samples α in the sampling guided by InsInfo is replaced with α calculated by dynamic playback. * When , the InsCL method of the present invention is constituted.
[0120] In text tasks, this method optimizes the fine-tuning process of the model on new text data through dynamic playback and InsInfo-guided sampling, while retaining the memory of old text tasks, thereby effectively alleviating the problem of catastrophic forgetting. In addition, the method of the present invention takes into account the optimization of computational efficiency and model parameters during design, so that it does not need to significantly change the model architecture or introduce additional computational overhead, and can be applied to large language models of different architectures, with strong portability. Through this method, large language models can better adapt to new tasks in the process of continuous learning, while maintaining the ability to adapt to old tasks, significantly improving the generalization ability and practicality of the model.
[0121] Text task application example:
[0122] Assuming a text multi-task scenario with continuous updating requirements, the large language model first learns the ability to generate summaries from Amazon product reviews. Subsequently, due to the emergence of new requirements, users want to add the ability of sentiment classification based on the existing model to divide the reviews into positive and negative sentiment tendencies. Traditionally, due to the catastrophic forgetting problem that naturally exists in neural networks, the model tends to forget some of the ability to generate review summaries when learning classification tasks. The method of the present invention identifies the complexity and diversity of summary task instruction data through InsInfo values, and then replays these high-quality data during the training process of new tasks to help the model recall old knowledge.
[0123] In addition, when there are many incremental learning tasks, the model will also calculate the Wasserstein distance between each old task and the new task instruction embedding as a similarity indicator, dynamically allocate the amount of data for replaying the old task, and help the large language model selectively recall the old task knowledge. For example, in the above-mentioned scenario where comment summary generation and sentiment classification have been learned, if a new requirement for identifying high-quality comments is further introduced, the classification ability of high-quality comments and general comments will be increased on the basis of the existing model. By calculating the Wasserstein distance, since the new requirement and the sentiment classification task have a large similarity, when replaying the old task data, the present invention will allocate less playback data to the sentiment classification task, and allocate more playback data to the summary task with large differences. And after confirming the amount of playback data corresponding to each old task, the InsInfo indicator is further introduced to filter high-quality instruction data for playback.
[0124] An embodiment of the present invention further provides a storage medium for storing a computer program, which at least performs the above method when executed.
[0125] An embodiment of the present invention further provides a control device, comprising a processor and a storage medium for storing a computer program; wherein the processor is configured to execute at least the method described above when executing the computer program.
[0126] An embodiment of the present invention further provides a processor, wherein the processor executes a computer program and at least executes the method described above.
[0127] The storage medium can be implemented by any type of non-volatile storage device, or a combination thereof. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a ferromagnetic random access memory (Flash Memory), a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The storage medium described in the embodiments of the present invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0128] In the several embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0129] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0130] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0131] A person skilled in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, etc. Various media that can store program codes.
[0132] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0133] The methods disclosed in the several method embodiments provided by the present invention can be arbitrarily combined without conflict to obtain new method embodiments.
[0134] The features disclosed in several product embodiments provided by the present invention can be arbitrarily combined without conflict to obtain new product embodiments.
[0135] The features disclosed in several method or device embodiments provided by the present invention can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0136] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art of the present invention, several equivalent substitutions or obvious variations can be made without departing from the concept of the present invention, and the performance or use is the same, which should be regarded as belonging to the protection scope of the present invention.
Claims
1. A continuous learning method for fine-tuning scenarios with text instructions, It is characterized in that The following steps are involved: Before or at the beginning of model training: A1. For text task instructions, they are converted into embedded representations through a large language model to facilitate subsequent similarity calculations; A2. For text tasks, the Wasserstein distance in optimal transfer theory is used to calculate the distribution distance between the embeddings of new and old task instructions, which is used as a measure of task similarity. A3. For old tasks in text tasks, use a large language model to generate intent labels for all instructions of the old tasks; A4. De-noise and normalize the generated intent labels to improve their accuracy and consistency. A5. Based on the number and frequency of labels corresponding to each text task instruction, the InsInfo value is calculated as a quantitative indicator to measure the diversity and complexity of instructions; During model training: B1. Based on the calculation result of Wasserstein distance, dynamically determine the amount of replay data for each old task, and allocate more replay data to old tasks that are more different from new tasks; B2. Use the InsInfo value to guide the selection of high-quality instruction data for playback, giving priority to text instruction data with high diversity and complexity; B3. For text tasks, continuously evaluate the performance of the model on new and old tasks to ensure that the model can effectively retain old task knowledge and learn new tasks in incremental learning.
2. The continuous learning method according to claim 1, It is characterized in that Step A2 includes: The cost metric is defined by calculating the cosine distance between the new and old task instruction embeddings; The instruction count ratio is used as the probability distribution to calculate the Wasserstein distance between tasks.
3. The continuous learning method according to claim 1, It is characterized in that Step A3 includes: Use a large language model to generate intent labels for instructions based on predefined prompt templates; Unify word forms; Get the semantic embedding of each tag; Tags are clustered and deduplicated based on cosine similarity, and a deduplication threshold is set.
4. The continuous learning method according to claim 1, It is characterized in that Step A5 includes: The InsInfo metric that quantifies the amount of information about a single instruction has the following definition: When tasks are input into the model in the form of sequences, the previously seen instructions will be stored in the instruction pool, where N is the sum of the number of instructions of all old tasks; for each instruction, T is the number of labels corresponding to the instruction, f t For the frequency of the tth label appearing in all instructions.
5. The continuous learning method according to claim 1, It is characterized in that Step B1 includes: The amount of replay data for each old task is allocated according to the ratio of the calculated Wasserstein distance between the old task and the current task to the sum of the Wasserstein distances of all old tasks.
6. The continuous learning method according to claim 1, It is characterized in that Step B2 includes: Using the intent labels generated by A3, we use the InsInfo metric to quantify the diversity and complexity of instructions; The generated intent labels are denoised and normalized, including the replacement of special characters, unification of word forms, and clustering and deduplication of semantic embeddings.
7. The continuous learning method according to claim 1, It is characterized in that In step B2, the playback sample sampling process guided by InsInfo includes: Step 1: Initialize an empty playback dataset and a list S for storing InsInfo values j ; Step 2: From the instruction pool I i Extract the instruction set I of task j from j ; Step 3: For Instruction Set I j Each query instruction I j,k : a. Calculation query instruction I j,k InsInfo value S j,k ; b. The calculated InsInfo value S j,k Add to ListS j middle; Step 4: Traverse Instruction Set I j For each instruction I j,k : a. According to the InsInfo value S j,k And the sum of all InsInfo values, calculate the sampling ratio β; b. From dataset D j Select and command I j,k Related data D j,k ; c. According to the sampling ratio β, from the data D j,k Randomly extract β data from to form a subset; Step 5: Add each subset extracted in step 4 to the playback dataset; Step 6: Return the constructed playback dataset.
8. The continuous learning method according to claim 7, It is characterized in that Sampling ratio β = (S j,k / sum(S j ))×α; where sum(S j ) is the instruction set I j The sum of the InsInfo values of all instructions in , and α is the total amount of predetermined playback data.
9. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by a processor, the continuous learning method for the text instruction fine-tuning scenario as described in any one of claims 1 to 8 is implemented.
10. A computer program product, It is characterized in that When the computer program product is executed by a processor, the continuous learning method for the text instruction fine-tuning scenario as described in any one of claims 1 to 8 is implemented.
Citation Information
Cited By
Teaching design generation, optimization and reflection method and system based on AI chain driving
CN119886737A
