Elamur Research

Robustness Challenges in Model Distillation and Pruning for Natural Language Understanding

Paper · 2023 · Mengnan Du, Subhabrata Mukherjee, Yu Cheng et al.

Summary

A smaller language system can score nearly as well as the original on familiar examples and still make many more mistakes when the examples change. Du and colleagues examine this risk in natural language understanding, using BERT as their starting point. They study two ways of making it smaller. Knowledge distillation trains a compact student using predictions from a larger teacher. Pruning removes individual weights or whole attention heads from an existing network. The authors compare both approaches on standard development sets and on out-of-distribution tests, where cues that work in the training data are less dependable.

The difference between those evaluations is visible even after modest pruning. On the matched development split of MNLI, a task that asks how a hypothesis follows from a premise, BERT-base scores 84.2% and the version at 40% sparsity scores 84.0%. On HANS, a test designed to expose reliance on syntactic shortcuts, the same systems score 59.8% and 54.7%. A separate analysis divides the MNLI development data according to whether the answer can be predicted from the hypothesis alone. As pruning becomes more severe, accuracy falls faster on examples that resist this shortcut. Comparisons among equally sized compact encoders also suggest that parameter count alone cannot explain the pattern.

The authors use this observation to design Robust Model Compression, or RMC. They present each training example to several pruned versions of BERT and measure how much its loss varies across those versions. Low variation is treated as evidence that the example may be easy to classify through a shortcut. During distillation, the teacher’s probability distribution is flattened more for these examples, so the student receives a less emphatic signal about which label to prefer. Examples with larger loss variation receive targets closer to the teacher’s original predictions. The student also continues to learn from the recorded labels.

RMC improves several shifted-test results while keeping development accuracy close to its starting point. At 40% sparsity, it raises HANS accuracy from 54.7% to 58.6%. With MiniLM, an already distilled encoder, it raises HANS accuracy from 51.4% to 57.8% and MNLI matched development accuracy from 83.1% to 83.7%. On the MNLI subset that resists hypothesis-only prediction, both compact systems also improve. The results show that changing the confidence of the teaching signal can recover some of the robustness lost in compression, within the BERT-based classification tasks the authors examine.

Deep dive: Robustness Challenges in Model Distillation and Pruning for Natural Language Understanding

A study of why distilled and pruned BERT systems lose accuracy under distribution shift and how example-specific smoothing helps. · about 34 minutes to read

The problem and its context

What a standard development score can miss

Compression usually starts with a practical constraint. An encoder that performs well on a language task may be difficult to deploy where memory and response time are limited. The paper mentions mobile phones and edge devices as examples. A smaller encoder, or one with many weights removed, offers a way to reduce the amount of information the system has to store. The usual question is how much predictive performance survives. Du and colleagues ask how the answer changes when familiar and unfamiliar examples are evaluated separately.

In a conventional split, the training and development examples are drawn under similar conditions. They can share writing conventions, annotation habits, and statistical associations between phrases and labels. Held-out development examples still test whether a system can make predictions on inputs it has never seen. They can also reward a decision rule that works because both splits share an accidental cue. A good score establishes that the rule works frequently under those conditions. It leaves open how well it works where the cue and label come apart.

Natural language inference makes this distinction concrete. Given a premise, determine whether it entails the hypothesis, conflicts with it, or leaves its status undetermined. A classifier might instead find that a strong resemblance between the sentences is frequently associated with entailment. Such resemblance is easy to detect and sometimes informative. Its reliability depends on the construction of the examples. Sentences can contain much of the same vocabulary and still make different claims. An evaluation designed around cases like these measures whether the classifier can make the distinction when word overlap offers poor guidance.

The paper calls this kind of behavior shortcut learning. A shortcut is defined by how a cue is used in relation to the task. Lexical information is often relevant, and a classifier that attends to particular words can be doing something quite appropriate. The concern is reliance on an association that predicts the benchmark label even when the information needed for the intended judgment is elsewhere. In inference, one indication is that the hypothesis on its own can predict the answer. In fact verification, the wording of a claim can correlate with its label even though deciding whether the claim is supported requires considering the evidence.

An out-of-distribution test, abbreviated OOD, changes important properties of the examples relative to the familiar data. The paper uses test sets that make particular shortcuts harder to use and, in one case, examines text from a different source. This gives robustness a specific meaning in the study. It concerns how well decisions transfer to the named test conditions, especially where common benchmark cues are unreliable. Each test can expose a different weakness. Their results describe several forms of transfer instead of a single property that an encoder possesses independently of its task and data.

Why compression makes the question harder

Work on efficient models and compression had already developed several ways to build compact versions of pretrained encoders. In knowledge distillation, a large teacher creates a training signal for a smaller student. A recorded class gives the student a single target label. A teacher’s probability distribution supplies additional information about how it ranks the other labels and how confidently it favors the first. The smaller network learns to approximate some of the original network’s behavior using that richer signal.

Pruning starts with an existing network and removes part of it. One strategy sets individual weights to zero, choosing weights according to their magnitudes. Another removes complete components, such as attention heads, according to their estimated contribution to predictions. Work cited by the paper had examined whether attention heads can be pruned because their functions are unequally important or partly redundant. These strategies can preserve useful behavior while reducing the active parts of the network. A development score alone gives little information about which behavior was preserved.

Distillation and pruning also pose different risks. The student in distillation learns from a teacher that may already exploit training artifacts. If the teacher is especially confident on examples with an obvious shortcut, using its predictions as targets can transmit that confidence. Pruning can change which patterns an existing encoder can use reliably. If decisions on certain examples depend on parts of the network that are removed, the cost can be concentrated on those examples even while the average score looks stable. These are reasons to inspect the error patterns of compressed systems separately from their overall development accuracy.

