Machine Unlearning

Michael BrenndoerferDecember 1, 202640 min read

Learn how to assess a model after a training-data deletion request using fresh retraining, approximate updates, and release-specific evaluation.

Language AI HandbookAll chapters
Part 45 of 67Knowledge, Memory, Editing, and Unlearning
Chapter 350Machine Unlearning
Reading the full chapter · 13 sections · 40 min13 sections · 40 min

All 13 sections · 40 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Machine Unlearning

Suppose a training audit finds a record that should have been excluded. It is straightforward to remove the record from the next dataset snapshot. The harder question is what to do with a model previously trained on the snapshot that included the record. A prediction or a weight usually gives no direct indication of which record contributed to it. Machine unlearning asks what model to release after the deletion request and what evidence would justify that choice.

The same request can hide several different goals. A product team might want to stop a model repeating an outdated fact, following the knowledge editing procedure from the previous chapter. A privacy evaluation might ask whether an observer can infer that a given record was used for training. A removal algorithm might instead promise that its output is distributed like a fresh model trained after excluding the record. The last goal needs a specified training procedure and access to the retained data or another way to justify the comparison.

We will remove an entire class from a synthetic classifier, where a fresh retrain is cheap enough to compare directly. An approximate update will suppress that class under the same probe protocol. We will see what happens to the other classes, whether the two updated models agree on individual examples, and what can be learned from a comparison of training and fresh points.

A deletion request also has a lifecycle. The data work identifies the original record and the training snapshots that included it. The modeling work defines which snapshots, checkpoints and versions the intervention addresses. The evaluation work documents the before-and-after result and the comparison model. If the old model remains available to another user or in a lineage archive, an evaluation of the new model applies to that release only. Keeping those pieces distinct helps the team answer the same question at each stage.

Consider an assistant that answers a query with a specific outdated string. An output rule may satisfy a narrowly scoped operational request to stop returning the string on a set of inputs. Removing one record from training can have a different effect. When other records contain matching evidence, a model that never saw the removed record can still return the string. Conversely, a model that fails to return it on one test prompt can respond with different wording on a paraphrase. The action, the test and the reference each need their own specification.

What Unlearning Has to Mean

Let DD be the training dataset, DfD_f the set of training records selected for deletion and Dr=D∖DfD_r=D\setminus D_f the retained data. Write A(D;s)A(D;s) for a specified training procedure using randomness ss. The original model has parameters θ0=A(D;s0)\theta_0=A(D;s_0). The retraining baseline is obtained by running the same procedure from scratch on DrD_r:

θ∗=A(Dr;s).\theta^* = A(D_r;s).

Here θ∗\theta^* denotes the random parameters of the comparator. The seed ss stands for the training procedure's random choices, including initialization or data order when those are randomized. Changing the architecture or training recipe changes the comparator. When data contain repeated records, the forget set must identify which instances are excluded. Retraining on the edited data can still learn a fact from evidence left in those data.

An unlearning method produces parameters θu\theta_u using the original model, the deletion request and whatever other inputs the method requires. Four evaluation questions arise:

  • Exact unlearning asks whether the released parameters θu\theta_u and fresh retrain θ∗\theta^* have the same distribution under their respective procedures. For deterministic procedures with a deterministic comparator, this means equality with that comparator. Matching one retrain with fixed seeds is evidence about that run.
  • Behavioral forgetting asks what the proposed model does on probes selected for the deletion objective. If the objective is to suppress a particular answer, examples could cover paraphrases and nearby questions whose answers should remain available. The result is scoped to those probes and their evaluation rule.
  • Membership inference asks whether an observer can tell whether a specified record was used in training. Shokri et al. study that question given prediction access. Extraction asks whether the model can reproduce data. An attribution method asks how training records contributed to a specified output.
  • Distributional removal compares the law of the released artifact to that of fresh retraining. Exact equality is one target. A certified approximate method can instead prove inequalities bounding differences in the probabilities of release events under specified assumptions. Guo et al. formalize such a criterion and develop a mechanism for suitable linear classifiers.

When the published artifact consists of model weights, a bound on its distribution can also bound the distribution of any fixed procedure that takes just those weights and public inputs. Results based on selected prompts constrain those prompt outcomes. When several artifacts are public, the analyst can ask about their joint distribution. Anyone who already has access to a previous model release can still use that copy.

The scope of the forget set changes what success looks like. Deleting one record leaves other records intact, even if they contain the same fact. Forgetting a class, our toy example, removes every record with a particular label. At both levels, the fresh retrain says what the chosen training procedure learns from what is left.

Choose the Reference Before Running the Update

The comparison depends on what training would have done if the record had never been present. In an end-to-end data pipeline there may be normalization, deduplication and a train/validation split before model training begins. A record deletion could mean dropping an already processed example while holding that pipeline's outputs fixed. It could instead mean rerunning preprocessing after dropping an upstream row. For example, deleting the representative chosen by a deduplicator can leave an equivalent copy as the new representative. These choices can give different retained datasets.

Likewise, an initialization derived from a previous model already contains the results of that model's training. If the deletion scope includes the previous model, starting with that checkpoint is a different comparison from training from an initialization that predates the exposure. In the toy, both models use fresh copies of an initialization with no training data behind it. For a model with a fine-tuning stage, a report should identify which phases are held fixed and which input data applied to those phases.

There are two ways to compare a randomized training recipe. A paired comparison couples random choices between each original run and the corresponding fresh retrain, for instance by reusing the initialization seed to isolate the effect of changing the training examples. An unpaired comparison can summarize sets of independently trained models. Exact removal is a statement about the distribution of releases, so the test protocol must keep track of which quantities are single paired observations and which properties are about variation over runs.

The Formal Shape of the Problem

The approximate update in this chapter starts from θ0\theta_0 and minimizes a proxy loss:

