Data forgetting method and device for text generation model
Through comparative learning methods, the parameters of the text generation model are updated using negative sample pairs, and the problem of large-scale language models absorbing wrong knowledge in the pre-training stage is solved, selective forgetting of the model is realized, and rationality and compliance of generated answers are improved. sex.
Patent Information
- Application Number
- CN202411313013.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2024-12-27
AI Technical Summary
The error, useless or harmful knowledge absorbed by large-scale language models during the pre-training phase can lead to negative effects, or even legal risks, and a reasonable method of data forgetting is needed to ensure that the generated answers are reasonable and compliant.
By obtaining negative sample pairs containing words that need to be forgotten, using the text generation model to convert words into embedding representations, and compute the comparison loss based on the similarity between the embedded representations, and update the model parameters to reduce the word elements that need to be forgotten. Embed the expression of the representation, thereby achieving selective forgetting.
Effectively ensure that text-generating models forget the knowledge of negative impacts, improve their credibility and compliance, avoid adverse outcomes and legal risks, while maintaining the model’s learning outcomes in other aspects.
Smart Images

Figure CN119204147A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification belong to the field of computer technology, and in particular, to a method and device for data forgetting of a text generation model. Background Art
[0002] Large Language Models (LLMs) are language models built with deep neural networks containing more than tens of billions of parameters, and are trained using a large amount of unlabeled text using self-supervised learning methods. Among them, large-scale language models can process and generate natural language text and can be called text generation models.
[0003] Text generation models absorb and store a large amount of knowledge during the pre-training phase, but this knowledge may contain erroneous, useless, or harmful knowledge, which may negatively affect the output of the application and even lead to undesirable results or legal risks.
[0004] Therefore, there is an urgent need for a reasonable and reliable solution that can enable the text generation model to forget knowledge that may have a negative impact (such as malicious content, inaccurate or false content, infringing information, copyright-related content, and personal privacy content), so as to ensure that the answers generated by the text generation model are reasonable and compliant, and to improve the credibility and compliance of the text generation model. Summary of the invention
[0005] The purpose of the present invention is to provide a data forgetting solution for a text generation model, which can enable the text generation model to forget knowledge that may have a negative impact, so as to ensure that the answers generated by the text generation model are reasonable and compliant, and improve the credibility and compliance of the text generation model.
[0006] A first aspect of the present specification provides a data forgetting method for a text generation model, wherein the text generation model has been pre-trained, and part of the training data used for the pre-training is set as a forgetting data set, wherein the forgetting data set includes word-grams set to be forgotten, and the method includes: obtaining a first negative sample pair, which includes a first word-gram and a second word-gram, wherein the first word-gram is the word-gram to be forgotten in the forgetting data set; using the text generation model, converting the first word-gram into a first embedding representation, and converting the second word-gram into a second embedding representation; determining a first contrast loss based on a first similarity between the first embedding representation and the second embedding representation, wherein the first contrast loss is positively correlated with the first similarity; and updating the parameters of the text generation model based on the first contrast loss.
[0007] According to a second aspect of the present specification, there is provided a data forgetting device for a text generation model, wherein the text generation model has been pre-trained, and part of the training data used for the pre-training is set as a forgetting data set, wherein the forgetting data set includes word-grams set to be forgotten, and the device includes: an acquisition unit, configured to acquire a first negative sample pair, which includes a first word-gram and a second word-gram, wherein the first word-gram is the word-gram to be forgotten in the forgetting data set; a conversion unit, configured to use the text generation model to convert the first word-gram into a first embedding representation, and to convert the second word-gram into a second embedding representation; a loss determination unit, configured to determine a first contrast loss according to a first similarity between the first embedding representation and the second embedding representation, wherein the first contrast loss is positively correlated with the first similarity; and a parameter updating unit, configured to update the parameters of the text generation model according to the first contrast loss.
[0008] A third aspect of the present specification provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method described in the first aspect.
[0009] A fourth aspect of the present specification provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in the first aspect is implemented.
[0010] A fifth aspect of the present specification provides a computer program product, comprising a computer program / instructions, which implement the method described in the first aspect when executed by a processor.
[0011] The solution provided by the embodiment of this specification can obtain a first negative sample pair containing a second word and a first word that needs to be forgotten, and then use a text generation model to convert the first word into a first embedding representation and the second word into a second embedding representation, and then determine a first contrast loss that is positively correlated with the first similarity based on the first similarity between the first embedding representation and the second embedding representation, and update the parameters of the text generation model based on the first contrast loss. Therefore, the solution can adopt the idea of contrastive learning, and through a large number of negative sample pairs containing words that need to be forgotten for training, the text generation model learns to reduce the expression of the embedding representation of the word that needs to be forgotten, thereby forgetting the word, to ensure that the answer of the text generation model is reasonable and compliant, and to improve the credibility and compliance of the text generation model. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0013] Figure 1 It is a schematic diagram of an application scenario in which the embodiments of this specification can be applied;
[0014] Figure 2 is a flow chart of a data forgetting method for a text generation model in an embodiment of this specification;
[0015] Figure 3 is another flow chart of the data forgetting method of the text generation model in the embodiments of this specification;
[0016] Figure 4 is another flow chart of the data forgetting method of the text generation model in the embodiment of this specification;
[0017] Figure 5 It is a structural diagram of a data forgetting device of a text generation model in an embodiment of this specification. DETAILED DESCRIPTION
[0018] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0019] As mentioned earlier, text generation models absorb and store a lot of knowledge during the pre-training phase, but this knowledge may contain erroneous, useless, or harmful knowledge, which may negatively affect the output of the application and even lead to undesirable results or legal risks.
[0020] The embodiments of this specification provide a data forgetting solution for a text generation model, which can enable the text generation model to forget knowledge that may have a negative impact, so as to ensure that the answers generated by the text generation model are reasonable and compliant, and improve the credibility and compliance of the text generation model.
[0021] It should be noted that in the selective forgetting learning of the text generation model, it is often required to only forget a small amount of training data, so the ideal text generation model after selective forgetting learning should be similar to the original text generation model learned from all the training data. Therefore, the embodiment of this specification provides a solution that uses a hot start strategy to accelerate the training process of the model selective forgetting learning, that is, the original text generation model is used as the text generation model to be selectively forgotten. By using the parameters of the original text generation model as the training starting point for selective forgetting learning, the cost and time consumption of training from scratch are avoided. Such a strategy is particularly efficient in scenarios where only a small amount of data needs to be forgotten, ensuring a high degree of similarity between the text generation model after selective forgetting learning and the original text generation model.
[0022] Figure 1 It is a schematic diagram of an application scenario in which the embodiments of this specification can be applied. Figure 1 The application scenario shown involves a pre-trained text generation model f, and a forgetting data set set according to part of the training data used for the pre-training. Each piece of training data in the part of the training data includes one or more word units that need to be forgotten. The forgetting data set includes word units that are set to be forgotten. In one example, the forgetting data set can be formed by each word unit that needs to be forgotten in the part of the training data, for example, each word unit can be used as forgetting data to form a forgetting data set. In another example, the forgetting data set can be formed by the part of the training data, for example, the part of the training data can be used as forgetting data to form a forgetting data set; further, when the text generation model f is required to forget the specific information (the word unit that needs to be forgotten) and the relationship between the context of the specific information to achieve forgetting the specific information, the forgetting data set is formed by the part of the training data.
[0023] In order to maintain the overall structural integrity of the text generation model f and ensure that the text generation model f forgets specific information, the idea of contrastive learning can be used to construct negative sample pairs containing word units that need to be forgotten and word units that do not need to be forgotten, and then train the text generation model f based on the negative sample pairs. Among them, for any word unit that needs to be forgotten, one or more negative sample pairs can be constructed for the word unit.
[0024] Take the word x1 that needs to be forgotten in the forgetting data set as an example, Figure 1 As shown in , a negative sample pair N1 including word-gram x1 and word-gram k1 can be constructed. The word-gram k1 can be any word-gram that does not need to be forgotten in all the training data used for the above pre-training; or, the word-gram x1 and the word-gram k1 are included in the training data D1, and the word-gram k1 is the context of the word-gram x1. It should be pointed out that when the forgotten data set is formed by the above part of the training data, the training data D1 is specifically the forgotten data in the forgotten data set.
[0025] When training the text generation model f based on the negative sample pair N1, the text generation model f can be used to convert the word x1 into an embedded representation f(x1), and to convert the word k1 into an embedded representation f(k1). Afterwards, the contrast loss L1 can be determined based on f(x1) and f(k1). Specifically, the contrast loss L1 is determined based on the similarity S1 between f(x1) and f(k1), and the contrast loss L1 is positively correlated with the similarity S1. Then, the parameters of the text generation model f can be updated based on the contrast loss L1. It should be understood that the higher the similarity S1, the greater the contrast loss L1, and the lower the similarity S1, the smaller the contrast loss L1. Updating the parameters of the text generation model f with the goal of minimizing the contrast loss L1 can reduce the similarity between the embedded representations of word x1 and word k1, and distance the embedded representations of word x1 and word k1, thereby achieving the purpose of making the text generation model f forget word x1.
[0026] Next, combine Figure 2 , introduces the data forgetting process of the text generation model. Among them, Figure 2 It is a flow chart of the data forgetting method of the text generation model in the embodiment of this specification. The text generation model has been pre-trained, and part of the training data used for the pre-training is set as a forgetting data set, and the forgetting data set includes the word elements set to be forgotten. The method can be executed by any device, platform or device cluster with computing and processing capabilities, including steps S201-S207 as shown below.
[0027] like Figure 2 As shown, first, in step S201, a first negative sample pair is obtained, which includes a first word-gram and a second word-gram, and the first word-gram is a word-gram that needs to be forgotten in the forgetting data set.
[0028] Specifically, in one embodiment, a negative sample pair set can be constructed in advance based on a forgotten data set, so that a negative sample pair can be obtained from the negative sample pair set as a first negative sample pair. In another embodiment, one or more words that need to be forgotten can be selected from the forgotten data set as the first word, and one or more first negative sample pairs can be constructed for each first word. For example, the context of the first word in the training data in which it is located can be used as the second word to generate a first negative sample pair including the first word and the second word; or, one or more words that do not need to be forgotten in all the training data used for the above pre-training can be used as the second word, and each second word can be used with the first word to form a first negative sample pair.
[0029] It should be understood that the first negative sample pair obtained in step S201 is one or more first negative sample pairs. The multiple first negative sample pairs are constructed for one first word unit, or for multiple different first word units.
[0030] Next, in step S203, the text generation model is used to convert the first word-gram into a first embedding representation, and the second word-gram is converted into a second embedding representation.
[0031] Specifically, for each first negative sample pair obtained, the text generation model is used to convert the first word in the first negative sample pair into a first embedding representation, and the second word in the first negative sample pair into a second embedding representation. In one example, the first negative sample pair can be directly input into the text generation model for embedding processing, so that the text generation model outputs the respective embedding representations of the first word and the second word in the first negative sample pair. In another example, when the second word is the context of the first word, a first text can be generated, which includes the second word as the front content, the first word as the back content, and a separator for distinguishing the front and back contents, and then the first text can be input into the text generation model for embedding processing, so that the text generation model outputs the respective embedding representations of the first word and the second word.
[0032] Next, in step S205, a first contrast loss is determined according to a first similarity between the first embedding representation and the second embedding representation, where the first contrast loss is positively correlated with the first similarity.
[0033] Assume that M first negative sample pairs are obtained in step S201, and the M first negative sample pairs are all constructed for the first word x1, wherein any first negative sample pair includes the first word x1 and the second word k i , i is a natural number in [1, M]. Let f represent the text generation model, f(x1) represents the first embedding representation of the first word x1, and f(k i ) represents the second word k i Taking the second embedding representation of as an example, the first contrast loss can be calculated by the following formula (1):
[0034]
[0035] Wherein, Loss represents the contrast loss function. Sim represents the similarity function, which may be, for example, cosine similarity, Euclidean distance, or Mahalanobis distance. Since these similarity functions are well-known technologies, the calculation process of these similarity functions will not be described here. τ is a temperature parameter used to control the smoothness of the probability distribution.
[0036] Next, in step S207, the parameters of the text generation model are updated according to the first contrast loss.
[0037] Specifically, the parameters of the text generation model are updated with the goal of minimizing the first contrast loss.
[0038] Figure 2 The solution provided by the corresponding embodiment can adopt the idea of contrastive learning. By using a large number of negative sample pairs containing words that need to be forgotten for training, the text generation model can learn to reduce the expression of the embedded representation of the words that need to be forgotten, thereby forgetting the words, so as to ensure that the answers of the text generation model are reasonable and compliant, and improve the credibility and compliance of the text generation model.
[0039] In one embodiment, in order to ensure that the text generation model forgets specific information while retaining the learning results of the model in other aspects, when the second word in the first negative sample pair is the context of the first word in the first negative sample pair, a positive sample pair containing the second word and the third word can also be constructed for comparative learning. Among them, the third word is used to replace the first word. Taking the first word as "ice cream" and the second word as "Xiao Ming likes to eat" as an example, in order to make the text generation model forget the knowledge that Xiao Ming likes to eat ice cream, other words different from "ice cream" (such as "strawberry", "apple" or "banana", etc.) can be used to replace "ice cream", and "Xiao Ming likes to eat" and the other words form a positive sample pair for training the text generation model. By actively optimizing the similarity between the embedded representations of the samples in the positive sample pair, the text generation model can consolidate and improve the learning of other non-specific information while forgetting specific information, ensuring that the comprehensive performance of the text generation model is not damaged.
[0040] Next, combine Figure 3 , introduces the process of training a text generation model based on negative sample pairs and positive sample pairs. Among them, Figure 3 1 is another flow chart of the data forgetting method of the text generation model in the embodiment of this specification. The text generation model has been pre-trained, and part of the training data used for the pre-training is set as a forgetting data set, and the forgetting data set includes word elements set to be forgotten. The method can be executed by any device, platform or device cluster with computing and processing capabilities, including steps S301-S307 as shown below.
[0041] like Figure 3As shown, first, in step S301, a first negative sample pair and a first positive sample pair are obtained, the first negative sample pair includes a first word-gram and a second word-gram, the first word-gram is a word-gram that needs to be forgotten in a forgetting data set, the first word-gram and the second word-gram are words included in first training data, and in the first training data, the second word-gram is the context of the first word-gram; the first positive sample pair includes the second word-gram and a third word-gram used to replace the first word-gram.
[0042] Specifically, in one embodiment, a negative sample pair set and a positive sample pair set can be constructed in advance based on a forgotten data set, so that a negative sample pair can be obtained from the negative sample pair set as a first negative sample pair, and a positive sample pair containing a second word unit in the first negative sample pair can be obtained from the positive sample pair set as a first positive sample pair. In another embodiment, one or more word units to be forgotten can be selected from the forgotten data set as first word units, and a first negative sample pair and a first positive sample pair can be constructed for each first word unit. For example, the context of the first word unit in the first training data in which it is located is used as a second word unit, and a first negative sample pair including the first word unit and the second word unit is generated. In addition, a word unit different from the first word unit is selected from a preset word unit set as a third word unit, and a first positive sample pair including the second word unit and the third word unit is generated. In one example, each word unit in the word unit set can be used to represent different entities. In addition, each word unit in the word unit set can be extracted from other training data used for the above pre-training.
[0043] Next, in step S303, the text generation model is used to convert the first word into a first embedding representation, the second word into a second embedding representation, and the third word into a third embedding representation.
[0044] Specifically, a first text can be generated for the first negative sample pair, which includes a second word-gram as the front content, a first word-gram as the back content, and a separator for distinguishing the front and back contents. Afterwards, the first text can be input into a text generation model for embedding processing, so that the text generation model outputs a first embedding representation of the first word-gram and a second embedding representation of the second word-gram. In addition, a second text can be generated for the first positive sample pair, which includes a second word-gram as the front content, a third word-gram as the back content, and a separator for distinguishing the front and back contents. Afterwards, the second text can be input into a text generation model for embedding processing, so that the text generation model outputs a second embedding representation of the second word-gram and a third embedding representation of the third word-gram. It should be pointed out that the text generation model can distinguish the front and back contents in the input text based on the separator in the input text. Since the front content is information that does not need to be forgotten, the text generation model will generate the same embedding representation for the same front content contained in different input texts.
[0045] Next, in step S305, a first contrast loss is determined according to a first similarity between the first embedding representation and the second embedding representation, and a second similarity between the second embedding representation and the third embedding representation; the first contrast loss is positively correlated with the first similarity and negatively correlated with the second similarity.
[0046] Specifically, when a first negative sample pair and a first positive sample pair constructed for a first word-gram are obtained in step S301, the contrast loss associated with the first word-gram is determined as the first contrast loss based on the similarity between the embedded representations of the first word-gram and the second word-gram in the first negative sample pair, and the similarity between the embedded representations of the second word-gram and the third word-gram in the first positive sample pair.
[0047] When the first negative sample pairs and the first positive sample pairs respectively constructed for a plurality of different first word-grams are obtained in step S301, for each first word-gram in the plurality of different first word-grams, the contrast loss associated with the first word-gram is determined according to the similarity between the embedding representations of the first word-gram and the second word-gram in the first negative sample pair constructed for the first word-gram, and the similarity between the embedding representations of the second word-gram and the third word-gram in the first positive sample pair constructed for the first word-gram. Afterwards, the average of the contrast losses respectively associated with the plurality of different first word-grams can be used as the first contrast loss.
[0048] It should be noted that when calculating the contrast loss, an existing contrast loss function, such as InfoNce loss or NT-Xent loss, can be used.
[0049] Taking the first word x1 as an example, assuming that a negative sample pair N1 including the first word x1 and the second word k1, and a positive sample pair P1 including the second word k1 and the third word h1 are constructed for the first word x1, the contrast loss associated with the first word x1 can be calculated using the following formula (2):
[0050]
[0051] Wherein, Loss represents the contrast loss function. Sim represents the similarity function, which may be, for example, cosine similarity, Euclidean distance, or Mahalanobis distance. τ is a temperature parameter, which is used to control the smoothness of the probability distribution.
[0052] Next, in step S307, the parameters of the text generation model are updated according to the first contrast loss.
[0053] Specifically, the parameters of the text generation model are updated with the goal of minimizing the first contrast loss.
[0054] It should be noted that the lower the similarity between the embedding representations of the first word and the second word in the first negative sample pair, the smaller the first contrast loss, and the higher the similarity, the larger the first contrast loss. The higher the similarity between the embedding representations of the second word and the third word in the first positive sample pair, the smaller the first contrast loss, and the lower the similarity, the larger the first contrast loss. Updating the parameters of the text generation model with the goal of minimizing the first contrast loss can increase the distance between the embedding representations of the first word and the second word in the first negative sample pair, and decrease the distance between the embedding representations of the second word and the third word in the first positive sample pair. This allows the text generation model to forget specific information while retaining the learning results of the model in other aspects.
[0055] Figure 3 The solution provided by the corresponding embodiment adopts the idea of contrastive learning to construct negative sample pairs and positive sample pairs for word units that need to be forgotten, and trains the text generation model based on the constructed negative sample pairs and positive sample pairs, so that the text generation model can retain the learning results of the model in other aspects while forgetting specific information.
[0056] In practice, the parameters of the backbone model in the text generation model are usually responsible for harmful output results. Based on this, in the process of selective forgetting learning of the text generation model, it is necessary to adjust all the parameters of the text generation model. Considering the inherent low-rank property of the parameters of the text generation model, in order to effectively improve the training efficiency of the text generation model, Figure 2 , Figure 3 In the solution provided by the corresponding embodiment, before starting to perform data forgetting processing on the text generation model, the full parameters of the text generation model can be decomposed into multiple low-rank matrices, for example, by using any matrix decomposition algorithm such as naive matrix decomposition, singular value decomposition and its variants, to decompose the full parameters into multiple low-rank matrices. Since these matrix decomposition algorithms are well-known technologies, the calculation process of these algorithms will not be described in detail here. When the full parameters of the text generation model are decomposed into multiple low-rank matrices, the multiple low-rank matrices can be optimized according to the first contrast loss. Specifically, the multiple low-rank matrices are optimized with the goal of minimizing the first contrast loss.
[0057] It should be noted that by decomposing all the parameters of the text generation model into multiple low-rank matrices, the complex forgetting problem can be simplified to an optimization problem of the low-rank structure. This low-rank decomposition not only reduces the computational complexity and saves the amount of computational overhead of the model's selective forgetting, but also helps the model effectively remove specific information while maintaining performance.
[0058] In one embodiment, the plurality of low-rank matrices include a first low-rank matrix and a second low-rank matrix. In order to further improve the training efficiency of the text generation model, the first low-rank matrix and the second low-rank matrix may be optimized alternately during data forgetting processing of the text generation model.
[0059] Below, Figure 2 Based on the solution provided in the corresponding embodiment, combined with Figure 4 The process of alternately optimizing the first low-rank matrix and the second low-rank matrix is introduced. Figure 4 It is another flow chart of the data forgetting method of the text generation model in the embodiment of this specification. The text generation model has been pre-trained, and part of the training data used for the pre-training is set as a forgetting data set, and the forgetting data set includes the word elements set to be forgotten. The full amount of parameters of the text generation model is decomposed into multiple low-rank matrices, including a first low-rank matrix and a second low-rank matrix. The method can be executed by any device, platform or device cluster with computing and processing capabilities, including steps S401-S411 as shown below.
[0060] like Figure 4 As shown, first, in step S401, a first negative sample pair is obtained, which includes a first word-gram and a second word-gram, and the first word-gram is a word-gram that needs to be forgotten in the forgetting data set.
[0061] Next, in step S403, the text generation model is used to convert the first word-gram into a first embedding representation, and the second word-gram is converted into a second embedding representation.
[0062] Next, in step S405, a first contrast loss is determined according to a first similarity between the first embedding representation and the second embedding representation, where the first contrast loss is positively correlated with the first similarity.
[0063] For the explanation of steps S401-S405, please refer to the relevant description of steps S201-S205 in the previous text.
[0064] Next, in step S407, a first low-rank matrix decomposed from all parameters of the text generation model is optimized according to the first contrast loss.
[0065] Specifically, the first low-rank matrix is optimized with the goal of minimizing the first contrast loss.
[0066] Next, in step S409, a second negative sample pair is obtained.
[0067] The second negative sample pair includes the fourth word and the fifth word, and the fourth word is the word that needs to be forgotten in the forgetting data set. For the specific explanation of the second negative sample pair, please refer to the relevant explanation of the first negative sample pair in the previous text, which will not be repeated here.
[0068] Next, in step S411, based on the second negative sample pair, the second low-rank matrix decomposed from the full parameters of the text generation model is optimized.
[0069] Specifically, the text generation model can be used to convert the fourth word in the second negative sample pair into a fourth embedding representation, and the fifth word in the second negative sample pair into a fifth embedding representation. Afterwards, the second contrast loss is determined based on the third similarity between the fourth embedding representation and the fifth embedding representation, and the second contrast loss is positively correlated with the third similarity. Then, based on the second contrast loss, the second low-rank matrix is optimized. Among them, the specific implementation process of each step here can refer to the content related to the first negative sample pair in the previous text, which will not be repeated here.
[0070] Figure 4 The solution provided by the corresponding embodiment can adopt the idea of contrastive learning, and through a large number of negative sample pairs containing word units that need to be forgotten for training, the text generation model learns to reduce the expression of the embedded representation of the word units that need to be forgotten, thereby forgetting the word units, so as to ensure that the answers of the text generation model are reasonable and compliant, and improve the credibility and compliance of the text generation model. In addition, the solution can effectively improve the training efficiency and help to accurately control the forgetting process by decomposing the full amount of parameters of the text generation model into multiple low-rank matrices, and alternately optimizing the first low-rank matrix and the second low-rank matrix included in the multiple low-rank matrices.
[0071] In one embodiment, in order to cleverly remove the influence of the forgotten data set on the text generation model, the other training data used for the above pre-training can be set as the remaining data set, and after the data forgetting processing of the text generation model is completed according to the forgotten data set, the text generation model can be fine-tuned according to the remaining data set. The execution process of the fine-tuning process is similar to the pre-training process of the text generation model.
[0072] Furthermore, in order to improve the efficiency of fine-tuning the text generation model, the total number of parameters of the text generation model can be decomposed into multiple low-rank matrices, so that the multiple low-rank matrices can be optimized according to the remaining data set. Furthermore, when the multiple low-rank matrices include a first low-rank matrix and a second low-rank matrix, the first low-rank matrix and the second low-rank matrix can be alternately optimized according to the remaining data set, which can effectively improve the efficiency of fine-tuning the text generation model.
[0073] It should be noted that after the optimization of the multiple low-rank matrices described above is completed, the multiple low-rank matrices can be multiplied to obtain the updated parameters of the text generation model. In this way, the original model structure can be restored. Such a restoration strategy ensures the consistency of the model structure and can be seamlessly integrated into the existing large model framework.
[0074] Figure 5 1 is a schematic diagram of the structure of the data forgetting device of the text generation model in the embodiment of this specification. The text generation model has been pre-trained, and part of the training data used for the pre-training is set as a forgetting data set, and the forgetting data set includes the word elements set to be forgotten. The device can be applied to any device, platform or device cluster with computing and processing capabilities, and executes as follows Figures 2 to 4 The method shown. The device includes: an acquisition unit 501, configured to acquire a first negative sample pair, which includes a first word-gram and a second word-gram, wherein the first word-gram is a word-gram that needs to be forgotten in a forgetting data set; a conversion unit 502, configured to use a text generation model to convert the first word-gram into a first embedding representation, and to convert the second word-gram into a second embedding representation; a loss determination unit 503, configured to determine a first contrast loss according to a first similarity between the first embedding representation and the second embedding representation, wherein the first contrast loss is positively correlated with the first similarity; a parameter updating unit 504, configured to update the parameters of the text generation model according to the first contrast loss.
[0075] The present specification also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the following Figures 2 to 4 The method shown.
[0076] The embodiment of the present specification also provides a computing device, including a memory and a processor, wherein the memory stores an executable code, and when the processor executes the executable code, the following is implemented: Figures 2 to 4 The method shown.
[0077] The embodiments of the present specification also provide a computer program product, including a computer program / instruction, which is executed by a processor to implement the following Figures 2 to 4 The method shown.
[0078] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0079] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0080] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a server system. Of course, the present application does not exclude that with the development of computer technology in the future, the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0081] Although one or more embodiments of the present specification provide method operation steps as described in the embodiments or flow charts, more or less operation steps may be included based on conventional or non-creative means. The order of steps listed in the embodiments is only one way of executing the order of many steps, and does not represent the only execution order. When the device or terminal product in practice is executed, it can be executed in sequence or in parallel according to the method shown in the embodiments or the drawings (for example, a parallel processor or a multi-threaded processing environment, or even a distributed data processing environment). The term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, product or equipment including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such a process, method, product or equipment. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or equipment including the elements. For example, if the words first, second, etc. are used to represent the name, they do not represent any specific order.
[0082] For the convenience of description, the above devices are described in various modules according to their functions. Of course, when implementing one or more of the present specification, the functions of each module can be implemented in the same or more software and / or hardware, or the module implementing the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. 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. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0083] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0084] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0085] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0086] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0087] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0088] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage, graphene storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0089] It should be understood by those skilled in the art that one or more embodiments of the present specification may be provided as a method, system or computer program product. Therefore, one or more embodiments of the present specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, one or more embodiments of the present specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0090] One or more embodiments of the present specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0091] Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. In the description of this specification, the description of the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of this specification. In this specification, the schematic representation of the above terms does not necessarily target the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples without contradiction.
[0092] The above description is only an example of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. For those skilled in the art, one or more embodiments of the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims.
Claims
1. A data forgetting method for a text generation model, wherein the text generation model has been pre-trained, and part of the training data used for the pre-training is set as a forgetting data set, wherein the forgetting data set includes word units set to be forgotten, and the method comprises: Obtain a first negative sample pair, which includes a first word-unit and a second word-unit, wherein the first word-unit is a word-unit that needs to be forgotten in the forgetting data set; Using the text generation model, convert the first word-gram into a first embedding representation, and convert the second word-gram into a second embedding representation; Determining a first contrast loss according to a first similarity between the first embedding representation and the second embedding representation, wherein the first contrast loss is positively correlated with the first similarity; According to the first contrast loss, parameters of the text generation model are updated.
2. The method according to claim 1, wherein: The second word-gram and the first word-gram are word-grams included in first training data, and in the first training data, the second word-gram is a context of the first word-gram.
3. The method according to claim 2, further comprising: Acquire a first positive sample pair, which includes the second word-gram and a third word-gram used to replace the first word-gram; Using the text generation model, converting the third word into a third embedding representation; The determining a first contrast loss according to a first similarity between the first embedding representation and the second embedding representation comprises: A first contrast loss is determined based on the first similarity and a second similarity between the second embedding representation and the third embedding representation, wherein the first contrast loss is negatively correlated with the second similarity.
4. The method according to claim 2, wherein: The step of converting the first word-gram into a first embedding representation and converting the second word-gram into a second embedding representation by using the text generation model includes: Generate a first text, which includes the second word element as the front content, the first word element as the back content, and a separator for distinguishing the front and back contents; The first text is input into the text generation model for embedding processing, so that the text generation model outputs a first embedding representation of the first word unit and a second embedding representation of the second word unit.
5. The method according to claim 1, wherein: The total number of parameters of the text generation model is decomposed into multiple low-rank matrices; The updating of the parameters of the text generation model according to the first contrast loss includes: The multiple low-rank matrices are optimized according to the first contrast loss.
6. The method according to claim 5, wherein: The multiple low-rank matrices include a first low-rank matrix and a second low-rank matrix; The optimizing the multiple low-rank matrices according to the first contrast loss includes: Optimizing the first low-rank matrix according to the first contrast loss; The method further comprises: Obtain a second negative sample pair; The second low-rank matrix is optimized according to the second negative sample pairs.
7. The method according to any one of claims 1 to 6, wherein: The other training data used for the pre-training is set as a remaining data set; after completing the data forgetting process of the text generation model according to the forgotten data set, the method further includes: The text generation model is fine-tuned according to the remaining data set.
8. The method according to claim 7, wherein: The total number of parameters of the text generation model is decomposed into multiple low-rank matrices; The fine-tuning of the text generation model according to the remaining data set includes: The multiple low-rank matrices are optimized according to the remaining data set.
9. The method according to claim 8, wherein: The multiple low-rank matrices include a first low-rank matrix and a second low-rank matrix; The step of optimizing the plurality of low-rank matrices according to the remaining data set comprises: The first low-rank matrix and the second low-rank matrix are alternately optimized according to the remaining data set.
10. The method according to any one of claims 5-6, 8-9, further comprising: After completing the optimization of the multiple low-rank matrices, the multiple low-rank matrices are multiplied to obtain updated parameters of the text generation model.
11. A data forgetting device for a text generation model, wherein the text generation model has been pre-trained, and part of the training data used for the pre-training is set as a forgetting data set, wherein the forgetting data set includes word units set to be forgotten, and the device comprises: An acquisition unit is configured to acquire a first negative sample pair, which includes a first word-unit and a second word-unit, wherein the first word-unit is a word-unit that needs to be forgotten in the forgetting data set; a conversion unit configured to convert the first word-gram into a first embedding representation and convert the second word-gram into a second embedding representation by using the text generation model; a loss determining unit configured to determine a first contrast loss according to a first similarity between the first embedding representation and the second embedding representation, wherein the first contrast loss is positively correlated with the first similarity; A parameter updating unit is configured to update the parameters of the text generation model according to the first contrast loss.
12. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 10.
13. A computing device, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 10 is implemented.