The paper also distinguishes the effect of becoming smaller from the effect of the way that smaller system was produced. A compact network has less capacity than BERT-base in the sense relevant to this study, where parameter count is used to compare size. A distilled network may have learned different patterns from a similarly sized network that went through pretraining without distillation. A structured pruning method can also produce networks of the same size that keep different heads. Including such comparisons lets the authors ask whether networks with similar parameter counts have similar behavior on difficult examples.

What earlier robustness work had established

As the authors describe it, studies of general-purpose pretrained encoders had already documented the problem of spurious associations in language benchmarks. Work on annotation artifacts in natural language inference had shown how to use hypothesis-only predictions to identify examples that are susceptible to this particular shortcut. The paper draws on that work to separate an ordinary development set into groups with different diagnostic value. Other studies had examined lexical cues, overlap between inputs, and the degree to which apparently successful systems transfer when those cues become unreliable.

Prior mitigation methods approached the problem from several directions. Some combined the main classifier with another predictor built to capture a known bias, so that the training procedure could account for cases that the biased component already handled. Other methods adjusted the importance of examples, used adversarial training, or constrained the distributions produced by a classifier. The paper cites these as ways of trying to make general pretrained encoders less dependent on artifacts. Its own intervention is designed for compressed students and changes the targets supplied by their teacher.

Earlier compression research had also raised concerns about uneven effects. Studies in computer vision discussed in the paper found examples for which compressed networks were particularly unreliable and reported changes in errors across demographic groups. Those findings motivated looking beyond aggregate accuracy, while leaving open what would happen on language tasks. Closely related work in language studied the behavior of compressed encoders under adversarial input manipulation. Du and colleagues emphasize generalization across test sets built to reveal shortcut reliance. Some of those test sets are themselves adversarially constructed, so the distinction lies in the evaluation setup and the conclusions drawn from it.

The study therefore brings together two questions that a standard benchmark score leaves unresolved. The first is whether a small encoder preserves the full encoder’s ability to classify examples under shift. The second is whether a measurable property of individual examples can guide the training of a compact encoder towards better transfer. To connect the questions, the authors use pruning both as a compression technique to evaluate and as a diagnostic that helps determine how strongly a teacher should supervise each example.

The method, step by step

Establishing the teacher and the compact alternatives

The common starting point is uncased BERT-base. For a downstream classification task, the encoder produces a pooled representation of its input, and a linear layer maps that representation to scores for the possible classes. The softmax operation converts those scores into probabilities. A classifier can then choose a label, while the full probability distribution remains available for distillation. In the paper, fine-tuning means adapting the pretrained encoder and its task classifier using the labeled training examples for the downstream task.

To study distillation as a compression technique, the authors select DistilBERT and MiniLM, using versions distilled from BERT-base. These are task-agnostic starting points for the paper’s experiments. Their initial compression takes place before fine-tuning for a particular benchmark. The authors also include a truncated encoder that keeps the first 6 layers of the larger one and a compact 6-layer encoder pretrained from scratch. Each compact encoder in this comparison has 66M parameters. This holds parameter count fixed while allowing the way the encoder acquired its weights to vary.

The paper restricts this comparison to systems with reasonably comparable training and teacher choices. It leaves out TinyBERT because the task fine-tuning described for that system uses data augmentation. It also leaves out MobileBERT because its teacher is BERT-large. Such distinctions matter when assigning an observed change to compression. Additional data or a different teacher could alter the prediction patterns independently of the size and compression procedure.

Iterative magnitude pruning takes a different route. As the encoder is fine-tuned for a task, the procedure repeatedly removes the eligible weights with the smallest magnitudes until it reaches the target sparsity. Sparsity indicates the fraction removed. For instance, the paper explains that at 60% sparsity, 40% of parameters remain under that convention. In its implementation, the embedding modules are frozen and pruning is applied to parameters within the 12 Transformer blocks. A removed weight is set to 0. The authors use the standard procedure without rewinding, so they continue fine-tuning instead of restoring the surviving weights to an earlier training state.

Structured pruning removes complete attention heads. A head is a component of an encoder layer that determines how information at different input positions contributes to the representation. To estimate its importance, the authors associate each head with a mask and look at the sensitivity of the classification loss to that mask. The appendix expresses the contribution score as an expected derivative:

Iₕ⁽ʰ,ˡ⁾ = Eₓ∼ₓ[∂L(x) / ∂ξ⁽ʰ,ˡ⁾]

Here the subscript of the expectation denotes drawing an example x from the data collection X, so the expectation is over examples. The symbols h and l identify the head and its layer. Iₕ⁽ʰ,ˡ⁾ is the head’s contribution score. L(x) is the loss on x, ξ⁽ʰ,ˡ⁾ is the mask for that head, and ∂ denotes a partial derivative. The derivative describes how sensitive the loss is to changes in the mask. Heads with the lowest contribution scores are removed. The reported configurations remove 28 heads, around 20% of the total, and retain 116 heads. The authors chose this scale because further removal substantially degraded development accuracy.

Turning pruning into a measure of difficulty

RMC begins by creating several magnitude-pruned versions of BERT-base at different sparsities. Each serves as a probe of the same labeled examples. For a given example, the authors record the loss assigned by each pruned network. Loss is the penalty associated with its prediction on that example. The probe therefore uses the known label and the network’s prediction. It can register changes in how strongly the correct class is supported even when the chosen label stays the same.

The diagnostic is based on variation across sparsities. If a cue remains easy to exploit as weights are removed, networks at different sparsities may treat the example similarly. If correct classification depends on information that some of those networks preserve and others lose, their losses can differ substantially. The authors use the latter pattern as evidence of difficulty. The probe produces a numerical score for every training example and does not require the annotator to identify particular words or constructions as the cause.