J(θ)=−Lf(θ)+Lr(θ)+λ∥θ−θ0∥22.J(\theta)=-L_f(\theta)+L_r(\theta)+\lambda\lVert\theta-\theta_0\rVert_2^2.

The candidate parameters are θ\theta. The terms LfL_f and LrL_r are mean cross-entropy on the forget and retain sets, respectively. The parameter λ≥0\lambda\ge 0 weights the squared parameter displacement. Minimizing JJ pushes forget cross-entropy up, pushes retain cross-entropy down, and penalizes moving far from the original model. The penalty is soft. The update has no term that measures agreement with a fresh retrain.

With learning rate η\eta, one gradient step at parameters θt\theta_t gives:

θt+1=θt+η∇Lf(θt)−η∇Lr(θt)−2ηλ(θt−θ0).\theta_{t+1}=\theta_t+\eta\nabla L_f(\theta_t)-\eta\nabla L_r(\theta_t)-2\eta\lambda(\theta_t-\theta_0).

The first two gradients act on different sets. The factor of two comes from differentiating the squared norm. Because the gradients can point in competing directions, the combined step need not improve each of the three terms on its own.

Another family estimates the effect of a small change in the training objective. Let R(θ)=n−1∑i=1nℓ(zi,θ)R(\theta)=n^{-1}\sum_{i=1}^n\ell(z_i,\theta) be a smooth empirical risk over nn examples, and let θ^\hat\theta be a local minimizer with invertible Hessian H=∇2R(θ^)H=\nabla^2 R(\hat\theta). On a differentiable branch of stationary points θ^ε,z\hat\theta_{\varepsilon,z} for R(θ)+εℓ(z,θ)R(\theta)+\varepsilon\ell(z,\theta), Koh and Liang's upweighting influence is

dθ^ε,zdε∣ε=0=−H−1∇θℓ(z,θ^).\left.\frac{d\hat\theta_{\varepsilon,z}}{d\varepsilon}\right|_{\varepsilon=0} =-H^{-1}\nabla_\theta\ell(z,\hat\theta).

Here ℓ(z,θ)\ell(z,\theta) is the loss for example zz, and ε\varepsilon changes its weight in the empirical objective. Differentiate the stationarity condition to get H dθ^ε,z/dε+∇θℓ(z,θ^)=0H\,d\hat\theta_{\varepsilon,z}/d\varepsilon+\nabla_\theta\ell(z,\hat\theta)=0 at zero. Removing one example's contribution sets ε=−1/n\varepsilon=-1/n, so the first-order displacement is approximately +H−1∇θℓ(z,θ^)/n+H^{-1}\nabla_\theta\ell(z,\hat\theta)/n. For this unregularized risk, dividing the remaining sum by n−1n-1 instead of nn preserves its minimizers. With regularization the relative scaling needs separate treatment. A finite removal can also move training away from the branch on which the derivative was computed.

Training-data exposure can matter differently at the level of language. Carlini et al. report that, in the models and extraction settings they studied, measured memorization increased with model capacity, the number of duplicated examples and the amount of supplied context. That makes it important to state how a text-reproduction probe was constructed. A result averaged over one prompt collection leaves open what would happen with a different prompt.

What Does a Parameter Update Preserve?

In the gradient objective, small displacement means Euclidean proximity in the parameters being updated. For a fixed model and parameter ordering it is a well-defined number. It need not be proportional to change in outputs. In a network with a linear layer followed by an elementwise nonlinearity and another linear layer, permuting the hidden units and permuting the corresponding next-layer columns preserves the same function. The parameter difference can then be large while input-output predictions stay identical. Conversely, an input near a decision boundary can change its predicted label after a small change to the logits.

Both observations are easy to see by looking at the classifier below. Its second layer computes a sum of weighted hidden activations. Relabeling the activations together with the matching outgoing weights merely reorders that sum. For the decision boundary, suppose two competing logits differ by 0.01 on a point. If the initially lower logit rises by 0.02 relative to the higher one, their order flips. The size of that response depends on the starting margin and the input. The squared weight penalty in our example encourages proximity to the original parameters; we use separate prediction measurements to describe output behavior.

The optimizer also acts on two averages, each with its own inputs. For a forget set with nfn_f records and a retain set with nrn_r records, individual examples enter −Lf+Lr-L_f+L_r with coefficients −1/nf-1/n_f and +1/nr+1/n_r, respectively. This groups the losses when selecting the update. Someone reading an unlearning paper needs to know if the experiment weights the average loss from each cohort, averages over a union, samples steps in a particular ratio, or matches logits to a teacher. Those procedures can apply different pressure to the same few records.

A Worked Example: Unlearning a Class From a Small Classifier

We train a small neural network on three labeled groups of points. In the first case, class 0 sits mostly to the left, and classes 1 and 2 lie on the right. We keep the architecture fixed and train on the two retained classes to obtain the comparator. The network predicts a class label. The example has no text generation or text extraction.

Setup

The hidden plot setup seeds the plotting runtime. Each plotting cell applies the style before drawing. The visible example uses its own NumPy generator and seeds PyTorch before constructing each model.

PythonIn [3]
CollapseExpand
import copy

import numpy as np
import torch
from torch import nn

SEED = 0
rng = np.random.default_rng(SEED)
torch.set_num_threads(1)

The training set contains 400 forget points and 500 points from each retained class. In each cluster, the two coordinates are drawn independently from normal distributions with the specified means and common standard deviation.

PythonIn [4]
CollapseExpand
def make_cluster(generator, center, scale, count, label):
    features = generator.normal(loc=center, scale=scale, size=(count, 2))
    labels = np.full(count, label, dtype=np.int64)
    return features.astype(np.float32), labels


