Model generation method and apparatus, computer storage medium, electronic equipment
By detecting pre-configured forgetting model generation strategies and incremental parameter adjustments, a forgetting model is generated, which solves the problems of high cost and resource waste in existing technologies, and achieves efficient forgetting of specific data while maintaining model performance.
Patent Information
- Application Number
- CN202410389643.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-01
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2044-04-01
AI Technical Summary
Existing forgetting learning methods are too costly, requiring model restructuring and retraining, resulting in wasted computational resources and an inability to effectively forget specific data.
By detecting the pre-configured forgetting model generation strategy, iterative training is performed using the dataset to be forgotten to obtain parameter increments. Based on the increments and hyperparameters, the original model parameters are adjusted to generate a forgetting model, thus avoiding the need to readjust the model structure.
It enables efficient forgetting of specific data without changing the model structure, reducing costs, ensuring that the performance of general tasks does not degrade, and reducing the risk caused by the model.
Smart Images

Figure CN118297182B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, and in particular to a model generation method, a model generation apparatus, a computer storage medium, and an electronic device. Background Technology
[0002] Machine Unlearning is a form of reverse engineering of machine learning. Its purpose is to make a trained model "forget" the features of a certain data point and restore it to the state before that data point was trained, thereby protecting the privacy of the data.
[0003] In related technologies, the forgetting model is usually obtained by redesigning the structure of the trained base model and retraining it, but this approach is obviously too costly.
[0004] Therefore, there is an urgent need in this field to develop a new model generation method and apparatus.
[0005] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure. Summary of the Invention
[0006] The purpose of this disclosure is to provide a model generation method, a model generation apparatus, a computer storage medium, and an electronic device, thereby overcoming, at least to some extent, the technical problem of excessively high costs caused by limitations in related technologies.
[0007] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part from practice of this disclosure.
[0008] According to a first aspect of this disclosure, a model generation method is provided, comprising:
[0009] Detect a pre-configured forgetting model generation strategy; the forgetting model generation strategy is used to indicate the method of generating a forgetting model corresponding to the original model; the forgetting model generation strategy includes at least a first strategy;
[0010] In response to the pre-configured forgetting model generation strategy being the first strategy, the original model is iteratively trained based on the acquired dataset to be forgotten until the original model meets the first preset training termination condition, and new model parameters are obtained.
[0011] Obtain the parameter increment between the new model parameters and the original model parameters;
[0012] The model parameters of the original model are adjusted according to the parameter increment to obtain the forgetting model corresponding to the original model.
[0013] In an exemplary embodiment of this disclosure, the dataset to be forgotten is obtained in the following manner:
[0014] Obtain the initial dataset to be forgotten;
[0015] The initial dataset to be forgotten is preprocessed to obtain the dataset to be forgotten;
[0016] The preprocessing includes at least one of the following: data extraction, data cleaning, and data transformation.
[0017] In an exemplary embodiment of this disclosure, adjusting the model parameters of the original model according to the parameter increment to obtain the forgotten model corresponding to the original model includes:
[0018] The model parameters of the original model are adjusted based on the parameter increment and the pre-configured hyperparameters to obtain the forgotten model corresponding to the original model.
[0019] In an exemplary embodiment of this disclosure, adjusting the model parameters of the original model based on the parameter increment and pre-configured hyperparameters to obtain the forgotten model corresponding to the original model includes:
[0020] Obtain the first product between the parameter increment and the hyperparameter;
[0021] The model parameters of the original model are added to the first product to obtain the target model parameters;
[0022] The model parameters of the original model are replaced with the model parameters of the target model to obtain the forgotten model corresponding to the original model.
[0023] In an exemplary embodiment of this disclosure, the forgetting model generation strategy further includes a second strategy, and the method further includes:
[0024] In response to the pre-configured forgetting model generation strategy, which is the second strategy, a bypass network is constructed for a specified linear layer in the original model; the bypass network consists of a low-rank dimensionality reduction matrix and a low-rank dimensionality increase matrix.
[0025] With the model parameters of the original model frozen and only the bypass network updated, the original model after the bypass network is constructed is iteratively trained based on the dataset to be forgotten.
[0026] The process continues until the original model after the bypass network is constructed meets the second preset training termination condition, at which point a new bypass network is obtained.
[0027] The model parameters of the original model are adjusted based on the new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors to obtain the forgotten model corresponding to the original model.
[0028] In an exemplary embodiment of this disclosure, the new bypass network includes a new low-rank dimensionality reduction matrix and a new low-rank dimensionality increase matrix;
[0029] The step of adjusting the model parameters of the original model based on the new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors to obtain the forgotten model corresponding to the original model includes:
[0030] Obtain the second product between the pre-configured hyperparameters and the pre-configured hyperparameter scaling factor;
[0031] Obtain the third product between the new low-rank reduced-dimensional matrix and the new low-rank increased-dimensional matrix, and obtain the fourth product corresponding to the second product and the third product;
[0032] The forgetting model corresponding to the original model is obtained by replacing the specified model parameters corresponding to the specified linear layer in the original model with the fourth product.
[0033] In an exemplary embodiment of this disclosure, after obtaining the forgetting model corresponding to the original model, the method further includes:
[0034] Verify the first forgetting performance of the forgetting model on the dataset to be forgotten and the first generalization performance of the forgetting model on a general dataset;
[0035] In addition, verify the second forgetting performance of the original model for the dataset to be forgotten and the second generalization performance of the original model for the general dataset;
[0036] Based on the comparison results between the first forgetting performance and the second forgetting performance, and the comparison results between the first generalization performance and the second generalization performance, it is determined whether the forgetting model should be updated again.
[0037] In an exemplary embodiment of this disclosure, determining whether to update the forgetting model again based on the comparison result between the first forgetting performance and the second forgetting performance, and the comparison result between the first generalization performance and the second generalization performance, includes:
[0038] In response to the first forgetting performance being higher than the second forgetting performance, and the first generalization performance being no lower than the second generalization performance, the forgetting model is determined to be the final forgetting model;
[0039] In response to the first forgetting performance being lower than the second forgetting performance, or the first generalization performance being lower than the second generalization performance, the forgetting model is updated again.
[0040] In an exemplary embodiment of this disclosure, updating the forgetting model again includes:
[0041] Adjust the pre-configured hyperparameters;
[0042] The model parameters of the original model are readjusted based on the parameter increments and the updated hyperparameters to update the forgotten model;
[0043] Alternatively, the forgotten model can be updated by readjusting the model parameters of the original model based on the new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors.
[0044] According to a second aspect of this disclosure, a model generation apparatus is provided, comprising:
[0045] A strategy detection module is used to detect a pre-configured forgetting model generation strategy; the forgetting model generation strategy is used to indicate the method of generating a forgetting model corresponding to the original model; the forgetting model generation strategy includes at least a first strategy;
[0046] The training module is used to iteratively train the original model according to the acquired dataset to be forgotten, in response to the pre-configured forgetting model generation strategy being the first strategy, until the original model meets the first preset training termination condition and new model parameters are obtained.
[0047] The incremental acquisition module is used to acquire the parameter increment between the new model parameters and the model parameters of the original model;
[0048] The fine-tuning module is used to adjust the model parameters of the original model according to the parameter increment to obtain the forgotten model corresponding to the original model.
[0049] According to a third aspect of this disclosure, a computer storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the model generation method described in the first aspect above.
[0050] According to a fourth aspect of this disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the model generation method described in the first aspect by executing the executable instructions.
[0051] As can be seen from the above technical solutions, the model generation method, model generation apparatus, computer storage medium, and electronic device in the exemplary embodiments of this disclosure have at least the following advantages and positive effects:
[0052] In some embodiments of the present disclosure, the present disclosure detects a pre-configured forgetting model generation strategy. In response to the pre-configured forgetting model generation strategy being the first strategy, the original model is iteratively trained based on the acquired dataset to be forgotten until the original model meets the first preset training termination condition, and new model parameters are obtained. Then, the model parameters of the original model are adjusted according to the parameter increment between the new model parameters and the model parameters of the original model to obtain the forgetting model corresponding to the original model. On the one hand, the present disclosure can achieve efficient forgetting learning without readjusting the model structure, only requiring simple incremental fine-tuning, avoiding the waste of computing resources and reducing the cost of obtaining the forgetting model. On the other hand, since the present disclosure does not change the model structure of the original model, it can ensure that the forgetting model effectively forgets specific data without degrading the performance of general tasks, thereby reducing the possibility of the model causing risk problems.
[0053] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0054] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0055] Figure 1 A flowchart illustrating the model generation method in an embodiment of this disclosure is shown.
[0056] Figure 2 This is a flowchart illustrating how, in an embodiment of this disclosure, the model parameters of the original model are adjusted according to parameter increments and pre-configured hyperparameters to obtain the forgotten model corresponding to the original model.
[0057] Figure 3 A flowchart illustrating how a forgetting model is generated according to a second strategy in an embodiment of this disclosure is shown.
[0058] Figure 4 This illustration shows a flowchart of how, in an embodiment of this disclosure, the model parameters of the original model are adjusted based on the new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors to obtain the forgotten model corresponding to the original model.
[0059] Figure 5 This diagram illustrates a process for determining whether to use the forgetting model as the final forgetting model in an embodiment of this disclosure.
[0060] Figure 6 This diagram illustrates the overall flow of the model generation method in an embodiment of this disclosure.
[0061] Figure 7 This diagram illustrates the structure of the model generation apparatus in an exemplary embodiment of this disclosure.
[0062] Figure 8 A schematic diagram of the structure of an electronic device in an exemplary embodiment of this disclosure is shown. Detailed Implementation
[0063] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of the example embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more of the specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0064] The terms “a,” “an,” “the,” and “the” are used in this specification to indicate the presence of one or more elements / components / etc.; the terms “including” and “having” are used to indicate an open-ended inclusion and to mean that there may be other elements / components / etc. in addition to the listed elements / components / etc.; the terms “first” and “second” are used only as markings and are not a limitation on the number of objects.
[0065] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities.
[0066] Large language models, during unsupervised pre-training, can easily retain sensitive data, including unauthorized or malicious data, leading to risks such as privacy violations, security vulnerabilities, and performance degradation. Furthermore, the user's "right to be forgotten" is frequently raised—the right of service providers to delete all or part of their data from the system at the user's request. While deleting data from the backend database is compliant with regulations, this is insufficient in an AI environment because widely used machine learning models often "remember" old data, which also introduces legal risks. To address these issues, forgetting learning has become a key technology, selectively eliminating the influence of specific training data points on the training model.
[0067] Generally speaking, forgetting learning is mainly divided into two categories: exact forgetting and approximate forgetting.
[0068] Current precise forgetting learning methods are mainly based on the SISA (Sharding, Isolation, Slicing, and Aggregation) framework. The key idea of SISA is to divide the training data into multiple disjoint subsets, each used to train an independent sub-model. A given data point only appears on a specific sub-model. When data is deleted, only the affected sub-model needs to be retrained. However, this approach requires redesigning and retraining the base language model, which is an unacceptable cost burden for most developers.
[0069] Approximate forgetting methods aim to reduce the impact of a given data point to an acceptable level rather than completely eliminate it. Different methods are needed for different tasks or different models, but there is currently no approximate forgetting algorithm for generative big oracle models in the relevant technology.
[0070] This disclosure aims to provide a simple and ready-to-use forgetting learning method for generative large language models, helping them to selectively forget specific data points. Compared to existing forgetting learning methods, this disclosure does not require adjusting the model structure and retraining the model; it only requires simple incremental fine-tuning to achieve efficient forgetting learning, avoiding waste of computational resources. Furthermore, this disclosure effectively forgets specific data points while ensuring that the performance of generative large language models does not degrade on general tasks, helping developers address growing concerns about privacy and copyright infringement issues associated with generative large language models.
[0071] In the embodiments of this disclosure, a model generation method is first provided, which at least to some extent overcomes the drawback of excessive cost in related technologies.
[0072] Figure 1 The diagram shows a flowchart of a model generation method in an embodiment of this disclosure. The execution entity of the model generation method can be a model generation server.
[0073] refer to Figure 1 A model generation method according to an embodiment of the present disclosure includes the following steps:
[0074] Step S110: Detect the pre-configured forgetting model generation strategy; the forgetting model generation strategy is used to indicate the method of generating the forgetting model corresponding to the original model; the forgetting model generation strategy includes at least the first strategy;
[0075] Step S120: In response to the pre-configured forgetting model generation strategy being the first strategy, the original model is iteratively trained based on the obtained dataset to be forgotten until the original model meets the first preset training termination condition, and new model parameters are obtained.
[0076] Step S130: Obtain the parameter increment between the new model parameters and the original model parameters;
[0077] Step S140: Adjust the model parameters of the original model according to the parameter increment to obtain the forgetting model corresponding to the original model.
[0078] exist Figure 1 In the technical solution provided by the illustrated embodiment, this disclosure detects a pre-configured forgetting model generation strategy. Responding to the pre-configured forgetting model generation strategy as the first strategy, the original model is iteratively trained based on the obtained dataset to be forgotten until the original model meets the first preset training termination condition, obtaining new model parameters. Then, the model parameters of the original model are adjusted according to the parameter increment between the new model parameters and the model parameters of the original model to obtain the forgetting model corresponding to the original model. On the one hand, this disclosure can achieve efficient forgetting learning without readjusting the model structure, requiring only simple incremental fine-tuning, avoiding the waste of computing resources and reducing the cost of obtaining the forgetting model. On the other hand, since this disclosure does not change the model structure of the original model, it can ensure that the forgetting model effectively forgets specific data without degrading the performance of general tasks, thereby reducing the possibility of the model causing risk problems.
[0079] The following are Figure 1 The specific implementation process of each step in the process will be explained in detail:
[0080] Before step S110, it should be noted that this disclosure pre-configures two strategies for generating forgetting models, namely the first strategy and the second strategy (hereinafter referred to as the LoRA fine-tuning strategy, Low-Rank Adaptation). The two strategies generate forgetting models in different ways. However, it should be noted that neither of the two strategies provided in this disclosure requires the costly process of reconstructing the overall model structure and retraining the model as in the prior art. Instead, efficient forgetting learning can be achieved through a simple process, avoiding the waste of computing resources.
[0081] For details, please refer to Figure 1 In step S110, the pre-configured forgetting model generation strategy is detected.
[0082] In this step, a pre-configured forgetting model generation strategy can be detected. This strategy indicates how to generate a forgetting model corresponding to the original model. The original model can be a pre-trained generative language model that has remembered some sensitive data, such as unauthorized or malicious data. The forgetting model can be a model that makes the original model forget the aforementioned sensitive data.
[0083] In step S120, in response to the pre-configured forgetting model generation strategy being the first strategy, the original model is iteratively trained based on the obtained dataset to be forgotten until the original model meets the first preset training termination condition, and new model parameters are obtained.
[0084] In this step, a dataset to be forgotten can be pre-acquired. This dataset is a specially designed dataset (for example, it may consist of sensitive data that the model needs to forget). Such datasets are typically used to evaluate whether the model can effectively forget previously learned knowledge and focus its attention on new tasks. By evaluating the model's performance when processing the dataset to be forgotten, we can understand whether the model can effectively utilize previously learned knowledge and forget it when needed.
[0085] For example, the dataset to be forgotten can be obtained by: obtaining the initial dataset to be forgotten, preprocessing the initial dataset to be forgotten, and obtaining the dataset to be forgotten.
[0086] Preprocessing refers to the process of cleaning, organizing, and standardizing data to better suit the needs of model training and data analysis. For example, the preprocessing process may include at least one of the following steps:
[0087] ① Data cleaning: Deleting invalid, erroneous, or duplicate data, filling in missing values, removing outliers, etc., to ensure data quality and accuracy;
[0088] ② Data transformation: Converting data into a format and type suitable for model training. For example, converting text data into numerical data, or normalizing data to eliminate the influence of units on the model;
[0089] ③ Data normalization and standardization: Normalize or standardize the data to map it to a specific range in order to improve the training effect and generalization ability of the model;
[0090] ④ Data Encoding: Text data or other non-numerical data requires encoding. Common encoding methods include one-hot encoding, word embedding, and converting text into a numerical representation.
[0091] ⑤ Data splitting: The dataset is split into training, validation and test sets to enable cross-validation and model evaluation during training.
[0092] By preprocessing the initial dataset to be forgotten, the constructed dataset can be made more standardized, accurate, and complete, thus providing better input data for model training. This preprocessing process can better improve the training effect and prediction accuracy of the model, and help to better solve specific tasks and problems.
[0093] After obtaining the aforementioned dataset to be forgotten, the dataset can be used as a training set. Next Token Prediction can be selected as the task, and the original model can be iteratively trained for 1-3 rounds until the original model meets the first preset training termination condition (e.g., the loss function meets the preset convergence condition) to obtain new model parameters.
[0094] The "predict the next token" task is a language modeling task in the field of natural language processing, aiming to train a language model to predict the next token for a given text sequence. During training, the model extracts features from the input text sequence and uses these features to predict the next token. Given an input sequence and a preceding token, the model will attempt to generate the correct next token.
[0095] In step S130, the parameter increment between the new model parameters and the original model parameters is obtained.
[0096] In this step, the parameter increment refers to the difference or change between two values. For example, if a value changes from 10 to 15, the increment is 5. Therefore, this disclosure allows us to obtain the parameter increment Δw by subtracting the original model parameters from the new model parameters. It should be noted that there is a one-to-one correspondence between the new model parameters and the original model parameters. Assuming the original model parameters contain three parameters (e.g., a, b, c), and the new model parameters also contain three parameters (e.g., a′, b′, c′), then we can calculate the parameter increment Δw1 between a′ and a, the parameter increment Δw2 between b′ and b, and the parameter increment Δw3 between c′ and c, respectively.
[0097] In step S140, the model parameters of the original model are adjusted according to the parameter increment to obtain the forgetting model corresponding to the original model.
[0098] In this step, for example, the model parameters of the original model can be adjusted according to the parameter increment Δw and the pre-configured hyperparameter λ to obtain the forgotten model corresponding to the original model.
[0099] For details, please refer to Figure 2 , Figure 2 This embodiment of the present disclosure illustrates how to adjust the model parameters of the original model based on parameter increments and pre-configured hyperparameters to obtain the forgotten model corresponding to the original model, including steps S201-S203:
[0100] In step S201, the first product between the parameter increment and the hyperparameter is obtained.
[0101] In this step, the first product between the above parameter increment Δw and the pre-configured hyperparameter λ (λ is less than 0 and is used to control the degree of forgetting) can be obtained, that is, Δw*λ.
[0102] Hyperparameters are parameters that need to be manually set in machine learning algorithms to control the structure of the model and the training process, rather than being determined through learning and optimization. These parameters cannot be learned directly from data, but are selected through experience and experimentation.
[0103] In step S202, the model parameters of the original model are summed with the first product to obtain the target model parameters.
[0104] In this step, the model parameters of the original model can be accumulated with the first product to obtain the target model parameters. Referring to the relevant explanation of step S130 above, for the model parameter a of the original model, a can be accumulated with Δw1*λ to obtain the target model parameters corresponding to the model parameter a.
[0105] In step S203, the model parameters of the original model are replaced based on the target model parameters to obtain the forgotten model corresponding to the original model.
[0106] In this step, the model parameters of the original model can be replaced with the target model parameters to obtain the forgotten model corresponding to the original model.
[0107] Therefore, based on this first strategy, this disclosure enables efficient forgetting learning with only simple incremental fine-tuning without needing to readjust the model structure, thus avoiding waste of computational resources. Furthermore, since this scheme does not alter the model structure, it ensures that the model effectively forgets specific data without degrading its performance on general tasks, thereby reducing the possibility of the model causing risk issues.
[0108] It should be noted that if the pre-configured model generation strategy in step S110 is the second strategy, then it can be referred to Figure 3 , Figure 3 This diagram illustrates the process of generating a forgetting model based on a second strategy in an embodiment of this disclosure, including steps S301-S304:
[0109] In step S301, in response to the pre-configured forgetting model generation strategy being the second strategy, a bypass network is constructed for the specified linear layer in the original model.
[0110] In this step, in response to the pre-configured forgetting model generation strategy being the second strategy, namely the LoRA fine-tuning strategy, this disclosure can construct a bypass network for a specified linear layer in the original model. This bypass network consists of a low-rank dimensionality-reduced matrix A initialized with a Gaussian distribution and a low-rank dimensionality-increasing matrix B initialized with all zeros.
[0111] The aforementioned specified linear layer can be at least one linear layer of the attention layer, and can be set according to the actual situation. This disclosure does not impose any special limitations on it.
[0112] Parameter initialization refers to the process of initializing and assigning values to the parameters of a machine learning or deep learning model before training it. Parameter initialization is one of the key processes in model training. It provides the model with initial parameter values, thereby helping the model to train better and improving training efficiency and model performance.
[0113] Gaussian distribution initialization refers to using a Gaussian distribution N(0, σ) 2Each parameter is randomly initialized. The choice of σ can be adaptively adjusted according to the number of connections of neurons to achieve better results. Using Gaussian distribution for parameter initialization can reduce the dimensionality of the input data to a lower space. All-zero initialization is to initialize all parameters to 0. This is a method of initializing neural parameters, which can increase the dimensionality of data from a low-dimensional space to the original dimension.
[0114] In step S302, with the model parameters of the original model frozen and only the bypass network updated, the original model after the bypass network is constructed is iteratively trained based on the dataset to be forgotten.
[0115] In this step, the original model after constructing the side network can be iteratively trained based on the dataset to be forgotten, provided that the model parameters of the original model are frozen and only the side network is updated (i.e., the low-rank dimensionality reduction matrix A and the low-rank dimensionality increase matrix B mentioned above are updated).
[0116] In step S303, a new bypass network is obtained until the original model after the bypass network is constructed meets the second preset training termination condition.
[0117] In this step, when the original model after constructing the bypass meets the second preset training termination condition, the bypass network can be finally determined.
[0118] In step S304, the model parameters of the original model are adjusted based on the new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors to obtain the forgotten model corresponding to the original model.
[0119] In this step, after determining the new bypass network, namely the new low-rank dimensionality reduction matrix A′ and the new low-rank dimensionality increase matrix B′, the model parameters of the original model can be adjusted according to the new low-rank dimensionality reduction matrix A′, the new low-rank dimensionality increase matrix B′, the pre-configured hyperparameter λ, and the pre-configured hyperparameter scaling factor α to obtain the forgetting model corresponding to the original model.
[0120] In deep learning model training, the hyperparameter scaling factor is a hyperparameter used to control the magnitude of parameter updates. This hyperparameter directly affects the amount of parameter change during training. During training, the hyperparameter scaling factor can be used to adjust the step size of the optimization algorithm, thereby affecting the direction and speed of parameter updates.
[0121] refer to Figure 4 , Figure 4This embodiment of the present disclosure illustrates how to adjust the model parameters of the original model based on a new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors to obtain the forgotten model corresponding to the original model, including steps S401-S403:
[0122] In step S401, the second product between the pre-configured hyperparameters and the pre-configured hyperparameter scaling factor is obtained.
[0123] In this step, the second product between the pre-configured hyperparameter λ and the configured hyperparameter scaling factor α can be obtained, i.e., λ*α.
[0124] In step S402, the third product between the new low-rank reduced-dimensional matrix and the new low-rank increased-dimensional matrix is obtained, and the fourth product corresponding to the second product and the third product is obtained.
[0125] In this step, given that the new bypass network includes a new low-rank reduced-dimensional matrix A′ and a new low-rank increased-dimensional matrix B′, the third product of A′ and B′ can be obtained. Then, the second product mentioned above is multiplied by the third product again to obtain the fourth product.
[0126] In step S403, the specified model parameters corresponding to the specified linear layer in the original model are replaced based on the fourth product to obtain the forgetting model corresponding to the original model.
[0127] In this step, the specified model parameters corresponding to the specified linear layer in the original model can be replaced based on the fourth product mentioned above to obtain the forgetting model corresponding to the original model.
[0128] The LoRA fine-tuning strategy simulates changes in the original parameters and updates the parameters of the linear layers by constructing bypasses, without altering other parts of the original model. Therefore, this approach can fine-tune model parameters while maintaining model performance. Due to the low-rank nature of matrices A and B, this method effectively reduces computation and memory usage, improving training efficiency. Furthermore, the introduction of bypass structures avoids overfitting issues that might arise from directly fine-tuning the original model's parameters, thus better preserving the model's generalization ability.
[0129] It should be noted that after generating the forgetting model corresponding to the original model using either the first or second strategy, you can refer to... Figure 5 , Figure 5 This illustration shows a flowchart of how to determine whether to determine the forgetting model as the final forgetting model in an embodiment of this disclosure, including steps S501-S503:
[0130] In step S501, the first forgetting performance of the forgetting model on the dataset to be forgotten and the first generalization performance of the forgetting model on a general dataset are verified.
[0131] In this step, we can verify the first forgetting performance of the forgetting model on the dataset to be forgotten and the first generalization performance of the forgetting model on a general dataset.
[0132] For example, the relevant explanation of the dataset to be forgotten can be found in step S120, and will not be repeated here. The general dataset can be a pre-processed training set that does not contain sensitive data.
[0133] For example, the performance of a forgetting model can be tested using a dataset to be forgotten. This can be done by calculating the perplexity of the forgetting model on the dataset to be forgotten, thus evaluating its forgetting performance. Perplexity is a metric for language model performance, such as accuracy in classification tasks or mean squared error in regression tasks. Higher perplexity indicates a better forgetting effect of the forgetting model on the dataset to be forgotten, meaning a better performance of the forgetting model.
[0134] Furthermore, for example, a general dataset can be used to test the generalization performance of the forgetting model. The better the generalization performance of a model, the more accurately it can predict or classify unknown data, meaning the model performs better. Optionally, metrics such as accuracy, recall, and F1 score of the forgetting model on various tasks can be calculated to evaluate the model's generalization performance on general tasks. Higher values for these metrics indicate better performance of the forgetting model on general tasks.
[0135] In step S502, the second forgetting performance of the original model on the dataset to be forgotten and the second generalization performance of the original model on the general dataset are verified.
[0136] In this step, referring to the relevant explanation of step S501 above, we can similarly verify the second forgetting performance of the original model on the dataset to be forgotten and the second generalization performance of the original model on the general dataset.
[0137] In step S503, based on the comparison results between the first forgetting performance and the second forgetting performance, and the comparison results between the first generalization performance and the second generalization performance, it is determined whether the forgetting model should be updated again.
[0138] In this step, if the first forgetting performance is higher than the second forgetting performance, and the first generalization performance is not lower than the second generalization performance, it can be determined that the currently obtained forgetting model can significantly improve its perplexity on the dataset to be forgotten while ensuring that the performance of the general task does not decrease. Therefore, the forgetting model can be determined as the final forgetting model.
[0139] If the first forgetting performance is lower than the second forgetting performance, or the first generalization performance is lower than the second generalization performance, it can be determined that the forgetting model has not achieved the goal of "significantly improving its perplexity on the dataset to be forgotten while ensuring that the performance of the general task does not decrease". Therefore, this disclosure can update the forgetting model again.
[0140] Specifically, this disclosure can adjust the pre-configured hyperparameter λ. Then, if the pre-configured forgetting model generation strategy is the first strategy, it can jump to step S140, where the model parameters of the original model are readjusted based on the parameter increment and the updated hyperparameters to update the forgetting model. If the pre-configured forgetting model generation strategy is the second strategy, it can jump to step 304, where the model parameters of the original model are readjusted based on the new bypass network, the pre-configured hyperparameters, and the pre-configured hyperparameter scaling factor to update the forgetting model, until the goal of "significantly improving its perplexity on the dataset to be forgotten while ensuring that the performance of the general task does not decrease" is achieved, and the final forgetting model is obtained.
[0141] refer to Figure 6 , Figure 6 This diagram illustrates the overall flow of the model generation method in this embodiment, including steps S601-S609:
[0142] In step S601, begin;
[0143] In step S602, the original model (i.e., the trained generative large language model) is obtained;
[0144] In step S603, it is determined whether fine-tuning is performed based on the LoRA strategy; if not, proceed to step S605.
[0145] If so, proceed to step S604 to add a bypass network to the original model;
[0146] In step S605, the dataset to be forgotten is constructed;
[0147] In step S606, train the original model / the original model after adding the bypass network until convergence;
[0148] In step S607, the parameter changes before and after training are obtained (including two cases: the first is the parameter increment between the new model parameters and the original model parameters, and the second is the new bypass network).
[0149] In step S608, the model parameters of the original model are updated according to the parameter changes;
[0150] In step S609, the process ends.
[0151] Based on the above technical solutions, this disclosure can achieve at least the following technical effects:
[0152] First, compared with existing forgetting learning methods, this disclosure does not require adjusting the model structure and retraining the model. It only requires simple incremental fine-tuning to achieve efficient forgetting learning, thus avoiding the waste of computing resources.
[0153] Second, this disclosure ensures that the performance of generative large language models does not degrade on general tasks while effectively forgetting specific data points. This helps developers address growing concerns about privacy and copyright infringement issues associated with generative large language models.
[0154] This disclosure also provides a model generation apparatus. Figure 7 This diagram illustrates the structure of the model generation apparatus in an exemplary embodiment of this disclosure; as shown below. Figure 7 As shown, the model generation device 700 may include a policy detection module 710, a training module 720, an incremental acquisition module 730, and a fine-tuning module 740.
[0155] in:
[0156] The strategy detection module 710 is used to detect a pre-configured forgetting model generation strategy; the forgetting model generation strategy is used to indicate the method of generating a forgetting model corresponding to the original model; the forgetting model generation strategy includes at least a first strategy;
[0157] The training module 720 is used to respond to the pre-configured forgetting model generation strategy as the first strategy, and to iteratively train the original model according to the acquired dataset to be forgotten until the original model meets the first preset training termination condition and obtains new model parameters.
[0158] The incremental acquisition module 730 is used to acquire the parameter increment between the new model parameters and the model parameters of the original model;
[0159] The fine-tuning module 740 is used to adjust the model parameters of the original model according to the parameter increment to obtain the forgotten model corresponding to the original model.
[0160] In an exemplary embodiment of this disclosure, the dataset to be forgotten is obtained in the following manner:
[0161] Obtain the initial dataset to be forgotten;
[0162] The initial dataset to be forgotten is preprocessed to obtain the dataset to be forgotten;
[0163] The preprocessing includes at least one of the following: data extraction, data cleaning, and data transformation.
[0164] In an exemplary embodiment of this disclosure, the incremental acquisition module 730 adjusts the model parameters of the original model according to the parameter increment to obtain the forgotten model corresponding to the original model, including:
[0165] The model parameters of the original model are adjusted based on the parameter increment and the pre-configured hyperparameters to obtain the forgotten model corresponding to the original model.
[0166] In an exemplary embodiment of this disclosure, the incremental acquisition module 730 adjusts the model parameters of the original model according to the parameter increment and pre-configured hyperparameters to obtain the forgotten model corresponding to the original model, including:
[0167] Obtain the first product between the parameter increment and the hyperparameter;
[0168] The model parameters of the original model are added to the first product to obtain the target model parameters;
[0169] The model parameters of the original model are replaced with the model parameters of the target model to obtain the forgotten model corresponding to the original model.
[0170] In an exemplary embodiment of this disclosure, the forgetting model generation strategy further includes a second strategy, and the fine-tuning module 740 is configured to:
[0171] In response to the pre-configured forgetting model generation strategy, which is the second strategy, a bypass network is constructed for a specified linear layer in the original model; the bypass network consists of a low-rank dimensionality reduction matrix and a low-rank dimensionality increase matrix.
[0172] With the model parameters of the original model frozen and only the bypass network updated, the original model after the bypass network is constructed is iteratively trained based on the dataset to be forgotten.
[0173] The process continues until the original model after the bypass network is constructed meets the second preset training termination condition, at which point a new bypass network is obtained.
[0174] The model parameters of the original model are adjusted based on the new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors to obtain the forgotten model corresponding to the original model.
[0175] In an exemplary embodiment of this disclosure, the new bypass network includes a new low-rank dimensionality reduction matrix and a new low-rank dimensionality increase matrix;
[0176] The fine-tuning module 740 adjusts the model parameters of the original model based on the new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors to obtain the forgotten model corresponding to the original model, including:
[0177] Obtain the second product between the pre-configured hyperparameters and the pre-configured hyperparameter scaling factor;
[0178] Obtain the third product between the new low-rank reduced-dimensional matrix and the new low-rank increased-dimensional matrix, and obtain the fourth product corresponding to the second product and the third product;
[0179] The forgetting model corresponding to the original model is obtained by replacing the specified model parameters corresponding to the specified linear layer in the original model with the fourth product.
[0180] In an exemplary embodiment of this disclosure, after obtaining the forgetting model corresponding to the original model, the fine-tuning module 740 is configured to:
[0181] Verify the first forgetting performance of the forgetting model on the dataset to be forgotten and the first generalization performance of the forgetting model on a general dataset;
[0182] In addition, verify the second forgetting performance of the original model for the dataset to be forgotten and the second generalization performance of the original model for the general dataset;
[0183] Based on the comparison results between the first forgetting performance and the second forgetting performance, and the comparison results between the first generalization performance and the second generalization performance, it is determined whether the forgetting model should be updated again.
[0184] In an exemplary embodiment of this disclosure, the fine-tuning module 740 determines whether to update the forgetting model again based on a comparison result between the first forgetting performance and the second forgetting performance, and a comparison result between the first generalization performance and the second generalization performance, including:
[0185] In response to the first forgetting performance being higher than the second forgetting performance, and the first generalization performance being no lower than the second generalization performance, the forgetting model is determined to be the final forgetting model;
[0186] In response to the first forgetting performance being lower than the second forgetting performance, or the first generalization performance being lower than the second generalization performance, the forgetting model is updated again.
[0187] In an exemplary embodiment of this disclosure, the fine-tuning module 740 updates the forgetting model again, including:
[0188] Adjust the pre-configured hyperparameters;
[0189] The model parameters of the original model are readjusted based on the parameter increments and the updated hyperparameters to update the forgotten model;
[0190] Alternatively, the forgotten model can be updated by readjusting the model parameters of the original model based on the new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors.
[0191] The specific details of each module in the above model generation device have been described in detail in the corresponding model generation method, so they will not be repeated here.
[0192] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0193] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.
[0194] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0195] This application also provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device.
[0196] Computer-readable storage media can be, for example—but not limited to—electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0197] A computer-readable storage medium can be sent, propagated, or transmitted for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable storage medium can be transmitted using any suitable medium, including but not limited to: wireless, wireline, optical fiber, RF, etc., or any suitable combination thereof.
[0198] A computer-readable storage medium carries one or more programs that, when executed by an electronic device, cause the electronic device to perform the methods described in the above embodiments.
[0199] Furthermore, this disclosure also provides an electronic device capable of implementing the above-described method.
[0200] Those skilled in the art will understand that various aspects of this disclosure can be implemented as a system, method, or program product. Therefore, various aspects of this disclosure can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software aspects, collectively referred to herein as a "circuit," "module," or "system."
[0201] The following reference Figure 8 To describe an electronic device 800 according to such an embodiment of the present disclosure. Figure 8 The electronic device 800 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.
[0202] like Figure 8 As shown, the electronic device 800 is manifested in the form of a general-purpose computing device. The components of the electronic device 800 may include, but are not limited to: at least one processing unit 810, at least one storage unit 820, a bus 830 connecting different system components (including storage unit 820 and processing unit 810), and a display unit 840.
[0203] The storage unit stores program code that can be executed by the processing unit 810, causing the processing unit 810 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure. For example, the processing unit 810 can perform actions such as... Figure 1 As shown: Step S110, detect a pre-configured forgetting model generation strategy; the forgetting model generation strategy is used to indicate the method of generating a forgetting model corresponding to the original model; the forgetting model generation strategy includes at least a first strategy; Step S120, in response to the pre-configured forgetting model generation strategy being the first strategy, iteratively train the original model according to the obtained dataset to be forgotten until the original model meets the first preset training termination condition, and obtain new model parameters; Step S130, obtain the parameter increment between the new model parameters and the model parameters of the original model; Step S140, adjust the model parameters of the original model according to the parameter increment to obtain the forgetting model corresponding to the original model.
[0204] Storage unit 820 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 8201 and / or cache memory 8202, and may further include a read-only memory (ROM) 8203.
[0205] The storage unit 820 may also include a program / utility 8204 having a set (at least one) of program modules 8205, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.
[0206] Bus 830 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.
[0207] Electronic device 800 can also communicate with one or more external devices 900 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 800, and / or with any device that enables electronic device 800 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 850. Furthermore, electronic device 800 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 860. As shown, network adapter 860 communicates with other modules of electronic device 800 via bus 830. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0208] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
Claims
1. A model generation method characterized by comprising: include: Detect the pre-configured forgetting model generation strategy; The forgetting model generation strategy is used to indicate the method for generating the forgetting model corresponding to the original model; The forgetting model generation strategy includes at least a first strategy; In response to the pre-configured forgetting model generation strategy being the first strategy, the original model is iteratively trained based on the acquired dataset to be forgotten until the original model meets the first preset training termination condition, and new model parameters are obtained. Obtain the parameter increment between the new model parameters and the original model parameters; The model parameters of the original model are adjusted according to the parameter increment to obtain the forgetting model corresponding to the original model; The forgetting model generation strategy also includes a second strategy, and the method further includes: In response to the pre-configured forgetting model generation strategy, which is the second strategy, a bypass network is constructed for a specified linear layer in the original model; the bypass network consists of a low-rank dimensionality reduction matrix and a low-rank dimensionality increase matrix. With the model parameters of the original model frozen and only the bypass network updated, the original model after the bypass network is constructed is iteratively trained based on the dataset to be forgotten. The process continues until the original model after the bypass network is constructed meets the second preset training termination condition, at which point a new bypass network is obtained. The model parameters of the original model are adjusted based on the new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors to obtain the forgotten model corresponding to the original model.
2. The method of claim 1, wherein, The dataset to be forgotten was obtained through the following methods: Obtain the initial dataset to be forgotten; The initial dataset to be forgotten is preprocessed to obtain the dataset to be forgotten; The preprocessing includes at least one of the following: data extraction, data cleaning, and data transformation.
3. The method according to claim 1 or 2, characterized in that, The step of adjusting the model parameters of the original model according to the parameter increment to obtain the forgetting model corresponding to the original model includes: The model parameters of the original model are adjusted based on the parameter increment and the pre-configured hyperparameters to obtain the forgotten model corresponding to the original model.
4. The method of claim 3, wherein, The step of adjusting the model parameters of the original model based on the parameter increment and pre-configured hyperparameters to obtain the forgotten model corresponding to the original model includes: Obtain the first product between the parameter increment and the hyperparameter; The model parameters of the original model are added to the first product to obtain the target model parameters; The model parameters of the original model are replaced with the model parameters of the target model to obtain the forgotten model corresponding to the original model.
5. The method of claim 1, wherein, The new bypass network includes a new low-rank dimensionality reduction matrix and a new low-rank dimensionality increase matrix; The step of adjusting the model parameters of the original model based on the new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors to obtain the forgotten model corresponding to the original model includes: Obtain the second product between the pre-configured hyperparameters and the pre-configured hyperparameter scaling factor; Obtain the third product between the new low-rank reduced-dimensional matrix and the new low-rank increased-dimensional matrix, and obtain the fourth product corresponding to the second product and the third product; The forgetting model corresponding to the original model is obtained by replacing the specified model parameters corresponding to the specified linear layer in the original model with the fourth product.
6. The method according to claim 4 or 5, characterized in that, After obtaining the forgetting model corresponding to the original model, the method further includes: Verify the first forgetting performance of the forgetting model on the dataset to be forgotten and the first generalization performance of the forgetting model on a general dataset; In addition, verify the second forgetting performance of the original model for the dataset to be forgotten and the second generalization performance of the original model for the general dataset; Based on the comparison results between the first forgetting performance and the second forgetting performance, and the comparison results between the first generalization performance and the second generalization performance, it is determined whether the forgetting model should be updated again.
7. The method of claim 6, wherein, The step of determining whether to update the forgetting model again based on the comparison results between the first forgetting performance and the second forgetting performance, and the comparison results between the first generalization performance and the second generalization performance, includes: In response to the first forgetting performance being higher than the second forgetting performance, and the first generalization performance being no lower than the second generalization performance, the forgetting model is determined to be the final forgetting model; In response to the first forgetting performance being lower than the second forgetting performance, or the first generalization performance being lower than the second generalization performance, the forgetting model is updated again.
8. The method of claim 6, wherein, The process of updating the forgetting model again includes: Adjust the pre-configured hyperparameters; The model parameters of the original model are readjusted based on the parameter increments and the updated hyperparameters to update the forgotten model; Alternatively, the forgotten model can be updated by readjusting the model parameters of the original model based on the new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors.
9. A model generation device, characterized in that, include: The policy detection module is used to detect the pre-configured forgetting model generation policy; The forgetting model generation strategy is used to indicate the method for generating the forgetting model corresponding to the original model; The forgetting model generation strategy includes at least a first strategy; The training module is used to iteratively train the original model according to the acquired dataset to be forgotten, in response to the pre-configured forgetting model generation strategy being the first strategy, until the original model meets the first preset training termination condition and new model parameters are obtained. The incremental acquisition module is used to acquire the parameter increment between the new model parameters and the model parameters of the original model; The fine-tuning module is used to adjust the model parameters of the original model according to the parameter increment to obtain the forgotten model corresponding to the original model; The forgetting model generation strategy further includes a second strategy. The fine-tuning module is used to construct a bypass network for a specified linear layer in the original model in response to the pre-configured forgetting model generation strategy being the second strategy. The bypass network consists of a low-rank dimensionality reduction matrix and a low-rank dimensionality increase matrix. With the model parameters of the original model frozen and only the bypass network updated, the original model after the bypass network is constructed is iteratively trained based on the dataset to be forgotten. The process continues until the original model after the bypass network is constructed meets the second preset training termination condition, at which point a new bypass network is obtained. The model parameters of the original model are adjusted based on the new bypass network, pre-configured hyperparameters, and pre-configured hyperparameter scaling factors to obtain the forgotten model corresponding to the original model.
10. A computer storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the model generation method according to any one of claims 1 to 8.
11. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the model generation method according to any one of claims 1 to 8 by executing the executable instructions.
Citation Information
Patent Citations
Data processing method and device, equipment and medium
CN114780997A
Zero-suppression incremental knowledge tuning method and device and electronic equipment
CN116911384A