The method has two training stages. The first produces difficulty estimates using pruned networks. The second adjusts the teacher’s targets and uses those targets to train a compact classifier.

How RMC builds example-specific teaching targets

The steps in order.

How RMC builds example-specific teaching targetsStep 1: Prune BERT-base at several sparsity levels1. Prune BERT-base at several sparsity levelsStep 2: Score each labeled example with every pruned network2. Score each labeled example with every pruned networkStep 3: Measure how much each example’s loss varies3. Measure how much each example’s loss variesStep 4: Scale the variances into difficulty scores4. Scale the variances into difficulty scoresStep 5: Fine-tune the full teacher on the downstream task5. Fine-tune the full teacher on the downstream taskStep 6: Smooth each teacher prediction using its difficulty score6. Smooth each teacher prediction using its difficulty scoreStep 7: Train the student with labels and smoothed targets7. Train the student with labels and smoothed targets

The paper uses n = 5 sparsity levels for the variance calculation. The range shown for these probes runs from 0.2 to 0.85. It is wider than the range used for the main pruning benchmark. The probes serve to expose differences in how examples respond to weight removal. They are used for their losses on individual examples, while the main benchmark evaluates pruned classifiers as possible compact alternatives to the teacher. Those are different jobs for a heavily pruned network.

For an example xᵢ, the variance is calculated as follows:

vᵢ = (1 / n) ∑ₜ₌₁ⁿ (ℓᵢ,ₜ − ℓ̄ᵢ)²

The index i identifies the example and t identifies a pruned network at one of the chosen sparsities. The symbol ℓᵢ,ₜ denotes its loss on xᵢ, and ℓ̄ᵢ is the mean of that example’s losses across the networks. The sum runs from the first pruning setting to n, the number of settings. Subtracting the mean centers the losses, squaring makes departures in either direction contribute positively, and dividing by n gives the variance vᵢ. The formula uses changes around the example’s own mean. Consistently low losses and consistently high losses can each yield low variance.

The authors then scale the training-example variances into a bounded range:

dᵢ = α + [(1 − α) / (Vₘₐₓ − Vₘᵢₙ)] × (vᵢ − Vₘᵢₙ)

Here dᵢ is the estimated difficulty of training example i. The quantities Vₘᵢₙ and Vₘₐₓ are the smallest and largest variances among the training examples. The hyper-parameter α sets the lower endpoint of the scale, and 1 is its upper endpoint. The factor involving Vₘₐₓ and Vₘᵢₙ maps the observed variance range onto the desired difficulty range. An example at the minimum receives dᵢ equal to α. An example at the maximum receives dᵢ equal to 1. Intermediate examples receive intermediate values and retain their ordering by variance.

This normalization gives the training procedure a way to use the ranking without committing to a binary easy-or-hard label for each training item. It also makes α a consequential choice. Changing it alters how far the least variable examples can move from the original teacher distribution. The authors motivate separate values for separate datasets by arguing that each dataset can have a different degree of bias arising from its collection and annotation.

For tuning, the authors use the in-distribution development set to compare performance on examples with lower and higher variance. They choose α values of 0.5 for MNLI, 0.3 for FEVER, and 0.2 for QQP. These are training choices for the named tasks. They describe the minimum exponent the teacher probabilities can receive, rather than a direct estimate of the fraction of biased examples in each dataset. The shifted test sets are reserved for evaluation.

Smoothing the teacher’s predictions

In the second stage, the authors fine-tune the full BERT-base teacher on the downstream task. They collect its predicted class probabilities for the training examples. Then, for each example, they raise every class probability to that example’s difficulty score and renormalize across the classes. The resulting probabilities form the target distribution used for distillation.

sᵢ,ⱼ = (ŷᵀᵢ,ⱼ)ᵈⁱ / ∑ₖ₌₁ᴷ (ŷᵀᵢ,ₖ)ᵈⁱ

The symbol sᵢ,ⱼ is the smoothed probability assigned to class j for example i. The expression ŷᵀᵢ,ⱼ is the original probability of that class from the teacher, indicated by T. The exponent written dⁱ in the formula is the example’s difficulty score dᵢ. In the denominator, k runs over the K possible labels, so the powered probabilities are divided by their sum. That division makes the smoothed values a probability distribution again.

When dᵢ equals 1, the transformation leaves the probabilities as they were. As dᵢ moves toward α, the distribution flattens. A small probability gains weight relative to a large one, while the ordering of the probabilities is preserved. The teacher can still favor the same class and give the other classes their original ranking. The student receives a weaker preference for the leading class. Keeping the lower endpoint above 0 limits how far the teacher’s distribution can be flattened.

The distinction between adjusting confidence and changing the preferred class is important. Suppose the teacher strongly favors a class for an example that several pruned networks also find easy. The procedure does not identify a replacement label or tell the student to disagree with the teacher. It reduces the emphasis of the preference communicated by the teacher. If the dataset also supplies that class as the correct label, the recorded label still appears in the training objective. The method changes how much of the teacher’s certainty reaches the compact student on that particular input.

A globally smoothed teacher would perform the same probability transformation on every example with the same exponent. RMC uses the estimated difficulty to make the extent of smoothing vary. At the high-variance end, information in the teacher’s original probability distribution is largely preserved. At the low-variance end, the transformed probabilities ask the student to reproduce less of the sharpness of the teacher’s prediction. This is the mechanism the baseline comparisons later isolate.

Training the student from two targets

The student is trained with a combination of the recorded class label and the smoothed teacher distribution. The paper writes the objective as:

L(xᵢ) = (1 − λ) × L₁(yᵢ, ŷˢᵢ) + λ × L₂(sᵢ, ŷˢᵢ)