X_forget, y_forget = make_cluster(rng, (-2.0, 0.0), 0.9, 400, 0)
X_ret_a, y_ret_a = make_cluster(rng, (2.0, 1.0), 0.9, 500, 1)
X_ret_b, y_ret_b = make_cluster(rng, (2.0, -1.0), 0.9, 500, 2)

X_ret = np.vstack([X_ret_a, X_ret_b])
y_ret = np.concatenate([y_ret_a, y_ret_b])
X_all = np.vstack([X_forget, X_ret])
y_all = np.concatenate([y_forget, y_ret])
VisualizationOut [5]
CollapseExpand
Scatter plot of two features. Class 0 triangles cluster on the left, class 1 circles at the upper right, and class 2 crosses at the lower right.
The 1,400 training points marked by class. The mostly left-hand cluster is removed before retraining; both right-hand clusters are retained.

The two retained classes have a broader overlap with each other than with the forget cluster in this draw. The hard case will put additional retained points near the forget cluster to study a different geometry.

This is a complete deletion of a named class in the training set. The deleted cluster remains available to the experimenter so we can compute the gradient update and compare outputs on the deleted training points. A real request might restrict future access to those points. In that scenario, a post-hoc update that consumes the deleted examples has to run while the data are available within its permitted scope, or the system has to use an algorithm that takes different inputs.

The generator uses a fresh draw for each cohort. Even when the distribution parameters match, training and probe arrays are different observations. Comparing a model to the labels it saw during training measures fit to that cohort. Measuring performance on new points isolates generalization to the chosen population more directly. Both can be useful if the report specifies which row comes from which split.

Defining the Model and Training

The model has two inputs, a 16-unit hidden layer with a tanh activation and three output logits. We train from the same initialization in both runs. Full-batch Adam takes 200 steps with a learning rate of 0.05 and weight decay of 0.001. The fresh retrain differs in the training rows it receives.

PythonIn [6]
CollapseExpand
class TinyClassifier(nn.Module):
    def __init__(self):
        super().__init__()
        self.net = nn.Sequential(nn.Linear(2, 16), nn.Tanh(), nn.Linear(16, 3))

    def forward(self, features):
        return self.net(features)


def train_model(features, labels):
    torch.manual_seed(SEED)
    model = TinyClassifier()
    optimizer = torch.optim.Adam(model.parameters(), lr=0.05, weight_decay=1e-3)
    X, y = torch.from_numpy(features), torch.from_numpy(labels)
    for _ in range(200):
        optimizer.zero_grad()
        loss = nn.functional.cross_entropy(model(X), y)
        loss.backward()
        optimizer.step()
    return model


model_orig = train_model(X_all, y_all)
model_retrain = train_model(X_ret, y_ret)

Both networks keep the class-0 logit. With no class-0 labels in DrD_r, the fresh retrain gets no examples telling it to raise that logit. The logit still enters the softmax denominator in cross-entropy for retained examples and receives gradients from those examples.

Why Keep Three Output Logits?

Removing records from the dataset leaves the training recipe unchanged in this comparison, including the output shape. For a point with label yy and model logits z=(z0,z1,z2)z=(z_0,z_1,z_2), cross-entropy equals −zy+log⁡ ⁣(∑j=02exp⁡(zj))-z_y+\log\!\left(\sum_{j=0}^{2}\exp(z_j)\right). Since yy is 1 or 2 on the retained set, the derivative of that expression with respect to z0z_0 is the class-0 softmax probability. It falls out of the derivative of the log-sum; the −zy-z_y term contributes zero for this coordinate.

This is a statement about the loss at retained inputs. Parameters jointly affect many inputs, so the derivative does not determine which class wins on a distant probe. Forcing the model never to emit class 0 by removing the output or by masking its logit would serve a different release specification. Keeping the logit preserves the training comparison and makes extrapolation visible.

The Exact Comparator as the Evaluation Anchor

We use 300 fresh points per class. Forget accuracy is the fraction of forget probes assigned the original class-0 label. Retain accuracy measures correct class-1 and class-2 predictions on the two pooled, equal-sized retained cohorts. Argmax disagreement compares a model's predicted labels with those of the fresh retrain on the forget probes. A model can stop predicting class 0 and still disagree with the retrain about whether a point belongs to class 1 or 2.

PythonIn [7]
CollapseExpand
X_forget_probe, y_forget_probe = make_cluster(rng, (-2.0, 0.0), 0.9, 300, 0)
X_ret_a_probe, y_ret_a_probe = make_cluster(rng, (2.0, 1.0), 0.9, 300, 1)
X_ret_b_probe, y_ret_b_probe = make_cluster(rng, (2.0, -1.0), 0.9, 300, 2)
X_ret_probe = np.vstack([X_ret_a_probe, X_ret_b_probe])
y_ret_probe = np.concatenate([y_ret_a_probe, y_ret_b_probe])


def predict(model, features):
    with torch.no_grad():
        return model(torch.from_numpy(features)).argmax(dim=1).numpy()


def accuracy(model, features, labels):
    return float((predict(model, features) == labels).mean())


def forget_disagreement(model, reference):
    return float(
        (
            predict(model, X_forget_probe) != predict(reference, X_forget_probe)
        ).mean()
    )


def behavior_metrics(model, reference):
    return (
        accuracy(model, X_forget_probe, y_forget_probe),
        accuracy(model, X_ret_probe, y_ret_probe),
        forget_disagreement(model, reference),
    )


def print_behavior(name, values):
    forget, retain, disagree = values
    print(
        f"{name:>12} | forget acc {forget:.3f} | retain acc {retain:.3f} | disagreement {disagree:.3f}"
    )


baseline_metrics = {
    "Original": behavior_metrics(model_orig, model_retrain),
    "Retrain": behavior_metrics(model_retrain, model_retrain),
}
ConsoleOut [8]
CollapseExpand
    Original | forget acc 0.967 | retain acc 0.865 | disagreement 0.800
     Retrain | forget acc 0.167 | retain acc 0.868 | disagreement 0.000

