The Heuristic Core: Understanding Subnetwork Generalization in Pretrained Language Models
Paper · 2024 · Adithya Bhaskar, Dan Friedman and Danqi Chen
Summary
Two sentences can contain the same words and describe different events. If a doctor thanks a patient, reversing their roles changes who did the thanking. A system trained to judge whether one sentence follows from another can nonetheless do well on ordinary test data by treating shared words as evidence for entailment. The Heuristic Core asks what happens inside a pretrained language model when it learns to handle examples on which that shortcut fails. The authors look inside a single fine-tuned network and ask which parts support the shortcut, which parts support better judgments, and whether the two behaviors depend on separate machinery.
The authors freeze a trained BERT network and search for different subsets of its components using structured pruning. Each search tries to preserve the original predictions while removing a specified fraction of the components. Several subnetworks come close to the full network on ordinary validation data yet behave very differently on tests designed to expose shortcuts. At 50% sparsity, the MNLI subnetworks score within 2-3% of the full BERT network on the in-domain validation split. On the HANS Embed-If challenge, their accuracies range from 4.1% to 50.2%. The subnetworks that do better on one kind of challenge can do worse on another. Much sparser subnetworks generally retain considerable in-domain accuracy while losing most of their ability to handle misleading examples.
One explanation would be that separate subnetworks compete during training, with a generalizing solution eventually taking over. The authors instead find nine attention heads in every BERT subnetwork in their main MNLI comparison, including those whose decisions mostly follow shortcuts. The same heads recur when the authors prune a checkpoint saved before out-of-domain accuracy starts improving. Several of the shared heads place attention on words repeated across the two sentences. Yet removing some of those heads from the full network sharply reduces its accuracy on examples where overlap is misleading. The authors call the shared set the heuristic core. Their interpretation is that later computations use simple features supplied by this core to make finer distinctions.
The amount of the network needed to match the full classifier on challenge examples also rises as its performance improves, while the amount needed on ordinary validation data stays relatively stable. Experiments on question paraphrases and on RoBERTa support parts of the same account. GPT-2 shows a similar gap between in-domain and challenge performance across subnetworks, alongside cases where pruning changes accuracy in the opposite direction. Together, the experiments show how much a routine validation score can conceal about what pruning removes and how a network handles a misleading cue.
Deep dive: The Heuristic Core: Understanding Subnetwork Generalization in Pretrained Language Models
The Heuristic Core traces how pretrained language networks learn to handle misleading word overlap by building on attention heads they already use. · about 33 minutes to read
The problem and its context
When different rules fit the same examples
In natural language inference, a classifier sees a premise and a hypothesis. Its job includes deciding whether the hypothesis is warranted by the premise. A shared vocabulary is often relevant. If both sentences mention the same people and the same action, they may be about the same event. To settle whether the premise entails the hypothesis, the classifier also needs to account for the roles those people play and for any qualifications on the event. A premise placing an event inside a condition gives different grounds for drawing a conclusion from a premise asserting that the event happened. A count or match of repeated words leaves those distinctions unresolved.
A heuristic is a rule that can give useful answers without resolving all the distinctions the task makes. Lexical overlap is the paper's central example. A classifier can learn to favor entailment when the two sentences share many words. Where the association holds, a lexical rule and a rule sensitive to sentence structure get credit for the same answer. The test for choosing between their predictions comes from examples built to break the association. The study uses a comparable distinction in paraphrase identification. Two questions can share their important words while asking about different relationships, so the usefulness of matching words depends on how the rest of the decision treats the match.
The paper calls validation data from the task used in training in-domain, abbreviated ID. It calls the separate challenge data out-of-domain, abbreviated OOD. Here the challenge data expose specified departures from the usual usefulness of a cue. For instance, a test can present pairs whose overlap favors entailment even though the premise provides insufficient grounds for the hypothesis. Ordinary validation and challenge evaluation answer complementary questions. The first measures how well the learned decision works on held-out examples from the original task. The second measures how often it survives a deliberate conflict between the cue and the label. Both scores refer to correct classifications, but the examples place different demands on the classifier.
Earlier work had found that repeated fine-tuning runs could produce BERT classifiers with similar ID scores and widely different OOD scores. The runs differed in their random seeds, which control random choices during training. Thus even when standard evaluation made the end products look interchangeable, challenge evaluation could distinguish them. Bhaskar, Friedman, and Chen ask whether comparable variation also exists across parts of a single trained classifier. Their setup holds the learned weights fixed and changes which components are allowed to supply input-dependent outputs. That isolates a different source of variation from the one studied in earlier fine-tuning comparisons. BERTs of a feather do not generalize together
Earlier work also found a gap in timing. Ordinary validation accuracy can level off while performance on challenge examples still has room to improve. The paper discusses research that attributes some delayed improvement to hard minority examples. Such examples matter because an average dominated by cases where a cue is helpful may change very little when a network begins to handle cases where the cue fails. The order in which the scores improve motivates an internal question. Once the classifier has a way to do well in-domain, does further training develop a separate procedure or build on the computations already in use? An Empirical Study on Robustness to Spurious Correlations using Pre-trained Language Models
Why the authors test for competition
The authors take a candidate explanation from work on grokking. In small algorithmic tasks, a network can fit its training examples early and then, after a long period of continued training, improve abruptly on unseen examples. In the explanation the paper considers, the network develops competing solutions. One solution is relatively large and good at fitting known cases. The other is smaller and captures a rule that transfers to new cases. A change in which solution dominates can then account for the apparent delay followed by sudden improvement. The analogy to sentence-pair classification is the separation in timing between success on familiar cases and success on more demanding ones. Grokking
The authors turn that analogy into two expectations they can check. If the solutions live in disjoint subnetworks, components supporting the shortcut should be separable from those supporting the more general decision. If the later solution is more compact, the amount of the network needed to reproduce its generalization should shrink as challenge performance improves. Those expectations concern visible consequences of the proposed explanation. A delayed improvement curve alone cannot establish where the different computations reside, how much they share, or whether the classifier retains its earlier machinery.
The alternative investigated in the paper treats the shortcut as an early use of features that can serve more than one purpose. Finding the same word across a sentence pair is a simple operation. A later computation might use the resulting correspondence while checking whether that word plays the same role in both sentences. The distinction is between a feature and the decision that uses it. A feature can support poor decisions when it dominates the prediction and still be useful when combined with other information. The authors look for signs of this arrangement in retained attention heads, in the evolution of the network during training, and in the response to removing individual heads.
Why pruning can address the question
Pruning usually serves an engineering goal. It removes parts of a network to reduce storage or computation. Structured pruning removes units with identifiable roles in the architecture. Other approaches can select individual weights, giving the search finer control over what remains. The paper describes a tradeoff in the compression literature: selecting weights individually can allow greater compression, while structured removals can more readily yield speed gains. Here the choice of structure also serves an experimental purpose. If two masks retain the same attention head, the authors can name the shared unit and examine what happens when its output is replaced. Structured Pruning of Large Language Models
This use of pruning belongs to interpretability, the study of how a network's internal computations contribute to its behavior. The paper describes earlier efforts that used masks to find modular pieces of learned behavior or to study the effects of fine-tuning. It also distinguishes its search from circuit discovery, where the objective is to trace interactions in greater detail. Removing entire heads and feed-forward layers makes it possible to run many searches and compare the resulting subsets. Examining where a head assigns attention can then suggest a function, while intervening on the head tests whether the rest of the classifier depends on its output. The motivation for combining these approaches comes in part from earlier evidence that attention weights can be misleading when used on their own. Attention is not Explanation
The method, step by step
Make the shortcut and the task disagree
The experiments begin with two sentence-pair tasks. In MNLI, the input is a premise and a hypothesis. In QQP, the input is a pair of questions and the classifier judges whether their meanings are equivalent. Each task supplies training data and ordinary validation examples. The authors pair MNLI with HANS for challenge evaluation and use the QQP-derived portion of PAWS to challenge the paraphrase classifier. The resulting design allows the authors to ask whether a subnetwork that preserves ordinary classification also preserves correct decisions when overlap is a poor guide.
The main BERT inference analysis emphasizes four HANS subcases. SO-Swap tests reversal of subject and object, as when a premise says a doctor advised a president and the hypothesis reverses who gave the advice. Prep tests misleading matches involving a prepositional phrase. In the paper's example, a tourist is by a manager and sees some artists, while the purported conclusion makes the artists the observers and the manager the person observed. The words provide plausible correspondences, but their arrangement fails to warrant the new claim. These cases fall under lexical overlap because the words in the hypothesis also occur in the premise.
Embed-If and Embed-Verb probe a different shortcut. In the first, the premise contains a statement within a conditional construction. The hypothesis asserts the statement without the condition. In the second, the premise attributes a claim to somebody's belief, and the hypothesis asserts the claim as fact. For example, learning that lawyers believed some tourists had shouted gives grounds for a claim about the lawyers' belief. It leaves open whether the shouting occurred. The target words form a constituent within the premise, so a classifier that accepts a contained phrase on the strength of that relationship is likely to make the wrong judgment. The paper gives 1000 validation examples per HANS subcase.
The PAWS comparison uses question pairs marked as inequivalent. These pairs are especially revealing when rearranging similar words changes the meaning. In one example, the names of Perth and Melbourne exchange places in a question asking how one is better than the other. The same names and comparison appear in both versions, while the direction of the comparison changes. Equivalent pairs are compatible with the overlap shortcut. By restricting the challenge evaluation to inequivalent pairs, the authors measure performance on the cases where the shortcut favors the wrong answer.
Train a full classifier and save its checkpoints
The primary classifier is bert_base_cased, which the authors describe as having 125M parameters. They fine-tune it on MNLI for 5 epochs, corresponding to 61,360 steps with a batch size of 32. The learning rate is 2 · 10⁻⁵, and the maximum sequence length is 128. For QQP, they fine-tune for 40,000 steps at a learning rate of 2 · 10⁻⁵, using an effective batch size of 256. For both tasks they save checkpoints and evaluate every 500 steps. A checkpoint records the network's state at a particular point in training, making it possible to apply the same pruning analysis before and after its challenge accuracy improves.
The optimizer for these fine-tuning runs is Adam. The paper gives its β settings as (0.9, 0.999) and its ϵ setting as 10⁻⁸. The pair of β values controls the running estimates used in Adam's updates, and ϵ is its numerical stability constant. These settings apply to training the classifier. Later, the pruning procedure introduces its own parameters and constants. The authors report approximately 3 hours per fine-tuning run on one NVIDIA A5000 GPU.
The distinction between training weights and searching for a mask is essential to the design. Fine-tuning changes the classifier so it can make the sentence-pair judgments. Once the authors pick a checkpoint for pruning, its weights stay fixed. The optimization that follows can select which outputs to keep or replace. The surviving components retain the weights they had at that checkpoint. This gives the authors a way to ask what the trained network already contains, with the answer qualified by the kinds of replacement and component selection the pruning search permits.
Define the units a mask can select
A Transformer block combines a multi-head attention layer with a feed-forward layer, also called a multilayer perceptron or MLP. The paper describes the representation passed through these layers as a residual stream. An attention head reads from the stream and contributes a projected output back to it. Different heads can pay attention to different positions or relationships in the input pair. The MLP applies a learned nonlinear transformation and also contributes its result to the stream. The architecture description places layer normalization before both kinds of layer.
The paper writes the attention update in residual form. Using a bracketed index to keep the head labels attached to the corresponding matrices, the expression is:
X + ∑ᵢ₌₁ᴺʰ Attn(W_Q[i], W_K[i], W_V[i], X) W_O[i]
Here X is the input representation on the residual stream. The plus sign adds the heads' contributions to that representation. The summation runs over the head index i, from 1 through Nʰ, the number of heads. The bracketed i on each W matrix identifies the head to which the matrix belongs. Q, K, and V denote queries, keys, and values. The query and key projections are used to decide which positions receive attention, and the value projection supplies the information combined through that attention. Attn denotes this head computation. The O subscript identifies the output projection, which maps the result into the representation to which it is added. Juxtaposing the head output and W_O[i] denotes multiplication by that projection.
For the feed-forward part, the paper gives the following residual update:
X + GeLU(XW_U)W_D
In this expression, X is the representation entering the feed-forward layer. W_U is the learned up-projection, and U identifies that role. It maps the input from the hidden dimension d into the feed-forward dimension dₕ, which the paper says is typically 4d. GeLU is the nonlinear activation applied after the up-projection. W_D is the down-projection, with D identifying the map back into the hidden dimension so the result can be added to X. The adjacent terms again denote matrix multiplication. The mask treats the whole feed-forward layer as a unit, while it can make separate selections for the individual heads in an attention layer.
At the end of pruning, each component has a binary gate. A value of 1 keeps its input-dependent output. A value of 0 replaces the output with that component's mean activation on the training data. This replacement is called mean ablation. It leaves a typical contribution in place while stopping the component from changing that contribution to suit the current input. Thus a head described as removed no longer supplies its example-specific output, even though the rest of the network receives a fixed substitute where the output would have been. That convention matters when interpreting how much function the retained components can supply.
From a trained classifier to subnetwork comparisons
The steps in order.
Learn the mask with the weights frozen
The mask search follows CoFi pruning. During optimization the gates can take values in [0, 1], so gradient updates can adjust them before the authors make a final binary selection. The prediction loss is the KL divergence between the full classifier's predictions and the subnetwork's predictions. KL divergence measures a discrepancy between probability distributions. Here the full classifier supplies the behavior the search tries to preserve. Two classifiers can produce the same most likely label yet assign different probabilities to the other possibilities, and the loss can register that difference. This objective is distinct from the accuracy scores used later to compare the discovered subnetworks.
The paper models the gates using a hard concrete distribution. It starts by sampling:
u ∼ Uniform(ϵ, 1 − ϵ)
The variable u is the random draw. The ∼ sign means it is drawn from the distribution to its right. Uniform gives equal density throughout the interval between the listed endpoints. The pruning constant ϵ is 10⁻⁶. Using ϵ and 1 − ϵ as endpoints keeps the calculation away from the extremes where the next operation can be undefined.
The draw is then transformed into a smooth gate value:
s = σ((log(u / (1 − u)) + log α) / β)
Here s is the intermediate gate before stretching. The function σ is the sigmoid, which maps its input between 0 and 1. The function log is the natural logarithm, and the argument of the first logarithm is the odds corresponding to u. The trainable parameter is log α for the component being gated. Adding it shifts the gate toward smaller or larger values. The fixed temperature β controls the steepness of the transformation. This β belongs to the hard concrete gate construction. The parentheses group the log odds and the learned offset before division by β.
The authors stretch the intermediate value:
s̃ = s × (r − l) + l
The stretched value is s̃, and s is the sigmoid output. The lower and upper stretch endpoints are l and r, with [l, r] set to [−0.1, 1.1]. The multiplication sign scales the sigmoid output by the width r − l. Adding l shifts the resulting interval to the intended endpoints. The stretch lets some probability fall below 0 or above 1 before the next operation puts those values at the boundaries.
The gate used by the distribution is:
z = min(1, max(0, s̃))
The variable z is the gate, and s̃ is the stretched value. The max operation puts values below 0 at 0, and the min operation puts values above 1 at 1. Values between those bounds pass through. This gives the search a smooth region for optimization along with probability mass at the two values corresponding to complete removal and complete retention.
Enforce sparsity and make a discrete selection
Sparsity is the fraction of eligible components removed. The definition counts attention heads and whole feed-forward layers as the units available to remove. It therefore describes the mask over those units. A head and an MLP need not account for equal shares of the original parameters or computation. The authors use L0 regularization, which in this setting concerns how many gates remain active, and a term that steers the search towards a specified sparsity. In the notation of that term the paper uses s again, now for the sparsity target:
Lₛ = λ₁(t − s) + λ₂(t − s)²
Lₛ is the term added to the loss, t is the current sparsity, and s is the target sparsity. The difference t − s measures the mismatch. The coefficient λ₁ weights the signed mismatch, and λ₂ weights the squared mismatch. The subscripts distinguish the two coefficients. The gate parameters update by gradient descent, while the two λ coefficients update by gradient ascent. The latter updates adjust how strongly missing the desired sparsity affects the objective.
For BERT pruning, the effective batch size is 128 with gradient accumulation, and the sequence-length limit remains 128. The authors use a learning rate of 0.1 for the log α parameters and 1 for the λ parameters. They increase the target sparsity gradually. An immediate demand for a sparse mask would give the objective little opportunity to retain the full classifier's behavior while adjusting to intermediate levels. In practice the authors find that the learning rate for the constraint matters. With too slow an update the search can lag behind the target and then overshoot it. An overly fast update can also leave too little room for the search to settle.
The appendix gives this schedule for the ramp:
warmup_steps = 6500 + 50 × sparsity_pct
Here warmup_steps is the number of updates over which the target sparsity rises linearly. The variable sparsity_pct expresses the desired final sparsity as a percentage. The constant 6500 sets the base number of warmup updates, and the multiplier 50 scales the added updates with the sparsity target.
It also gives a formula for the full run:
total_steps = warmup_steps + 6 × sparsity_pct
The variable total_steps is the total update count, warmup_steps is the ramp duration from the previous expression, and sparsity_pct is the same target. The coefficient 6 sets the proportional number of updates after warmup. For the 50% target the paper reports 9300 steps, of which 9000 raise the target. For 70% it reports 10,500 total steps and 10,000 warmup steps. The stated total for the latter setting and the schedule formula describe different run lengths.
The authors evaluate and save pruning checkpoints every 64 steps and report results from the final checkpoint. They choose a threshold by searching [0, 1] in increments of 0.05, with the goal of getting as close as possible to the target sparsity after making the mask binary. For targets of 0.5 and 0.7, the reported thresholds are 0.5 and 0.35, respectively. A particular threshold is therefore a means of producing the discrete mask at the desired sparsity. It is the resulting retained component set whose accuracy and membership the authors compare across runs.
Measure how much of a checkpoint is effective
The authors give effective size a dataset-specific meaning. They look for the sparsest mask whose accuracy is within 3% of the full checkpoint's accuracy on the chosen evaluation data. The size of the subnetwork at that sparsity is their estimate. They try sparsities at multiples of 5%, averaging accuracy over three pruning seeds at each setting. They repeat the calculation using the ordinary validation data, the challenge data, and an equally weighted combination of the two. The same full checkpoint can consequently have a different effective size for each choice of evaluation.
There are two uses of faithfulness in the procedure. During mask optimization, the KL loss favors matching the full classifier's probability predictions. When the authors calculate effective size, they use closeness in aggregate accuracy on a named evaluation dataset. A subnetwork and a full checkpoint can earn similar aggregate accuracy while succeeding on different examples. Furthermore, on a challenge set where the full checkpoint performs poorly, a subnetwork can be faithful by reproducing similarly poor performance. These conventions make effective size a measure of the retained capacity needed to approximate a particular checkpoint under the paper's search and scoring procedure.
The authors release their implementation under the name Heuristic-Core. They report about 90 minutes for a BERT pruning run on an A5000 GPU and estimate 750 GPU hours for the study. The repeated searches are part of the experimental design. Varying the mask search seed gives the authors several candidate explanations of similar in-domain performance, which can then be compared for their component membership and their responses to challenge examples.
Experiments and results
Similar ordinary scores conceal different kinds of failure
In the main fixed-sparsity comparisons, the authors run the pruning search with 12 random seeds. The baseline is the full classifier at the same fine-tuned checkpoint. The measure is accuracy, the share of examples assigned the correct label. They report it separately for the ordinary validation split and for challenge data. For BERT inference, the principal comparison is between 50% and 70% target sparsity. For question paraphrases the corresponding targets are 30% and 60%. Though feed-forward layers are eligible for removal, the authors observe that their runs keep them. Attention head selection supplies the component variation they examine.
At 50% sparsity on MNLI and 30% on QQP, the paper reports that the subnetworks on each task remain within 2-3% of their full classifier's in-domain validation accuracy. The closeness extends across different seeds for the mask search. Challenge accuracy tells a different story. On HANS Embed-If, the 50% MNLI subnetworks range from 4.1% to 50.2% accuracy. The higher endpoint belongs to subnetwork 5, whose strength on this particular case does not extend uniformly to the other challenge categories.
BERT and selected 50% subnetworks on HANS Embed-If accuracy
The stronger pruned subnetwork on this subcase exceeds the full classifier.
The numbers
| System or setting | accuracy % |
|---|---|
| Lowest reported 50% subnetwork | 4.1 |
| Subnetwork 8 | 18.0 |
| Full BERT | 33.0 |
| Subnetwork 5 (this paper) | 50.2 |
On HANS SO-Swap, subnetwork 8 reaches 41.4% accuracy and subnetwork 5 reaches 19.5%. On Embed-If the ordering reverses. The authors also describe subnetwork 2 as doing well on Embed-If without comparable success on Embed-Verb. That last comparison matters because those challenges both test the temptation to accept a constituent of the premise as a warranted hypothesis. Even within the same family of heuristic tests, preserving performance on one construction gives limited information about performance on another. Matching the in-domain baseline and fixing the overall amount pruned leave room for each mask to preserve a different mix of capabilities.
BERT and selected 50% subnetworks on HANS SO-Swap accuracy
The pruned subnetwork favored on Embed-If trails the other selected mask on role reversals.
The numbers
| System or setting | accuracy % |
|---|---|
| Subnetwork 5 | 19.5 |
| Subnetwork 8 | 41.4 |
| Full BERT (this paper) | 86.7 |
The full classifier remains an important reference precisely because a mask can improve one score while degrading another. The authors report full BERT accuracies of 83.3% on the matched MNLI validation split, 86.7% on HANS SO-Swap, and 73.5% on HANS Prep. The corresponding full classifier scores on Embed-If and Embed-Verb are 33.0% and 33.4%. Thus the full classifier itself handles the selected HANS constructions unevenly. A higher score from a particular mask on Embed-If establishes a local improvement on that evaluation condition. The other subcases are needed to establish whether the same mask broadly preserves the classifier's challenge performance.
The QQP experiment shows a similar separation between ordinary and challenging examples, with less pronounced effects in the paper's account. The full classifier scores 91.2% on QQP validation and 14.8% on the adversarial, inequivalent PAWS-QQP subset. This difference provides context for interpreting a subnetwork that approximates the original. There is already considerable reliance on the misleading cue among the full classifier's decisions on the adversarial subset. The pruning comparison can show whether some masks preserve or worsen what limited challenge performance the full classifier does achieve.
Greater sparsity exposes the behavior that survives removal
At the more aggressive sparsities of 70% for MNLI and 60% for QQP, nearly all subnetworks lose generalization on almost all the challenge subcases considered in that comparison. Their in-domain accuracies stay at 74-76%. The fuller HANS evaluation supplies another piece of evidence about the behavior that remains. On examples friendly to the heuristic, the heavily pruned subnetworks can slightly outperform full BERT even though their accuracy on heuristic-resistant examples deteriorates. Choosing the label favored by overlap more frequently can produce both outcomes. The two kinds of test examples help distinguish a systematic reliance on a cue from a general loss of ability to process the sentence pair.
The authors also sweep across sparsity with 3 pruning seeds. Challenge accuracy generally declines as more components are removed. In-domain accuracy changes more slowly and shows little variation across seeds in the sweep. The curve provides little evidence of a sudden transition from a fully functioning challenge solution to a wholly heuristic one at a single sparsity. The authors find no subnetworks sparser than 30% that match the full network's generalization on either task. This comparison concerns the masks found in the sweep. An individual peak on a subcase, such as the Embed-If score in the first chart, can coexist with a failure to preserve the full classifier's performance across the challenge evaluation.
The same-sparsity experiment and the sparsity sweep expose different properties of the search. Varying the seeds at one target shows how much the identity of the retained components matters even when the component budget stays the same. Varying the target shows what tends to be lost as that budget shrinks. Taken together, the results suggest that cue-based performance is easier to preserve under the paper's pruning objective than the particular mix of computations needed for the full classifier's challenge performance.
What the training checkpoints reveal
The ordinary validation curves for fine-tuned BERT level off early. On the HANS subcases where the full classifier eventually makes progress, out-of-domain accuracy begins to rise later. The extended evaluation includes subcases where the classifier makes very little progress. The timing claim therefore concerns the behavior the network acquires on the challenge categories where improvement is visible. The paper reports that the corresponding effect in the paraphrase setting is smaller but consistent.
When the authors apply the effective-size measurement to successive checkpoints, the estimate for in-domain validation remains relatively flat. The estimates for the challenge data and the mixed evaluation increase as challenge accuracy improves. In practical terms, reproducing the later checkpoint's stronger challenge performance requires retaining more components than reproducing the earlier checkpoint's weaker challenge performance. Under the competition explanation the authors set out to test, the emerging rule was expected to be smaller than the solution it overtook. The measured change runs in the opposite direction.
The dataset-specific curves help locate the change. A rise on every split could reflect a general increase in how hard the classifier is to approximate. Here the increase is most evident when the scoring includes challenge examples. The already strong in-domain behavior remains reproducible at a relatively stable effective size. The authors interpret that pattern as evidence that the additional components are especially important to the distinctions challenge cases require. The later checkpoint still solves routine examples, but the component budget inferred from those examples understates what its broader behavior needs.
RoBERTa broadens the inference comparison
The RoBERTa experiment uses roberta-base, follows the same fine-tuning and pruning recipe, and tests the same four HANS constructions. Full RoBERTa scores 87.5% on MNLI matched and 87.2% on MNLI mismatched. At 50% sparsity, the subnetworks range from 84.1% to 85.8% on the matched split and from 84.1% to 85.7% on the mismatched split. Those two MNLI evaluations remain part of the in-domain comparison in this experiment.
The challenge scores show substantially greater spread. For HANS Prep, the full RoBERTa score is 93.2% and the 50% subnetworks range from 52.2% to 86.4%. For HANS SO-Swap, the corresponding full score is 99.4% and the subnetworks range from 46.0% to 87.0%. On Embed-Verb the full score is 72.6% and the pruned accuracy ranges from 42.3% to 75.6%. The Embed-Verb range, like the BERT Embed-If example, contains a mask that beats the original on one construction. At the same sparsity much lower scores are also possible, and the ordinary validation scores give little indication of which mask will achieve which outcome.
RoBERTa also shows a rise in effective size as its generalization improves. The authors find 11 attention heads common to the 12 subnetworks in the comparison, with the same shared heads appearing in the effective-size subnetworks before generalization. Since full RoBERTa achieves stronger challenge scores than full BERT on these cases, the repeated pattern covers classifiers that differ in how frequently they solve the challenge examples. The shared set's specific head identities also differ. The recurring finding is the presence of a stable intersection under the pruning procedure, alongside the need to retain other components to preserve the later classifier's challenge performance.
GPT-2 tests a decoder-only case
The decoder-only experiment uses GPT-2 small, with 117M parameters. The fine-tuning setting in the paper uses 10 epochs and reports 12,270 steps. Full GPT-2 generalizes poorly to the adversarial HANS cases overall. Embed-If is the only subcase in the paper's contradiction group where accuracy exceeds 30%, so it is the adversarial subcase chosen for the main pruning comparison. The authors also track two heuristic-friendly entailment subcases, Rel-Clause and Embed-Since. They call this group OOD-E. Tracking both label groups matters because a change favoring one kind of decision can help one group and harm the other.
Full GPT-2 scores 82.0% on MNLI matched and 82.2% on MNLI mismatched. The 40% subnetworks have mean accuracies of 79.4% and 80.1% on these validation splits, respectively. At 60% sparsity the corresponding means are 75.5% and 76.3%. On HANS Embed-If the full score is 47.4%. The 40% subnetworks range from 17.8% to 36.3% on Embed-If, with a mean of 26.9%. The 60% subnetworks range from 16.8% to 51.9%, with a mean of 33.9%. Thus a rise in sparsity coincides with a rise in average accuracy on this adversarial subcase, alongside a wider spread across masks.
On the entailment subcases, average accuracy moves in the other direction. On HANS Rel-Clause it is 98.1% for the 40% subnetworks and 85.3% for the 60% subnetworks. The full classifier scores 100.0%. On HANS Embed-Since the full classifier scores 88.8%, while the mean is 92.0% at 40% sparsity and 79.9% at 60%. As training continues, the entailment group’s effective size grows slightly while the full classifier’s scores for that group dip a little. The authors consider the possibility that GPT-2 learns simple cues favoring contradiction as well as cues favoring entailment. The results broaden the evidence for variation between masks. They also show that the direction of the change with sparsity depends on the classifier and the evaluation condition.
What the ablations show
The same heads recur across different behaviors
The overlap analysis asks a more specific question than whether the pruning runs achieve similar accuracy. For each candidate head, the authors count the number of masks that retain it, and then compare those counts across moderate and high sparsity. In BERT trained on MNLI, the two settings are 50% and 70%. A Spearman rank correlation compares how consistently the two collections rank the heads by retention frequency. It is 0.82, with p-value 1.6 · 10⁻³⁶. The corresponding QQP comparison uses 30% and 60% sparsity and produces a correlation of 0.74, with p-value 7.7 · 10⁻²⁶. Heads often kept in the sparser subnetworks therefore tend to be kept in the less sparse ones as well.
The authors also examine the intersection directly. All of the masks in the BERT MNLI comparison retain nine of the same heads. The paper gives 7.7 · 10⁻⁵ heads as the expected intersection for 12 random subnetworks at 70% sparsity. The recurring set under learned pruning stands out against that random reference. For QQP the common intersection contains eight heads, with five positions shared with the MNLI intersection. Since each task uses its own fine-tuned classifier, a shared position means the same head index and layer in the architecture. Its weights and its behavior after fine-tuning can still differ between the tasks.
The checkpoint comparison adds information about timing. When the authors prune a BERT MNLI checkpoint immediately before its challenge performance starts to improve, the same nine heads appear in the subnetworks. The core is therefore observable within the fine-tuning trajectory while the classifier still struggles on the challenge data. Coupled with the upward change in effective size, this is compatible with a larger computation growing around a set of already useful heads. The evidence concerns recurrence under pruning. It does not identify which later heads use each core head or the path by which information reaches them.
Attention patterns suggest what the core supplies
The authors next ask what a recurrent head appears to do on sentence pairs. Some attention maps show a head assigning weight between matching words across the two sentences, including when the words occur in different orders. That makes the head a candidate for supplying a representation of lexical correspondence. The paper classifies four of the nine BERT MNLI core heads as attending to repeated tokens. In its QQP examples, heads in the shared set display a similar preference for matching words across the question pair. A token here is an input unit processed by the classifier, so a match in the attention visualization is evidence concerning those units and their positions.
Other heads have different patterns. Some earlier heads concentrate attention on the preceding or following token. Heads higher in the network are harder to characterize and often direct attention to the separator token, the special marker used to distinguish parts of the input sequence. The authors suggest that this may help aggregate information across the pair. The core's functional label thus refers to a set that supports behavior dominated by simple cues when much of the rest is removed. The attention analysis identifies repeated-word matching as a plausible contribution from several members, with other members showing local or separator-focused behavior.
There is a gap between identifying a regularity in an attention map and establishing what reaches the output. Attention weights tell the reader where the head looks. The value and output projections affect what it sends, and downstream computations can use or disregard that output. The authors therefore pair the visual analysis with a more direct test: replace a head's output in the full classifier and measure how its predictions change. This connection matters most when a head associated with a simple cue helps the network avoid a decision that would follow from the cue alone.
Removing core heads can damage challenge performance
For BERT MNLI, the authors ablate each core head individually from the full classifier. They compare those interventions with the intact baseline and with the average result of ablating a head outside the core. On matched MNLI, the intact accuracy is 83.3% and the average with a non-core head ablated is 83.2%. With Layer 4, Head 0 ablated it is 82.9%. On HANS SO-Swap, the intact accuracy is 86.7%, the average non-core ablation gives 86.2%, and ablating Layer 4, Head 0 gives 45.4%. The same intervention reduces HANS Prep accuracy from 73.5% to 41.8%. The contrast within a single intervention shows that the effect is concentrated on the challenge conditions.
BERT attention head ablations on HANS SO-Swap accuracy
Removing several core heads sharply reduces role-reversal accuracy while the average non-core removal leaves it near the intact score.
The numbers
| System or setting | accuracy % |
|---|---|
| Layer 2 Head 5, Layer 3 Head 7 and Layer 4 Head 0 ablated | 3.6 |
| Layer 4 Head 0 ablated | 45.4 |
| Layer 3 Head 7 ablated | 68.6 |
| Layer 2 Head 5 ablated | 70.3 |
| Average non-core ablation | 86.2 |
| Full BERT (this paper) | 86.7 |
The intervention removing Layer 2, Head 5, Layer 3, Head 7, and Layer 4, Head 0 together gives 80.4% accuracy on matched MNLI. On HANS it produces 3.6% on SO-Swap, 11.1% on Prep, 20.1% on Embed-If, and 4.7% on Embed-Verb. The authors describe the losses as super-additive: the joint intervention can damage performance more than the individual effects would suggest. Multiple outputs may support related aspects of the computation, and changing them together can leave the rest of the network with substantially different inputs. The observations measure dependence on those outputs in combination, without resolving the intervening computation.
Some core interventions improve particular challenge scores. Removing Layer 10, Head 10 raises Embed-If accuracy from 33.0% to 41.1% and Embed-Verb accuracy from 33.4% to 38.7%. At the same time, matched MNLI accuracy with that head ablated is 81.5%. This variation is part of what makes the intervention results informative. Membership in the common set establishes that the pruning searches consistently retained a head. Its individual ablation can then reveal a beneficial contribution on one category, an adverse contribution on another, or a small detectable change. The strongest evidence for dependence comes from the core heads whose removal causes large challenge losses despite modest ordinary validation changes.
The follow-up interventions qualify the picture
For BERT trained on QQP, the authors again remove the common heads individually. The intact classifier achieves 91.2% on QQP validation and 14.8% on the adversarial PAWS-QQP subset. Removing Layer 2, Head 5 gives 91.1% on QQP and 9.9% on the challenge subset. Removing Layer 4, Head 0 gives 90.2% and 3.3%, respectively. Both head positions are also prominent in the MNLI ablations. The overlap between the cores, similar attention patterns, and similar sensitivity to removing those positions motivate the authors' suggestion that BERT may already contain some useful overlap computations before either fine-tuning run.
RoBERTa provides a further comparison with non-core ablation. Removing Layer 6, Head 11 yields 87.5% on matched MNLI, the same displayed score as full RoBERTa. The HANS Prep score after the intervention is 73.9%, against 93.2% with the classifier intact and 93.1% averaged over non-core ablations. The same core intervention yields 59.3% on HANS Embed-Verb, where the intact classifier scores 72.6%. The authors characterize the RoBERTa ablation effects overall as smaller than BERT's, while still finding head removals with much larger challenge effects than the non-core average.
GPT-2 shows why the direction of an intervention has to be measured. Full GPT-2 scores 47.4% on Embed-If. Removing Layer 5, Head 5 raises the score to 57.6%. Removing Layer 1, Head 0 or Layer 4, Head 9 gives 34.5% in each case. The individual ablations produce very little change on Rel-Clause and smaller effects on Embed-Since. The shifts on Embed-If are consistent with shared heads contributing differently to decisions that favor entailment or contradiction. The small effects on the entailment cases leave the late decline in OOD-E accuracy and the variation across sparse masks unexplained.
The BERT and RoBERTa interventions illustrate the paper's central distinction between using a feature and making a decision from it. A head that helps align repeated words can supply information the classifier needs to compare the roles of those words. When later computations are missing, the available evidence can favor entailment based on the match. When those computations are present, removing the head can deprive them of a useful input. The authors infer that some challenge-sensitive behavior builds on the outputs of the heuristic core. Their ablations show where the full classifier is sensitive to losing those outputs, while the masked evaluations show how differently the retained pieces can behave in other combinations.
Limitations
Limits the authors state
The authors describe their method as a top-down analysis. A pruning mask identifies whole heads and feed-forward layers whose outputs a subnetwork retains. An ablation measures what happens when a selected contribution is replaced. This granularity leaves the operations within a head and the interactions between heads unresolved. The study therefore falls short of identifying a circuit in which each step can be assigned a distinct computational role. The authors also leave open why training takes the path they observe. Showing that a core can be found early and that more components are involved later gives an account of the sequence of changes, while the reason the optimization develops those computations in that order remains a question.
The experiments concern text classification on English datasets. Sentence-pair classification gives the authors a way to specify a shortcut and test examples where it makes the wrong prediction. Tasks with different output formats or less clearly specified heuristics may require other ways of isolating and evaluating the relevant behavior. The paper's main evidence comes from BERT, with RoBERTa and small GPT-2 extensions. The authors caution that much larger networks, including those with 7B+ parameters, could generalize differently. They also raise the possibility that different pretraining could alter the route to generalization.
Two questions are explicit candidates for further work. One is whether the head positions common to BERT's inference and paraphrase cores already detect overlap in the pretrained checkpoint. The authors compare the positions and behavior after fine-tuning, which motivates the hypothesis. The other concerns GPT-2's entailment challenge cases. Their accuracy tapers off late in training and varies across highly sparse subnetworks. Individual ablations of the common heads give little leverage on this variation. Both questions concern mechanisms for which the paper reports observations but leaves the causal account open.
Limits that follow from the design
The discovered masks are solutions reached by a particular stochastic search. The eligible components, mean replacement, prediction objective, and target sparsity all shape the subsets the search can return. A shared head therefore has an empirical meaning: each mask in the relevant collection keeps its input-dependent output under this setup. There may be other masks or finer-grained decompositions with different intersections. Disjoint computations could even use separate parts of the same head or depend on a shared representation below the level the mask distinguishes. The experiments weigh against a particular explanation based on disjoint head-level subnetworks. The search leaves finer-grained forms of separation or competition open.
Effective size is also an estimate conditioned on the experiment. The authors try a grid of sparsities, use the available seeds, and accept closeness on the selected dataset. This is enough to compare the observed ID and OOD trends under a consistent procedure. It leaves open the globally smallest mask that could meet the accuracy criterion. The criterion also compresses example-level behavior into a single score. Two masks at the same effective size can differ in which examples they get right, as the fixed-sparsity comparison makes clear. The estimate of retained components should likewise be read in the paper's units. It does not directly measure a fraction of parameters, memory, or runtime.
Mean ablation supplies evidence about dependence under a fixed replacement. If changing a head's output harms a challenge score, other components in that full checkpoint depended on something about its ordinary contribution. The intervention cannot specify which information was lost or how much of the change comes from altered combinations of inputs delivered to later layers. The repeated-token visualizations narrow the possible interpretations for several heads. A demonstration that a later head uses a particular correspondence to resolve a syntactic role would require tracing that information through the intervening operations. The study's performance measurements support the broader dependency claim at the level of the removed output.
Finally, the meaning of generalization is bounded by the selected evaluations. The main HANS cases are ones where the authors can observe progress by the full BERT classifier. Other cases include categories where it makes little progress. The adversarial PAWS-QQP evaluation concentrates on inequivalent pairs, and the GPT-2 adversarial analysis concentrates on Embed-If because the full classifier performs poorly on the other candidates. A mask that succeeds under one of those conditions may still fail other constructions or favor one label for reasons the reported test cannot distinguish. The paper establishes how behavior varies within these controlled comparisons, with the scope of each result determined by the cases and the full classifier's starting performance.
What came after
A later citing study examines whether training on formal languages before ordinary pretraining imparts linguistic biases. Its title places that question between work on circuits and work on linguistic structure. The connection to The Heuristic Core is the question of how earlier learning shapes later behavior. The Heuristic Core follows attention heads through downstream fine-tuning and asks whether components present before challenge performance improves remain useful afterward. The later study puts the emphasis on an earlier training stage, asking what an initial choice of training material can contribute to the biases a network brings into subsequent learning. The citation establishes the connection between the papers. Whether the later study tests the specific head-level mechanism or applies the same pruning procedure remains open. Between Circuits and Chomsky: Pre-pretraining on Formal Languages Imparts Linguistic Biases
Cite
Cite as Adithya Bhaskar, Dan Friedman and Danqi Chen. 2024. The Heuristic Core: Understanding Subnetwork Generalization in Pretrained Language Models. Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).
@inproceedings{bhaskar2024heuristic,
title = {{The Heuristic Core: Understanding Subnetwork Generalization in Pretrained Language Models}},
author = {Adithya Bhaskar, Dan Friedman and Danqi Chen},
booktitle = {Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
year = {2024},
doi = {10.18653/v1/2024.acl-long.774},
url = {https://doi.org/10.18653/v1/2024.acl-long.774}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/bhaskar-2024-heuristic-core-understanding-subnetwork-generalization/