Here xᵢ is the training input, L(xᵢ) is its combined loss, and yᵢ is its recorded class. The vector ŷˢᵢ contains the student’s predicted probabilities, with the superscript S indicating the student. The vector sᵢ contains the smoothed teacher probabilities across all the classes. L₁ is cross-entropy against the recorded label. It penalizes a student that gives the correct class low probability. L₂ is the distillation loss based on Kullback–Leibler divergence, which compares the student’s probability distribution with the teacher target. The plus sign combines the two weighted terms. The hyper-parameter λ is fixed at 0.9 and controls the balance between the teacher target and the recorded label.

The same objective is applied at different points in the two compression workflows. For an already distilled encoder, it guides task-specific fine-tuning. The compact architecture and its pretrained starting point are already in place. For magnitude pruning, the objective guides fine-tuning while the procedure removes weights. The pruned versions used earlier to measure difficulty play a separate role from this final student. Once the student is trained, the loss-variance estimates and the teacher’s probabilities have served as training inputs.

Establishing the comparison metrics

The authors report ordinary classification accuracy for each development or test split. They also define a relative bias metric to compare the size of the development-to-test gap with the gap already present in BERT-base. They first calculate the gap separately for each classifier:

Δ = Fdev − FOOD

The symbol Δ is the gap for a particular classifier on a particular task. Fdev is its accuracy on the in-distribution development split, and FOOD is its accuracy on the shifted test data for the same task. The subtraction captures the difference between scores under the two evaluation conditions.

They then use the full encoder as the reference:

Fbias = Δcompressed / ΔBERT-base

Here Fbias is the relative bias metric. The numerator Δcompressed is the development-to-test gap for the compact classifier, and the denominator ΔBERT-base is the corresponding gap for the uncompressed classifier. A value above 1 means that the compact classifier has a larger gap. A value below 1 means it has a smaller gap. The paper uses the overall accuracy across the two symmetric test sets when obtaining the FEVER gap. It likewise uses overall accuracy across the two PAWS tests for the QQP gap.

The relative metric is useful because the full teacher can also perform poorly under shift. It provides a way to express how much larger or smaller the gap is after compression. It is also sensitive to both parts of the subtraction. A change in the development score can move Fbias even when the test score moves in the same direction. The split accuracies and the ratio therefore answer complementary questions. The split scores show where predictions improve or deteriorate, and the ratio relates that change to the full encoder’s gap on the same task.

Experiments and results

The tasks, shifted tests, and common training setup

The evaluation covers language inference, fact verification, and recognition of equivalent questions. Each involves a relationship between pieces of text. Their shortcuts differ, so a change that helps with one kind of shift cannot be assumed to have the same size or direction on the others. The authors use accuracy throughout and report results averaged over three runs.

MNLI asks whether a hypothesis is entailed by, contradicts, or is neutral with respect to a premise. The paper gives 392, 702 examples for training and 9, 815 for development. It reports standard development accuracy on the matched split. The shifted test is HANS, which contains 30, 000 synthetic examples. HANS is designed to expose inference strategies that work when familiar syntactic cues line up with the desired label. Its controlled construction makes it a targeted test of those strategies.

FEVER asks whether the evidence supports or refutes a claim, or provides insufficient information. The training set contains 242, 911 examples and the development set contains 16, 664. The paper notes that the claim text can contain strong label cues. It evaluates transfer using Sym v1 and Sym v2, each with 712 examples. These tests are organized around symmetric cases that make the consequences of relying on biased cues easier to see than on the ordinary development set.

QQP asks whether two questions have equivalent meanings. Its training and development sets contain 363, 846 and 40, 430 examples, respectively. The shifted tests come from PAWS. PAWS-qqp has 677 test examples derived from the QQP corpus, while PAWS-wiki has 8, 000 test examples derived from Wikipedia pages. This gives the question-equivalence task tests that differ in their source as well as from its ordinary development examples. High lexical similarity can be insufficient when deciding whether two inputs convey the same meaning.

The authors use the same fine-tuning settings across classifiers to make the relative comparison easier to interpret. Their training runs for five epochs with Adam, weight decay, and a learning rate of 2e-5. They use PyTorch and pretrained checkpoints from Hugging Face. The paper notes that different learning rates or training durations can change generalization. A shared schedule makes the reported comparisons conditional on the same training budget, which suits the authors’ goal of measuring the relative behavior of compressed and full encoders.

What ordinary compression does to shifted-test accuracy

With magnitude pruning, development scores change little at some sparsities where shifted-test scores have already fallen. On FEVER, for example, the full encoder scores 86.2% on development, 58.9% on Sym v1, and 64.5% on Sym v2. At 60% sparsity the corresponding accuracies are 86.3%, 56.9%, and 63.3%. The slightly higher development score and the lower scores on both symmetric tests lead to a larger measured gap. The result illustrates how an apparent gain under ordinary development conditions can coexist with weaker transfer.

The MNLI results show a stronger separation. At 20% sparsity, the matched development accuracy is 84.4%, compared with 84.2% for BERT-base, while HANS accuracy falls from 59.8% to 55.5%. At 60% sparsity, the development and HANS scores are 83.4% and 52.8%. At 70% sparsity they are 81.8% and 52.2%. By the highest sparsity in the main benchmark, both evaluations show a loss. HANS has already been registering a drop throughout the pruning series.

Magnitude pruning and BERT-base on HANS test accuracy

HANS accuracy falls as magnitude pruning removes more weights.

Magnitude pruning and BERT-base on HANS test accuracyBERT-base (this paper): 59.8BERT-base (this paper)59.820% sparsity: 55.520% sparsity55.540% sparsity: 54.740% sparsity54.760% sparsity: 52.860% sparsity52.870% sparsity: 52.270% sparsity52.2
The numbers
System or settingaccuracy %
BERT-base (this paper)59.8
20% sparsity55.5
40% sparsity54.7
60% sparsity52.8
70% sparsity52.2