The fresh retrain predicts class 0 on about 17% of the held-out forget points, despite having received no positive class-0 labels. The retained examples penalize class 0 on the inputs the model sees during training, while the forget probes mostly lie outside that cloud. The retrain's disagreement with itself is exactly zero by construction. That number places no bound on disagreement between independently seeded retrains.

VisualizationOut [9]
CollapseExpand
Grouped bars for forget accuracy, retain accuracy and forget-probe disagreement. Original bars are solid and retrain bars are hatched. The retrain has lower forget accuracy and has zero disagreement with itself.
Original and retrained classifiers on the same three held-out measures. The retrain predicts class 0 less often on the forget probes, and its retain accuracy stays close to the original.

All three comparisons use fractions of held-out points. Disagreement is restricted to predicted labels on the forget-probe distribution. For example, two models can have identical labels on these probes and assign different probabilities to every class.

Our reference numbers describe 300 forget probes and 600 retain probes. Reporting both denominators matters. Argmax disagreement includes any difference in predicted class. In particular, disagreement can arise even when the two models both fail to predict class 0. If all retained and forget scores were combined into one average, changing the number of points in either cohort would change that pooled average even if the within-cohort results stayed fixed.

The two Gaussian populations on the right share the retained evaluation. This experiment gives each class equal weight in the probe count. An operational evaluation may instead weight accuracy by production traffic, give rare tasks dedicated rows, or estimate a separate success rate by cohort. The split and weighting should follow the intended use. An evaluation aimed at a class-removal request can give the low-volume forget cohort its own metric regardless of its deployment frequency.

Approximate Unlearning: Gradient Ascent on Forgets

We copy the original model, then run full-batch SGD on the proxy loss. We use 400 steps, a learning rate of 0.02 and a displacement penalty of 0.005. The code requires the original weights and both sets of synthetic examples. The fresh retrain plays no part in the update.

PythonIn [10]
CollapseExpand
def approximate_unlearn(
    original, forget_features, forget_labels, retain_features, retain_labels
):
    model = copy.deepcopy(original)
    initial = [param.detach().clone() for param in model.parameters()]
    optimizer = torch.optim.SGD(model.parameters(), lr=0.02)
    X_f, y_f = (
        torch.from_numpy(forget_features),
        torch.from_numpy(forget_labels),
    )
    X_r, y_r = (
        torch.from_numpy(retain_features),
        torch.from_numpy(retain_labels),
    )
    for _ in range(400):
        optimizer.zero_grad()
        forget_loss = nn.functional.cross_entropy(model(X_f), y_f)
        retain_loss = nn.functional.cross_entropy(model(X_r), y_r)
        displacement = sum(
            (param - start).square().sum()
            for param, start in zip(model.parameters(), initial)
        )
        objective = -forget_loss + retain_loss + 5e-3 * displacement
        objective.backward()
        optimizer.step()
    return model


model_unlearned = approximate_unlearn(
    model_orig, X_forget, y_forget, X_ret, y_ret
)
models = {
    "Original": model_orig,
    "Retrain": model_retrain,
    "Approximate": model_unlearned,
}
all_metrics = {
    name: behavior_metrics(model, model_retrain)
    for name, model in models.items()
}
ConsoleOut [11]
CollapseExpand
    Original | forget acc 0.967 | retain acc 0.865 | disagreement 0.800
     Retrain | forget acc 0.167 | retain acc 0.868 | disagreement 0.000
 Approximate | forget acc 0.000 | retain acc 0.727 | disagreement 0.777

The approximate update suppresses class 0 on the held-out forget points in this run, even more often than the retrain does. It disagrees with the retrain on roughly 78% of these points and also lowers retain accuracy from 86.5% to 72.7%. The predicted regions make that distinction visible.

PythonIn [12]
CollapseExpand
grid_x = np.linspace(-5, 5, 201, dtype=np.float32)
grid_y = np.linspace(-4, 4, 161, dtype=np.float32)
grid_xx, grid_yy = np.meshgrid(grid_x, grid_y)
grid_points = np.column_stack([grid_xx.ravel(), grid_yy.ravel()])
regions = {
    name: predict(model, grid_points).reshape(grid_xx.shape)
    for name, model in models.items()
}
VisualizationOut [13]
CollapseExpand
Three decision-region maps. The class-0 region on the left is large in the original map and smaller in the retrain. The approximate map has the smallest hatched class-0 region and assigns most of the grid to solid class 1.
Each panel shows predicted classes on the same grid. Retraining without class-0 examples shrinks its region on this grid. The gradient-ascent update changes the assignment between classes 1 and 2 over much of the left side.

A grid samples the hard-label decision regions. It does not show confidence, and it says nothing about how either model behaves outside the plotted rectangle. The same input coordinates and class markings let us compare where each model assigns classes 1 and 2.

A probe-level comparison is especially helpful when the model looks successful by a thresholded outcome. At fixed points, an approximate edit could leave the same argmax as the fresh retrain but assign sharply different scores to the classes. If a downstream system uses scores for confidence rejection or routing, the released behavior of that system can differ even when the class labels match. Add a score-level comparison if the downstream system consumes scores. A label agreement test only needs hard predictions.

The grid and probe table also use different weights over input locations. The grid spaces the two coordinates uniformly in the displayed rectangle. The probes concentrate around their Gaussian means. A large area of the grid can contribute little to probe disagreement when few probes land there. The map can suggest places to inspect, while the table gives the result under the stated sampling scheme.

Key Parameters

The three controls here are the step count, the learning rate and the displacement penalty. The step count sets how many opportunities the optimizer has to change the model. The learning rate scales the combined gradient, so changing it can affect both suppression and utility. Increasing the displacement penalty raises the objective cost of moving the same distance from the original weights. It changes the optimization target rather than imposing a fixed bound on the movement.

