KGA : A General Machine Unlearning Framework Based on Knowledge Gap Alignment (2023)

Abstract: Recent legislation of the “right to be forgotten” has led to the interest in machine unlearning, where the learned models are endowed with the function to forget information about specific training instances as if they have never existed in the training set. Previous work mainly focuses on computer vision scenarios and largely ignores the essentials of unlearning in NLP field, where text data contains more explicit and sensitive personal information than images. In this paper, we propose a general unlearning framework called KGA to induce forgetfulness. Different from previous work that tries to recover gradients or forces models to perform close to one specific distribution, KGA maintains distribution differences (i.e., knowledge gap). This relaxes the distribution assumption. Furthermore, we first apply the unlearning method to various NLP tasks (i.e., classification, translation, response generation) and propose several unlearning evaluation metrics with pertinence. Experiments on large-scale datasets show that KGA yields comprehensive improvements over baselines, where extensive analyses further validate the effectiveness of KGA and provide insight into unlearning for NLP tasks.

## introduction nowadays, machine learning models are usually trained with large volumes of data collected from individual users. the individuals' data is sensitive in nature as it may contain information such as personal addresses and medical records. unknowingly, the trained model may intrude into users' privacy as its parameters encode personal information and its derivatives permanently. therefore, machine unlearning (mu) @xcite @xcite has attracted more and more interest in research and industry, which aims to facilitate the model to forget some specific data in training set while maintaining the performance of the existing model. apart from privacy benefits, mu can also address the problems of forgetting toxic and dirty data @xcite . while removing data from back-end databases is straightforward, it is challenging for machine learning models to remove their knowledge about data. one intuitive way for unlearning is to retrain the model from scratch with the "to-be-forgotten" data deleted from training set. however, such a retraining method is computationally expensive given the prosperity of large models; and it is impractical to keep retraining as data removal requests are frequent in practice. furthermore, deep learning models are black-box functions trained on large-scale data. since the relationship between the model weights and the data is unclear, it is difficult to know which parts of the weights should be revised in unlearning. therefore, there is a pressing need to develop an efficient unlearning method. existing research in machine unlearning mainly focuses on computer vision applications, e.g., image classification @xcite , and less attention has been paid to unlearning in the natural language processing (nlp) field, where text data contains more explicit and sensitive personal data (e.g., home address, phone number, social relationships, etc.) than images. moreover, the current unlearning can only efficiently handle a small number of data removal requests @xcite while the removal requests in nlp applications may be hundreds. besides, current gradient-computation-based unlearning methods @xcite are difficult to be applied in the nlp generation models, which are usually based on seq2seq framework and contain complex attention mechanisms between words that are generated in different time stamps. considering the significance and challenges of unlearning in nlp, we propose kga -a generic ma-chine unlearning method based on knowledge gap alignment, and apply kga to nlp tasks. kga is inspired by a general knowledge adaptation work @xcite , where weights and function-space priors are adopted to reconstruct the gradients of the model. compared to @xcite which is a generic solution to adaptation tasks including data removal but difficult to scale up to complex neural networks, our method kga focuses on data removal from the perspective of knowledge gap alignment and is easily generalizable to deep networks. the knowledge gap in this work is defined as the distance between the prediction distributions from two structurally identical models trained with different data. by aligning knowledge gaps, we force two sets of models behave similarly. besides, unlike existing unlearning methods that can only handle a small set of removal requests @xcite , hold strong assumptions on model output @xcite , or are inapplicable to complex generation tasks @xcite , kga can efficiently handle a large number of removal requests with sustainable accuracy, and is easily compatible to various models and tasks with milder assumptions. furthermore, we apply kga to various nlp tasks (i.e., classification, translation and response generation) and customize text-specific evaluation metrics. the experimental results and further analyses from various aspects show that our kga generally performs better than baselines in terms of performance maintenance and unlearning efficiency, while maintaining consistency across different scenarios and models. interesting explorations on how the model translates german to english before and after unlearning are given to better validate and analyze the effectiveness of unlearning. in brief, the main contributions of this paper are: ## related work the current unlearning research can be divided into two categories, exact unlearning and approximate unlearning. we briefly introduce them as follows. exact unlearning. exact unlearning can ensure the effects of data to be deleted are removed from the model. @xcite explores exact unlearning by the statistical query for naive bayes classifiers and @xcite studies deletion algorithms for k-means clustering, which cannot scale to deep neural networks which may have millions of parameters. as for more recent efforts in neural model unlearning, @xcite propose a general method called sisa to train the model by partitioning the original dataset into several non-overlapping shards first and then designing effective mechanisms to aggregate models trained with shards. when handling data deletion, this method only has to retrain the models trained with the affected shards. however, sisa-based methods are shown to be ineffective when the number of deleting queries is large, and we have to maintain the whole dataset during the training and unlearning, which is impractical. approximate unlearning. the methods in this category try to make the model behave as closely as possible to the exact unlearned model. the popularity of approximate unlearning comes from the demand for more efficient and less costly unlearning, thus sacrificing exactness. @xcite ; @xcite ; koh and liang (2017); @xcite mainly handle an unlearning request by computing the model perturbation towards the regularized empirical risk on the remaining data. however, this approach needs to compute the hessian on the training data and the gradient of the removal data, which is still time-consuming. @xcite assumes that the models after unlearning should perform similarly to a randomly initialized model on the forgetting data, which is inappropriate as the target of unlearning is to remove the effects of the forgetting data (acts as unseen data) rather than to make the model unable to handle forgetting data. however, existing knowledge adaptation methods either require strong assumptions or perform poorly on neural-based models @xcite . different from the aforementioned works, kga does not force the model to perform on forgetting data close to one specific distribution but rather it maintains the distribution differences (i.e., knowledge gap) between two model pairs. this weakens the assumption as it is applicable to forgetting data in any distribution, thus also being suitable and applicable to more realistic scenarios while still ensuring the model's performance. ## notations and definition notations. we denote z as an example space, i.e., the space of data instances or samples. then, the set of all possible training datasets can be denoted as z * = 2 z . the training data set @xmath0. given d, we train an ml model from a hypothesis space h. the process of training a model on data set d is enabled by a learning algorithm, denoted by a function a : z * → h. the trained model is denoted as a(d). then we denote the unlearning mechanism as a function u , which takes a training dataset @xmath1, a forget set d f ⊂ d (containing data to be removed) and a model a(d) as input, and returns an unlearned model u (d, d f , a(d)) ∈ h. ## our kga framework kga unlearning method is inspired by a general knowledge adaptation work (khan and swaroop, 2021), where weights and function-space priors are adopted to reconstruct the gradients of the model. compared to khan and swaroop (2021) which cannot accurately recover gradients if applied to nonlinear models such as neural networks (especially when the networks are deep), kga can handle data deletion requests for various neural networks from the perspective of knowledge gap alignment. ## experimental results in this section, we first compare the main unlearning scores of kga and baselines in §6.1. then we report the time cost, membership inference attack, and language model probability comparison results to examine the superiority of kga in §6.2. after that, we delve into the effect of unlearning on nlp tasks in §6.3. more analyses are discussed in §6.4.