QQP shows a similarly consistent decline in the shifted tests as pruning becomes more severe. BERT-base scores 90.9% on development, 48.9% on PAWS-wiki, and 34.7% on PAWS-qqp. At 40% sparsity those scores are 90.5%, 46.6%, and 32.4%. At 70% sparsity they are 89.5%, 45.4%, and 30.7%. Every magnitude-pruned setting has a relative bias above 1 on every evaluated task. The average relative bias is 1.088 at 20% sparsity, 1.101 at 40%, 1.132 at 60%, and 1.127 at 70%. The last ratio is lower than the preceding one even though the reported test accuracies continue to fall. The development side of the gap is also moving.

Structured pruning gives a comparison in which the number of remaining attention heads is held fixed. The compact variants score 84.1%, 84.2%, and 84.0% on matched MNLI development. Their respective HANS accuracies are 55.5%, 53.7%, and 55.3%, alongside 59.8% for BERT-base. Their relative bias values are 1.172, 1.250, and 1.176. All sustain approximately the development performance of the original. Their shifted-test results differ from the original and from one another. The paper uses this result to qualify earlier findings that mild pruning can preserve or improve ordinary benchmark performance.

The task-agnostic distilled encoders also lose more accuracy on HANS than on matched MNLI development. DistilBERT scores 82.3% on development and 51.2% on HANS. MiniLM scores 83.1% and 51.4%, respectively. The full encoder scores 84.2% and 59.8%. In the paper’s description of DistilBERT’s result, the development loss is 1.9% and the HANS loss is 8.6%. The same qualitative separation appears in FEVER. MiniLM reaches 84.2% on development, with 53.4% on Sym v1 and 60.7% on Sym v2. The corresponding BERT-base scores are 86.2%, 58.9%, and 64.5%.

The compact encoders made without distillation also have worse shifted-test scores than BERT-base. Their comparison with the distilled encoders clarifies the role of size. The pretrained 6-layer encoder scores 52.2% on HANS, 54.7% on Sym v1, and 62.6% on Sym v2. It exceeds both distilled alternatives on those three test splits. Its average relative bias of 1.130 is also below the 1.159 of DistilBERT and the 1.162 of MiniLM. The truncated encoder has an average relative bias of 1.155. QQP shows why those averages need to be read alongside the individual splits. DistilBERT reaches 48.1% on PAWS-wiki and 34.6% on PAWS-qqp, which are higher than the corresponding scores of the other compact encoders in this comparison.

What the mitigation baselines test

The mitigation experiments compare training procedures for students at the same size. Vanilla is ordinary task fine-tuning, including the pruning procedure where applicable, without the extra mitigation objective. Distil adds task-specific teaching from fine-tuned BERT-base. The teacher supplies its ordinary softmax probabilities. Smooth uses task-specific distillation with a common smoothing exponent of 0.9 on every example. Distil and Smooth both use the same 0.9 weight on the distillation loss as RMC. Comparing Distil and Smooth asks whether changing teacher confidence helps. Comparing Smooth and RMC asks whether distributing that change according to example difficulty helps further.

The remaining baselines adjust the influence of examples on training. Focal loss gives greater relative weight to examples whose correct labels currently receive lower predicted probabilities. The usual expression is:

FL(pᵢ) = −(1 − pᵢ)ᵞ × log(pᵢ)

In this expression, pᵢ is the probability assigned to the recorded class on example i, FL(pᵢ) is the focal loss, and log is the logarithm. The leading minus sign makes the log penalty positive for probabilities below 1. The factor involving 1 minus pᵢ is raised to γ, the parameter governing the strength of the weighting. The superscript ᵞ represents this γ. When pᵢ is high, the factor reduces the contribution of the example.

The paper normalizes the weights within each training batch:

FL(pᵢ) = −[(1 − pᵢ)ᵞ / ((1 / N) ∑ₖ₌₁ᴺ (1 − pₖ)ᵞ)] × log(pᵢ)

The symbols pᵢ, FL, γ, and log keep the same meanings. N is the number of examples in the batch, k indexes those examples, and pₖ is the probability assigned to the recorded class on example k. The denominator is the batch mean of the focal weights. Dividing by it makes the average weight 1.0, so training changes the relative influence of examples while keeping the mean weight fixed. The authors set γ to 2.0 for all tasks.

Just Train Twice, abbreviated JTT, identifies difficult examples through a preliminary classification run. It first trains BERT-base using ordinary cross-entropy. The compact classifier then gives extra weight to the examples that this preliminary classifier misclassified. Its up-weighting parameter is 2.0, and the authors again normalize the weights so that they average 1.0. Focal loss and JTT offer useful comparisons because both seek to direct learning toward difficult examples. Their intervention is on the loss weight. RMC uses variation across pruned networks to decide how to change the teacher’s probability distribution.

Mitigation with magnitude pruning

The main pruning mitigation experiment uses 40% sparsity, reported as 65.4M parameters for each compact setting. On matched MNLI development, RMC reaches 84.2%, compared with 84.0% for Vanilla. On HANS, every mitigation procedure improves on Vanilla in this comparison. RMC gives the highest HANS accuracy among the pruned students. The full BERT-base reference still has the higher HANS score of 59.8%.

Training methods at 40% sparsity on HANS test accuracy

Example-specific smoothing gives the highest HANS accuracy among the pruned students.

Training methods at 40% sparsity on HANS test accuracyVanilla: 54.7Vanilla54.7Distil: 56.2Distil56.2Smooth: 56.5Smooth56.5Focal: 56.7Focal56.7JTT: 56.3JTT56.3RMC (this paper): 58.6RMC (this paper)58.6
The numbers
System or settingaccuracy %
Vanilla54.7
Distil56.2
Smooth56.5
Focal56.7
JTT56.3
RMC (this paper)58.6