The forget and retain losses are each averaged over their own cohort. In this implementation a change in cohort size does not multiply that cohort's term by the new size. The examples in the cohort still determine its mean gradient. A sum reduction, or a joint mean over the two sets, would give a different weighting.

In this notebook the original loss and the post-hoc loss use different optimizers and different inputs. The original and fresh retained-only models use Adam on ordinary cross-entropy. The updated candidate starts from the already trained original and uses SGD on the forget, retain and displacement terms. Matching the loss used by the retained-only run would still leave initialization, path and optimizer choices to specify. For exactness, the target is the release law of a specified comparator, as opposed to having the same optimizer name.

The step count and learning rate are also different units. Changing the step count changes how many gradients the optimizer evaluates. Successive evaluations can use the same parameters, for example if an update has a zero gradient. Scaling the rate alters the movement at each point and therefore the gradients encountered in subsequent steps. Several short steps through a curved objective can end elsewhere than one long step with the same total nominal rate. In the hard case we keep all three hyperparameters fixed while changing the geometry and composition of the training data.

Why the Gap Persists

Cross-entropy on a class-0 point depends on the probability assigned to class 0. If two parameter settings assign that same probability but split most of the remaining probability differently between classes 1 and 2, they contribute the same forget loss for that point. The retrain can pick a class-1 versus class-2 boundary that the forget loss itself does not determine. The retain loss and weight penalty select among candidate updates, so the approximate method can suppress the old class without reproducing the new decisions.

Example-wise Loss and Decisions

For an input with model probability vector (p0,p1,p2)(p_0,p_1,p_2) and a known class-0 label, its cross-entropy is −log⁡p0-\log p_0. Suppose the predicted probabilities are (0.10,0.80,0.10)(0.10,0.80,0.10) after one intervention and (0.10,0.10,0.80)(0.10,0.10,0.80) after another. In both cases p0=0.10p_0=0.10, so the forget loss is about 2.30 in natural-log units. The first intervention predicts class 1, and the second predicts class 2. Both give that example a retained label, and both attain the same contribution to the forget objective.

You can also reverse the distinction. The vectors (0.10,0.80,0.10)(0.10,0.80,0.10) and (0.30,0.60,0.10)(0.30,0.60,0.10) assign the same argmax label. Their forget loss differs because the probability of the known old label differs. When comparing methods, first decide whether the downstream question concerns suppression of a label, level of confidence, similarity to a retrain's new decision, or something else the model emits.

Behavioral Forgetting versus Privacy and Attribution

Suppose the decision boundary matches the fresh retrain throughout the plotted grid. Even then the two models could use different hidden features or assign different probabilities. To examine this distinction we compare two scores on class-0 points the original model saw and on fresh class-0 points drawn from the same distribution.

The first score takes the largest softmax probability assigned to any class. It can be high when the classifier is confident in class 1 or 2. The second score takes the negative squared distance in the 16-dimensional hidden layer to a reference center. We form that center separately for each model using 300 independent reference points from the forget distribution. A larger score means closer to that center. No reference point is reused in either scoring cohort. The scoring cell reuses X_forget from the first draw of the main NumPy generator and X_forget_probe from the fourth draw. The new reference draw uses a separate generator seeded with 1. It does not advance the main generator. The hard case draws its nearby training and probe cohorts later from the main generator.

PythonIn [14]
CollapseExpand
reference_rng = np.random.default_rng(SEED + 1)
X_reference, _ = make_cluster(reference_rng, (-2.0, 0.0), 0.9, 300, 0)


def confidence_scores(model, features):
    with torch.no_grad():
        probabilities = torch.softmax(model(torch.from_numpy(features)), dim=1)
        return probabilities.max(dim=1).values.numpy()


def hidden_features(model, features):
    with torch.no_grad():
        return model.net[1](model.net[0](torch.from_numpy(features))).numpy()


def mean_gap(training_scores, fresh_scores):
    return float(training_scores.mean() - fresh_scores.mean())


score_gaps = {}
for name, model in models.items():
    center = hidden_features(model, X_reference).mean(axis=0)
    train_distance = ((hidden_features(model, X_forget) - center) ** 2).sum(
        axis=1
    )
    fresh_distance = (
        (hidden_features(model, X_forget_probe) - center) ** 2
    ).sum(axis=1)
    score_gaps[name] = (
        mean_gap(
            confidence_scores(model, X_forget),
            confidence_scores(model, X_forget_probe),
        ),
        mean_gap(-train_distance, -fresh_distance),
    )
ConsoleOut [15]
CollapseExpand
    Original | confidence gap -0.0011 | hidden-score gap +0.1483
     Retrain | confidence gap -0.0118 | hidden-score gap +0.0982
 Approximate | confidence gap +0.0000 | hidden-score gap +0.0824

Both gaps subtract the fresh cohort's mean from the training cohort's mean. A positive confidence gap means the model assigns higher confidence on average to the original training cohort; a negative hidden-score gap means those points are farther from the reference center on average. The fresh retrain has seen neither scoring cohort. Its gap can still be nonzero because the two cohorts are finite samples.

VisualizationOut [16]
CollapseExpand
Two signed bar charts compare original, retrained and approximate models on training-minus-fresh gaps. The left panel measures confidence and the right panel measures negative squared hidden distance.
Descriptive training-minus-fresh gaps for maximum probability and hidden-feature similarity. Each panel has its own scale. The fresh retrain also has finite-sample gaps.

The code reports differences in means. Evaluating a membership attack would require a rule for classifying individually scored records and a separate evaluation protocol, for example one that estimates the true-positive rate at a specified false-positive rate. A mean gap can miss differences elsewhere in the score distributions. A nonzero gap can occur with no membership effect at all. Those limits apply to the original, fresh retrain and approximate update alike.