FEVER is a case where the pruned student trained with RMC exceeds its teacher on both shifted test sets. RMC scores 61.9% on Sym v1 and 66.4% on Sym v2. Vanilla scores 57.2% and 64.0%. The teacher scores 58.9% and 64.5%. Global smoothing also exceeds the teacher on these tests, reaching 60.7% on Sym v1 and 65.8% on Sym v2. The development results are close. RMC scores 86.1%, compared with 86.4% for Vanilla and 86.2% for BERT-base. The test gains occur with a small decrease in development accuracy for this comparison.

On QQP, RMC at 40% sparsity scores 47.6% on PAWS-wiki and 34.3% on PAWS-qqp. These are the highest results among the pruned settings on those two splits. The teacher remains ahead with 48.9% and 34.7%. The pruned RMC student’s QQP development score is 90.4%, compared with 90.5% for Vanilla. Across the tasks, the improvements are clearest when the shifted tests are examined directly, with the development figures showing the size and direction of any accompanying changes on familiar data.

For this pruning experiment, the average relative bias falls from 1.101 with Vanilla to 0.990 with RMC. The authors report a reduction of 10% relative to Vanilla. The per-task values explain the average. RMC has relative bias of 1.049 on MNLI, 0.897 on FEVER, and 1.023 on QQP. The smaller FEVER gap brings the average below 1 even as the HANS and combined PAWS gaps remain larger than the teacher’s. The authors also test the mitigation across different sparsities for MNLI and report higher HANS accuracy and lower relative bias than Vanilla throughout the settings shown.

Mitigation with a distilled encoder

The second mitigation experiment begins with MiniLM at 66M parameters. Its Vanilla training is ordinary downstream fine-tuning of an encoder whose task-agnostic compression has already occurred. The later task-specific distillation stage can therefore change the compact classifier’s behavior without changing its parameter count. On MNLI, RMC gives 83.7% development accuracy and 57.8% on HANS. Vanilla scores 83.1% and 51.4%. The best HANS score among the alternative MiniLM baselines is 55.7% with JTT. The BERT-base score of 59.8% shows that the gap to the full teacher remains visible.

The FEVER results likewise favor RMC on the raw split accuracies among the MiniLM settings. It reaches 85.3% on development, 58.0% on Sym v1, and 63.3% on Sym v2. The Vanilla scores are 84.2%, 53.4%, and 60.7%. The globally smoothed baseline scores 83.7%, 56.9%, and 62.1%, respectively. Both RMC and Smooth receive a relative bias of 1.017 in the paper. RMC’s development score is higher as well as its shifted-test scores, which explains how the relative-gap metric can give the same reading to settings with different accuracies.

On QQP, RMC reaches 90.5% on development, 47.0% on PAWS-wiki, and 33.4% on PAWS-qqp. MiniLM with Vanilla scores 89.9%, 46.8%, and 31.0%. JTT matches RMC on PAWS-wiki and scores 32.9% on PAWS-qqp, while Focal reaches 33.2% on PAWS-qqp. In relative bias, RMC records 1.038 for QQP and Smooth records 1.032. A reader interested in successful predictions on these test sets would therefore favor a different setting from a reader choosing by the relative gap alone.

The MiniLM average relative bias moves from 1.162 with Vanilla to 1.041 with RMC. The authors report a reduction of 10.4%. MNLI shows the clearest separation among the MiniLM relative bias results. Vanilla records 1.309, Distil records 1.221, and RMC records 1.068. The task-specific training recovers more of the HANS loss when it adapts smoothing to individual examples than when it asks the student to imitate the teacher’s unchanged downstream probabilities.

MiniLM training methods and average relative bias across MNLI, FEVER, and QQP

Example-specific smoothing yields the smallest average relative gap among the MiniLM settings.

MiniLM training methods and average relative bias across MNLI, FEVER, and QQPVanilla: 1.162Vanilla1.162Distil: 1.103Distil1.103Smooth: 1.085Smooth1.085Focal: 1.089Focal1.089JTT: 1.083JTT1.083RMC (this paper): 1.041RMC (this paper)1.041
The numbers
System or settingrelative bias
Vanilla1.162
Distil1.103
Smooth1.085
Focal1.089
JTT1.083
RMC (this paper)1.041

What the ablations show

Keeping size fixed changes the interpretation

The study includes several controlled comparisons that answer different questions about the results. The compact encoders with 66M parameters test the claim that decreased size itself explains weaker transfer. Pretrained-l6, the smaller encoder pretrained from scratch, has better shifted-test accuracy than either distilled encoder on HANS and both FEVER tests. Parameter count is held fixed, so the difference is associated with how the networks were produced. The result is consistent with the authors’ view that the training and compression process plays a role in which useful behavior survives.

The comparison offers two other checks on that interpretation. First, the truncated encoder also has 66M parameters, and its outcomes differ from those of Pretrained-l6. Simply retaining the first 6 layers and pretraining a network of that depth lead to distinct starting points for fine-tuning. Second, the structured variants each retain 116 heads and obtain different HANS scores. The content of the retained network matters to its behavior, even at the same nominal size. Neither comparison assigns an exact share of the robustness loss to architecture, training history, or removal of particular parameters.

The task-specific mitigation comparisons hold the compact starting point or pruning target fixed more directly. At 40% sparsity, every mitigation variant has the same reported parameter count. The MiniLM runs start with the same kind of 66M-parameter encoder. The improvements in those comparisons come from modifying training, so an increase in network capacity cannot account for them. The changes are visible at different scales on the different tasks, which gives a more precise interpretation than treating size as a general predictor of test accuracy.

The development set contains examples of different diagnostic value

The authors use an existing MNLI partition to investigate where compressed classifiers lose accuracy. To construct that partition, the earlier study trained a classifier using only hypotheses and then applied it to the development data. Examples it classified correctly went into the easy subset. Those it missed went into the hard subset. The paper gives 5488 examples in the easy subset and 4302 in the hard subset. Here the term easy describes the success of a particular shortcut predictor. It does not rate how difficult the example would be for a person.

This partition makes it possible to look within ordinary development data. Both groups are drawn from the same benchmark, but they differ in whether the label is accessible to the hypothesis-only classifier. If a pruned encoder loses much more accuracy on the hard group, a nearly unchanged aggregate development score can mask a redistribution of errors. The evidence comes from the disagreement between performance patterns within the benchmark, independently of the comparisons with HANS.

Across five investigated sparsities, the authors report larger accuracy losses on the hard examples as pruning increases. At 0.4 sparsity, the easy-minus-hard accuracy gap is 16.1%. At 0.85 sparsity, the gap is 22.7%. The widening gap is consistent with the idea that cues sufficient for many easy examples are more resistant to the removal of weights. The authors also report that compressed networks tend to be overly confident on easy examples. They suggest that exploiting strong correlations between cues and labels could produce that confidence.

The variance diagnostic provides a separate check on whether sensitivity to pruning corresponds to this notion of difficulty. The authors calculate the loss variance of development examples across the pruned networks, rank the examples, and use low variance to identify an easy group. When they compare that grouping with the hypothesis-only partition, they report 82.8% accuracy. The reference grouping is defined by an independently trained shortcut classifier, so the agreement gives the variance measure an external point of comparison within MNLI. It also leaves room for examples whose sensitivity to pruning and susceptibility to hypothesis-only prediction differ.

Altering the teacher helps more than direct copying

Vanilla, Distil, Smooth, and RMC form a sequence of comparisons about the source of the learning signal. Vanilla relies on the task’s labels. Distil adds the teacher distribution. Smooth changes the confidence of that distribution uniformly. RMC changes confidence by different amounts across examples. For the pruned student, HANS accuracy rises from 54.7% with Vanilla to 56.2% with Distil and 56.5% with Smooth. It reaches 58.6% with RMC. The comparison indicates that a useful portion of the gain comes from how the teacher signal is prepared, after accounting for the addition of that signal.

FEVER offers a related comparison. With the pruned student, global smoothing lifts Sym v1 accuracy to 60.7%, compared with 58.4% for direct distillation. RMC reaches 61.9%. On Sym v2, the corresponding values are 65.8%, 64.5%, and 66.4%. Smoothing by itself can help on these tests. The example-specific method improves raw accuracy further while differing only slightly in the pruned student’s development score. The result supports both the use of softer targets and the decision to vary the amount of softening.

The focal-loss and JTT baselines help answer whether any method that directs more learning toward hard examples would give the same result. Both can help. On HANS with MiniLM, Focal scores 55.6% and JTT scores 55.7%, ahead of Distil at 53.7% and Smooth at 53.8%. RMC scores 57.8%. This comparison suggests that difficulty is useful in multiple forms. It also shows how much the result depends on the particular mechanism and task. On QQP, JTT matches RMC’s MiniLM accuracy on PAWS-wiki, and Smooth achieves a slightly smaller relative gap than RMC. The benchmark results support a pattern of improvements across tasks, with individual measures that favor another choice.

The hard subset improves under mitigation

The paper returns to the MNLI partition to see whether RMC’s benefits are concentrated in the group that motivated the method. With MiniLM, the hard subset rises from 73.2% accuracy under Vanilla to 74.9% under RMC. Easy-subset accuracy changes from 90.9% to 90.6%. The easy-minus-hard gap moves from 17.7% to 15.7%. Meanwhile, HANS accuracy rises from 51.4% to 57.8%. The gain on a separate shifted test accompanies a smaller difference between the two familiar-data groups.

With the student pruned to 40% sparsity, hard-subset accuracy rises from 74.9% to 75.9%, while easy-subset accuracy changes from 91.0% to 90.3%. The gap falls from 16.1% to 14.4%. HANS improves from 54.7% to 58.6%, and matched development accuracy rises from 84.0% to 84.2%. The authors report the reduction in the easy-to-hard gap as 10.6% at 0.4 sparsity and 11.3% for MiniLM. In both cases the hard-subset score increases as easy-subset accuracy falls slightly. The all-example development score on its own would obscure that change in where errors occur.

These subgroup results connect the intervention to its motivation. Pruning sensitivity is used to estimate which examples should receive softer teacher targets, and the finished compact classifiers improve on a set defined through another procedure. That pattern supports the authors’ interpretation that training becomes less concentrated on the readily predicted examples. Since the outcomes are group accuracies, they do not reveal which feature drove any individual decision. A classifier can also become more accurate on the hard subset by exploiting associations that a hypothesis-only classifier could not use.

Limitations

Limits identified by the authors

The authors limit their study to knowledge distillation and pruning. Their experiments cover several forms of those techniques, including unstructured weight removal and removal of whole attention heads. Other forms of compression, such as quantization and matrix decomposition, fall outside the study. The mechanism behind errors could differ when the values of parameters are represented with less precision or when a weight matrix is replaced by a decomposition. The paper leaves the robustness of those methods open.

The authors also identify an added training cost. RMC needs a collection of pruned networks and the losses they assign to each training example. Standard fine-tuning of the compact encoder would not require that diagnostic. The authors suggest parallel training and more efficient difficulty calculations as avenues for reducing the cost. The reported results establish what the intervention can do under the training setup used in the paper. They give no runtime comparison for those proposed ways of obtaining the difficulty scores.

Limits of the experimental evidence