Attribution asks a different question. Influence functions, for instance, estimate changes when a record's objective weight changes. The hidden score above never changes a record's weight. Data lineage matters for both tasks because it identifies model inputs that an audit may need to link to records or dataset snapshots. See Dataset Lineage and Provenance and Attribution and Training-Data Transparency.

The fresh retrain can provide a useful control for membership measurements. A score that varies similarly between the same two cohorts for the fresh retrain and for an edited model could reflect how those cohorts happened to sample the population. This is one reason to use matched data selection and to test on a new set of records. Reusing the records that helped choose a scoring rule for its final evaluation makes it hard to tell how much of the apparent separation would hold on fresh records.

A signed gap also hides the variability of individual scores. For a simple illustration, imagine two cohorts with scores [0,2][0,2] and [1,1][1,1]. Both have mean 1. A rule aimed at the extreme scores can still separate the cohorts in those four observations. In another example two cohorts can have different means yet have substantial overlap, so a rule based on one threshold produces both missed members and false positives. The toy chart reports two means subtracted, one pair for each model and score. It does not choose such a threshold.

Threat models specify what an evaluator sees. In one system the evaluator may only see sampled output text. In another they can see token probabilities. The hidden-feature score in this example needs access to activations and cannot be computed directly from just a class label returned by an endpoint. A score that works with activations in an experiment does not imply that a text-only interface reveals the same signal. Conversely, an unsuccessful attack with a narrow interface leaves open other access models.

The Measurement Stack and Its Limits

The toy reports forget behavior, retain utility and argmax disagreement with one fresh retrain, together with the two descriptive gaps. Each column uses a different question and several use a different probe cohort. A deployed-system audit can use the same separation and choose evidence appropriate to the claim being tested. The questions in Table unlearning-audit use different comparators.

Four distinct questions for a removal audit.
QuestionComparatorWhat the measurement covers
Did the specified behavior change?Original model on the same probesOutcome on a stated set of forget probes
Did retained behavior survive?Original model or retained-only retrainUtility on held-out retained tasks
Can an observer infer membership?Matched nonmembers and an explicit access modelAttack performance under the stated protocol
Did the release match retraining in law?A fixed fresh training procedure on retained dataDistribution over released artifacts

If a deployment requires a behavioral metric, write down the prompt selection rule, decoding settings and success criterion. For retain utility, include prompts near the target and broader checks. If the claim concerns data removal, describe the observation available to the evaluator and how the proposed released artifact compares with retraining.

A practical report can describe these metrics before it gives numbers:

  1. Identify the model before the request, the candidate afterward and the separate fresh comparator. Record what data and model artifacts each can access.
  2. Define the unit of deletion and the selection rule for forget, retained and neighboring probes. Inference confidence can vary across task types, so keep comparisons on the same cohorts if the goal is to attribute a change to the update.
  3. Give a definition and denominator for each reported value, plus the access and attack protocol for any attack statistic. For a toy or small proxy, state which results reproduce under the larger model separately.
  4. Record what was measured once and what was repeated across runs. Point estimates answer a question about that trial. Confidence intervals over sampled evaluation prompts and run-to-run variation over training seeds describe different kinds of uncertainty.

There is no single ordering of successful interventions across all those columns. A useful update might sacrifice some match to a fresh retrain to improve an intentionally different behavior. A removal evaluation, in contrast, can treat a large mismatch with retraining as substantive even when the change is useful. Explicit target and denominator make the same table interpretable under both uses.

What a Distributional Guarantee Would Add

Differential privacy is a guarantee about a randomized mechanism. Let M(D)M(D) denote a release computed from dataset DD, let D′D' be a dataset obtained by adding or removing one record, and let SS be any measurable set of possible releases. Under that adjacency convention, (ϵ,δ)(\epsilon,\delta)-DP requires