The tested encoders share a BERT-base lineage, and the tasks are supervised classifiers with a fixed set of labels. The evidence is strongest for a teacher that produces a probability distribution over the same classes the student is learning. Extending the conclusion to other encoder families or to tasks with a different output structure would require a corresponding way to define the losses, measure their sensitivity to pruning, and apply the smoothing operation. The structured pruning results establish a robustness problem on MNLI. The mitigation tables demonstrate the intervention for magnitude pruning and MiniLM.

The OOD tests probe specific kinds of shift. HANS highlights shortcuts in inference that its synthetic examples are designed to expose. The FEVER tests challenge reliance on claim-side cues, and the PAWS tests challenge conclusions based on surface similarity. These tests make the findings interpretable because they are tied to recognizable failure patterns. They cover only a portion of the conditions a deployed classifier might face. Scores on them quantify transfer to those test conditions, and the paper’s broader language about robustness is supported to that extent.

The variance proxy can detect instability without identifying its cause. An example that every pruned network classifies poorly can have low variance, since the score depends on the spread of losses. An example can show high variance because some choices of removed weights happen to affect the pattern it needs. In both cases, the metric describes how the example behaves across pruning settings. The input itself does not receive a verified semantic difficulty label from that measurement. The 82.8% agreement on MNLI supports the proxy for the particular shortcut partition used there. The paper does not offer corresponding independent agreement figures for FEVER or QQP.

Min–max scaling makes the training scores dependent on the range observed in each dataset. The smallest and largest variances define the scale for every other example. The method uses development performance on low- and high-variance groups to tune α, and the value differs by task. This is a practical way to choose the strength of regularization without using the OOD tests for tuning. It leaves open how sensitive the results are to the particular extremal examples, to the choice of pruning levels, and to the value of α on a new training set. The experiments compare several strategies, but do not independently vary each of these choices.

The matched fine-tuning schedule also shapes what the comparison establishes. The authors give every system the same learning rate and number of epochs and note that training duration can affect OOD results. The observed gaps therefore describe relative performance under a common schedule. A separate optimization for each compact encoder could change its absolute score or the ordering of some settings. The paper reports means across three runs without giving run-to-run dispersion alongside the main accuracies, so small differences among nearby settings are difficult to assess for consistency.

The name “relative bias” has a narrow interpretation in this study. Its calculation is based on a development-to-test accuracy gap, with the full encoder providing the denominator. The metric does not classify the errors by shortcut or count biased decisions directly. For a task with multiple OOD tests, the combined value can also hide variation among the component scores. The MiniLM FEVER results demonstrate one consequence. Smooth and RMC have the same reported relative bias while RMC has higher accuracy on development and on each symmetric test. Claims about improvement should specify whether they refer to raw accuracy, the relative gap, or both.

The paper’s characterization of preserved development performance refers to results that stay close in the aggregate. The pruned RMC student scores 86.1% on FEVER development, compared with 86.4% for Vanilla, and 90.4% on QQP development, compared with 90.5%. The MNLI partition also shows small decreases on the easy subset for both compact students. These movements are compatible with the method’s purpose of changing how the student learns across examples, and they matter if the comparison is read as a claim about a particular split or group. Similarly, matching or exceeding the teacher on the symmetric FEVER tests leaves the HANS and PAWS comparisons to be judged on their own scores.

Finally, the paper sometimes describes effects in prose that are best checked against the individual table entries. Its initial comparisons give BERT-base a parameter count of 109M, while the mitigation tables give 110M and report the same reference accuracies. The compact-versus-full comparisons remain interpretable from the named settings and split results, but the parameter counts should be read in the context of their respective tables. The paper’s strongest empirical argument rests on the large and recurring differences between development and shifted-test behavior, and on the matched-size intervention comparisons, where the underlying evaluation conditions are clear.

What came after

The related survey Shortcut Learning in Natural Language Understanding addresses the wider phenomenon that motivates this study. The compression paper cites it when explaining how conventional dataset splits can reward decision rules based on spurious cues. The survey is dated 2022, so the documented relationship here is one of context for the compression study. The latter turns the general concern into a more specific comparison by testing whether pruning or distillation enlarges the gap between familiar data and diagnostic test sets.

Foundational Challenges in Assuring Alignment and Safety places robustness in a broader setting concerned with the assurance of large language systems. The connection is the question of what favorable evaluation results can establish about behavior under changed conditions. The compression study offers a concrete classification example in which similar development scores accompany different generalization results. The citation establishes a connection between the papers. It leaves open whether the later work uses a particular experimental result, the relative bias measure, or the RMC training procedure.

Strategic Data Selection for Out-of-Distribution NLI returns to out-of-distribution performance on inference, with closed-source systems and data selection as its setting. Its stated focus shares the earlier paper’s interest in treating examples differently to improve transfer. Du and colleagues vary the strength of the teacher target for each training example, while the later title identifies the choice of data as the intervention. The citation connects the work to the same generalization problem. The documented connection does not specify whether strategic selection uses pruning-induced variance, the hypothesis-only partition, or another definition of difficulty.

Cite

Cite as Mengnan Du, Subhabrata Mukherjee, Yu Cheng, Milad Shokouhi, Xia Hu and Ahmed Hassan Awadallah. 2023. Robustness Challenges in Model Distillation and Pruning for Natural Language Understanding. Proceedings of the 17th Conference of the European Chapter of the Association for Computational Linguistics.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/2023.eacl-main.129

@inproceedings{du2023robustness,
  title = {{Robustness Challenges in Model Distillation and Pruning for Natural Language Understanding}},
  author = {Mengnan Du, Subhabrata Mukherjee, Yu Cheng, Milad Shokouhi, Xia Hu and Ahmed Hassan Awadallah},
  booktitle = {Proceedings of the 17th Conference of the European Chapter of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.eacl-main.129},
  url = {https://doi.org/10.18653/v1/2023.eacl-main.129}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/du-2023-robustness-challenges-model-distillation-pruning/