Pr⁡[M(D)∈S]≤eϵPr⁡[M(D′)∈S]+δ\Pr[M(D)\in S]\le e^\epsilon\Pr[M(D')\in S]+\delta

for every neighboring pair, so the inequality also holds with DD and D′D' swapped. The probabilities are over the mechanism's randomness. The parameter ϵ\epsilon bounds a multiplicative factor through eϵe^\epsilon, while δ\delta is an additive slack. NIST's guidelines discuss adjacency and the scope of a DP claim.

For a DP training mechanism and a single-record removal, the formula already relates the release from DD to training again on D′D'. That comparison covers the release defined by the mechanism. A response to a fixed public prompt inherits the distributional bound when it depends only on that release and independent sampling. The bound concerns probabilities of response events across runs. Removing several records requires its own privacy accounting. Publishing earlier checkpoints, auxiliary statistics or several versions can change the scope of the release and the guarantee.

An algorithm designed for certified removal can instead prove a bound between its post-removal release and a fresh retrain, as in Guo et al. The audit needs to identify which artifacts and requests the proof covers. Full retraining on the edited dataset implements the comparator directly. An update with measured utility and suppression gives useful evidence about those outcomes.

For context, Article 17 of the GDPR specifies grounds for erasure and sets out exceptions. A technical report can document the datasets and model artifacts affected by a procedure, and state the scope of any statistical guarantee. This chapter addresses those measurements.

Post-processing and Observable Releases

A statement about the distribution of released weights differs from a statement about a prediction at a specific input. For example, consider a scalar release that returns 0 or 2 with equal probability and one that always returns 1. They have the same mean. An event such as "release is exactly 1" has probability zero under the first and one under the second. Replacing the complete release law with a population average can therefore hide the entire difference.

Bounds on the full release law have a stronger implication. Given a deterministic post-processing rule gg and an event TT for the value g(M(D))g(M(D)), apply the distribution inequality with the event S={w:g(w)∈T}S=\{w:g(w)\in T\} in the release space. For dataset DD, Pr⁡[g(M(D))∈T]=Pr⁡[M(D)∈S]\Pr[g(M(D))\in T]=\Pr[M(D)\in S]. The corresponding identity holds for D′D'. Substitute these two identities into the inequality to compare the transformed probabilities. The argument also applies when additional independent randomness is used by the rule, by conditioning on that randomness and integrating over it. Information released alongside the model is part of the premise only if the bound covers the joint release or the extra information is itself suitable post-processing.

This is why it matters to specify whether the method publishes just a model, both old and new models together, or checkpoints and logs as well. The technical comparison in this chapter treats the fresh model and the candidate as individual releases. The toy uses both old and new models locally for its evaluation. That evaluation setup is not a proof about the joint distribution of the two models.

Worked Comparison: When Approximate Unlearning Fails

For a harder comparison, add two retained clusters near the forget cluster. These points use existing labels 1 and 2, so the architecture and output labels stay fixed. The original training set grows from 1,400 to 2,000 points while the forget cohort remains at 400. The retain set grows from 1,000 to 1,600 points, with the original distant clusters supplying 1,000 of those points. The comparison changes both the proximity of retained points to the forget cluster and the mixture within the retain loss. We train the original and retained-only models again with their respective datasets and use the same approximate update as before.

PythonIn [17]
CollapseExpand
X_near_a, y_near_a = make_cluster(rng, (-1.0, 1.0), 0.7, 300, 1)
X_near_b, y_near_b = make_cluster(rng, (-1.0, -1.0), 0.7, 300, 2)
X_hard_ret = np.vstack([X_ret, X_near_a, X_near_b])
y_hard_ret = np.concatenate([y_ret, y_near_a, y_near_b])
X_hard_all = np.vstack([X_forget, X_hard_ret])
y_hard_all = np.concatenate([y_forget, y_hard_ret])

model_orig_hard = train_model(X_hard_all, y_hard_all)
model_retrain_hard = train_model(X_hard_ret, y_hard_ret)
model_unlearned_hard = approximate_unlearn(
    model_orig_hard, X_forget, y_forget, X_hard_ret, y_hard_ret
)

The original forget and distant-retain probes stay the same. For the new nearby cohorts, draw 300 fresh points per cluster. Their accuracy is a separate column so a large gain or loss near the forget cluster stays visible.

PythonIn [18]
CollapseExpand
X_near_a_probe, y_near_a_probe = make_cluster(rng, (-1.0, 1.0), 0.7, 300, 1)
X_near_b_probe, y_near_b_probe = make_cluster(rng, (-1.0, -1.0), 0.7, 300, 2)
X_near_probe = np.vstack([X_near_a_probe, X_near_b_probe])
y_near_probe = np.concatenate([y_near_a_probe, y_near_b_probe])

hard_models = {
    "Original": model_orig_hard,
    "Retrain": model_retrain_hard,
    "Approximate": model_unlearned_hard,
}
hard_metrics = {
    name: (
        *behavior_metrics(model, model_retrain_hard),
        accuracy(model, X_near_probe, y_near_probe),
    )
    for name, model in hard_models.items()
}
ConsoleOut [19]
CollapseExpand
    Original | forget 0.640 | distant retain 0.870 | nearby retain 0.803 | disagreement 0.640
     Retrain | forget 0.000 | distant retain 0.873 | nearby retain 0.930 | disagreement 0.000
 Approximate | forget 0.000 | distant retain 0.748 | nearby retain 0.502 | disagreement 0.490

In this run the approximate model stops predicting class 0 on the forget probes, but its accuracy on the nearby retained clusters drops. Fresh retraining also stops predicting class 0 and classifies more of the nearby retained probes correctly. That is a failure of the particular update to match the comparator. The two outcomes show why low forget accuracy alone is an incomplete measure.

A language-model deletion request can similarly leave nearby text in the training set, such as documents on the same topic with different authors. Choose retain probes that reflect what those documents are supposed to preserve. The toy's clusters serve only to make it possible to vary related and less related evaluation cohorts separately.

The exact observed comparison is about 50.2% nearby-retain accuracy for the approximate update, 80.3% for the original and 93.0% for the fresh retrain. Nearby probes pool the two nearby retained cohorts. An approximate update can misclassify those points even when it succeeds at the chosen forget metric. In this run its accuracy on the distant cohorts also declines, but those two panels describe different mixtures of retained data.

Both updated models reach 0% forget accuracy on these probes and still disagree on 49.0% of them. Because both predict only classes 1 and 2 on those probes, every disagreement is a class-1 versus class-2 decision there. The hard case therefore isolates the distinction from the first case, where some disagreements can also come from the retrain still predicting class 0.

Accuracy in the nearby retained region is a property of predictions, so it is possible to improve it without restoring the original weights. The retained-only retrain here does that relative to the original, which had to also model the additional class. Whether performance uniformly improves on the retain data is a question for the held-out split. Looking at both nearby and distant cohorts documents where the change occurred.

Practical Methods and Their Tradeoffs

The gradient update requires direct access to the model and both sets of examples. If the request arrives after deployment, the method can start from existing weights, but its measured scope depends on what those examples and probes cover. Altering the retained dataset and restarting training uses the training recipe itself as the comparison. A distilled-model retrain can be a separate experiment, with conclusions scoped to that smaller model.

The influence approximation offers a way to estimate changes around a stationary point. Solving the Hessian system incurs computational cost, and the accuracy of the estimate depends on the local approximation. Our SGD example takes a different route. It evaluates gradients directly at each updated parameter vector, using the proxy objective introduced above.

Some systems prepare for removal when first training. Bourtoule et al. propose SISA, which partitions training data into disjoint shards, trains components on those shards and divides each shard into slices with intermediate checkpoints. When a record is removed, the affected component can be retrained from a checkpoint before the record was used. Here the natural comparator follows the same partitioned training procedure on the edited data. The saved training state and partitioned architecture are part of the method.

The candidate set also matters. A near-duplicate left in the retained dataset can carry the same content as the removed example. Deduplication and PII Removal describe data-pipeline stages that can help identify those cases. A report should say whether the request targets one record, a collection of exposures, or a behavior that may be supported by other data.

Relate the Method to the Request

A request may concern one example, a class of records, or an observable capability. The unit determines both data preparation and evaluation. A single known training row can be removed exactly from a versioned dataset. A coherent forget class involves many records, and one training-set edit can remove the entire group. A behavior expressed in many sources requires a behavioral specification or a carefully justified set of exposures. Those three cases have different experiments, so the observed ease of removing an entire class from a tiny classifier does not establish a ranking of difficulty.

There is also a difference between deletion of a record and removal of a memory from a surrounding context. If a document contains both a target string and material to preserve, removing the document removes both from that training example. Training on a rewritten document presents a different retained dataset. One can define that policy, run its retraining comparator and verify preservation tests for the intended consequences. State which dataset is retained so the unlearning claim has a concrete reference.

SISA and full retraining illustrate two infrastructure choices. A system with stored shards and usable checkpoints can pay some storage and bookkeeping costs earlier, with removal work focused on affected training components. A system with a single jointly trained model can define a fresh end-to-end comparator and measure what selective updates achieve relative to it. What is affordable depends on the size of the training job, the request pattern and the availability of checkpoints. A retrain of a smaller model is a separate result and may help to diagnose a method, while its evidence remains about that model.

Limitations and Impact

This example uses one fixed initialization, a toy architecture and probes drawn from the data generator we wrote. Changing the seed or Gaussian centers can change the measured gaps and accuracies. To compare approximate methods, use common probes for each comparison, vary the training seed and check how results depend on update settings. The held-out cohorts here show how to read one trial.

A deployed language model adds choices about what counts as a successful response, which capabilities to preserve and who can observe outputs or weights. The hard-case result illustrates why an average over broad retain tasks may miss a local loss. The score-gap comparison illustrates why a single descriptive number cannot settle a privacy claim. Both examples depend on a stated evaluation protocol, and a distributional claim additionally needs a justified comparator.

To generalize an observed result, specify which parts of the mechanism change between settings. A larger model may have different objectives, data exposure, output representations and usage. The worked example controls those choices inside the toy and demonstrates how to keep retain tests, sensitivity checks and comparators separate.

A complete report should also preserve enough configuration to explain the result later. For this notebook the cluster parameters, dataset counts, initial seeds, architecture and update rules appear next to the outputs. For a larger system the training inputs and revision, randomization choices, update code and observation protocol can be recorded alongside the numbers. This information explains what task a later reviewer would need to rerun.

Summary

Unlearning begins with the records to be removed and a specified retraining procedure. On a synthetic classifier, fresh retraining on the retain set gives a reference for the gradient-ascent update. The approximate method can suppress the old class while making different predictions from the retrain and losing accuracy on nearby retained points. The first fresh retrain itself can predict the removed class away from the retained training data.

Keep forget behavior, retain utility, membership inference and distributional removal distinct when reporting an intervention. Their evidence ranges from probe outcomes to explicit comparisons of release distributions. Evaluating Knowledge Interventions extends those evaluation questions to the interventions covered in this part.

Quiz

Ready to test your understanding? Take this quick quiz to reinforce what you've learned about machine unlearning and how to evaluate whether a removal claim actually holds.

Machine Unlearning

Question 1 of 80 of 8 completed
In the chapter's formal setup, what does the retraining baseline θ* most precisely represent?
Join the discussionAsk a question or share what you learned.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

A different angle
All writing
Language AI Handbook · Vol. 15

Knowledge Editing

Learn how to update specific facts in language models using rank-one weight edits, meta-learned editors, and memory-based approaches with evaluation controls.

43 min read
Language AI Handbook · Vol. 15

Personalization and Long-Term Memory

Build application-layer memory for LLM assistants. Learn typed records, provenance, consent scopes, conflict resolution, and erasure across stores.

33 min read
Language AI Handbook · Vol. 15

Evaluating Knowledge Interventions

Measure deliberate knowledge changes along five axes: efficacy, locality, generalization, side effects, and leakage. Build auditable evaluation harnesses.

40 min read

About the author

Reference

Citation details

Cite or share this article.

BIBTEXAcademic
@misc{brenndoerfer2026machineunlearning, author = {Michael Brenndoerfer}, title = {Machine Unlearning}, year = {2026}, url = {https://mbrenndoerfer.com/writing/machine-unlearning-model-data-removal-evaluation}, organization = {mbrenndoerfer.com}, note = {Accessed: 2026-12-03} }
APAAcademic
Michael Brenndoerfer (2026). Machine Unlearning. Retrieved from https://mbrenndoerfer.com/writing/machine-unlearning-model-data-removal-evaluation
MLAAcademic
Michael Brenndoerfer. "Machine Unlearning." 2026. Web. December 3, 2026. <https://mbrenndoerfer.com/writing/machine-unlearning-model-data-removal-evaluation>.
CHICAGOAcademic
Michael Brenndoerfer. "Machine Unlearning." Accessed December 3, 2026. https://mbrenndoerfer.com/writing/machine-unlearning-model-data-removal-evaluation.
HARVARDAcademic
Michael Brenndoerfer (2026) 'Machine Unlearning'. Available at: https://mbrenndoerfer.com/writing/machine-unlearning-model-data-removal-evaluation (Accessed: December 3, 2026).
SimpleBasic
Michael Brenndoerfer (2026). Machine Unlearning. https://mbrenndoerfer.com/writing/machine-unlearning-model-data-removal-evaluation
Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy