---
title: "Sharpness-Aware Minimization Improves Language Model"
description: "Sharpness-Aware Minimization changes how T5 is fine-tuned, improving language benchmark scores even when labeled training data is scarce."
canonical: "https://research.elamur.ai/free/en/papers/bahri-2022-sharpness-aware-minimization-improves-language/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/bahri-2022-sharpness-aware-minimization-improves-language/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2022](https://md.research.elamur.ai/free/en/papers/2022/) / Sharpness-Aware Minimization Improves Language Model Generalization

# Sharpness-Aware Minimization Improves Language Model Generalization

Paper · 2022 · Dara Bahri, Hossein Mobahi and Yi Tay

**Authors:** [Dara Bahri](https://md.research.elamur.ai/free/en/authors/dara-bahri/), [Hossein Mobahi](https://md.research.elamur.ai/free/en/authors/hossein-mobahi/) and [Yi Tay](https://md.research.elamur.ai/free/en/authors/yi-tay/) · **Year:** 2022 · **Venue:** Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers) · **Licence:** [CC BY 4.0 (ACL Anthology)](https://creativecommons.org/licenses/by/4.0/)

[**44** citations OpenAlex, 2026-10-14](https://openalex.org/works?filter=cites:W3207523779) · [Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)](https://aclanthology.org/volumes/2022.acl-long/) · [licence](https://creativecommons.org/licenses/by/4.0/)

- [Publisher's page](https://aclanthology.org/2022.acl-long.508/)
- [PDF](https://aclanthology.org/2022.acl-long.508.pdf)
- [DOI 10.18653/v1/2022.acl-long.508](https://doi.org/10.18653/v1/2022.acl-long.508)
- [OpenAlex](https://openalex.org/W3207523779)

Citations: OpenAlex, 2026-10-14.

## Summary

A training procedure can find weights that fit the examples it sees, yet still leave room for better performance on new examples. Bahri and colleagues investigate whether that room can be recovered by changing how pretrained [language models](https://md.research.elamur.ai/free/en/topics/language-models/) are updated during [fine-tuning](https://md.research.elamur.ai/free/en/concepts/fine-tuning/). They study Sharpness-Aware Minimization, or SAM, an optimization method that favors weights with low training loss across a small neighborhood. A solution is sharp when a small displacement in some direction raises the loss substantially. SAM looks for such a direction at each training step and uses what it finds to guide the next update.

The experiments start from public checkpoints of [T5](https://md.research.elamur.ai/free/en/papers/raffel-2019-exploring-limits-transfer-learning-unified/) and its multilingual counterpart, [mT5](https://md.research.elamur.ai/free/en/papers/xue-2021-mt5-massively-multilingual-pre-trained/). The ordinary and SAM runs share the training setup, including the underlying optimizer. What changes is the gradient supplied to that optimizer. SAM estimates an uphill direction using a subset of the training batch, then measures the full batch’s gradient at the displaced weights. The authors report about 25% more training time for this implementation. The smaller first pass makes the additional gradient calculation affordable in their setup.

With the full training splits, SAM improves the overall development scores on [SuperGLUE](https://md.research.elamur.ai/free/en/papers/wang-2019-superglue-stickier-benchmark-general-purpose/) and [GLUE](https://md.research.elamur.ai/free/en/papers/wang-2018-glue-multi-task-benchmark-analysis/) at every tested T5 size. For example, the Base SuperGLUE score rises from 75.3 to 78.5. In closed-book [question answering](https://md.research.elamur.ai/free/en/concepts/question-answering/), where the system generates an answer without a supplied passage, both reported metrics improve on all three test sets at every size in the full-data comparison. Improvements persist when the tasks are trained separately. On multilingual [TyDiQA-GoldP](https://md.research.elamur.ai/free/en/papers/clark-2020-tydi-qa-benchmark-information-seeking/), the gains are smaller when averaged across languages, and the authors use a smaller perturbation radius.

The authors also reduce the amount of labeled data available for fine-tuning. At a 5% sampling rate, SAM improves the overall SuperGLUE score at each tested size, with a reported relative gain of 7.2% for Base. Some individual task and metric scores still fall. A broader sampling experiment in closed-book question answering finds gains across the plotted data regimes, with the largest relative gains frequently appearing around 20% of the training data. The study establishes that a change to the fine-tuning update can improve held-out scores under these conditions. Its comparisons leave open how closely those gains track changes in the shape of the resulting language-task loss.

## Deep dive: Sharpness-Aware Minimization Improves Language Model Generalization

Sharpness-Aware Minimization changes how T5 is fine-tuned, improving language benchmark scores even when labeled training data is scarce. · about 31 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### Why look at the update rule?

A pretrained system brings a set of learned weights to a new task. Fine-tuning adjusts those weights using task examples, such as questions paired with answers. The training loss gives the optimizer a way to judge each adjustment. The eventual objective is generalization, which the paper evaluates by measuring performance on examples outside the training split. Keeping these two roles distinct matters. The optimizer can act directly on the loss it sees during training, while a development or test score supplies evidence about whether that training transfers to held-out examples.

The authors place their study in a field where many improvements had come from changing what a system could represent or what it learned from. The attention-enabled [Transformer](https://md.research.elamur.ai/free/en/concepts/transformer/) gave researchers a different architecture. Pretraining drew learning signals from large collections of text without requiring a person to label every example, an approach exemplified by work such as [BERT](https://md.research.elamur.ai/free/en/papers/devlin-2019-bert-pre-training-deep-bidirectional/). Larger systems and the engineering required to train them were another direction. The paper also points to multitask learning and to broader, more diverse datasets and evaluations. Each route can improve the eventual system, while giving an experimenter a different part of the pipeline to change.

This study holds much of that pipeline fixed. Given a pretrained checkpoint and examples for a downstream task, the authors ask whether the rule for turning those examples into a weight update affects later performance. The question matters when a team already has an architecture and a checkpoint it intends to use. An optimization change can be evaluated within that setup. It also matters when the task offers few labeled examples. A procedure that extracts a better solution from the same small training split addresses a different constraint from a procedure that depends on collecting more examples.

The paper describes optimization for generalization as comparatively less explored in this setting, while locating its question within a substantial body of work on regularization. It names early stopping, weight decay, [dropout](https://md.research.elamur.ai/free/en/papers/srivastava-2014-dropout-simple-way-prevent/), label smoothing, batch normalization, and augmentation among established approaches. It also discusses [distillation](https://md.research.elamur.ai/free/en/papers/hinton-2015-distilling-knowledge-neural-network/), which uses a trained system’s outputs as a learning signal, and [mixup](https://md.research.elamur.ai/free/en/papers/zhang-2017-mixup-empirical-risk-minimization/), which works through combinations of examples. These examples give context for SAM’s point of intervention. Its distinguishing calculation changes where the optimizer measures the gradient in parameter space.

The paper also places that calculation alongside earlier approaches to optimization in language tasks. It mentions work based on adversarial risk, including [FreeLB](https://md.research.elamur.ai/free/en/papers/zhu-2019-freelb-enhanced-adversarial-training-natural/), and work using trust regions, including [SMART](https://md.research.elamur.ai/free/en/papers/jiang-2020-smart-robust-efficient-fine-tuning/). The authors discuss second-order methods such as K-FAC and Shampoo as alternatives to the first-order procedures widely used for training neural networks. They highlight a scalable implementation of Shampoo that had reported convergence and runtime improvements, along with stronger results in machine translation and language modeling. This context makes the paper’s experimental question narrower than whether optimization in general matters. It asks what happens when the optimizer is given a gradient constructed to account for the local shape of the loss.

#### From a low point to a low neighborhood

The loss landscape is the training loss viewed as a function of the weights. One position in that landscape corresponds to one setting of all the trainable parameters. Changing the weights while keeping the training examples fixed moves to another position, where the same examples may incur a different loss. A low point can lie in a region where nearby settings also give low loss, or it can sit in a narrow region with steep increases along some directions. The loss at the original point alone cannot distinguish those cases.

The line of research surveyed by the paper connects relatively flat regions with better generalization. As one example, the authors describe prior work that treats the noise in stochastic gradient descent as implicit regularization. A stochastic gradient comes from a batch of examples, so the direction it indicates can change with the batch. In the earlier account summarized by the paper, this noise helps keep training out of sharp valleys. Entropy SGD pursues wider valleys explicitly. SAM likewise seeks low-loss neighborhoods, but states the preference through the highest loss allowed by a bounded displacement. The highest loss matters because a single steep direction can make a neighborhood sharp even when other directions are gentle.

The original SAM work supplied theoretical and empirical motivation for this objective, with experiments in vision on convolutional ResNets. The paper then points to a vision study that applied SAM to architectures including [Vision Transformers](https://md.research.elamur.ai/free/en/papers/dosovitskiy-2020-image-worth-16x16-words-transformers/) and [MLP-Mixers](https://md.research.elamur.ai/free/en/papers/tolstikhin-2021-mlp-mixer-all-mlp-architecture/). Those architectures were reported to be particularly prone to sharp minima compared with the convolutional systems in that study. The vision authors examined changes to the loss landscape and compared the smoothing associated with SAM and data augmentation. As Bahri and colleagues recount it, SAM controls a worst-case direction, while augmentation acts through directions induced by its transformations. Those observations motivated asking whether language fine-tuning would benefit from the same general objective under its own training conditions.

There were already variations on SAM itself. The paper describes Adaptive Sharpness-Aware Minimization as an attempt to make the radius insensitive to the scale of the weights. It also describes a computational shortcut from Brock and colleagues, who estimated the uphill direction using fewer examples. Bahri and colleagues use that shortcut with an ordinary Euclidean radius and a first-order optimizer. The resulting study concerns the transfer of an existing method to a new setting, including whether the useful behavior survives a cheaper approximation of the original update.

### The method, step by step

#### Look uphill before taking a training step

Consider the weights at the start of a fine-tuning step. Ordinary training samples a batch, measures the gradient at those weights, and passes the gradient to the optimizer. The gradient describes how the loss would change for small movements away from the current weights. The optimizer uses it to decide how to move the weights for the next step. In SAM, the current gradient has a different first job. It identifies a direction in which the loss is expected to rise.

SAM stretches or shrinks that direction to a chosen length, the perturbation radius. It temporarily moves the weights that far uphill. This creates what the paper calls the adversarial point, a nearby parameter setting selected to make the training examples harder for the current system. The word “adversarial” here concerns the weights. The question text, examples, and target answers stay as they were. A small set of examples is enough to propose the direction in the efficient implementation, while the full batch determines the gradient at the resulting point.

That full-batch gradient is passed to the optimizer as the gradient for the current training step. The optimizer applies its update to the original weights. The temporary displacement is a place to measure the loss gradient, and the original weights are the starting point of the actual update. This is the distinction that makes the procedure a form of minimization. Moving uphill helps decide what the optimizer should account for when it takes a step intended to reduce the loss.

One training update with efficient SAM The steps in order.

Using the two batches for different purposes is central to the cost of the method. The small batch supplies a direction in parameter space. Its loss magnitude is immaterial to the length of the displacement once the direction is normalized. The full batch supplies the gradient that influences the actual update, so examples outside the small batch still take part in training at that step. This is also a different use of sampling from the paper’s experiments on scarce labels. Here the subset is drawn inside a training step for efficiency. In the scarcity experiments, sampling limits the pool of labeled examples available throughout fine-tuning.

#### The objective and its approximation

The paper writes the loss for an example as a function with a parameter argument, an input, and a target.

```
L : W × X × Y → ℝ₊
```

Here `L` is the loss function, `W` is the space of parameter settings, `X` is the space of inputs, and `Y` is the space of targets. The `×` signs indicate that the function receives a combination of these arguments. The arrow `→` gives its range, `ℝ₊`, the non-negative real loss values. In the fine-tuning setup, an example can be understood as an input sequence and a target sequence. The training loss uses the examples in the training set, and the batch losses below use the examples selected for a particular calculation.

The ideal objective asks for weights whose worst neighboring loss is small.

```
min_w max_{‖ε‖₂ ≤ ρ} L_train(w + ε)
```

The variable `w` represents the trainable weights, and `ε` is a displacement from those weights. The addition `w + ε` gives the nearby weights being evaluated. `L_train` is the loss on the training data as a function of a parameter setting. The notation `‖ε‖₂` gives the Euclidean length of the displacement, with the subscript `₂` indicating the norm used in the paper. The inequality `≤` limits this length to `ρ`, the positive radius. The inner `max` asks how high the loss can get within that radius. The outer `min_w` then seeks a setting of the weights that makes this maximum as low as possible.

This form explains what SAM means by a neighborhood. The objective considers every permitted direction around the weights, and the radius fixes how far the search may go. A setting with low loss at its center can still have a high objective value if some nearby weights incur high loss. A setting whose neighbors also have low loss can have a lower objective value even if the loss at its center is a little higher. This is the operational meaning of preferring a flatter region in the paper’s formulation. It is relative to the particular radius and distance being used.

Finding the true maximum would require solving an optimization problem inside each training step. The paper instead uses a local linear approximation. In that approximation, the loss at the current weights is a fixed starting value, and the gradient predicts the increase for a proposed displacement.

```
ε̂(w) = arg max_{‖ε‖₂ ≤ ρ} [L_train(w) + εᵀ∇_w L_train(w)]
```

Here `ε̂(w)` is the estimated displacement for the current weights `w`. The `arg max` returns the displacement that maximizes the bracketed expression under the constraint `‖ε‖₂ ≤ ρ`. As before, `ε` is a candidate displacement, `‖·‖₂` is Euclidean length, and `ρ` is the radius. The term `L_train(w)` is the training loss at the starting point. The symbol `∇_w` takes the gradient with respect to the weights. The superscript `ᵀ` transposes the displacement so that its product with the gradient is a dot product. That dot product estimates the change in loss. The displayed derivation in the paper labels this operation `argmin`. The maximization objective, the direction of the resulting vector, and the algorithm’s ascent step all specify an uphill move, which is the maximization written here.

The linear approximation has a simple solution when the gradient has non-zero length.

```
ε̂(w) = ρ ∇_w L_train(w) / ‖∇_w L_train(w)‖₂
```

The left side again denotes the estimated perturbation at weights `w`. On the right, `∇_w L_train(w)` is the training-loss gradient with respect to those weights. The denominator `‖∇_w L_train(w)‖₂` is the Euclidean length of the gradient. Division by that length makes the direction a unit vector, and multiplication by `ρ` sets the step length to the neighborhood radius. The positive sign of the resulting vector makes it an ascent direction. Within the linear approximation, a displacement aligned with the gradient uses the permitted distance to obtain the greatest predicted increase.

The formula makes clear where the approximation lies. The selected direction is optimal for the linear expression based at the current weights. The real loss can bend as the weights move, so the point reached by the formula is an estimate of a difficult neighbor. The next calculation evaluates a gradient at that actual point. It therefore uses the loss behavior at the displaced weights, even though a linear approximation was used to decide where to look.

#### From the formula to a batch update

The efficient algorithm starts with a sampled training batch and takes a smaller ascent batch from it. The paper denotes the full batch by `B`, with size `b`, and the ascent batch by `M`, with size `a`. At a training step indexed by `t`, the current weights are `wₜ`. The algorithm substitutes the loss on `M` for the whole training loss when it constructs the uphill direction.

```
w_adv = wₜ + ρ [∇_w L_M(w) / ‖∇_w L_M(w)‖₂] evaluated at w = wₜ
```

The result `w_adv` is the adversarial weight setting for the current step. The symbol `wₜ` denotes the weights at the start of step `t`. The variable `w` inside the brackets is the argument with respect to which the gradient is taken. `L_M` is the loss on the ascent batch `M`, and `∇_w L_M(w)` is its gradient. The Euclidean norm `‖·‖₂` in the denominator normalizes the gradient, and `ρ` sets the length of the step. The instruction to evaluate at `w = wₜ` means that the gradient and its norm are both taken at the original weights. Adding the resulting scaled direction to those weights gives the temporary setting.

SAM then measures the gradient that the optimizer will receive.

```
g_adv = ∇_w L_B(w) evaluated at w = w_adv
```

Here `g_adv` is the gradient supplied for the update. `L_B` is the loss on the full training batch `B`, and `∇_w` differentiates that loss with respect to its weight argument `w`. The expression `w = w_adv` specifies the evaluation point. The gradient describes the slope at the displaced weights. It uses the full batch, including examples that were outside the ascent subset.

Finally, the first-order optimizer uses this gradient in the update from the original weights.

```
wₜ₊₁ = opt(wₜ, g_adv)
```

The left side `wₜ₊₁` denotes the weights for the next training step, with `ₜ₊₁` marking the successor to the current step `t`. The function `opt` stands for the optimizer’s update operation, `wₜ` is the current weight setting, and `g_adv` is the gradient just computed at the adversarial point. In these experiments the optimizer is AdaFactor. The formulation allows SAM to change the gradient calculation while preserving the optimizer that consumes it. The next batch begins with the updated weights, and the process repeats during fine-tuning.

#### Keep the extra calculation small

The paper discusses a SAM variant called *m*-sharpness, in which a batch is partitioned into disjoint micro-batches for ascent. Each micro-batch determines a different adversarial point. The corresponding SAM gradients are averaged. The parameter `m` counts how many such points are used. Earlier work had found benefits from using more than one point, while a sequential implementation would require more computation. Partitioning lets a run consider several plausible uphill directions at the same stage of training, but evaluating their gradients is more expensive than evaluating the gradient at a single displaced setting.

Bahri and colleagues use `m = 1` for their main experiments. Their ascent batch is 25% of the full batch unless the number of training devices requires more examples. The gradient calculation is distributed, and each device must receive an example. Thus the actual ascent batch follows the larger of the quarter-batch allocation and the device count. The full-batch gradient still uses the ordinary batch size. The authors implement this procedure by adapting an existing public SAM implementation to their language-training framework. They run the experiments in JAX on Google Cloud TPUs.

The paper attributes the idea of reducing the ascent batch to earlier vision work that used roughly 20% of the full batch for this purpose. The earlier estimate cited for the cost of a single-ascent-point SAM update fell from 2x to 1.2x with that approximation. In the language experiments the authors report an observed slowdown of about 25% relative to ordinary training. The fraction of examples used on the first pass and the measured wall-clock cost describe different things. The former specifies how the algorithm builds its uphill estimate, while the latter reflects the implementation and the training hardware on which it ran.

#### Start from the same pretrained checkpoints

The language experiments use encoder-decoder Transformers in the T5 framework. An encoder processes the input sequence, and a decoder generates a target sequence. Presenting tasks as input-to-target mappings allows different tasks to share a training framework without requiring the same target text for every task. The paper describes T5 pretraining using large corpora such as the Colossal Clean Crawled Corpus, or C4, and illustrates the kind of objective used with prediction of deliberately corrupted spans. For the SAM experiments, that pretraining has already happened. The initial weights are taken from public checkpoints, and the change to the update begins with downstream examples.

For the English experiments the checkpoints come from T5.1.1. The sizes are Small with 77M parameters, Base with 250M, Large with 800M, and XL with 3B. TyDiQA-GoldP uses the official public mT5 checkpoints. The comparisons pair ordinary fine-tuning and SAM fine-tuning at the same size. They share code and settings except for the calculation of the gradient passed to AdaFactor. The paper reports a learning rate of 1e-3 and a batch size of 128 across fine-tuning runs.

SuperGLUE fine-tuning uses 10% dropout, input sequence length 512, target sequence length 62, and 250k steps. Dropout is a regularizer already present in the training setup, so the comparison measures what happens when SAM is added with dropout in place. The full GLUE runs also use 250k steps. Closed-book question answering uses 5% dropout, input length 38, target length 18, and 20k steps. For TyDiQA, the authors use 10% dropout, input length 1024, target length 512, and 20k steps. Each length refers to the sequence presented to the corresponding side of the text-to-text system. The schedules are part of the conditions under which the optimizer comparison is made.

The radius determines how far the first pass moves from the current weights. The authors describe the main SuperGLUE search as using values of 0.02, 0.05, 0.1, 0.15, 0.2, and 0.3. They choose 0.05 for Small and 0.15 for Base, Large, and XL, then reuse those choices on the other English experiments. The appendix also includes a 0.4 radius in its Base SuperGLUE sensitivity results. TyDiQA is treated separately because the authors found that mT5 fine-tuning benefited from a smaller radius. They search 0.01, 0.02, and 0.05 there, report 0.02 for Small, Base, and Large, and use 0.05 for XL.

Checkpointing is part of the measurement procedure. The authors save weights every 1k steps on SuperGLUE and GLUE and every 200 steps on the other datasets. They select a best checkpoint separately for each task and metric. A pair of scores in the same row can consequently describe the best observed F1 and the best observed exact match across saved checkpoints. The authors run each experiment once because of resource constraints. This procedure gives a view of the best scores observed through each run, under the same checkpoint policy for standard and SAM fine-tuning.

### Experiments and results

#### What each evaluation measures

The experimental suites ask whether the same gradient change helps across different tasks, checkpoint sizes, and training conditions. SuperGLUE and GLUE bring multiple language-understanding tasks together and provide aggregate scores as well as task-level results. Their full-data results in the paper are development scores. A benchmark aggregate shows how a run performs across the suite as summarized by its scoring convention. Individual task scores show which parts of the suite contribute to that result and where the trend reverses.

The closed-book question answering setup follows the formulation studied by [Roberts and colleagues](https://md.research.elamur.ai/free/en/papers/roberts-2020-how-much-knowledge-can-you/). It uses [Natural Questions](https://md.research.elamur.ai/free/en/papers/kwiatkowski-2019-natural-questions-benchmark-question-answering/), [Web Questions](https://md.research.elamur.ai/free/en/papers/berant-2013-semantic-parsing-freebase-question-answer/), and [TriviaQA](https://md.research.elamur.ai/free/en/papers/joshi-2017-triviaqa-large-scale-distantly-supervised/). The question is the input, and the system produces answer text using its learned weights. The full-data tables for these tasks give test scores. They report F1 and exact match, or EM, in that order. F1 captures overlap with a reference answer, giving credit for a partial match. Exact match counts a response as correct when it matches the reference under the benchmark’s comparison. Their pairing lets a reader see whether an improvement extends to complete answers as well as overlap.

TyDiQA-GoldP adds a multilingual question answering setting using mT5 and supplied passages. The paper presents average F1 and exact match and gives language-by-language results in the appendix. Its tables label the benchmark and scores without specifying the evaluation split as the SuperGLUE, GLUE, and full closed-book tables do. Differences among these evaluations make the matched ordinary fine-tuning baseline especially important. Each result is best read as a comparison within its task, metric, and checkpoint size.

#### SuperGLUE and GLUE with the full training splits

Full-data SuperGLUE development scores rise when SAM is added at each T5 size. The chart keeps the benchmark and evaluation metric fixed and places each ordinary run beside its SAM counterpart. Base shows the largest change in the displayed scores. The authors report a 4.2% relative gain for Base and a 2.1% relative gain for XL on this overall development metric.

Full-data SuperGLUE overall development score by T5 size SAM raises the overall development score at every tested size.

**The numbers**

| System or setting | SuperGLUE score |
| --- | --- |
| Small | 67.7 |
| Small + SAM (this paper) | 68.4 |
| Base | 75.3 |
| Base + SAM | 78.5 |
| Large | 84.3 |
| Large + SAM | 84.6 |
| XL | 87.2 |
| XL + SAM | 89.1 |

The Base comparison illustrates how a stronger aggregate can be built from changes spread across the suite. On the SuperGLUE development split, BoolQ goes from 80.0 to 82.2, CoPA from 71.0 to 78.0, and RTE from 80.9 to 85.9. Base also improves on both reported ReCoRD metrics, from 76.2 / 75.4 to 78.2 / 77.2. These results make the aggregate improvement broader than a single unusually large task contribution. At the same time, these tasks each have their own evaluation, so their changes should be interpreted on their respective score scales.

The detail by size shows different combinations of gains and losses. CoPA’s development score for Small falls from 67.0 to 61.0. For Large it falls from 89.0 to 86.0, while for XL it stays at 95.0. On the same benchmark, Large records a lower pair of CB development scores with SAM, moving from 99.4 / 98.2 to 95.0 / 96.4. XL’s CB scores instead move from 93.7 / 96.4 to 100.0 / 100.0 in the reported development evaluations. All of these outcomes belong to runs with a higher aggregate. The aggregate therefore describes how the suite scores together, while any conclusion about a particular task has to come from its column.

The full GLUE development results also favor SAM at every tested size on the overall metric. Small moves from 79.8 to 79.9, Base from 84.7 to 85.1, Large from 86.2 to 88.3, and XL from 89.9 to 90.2. The authors give a relative improvement of 2.4% for Large on that aggregate. Small’s paired values show how little the benchmark total can move even when some individual tasks shift appreciably. Its CoLA development score rises from 39.9 to 42.9, while its RTE development score falls from 74.0 to 70.4.

For Large, the full GLUE CoLA development result rises from 57.8 to 65.6 and the paired MRPC scores rise from 89.5 / 85.3 to 93.6 / 91.2. Its GLUE RTE development score remains 85.9. For Base, CoLA instead goes from 50.9 to 49.8, while the paired MRPC scores rise from 91.5 / 88.2 to 93.4 / 90.7. Those examples help explain why a statement such as “SAM improves GLUE” is best tied to the reported aggregate. It conveys a real result across sizes while leaving room for a different response on a given task. It also gives the later sensitivity experiments a clear target. When those experiments choose the best setting by overall score, the choice reflects the suite rather than the best outcome for each task separately.

#### Closed-book question answering with the full training splits

In the main closed-book runs the tasks are trained together for 20k steps. The tasks contribute according to the number of examples in their training splits. The authors add no task weights to counteract or amplify those proportions. A single fine-tuning run can therefore contain examples from different datasets, with each task evaluated on its own held-out questions. Under this setup both F1 and exact match improve on the test split of every task at every reported T5 size.

The Base comparisons show the pattern on the three test splits. Natural Questions F1 and exact match go from 23.2 / 18.1 to 25.7 / 20.6. Web Questions goes from 29.7 / 22.5 to 31.0 / 24.5. TriviaQA goes from 19.3 / 15.3 to 21.5 / 17.4. The corresponding relative exact-match gains reported by the authors are 13.8% for Natural Questions, 8.8% for Web Questions, and 13.7% for TriviaQA. The relative gains express the change with respect to each starting score. The paired scores themselves give the level of performance at that starting point and after the optimization change.

For Large, the relative test exact-match gains reported in the same task order are 12.1%, 7.2%, and 15.7%. Its test F1 also improves on each dataset. Natural Questions moves from 27.4 to 30.6, Web Questions from 34.3 to 36.4, and TriviaQA from 25.2 to 28.5. The progress on both metrics is informative because a higher overlap score alone could arise from more answers getting part of the reference right. The corresponding exact-match improvements show that the benefit in these runs extends to the stricter answer comparison.

The chart follows Natural Questions exact match across the checkpoint sizes in this mixed-task setup. At Small, the test score moves from 12.4 to 13.1. At XL, it moves from 27.5 to 28.8. The ordinary runs are already separated by size, and the paired SAM runs show a further improvement within each size. That structure lets the reader see the effect associated with the update separately from the changes associated with choosing a larger checkpoint.

Full-data mixed-task training on Natural Questions test exact match Evaluating the gradient at the SAM perturbation improves exact match at every tested size.

**The numbers**

| System or setting | exact match |
| --- | --- |
| Small | 12.4 |
| Small + SAM (this paper) | 13.1 |
| Base | 18.1 |
| Base + SAM | 20.6 |
| Large | 22.3 |
| Large + SAM | 25.0 |
| XL | 27.5 |
| XL + SAM | 28.8 |

XL’s test improvements also appear on the other questions. On Web Questions the F1 and exact-match scores go from 39.3 / 31.6 to 40.7 / 33.3, and on TriviaQA they go from 36.5 / 31.1 to 38.0 / 32.6. The higher starting scores at XL leave room for improvement from SAM. Comparing improvements across sizes requires attention to the metric and dataset, since higher capacity and the change to optimization do not yield a single common pattern across all the suites.

#### Multilingual question answering

On TyDiQA-GoldP, the average F1 and exact-match results move from 73.4 / 62.1 to 74.3 / 63.0 for Small and from 81.6 / 71.0 to 82.0 / 71.3 for Base. For Large the averages move from 85.6 / 75.3 to 85.9 / 76.1, and for XL from 87.0 / 77.4 to 87.3 / 77.7. These are averages in the paper’s TyDiQA-GoldP evaluation. The authors characterize the gains as being in the 1-2% range. The table values show how modest the changes in average score are, even though they have the same direction for both metrics at each size.

The language-specific results add an important qualification. For Small on Swahili, the reported TyDiQA-GoldP F1 and exact match move from 78.0 / 68.9 to 79.9 / 72.1. For Small on Bengali, they move from 69.4 / 60.2 to 68.4 / 57.5. The direction can also vary by size for the same language. On Bengali, Base goes from 81.7 / 71.7 to 84.4 / 75.2. An improvement averaged across languages thus tells the reader something about the benchmark as a whole and leaves a separate question about how the setup performs for a particular language.

The two metrics sometimes move independently within a language. For Large on Finnish, TyDiQA-GoldP F1 goes from 84.6 to 84.5, while exact match goes from 71.6 to 72.5. For XL on Bengali, F1 rises from 88.9 to 89.2, while exact match falls from 82.3 to 81.4. These paired results show why the authors’ broader claim is easiest to substantiate at the average level. They also show why it would be hard to choose one language or metric as a proxy for the response of the entire multilingual setup.

#### Fine-tuning with scarce labels

To vary the amount of labeled data, the authors subsample the downstream training splits for SuperGLUE and the closed-book tasks. The stated sampling range runs from 2% to 80%. Both standard and SAM fine-tuning still begin with public pretrained checkpoints. The data fraction refers to examples for downstream adaptation, so these experiments ask how a fixed pretrained starting point responds to less task supervision. They are distinct from an experiment in which the same fraction of data is used to estimate the inner gradient at each step.

At 5% of the SuperGLUE training data, the overall held-out scores favor SAM at all tested sizes. The paired results are 50.2 and 51.9 for Small, 52.9 and 56.7 for Base, 62.8 and 64.3 for Large, and 75.9 and 77.0 for XL. The authors report a 7.2% relative gain on the Base aggregate. The overall effect is accompanied by a change in the distribution of task scores. Base’s paired ReCoRD scores rise from 47.8 / 46.5 to 59.7 / 57.9, while its WiC score goes from 57.2 to 55.3. Large’s BoolQ score rises from 65.3 to 77.3, while its two MultiRC scores move from 71.6 / 24.0 to 69.0 / 20.4. The lower-data table presents the same distinction between a suite-level improvement and the outcomes for its constituent tasks.

At the same 5% training-data rate, Base on Natural Questions goes from 7.9 / 4.8 to 8.6 / 5.6 on held-out F1 and exact match. The authors report a relative gain of 8.86% for F1 and 16.6% for exact match. Both exact-match values remain low in absolute terms. This matters to a reader asking how well the resulting system can answer questions with such limited supervision. The relative number addresses improvement over the matched baseline, whereas the held-out score describes the level reached in that condition.

There are exceptions to the full-data result in which both metrics rose in every closed-book comparison. At the 5% training-data rate, Base on Web Questions goes from 13.7 / 4.6 to 12.2 / 5.7 on held-out F1 and exact match. XL on TriviaQA moves from 19.6 / 15.3 to 19.1 / 14.5. The Base example is particularly informative because the same change to the gradient is associated with less overlap and more exact matches. Selecting a different metric can change the verdict on an individual result. XL on TriviaQA illustrates that even the direction of both metrics in a heavily sub-sampled run can differ from their direction in the full-data comparison.

A figure varies the sampling rate for Small and Base on the closed-book tasks. The authors describe gains across the plotted data regimes and say the relative advantage often appears largest around 20% of the training split. This observation belongs to the curves across sampling rates, while the detailed table gives exact values at 5%. Together they support a benefit when supervision is restricted, with the magnitude and direction of particular gains depending on the task, data fraction, and metric. The result also puts the very low scores at 5% in context. The opportunity for a large relative gain and the ability to answer many questions are separate properties of a run.

### What the ablations show

#### The gains survive training tasks separately

The main closed-book experiments leave open a possible explanation for the improvement. When examples from different tasks are mixed, the gradient can reflect more than one task within the same training run. SAM could help mainly by changing how this mixture affects updates. If so, the improvement should be harder to recover when the fine-tuning data for a run comes from a single task. The authors test this by fine-tuning separately on each closed-book dataset and evaluating on that dataset’s test split. The single-task comparisons still pair a standard run with a SAM run of the same T5 size.

Every reported single-task test comparison favors SAM on both F1 and exact match. For Base on Natural Questions, the scores go from 26.3 / 21.1 to 27.8 / 22.6. On Web Questions they go from 31.6 / 26.0 to 33.6 / 27.5, and on TriviaQA they go from 20.6 / 16.8 to 23.7 / 19.5. This gives a direct check on the explanation based on joint downstream training. The procedure continues to help even when a run draws all its fine-tuning examples from the task it will be evaluated on.

Large on TriviaQA provides a useful comparison between training conditions. In the single-task test evaluation its scores move from 25.1 / 20.8 to 28.8 / 24.2. In the mixed-task test evaluation they move from 25.2 / 20.9 to 28.5 / 24.2. Exact match reaches the same reported value with SAM in both cases, while F1 and the baseline values differ. Web Questions at Large shows why the ablation is better read through matched pairs than as a contest between training regimes. In the single-task test evaluation its scores move from 32.7 / 25.8 to 34.4 / 28.0, and the mixed-task run yields different scores with the same direction of improvement. The evidence establishes that joint fine-tuning is unnecessary for the gains in these experiments. It leaves room for differences in task transfer within the mixed setting.

#### Capacity alone gives a poor prediction of the gain

The authors expected that a method aimed at generalization might help Small and Base more, with less room for improvement at higher capacities. The comparisons across sizes let them check that expectation. On full-data SuperGLUE, XL improves more in the overall development score than Small. The largest improvement among the GLUE aggregates appears for Large. In full-data closed-book evaluation, Base and Large have substantial reported relative exact-match gains, while the direction remains positive at Small and XL.

The comparisons show that useful changes can occur throughout the tested size range. They do not identify size as an isolated cause of the variation. For instance, the English Small setting uses radius 0.05, whereas larger settings use 0.15. The results also start from different pretrained checkpoints, and the amount of improvement varies across test metrics at a fixed size. The authors’ initial expectation would have been useful if it gave a consistent ordering. Its failure in these experiments suggests interpreting the matched comparisons directly rather than trying to infer a method’s value from the capacity label.

#### How far to look uphill

The sensitivity analysis varies the perturbation radius on full-data SuperGLUE with Base. The ordinary fine-tuning development score is 75.3. Every radius in the appendix’s comparison produces a higher overall score. At radius 0.02 the aggregate is 76.6. At 0.15 it reaches 78.5, the highest aggregate in this sweep. At 0.3 it is 77.8, and at 0.4 it is 77.6. The values on both sides of 0.15 support the authors’ choice for the overall score in this setting. The gradual variation across the sweep also shows that the entire benefit does not depend on choosing the exact peak of the observed curve.

Base full-data SuperGLUE development score by perturbation radius Each tested radius improves the aggregate, with the selected radius giving the highest overall score.

**The numbers**

| System or setting | SuperGLUE score |
| --- | --- |
| Ordinary fine-tuning | 75.3 |
| SAM radius 0.02 | 76.6 |
| SAM radius 0.05 | 77.2 |
| SAM radius 0.1 | 77.4 |
| SAM radius 0.15 (this paper) | 78.5 |
| SAM radius 0.2 | 77.7 |
| SAM radius 0.3 | 77.8 |
| SAM radius 0.4 | 77.6 |

The task columns can favor a different radius. On the SuperGLUE development split, Base WiC scores 72.7 at 0.1 and 70.4 at 0.15. The corresponding ReCoRD pairs are 79.3 / 78.3 and 78.2 / 77.2. CoPA’s development score is 78.0 at 0.15 and 79.0 at 0.4. The selected radius is consequently a choice supported by the aggregate. A radius selected for an individual task could differ even within the same run configuration. The separate TyDiQA tuning illustrates the same point at the level of a whole evaluation setup, where the preferred mT5 radii are smaller than the respective choices for T5.

#### How many examples should guide the uphill direction?

The authors next vary the number of ascent examples while keeping the full batch at 128. The Base full-data SuperGLUE development aggregate is 77.8 with an ascent batch of 8, 78.1 with 24, and 78.5 with 32. With 64 ascent examples the aggregate is also 78.5. With 128 it is 78.8. The default of 32 therefore captures most of the aggregate improvement observed as the ascent batch grows in this sweep. Since the extra pass is the added work in the method, a nearly level curve beyond that point gives a reason for using fewer examples even though the full ascent batch yields the highest score in this particular comparison.

The individual results once again show variation behind the aggregate. In the same sweep, SuperGLUE development CoPA scores 77.0 with 32 ascent examples, 79.0 with 64, and 74.0 with 128. RTE scores 85.6, 84.5, and 87.0 with those respective ascent batches. A larger set of ascent examples can change the direction estimated at each step, and that change need not push all tasks’ scores the same way. The ablation justifies the economical setting chiefly as a choice for overall performance. It is a test of how much data the preliminary look uphill needs while the main gradient calculation continues to use the full batch.

#### How many uphill points should be evaluated?

In the *m*-sharpness comparison, the authors divide the ascent allocation into smaller groups when they increase the number of adversarial points. Each of the `m` micro-batches has size `32/m`, where `32` is the total number of ascent examples and the slash denotes division by the number of groups. Thus the comparison changes how the ascent examples are used to suggest directions, while the total ascent allocation is fixed. The full training batch continues to serve the update calculation.

For Base on full-data SuperGLUE, the development aggregate is 78.6 with `m = 1`, 78.1 with `m = 2`, and 78.3 with `m = 4` in this sweep. Extra adversarial points offer no overall advantage here. Task-level results can still favor them. For example, the development score for CoPA is 73.0 with `m = 1` and 77.0 with `m = 2`, while the corresponding RTE scores are 87.0 and 84.8. The overall outcome and the additional computation make the single point the authors’ choice for the language experiments. Since changing `m` here also shrinks the group that proposes each point, the comparison concerns that combined design. It cannot by itself tell how extra perturbation points would behave if each were estimated from as many examples as the single point.

### Limitations

#### Limits acknowledged by the authors

The authors report a single run for each experiment because of resource constraints. The results therefore lack a measure of run-to-run variability. This matters especially where two observed scores are close, as for Small on the full GLUE development aggregate at 79.8 and 79.9. A single run can establish those measured values under the reported procedure. Repeated runs would be needed to estimate how often the ordering recurs and how much fluctuation is typical. The consistency of several comparisons across sizes and tasks is evidence of breadth across settings, while uncertainty within any given setting remains unmeasured.

The authors also acknowledge a potential cost of approximating the ascent calculation and using a single adversarial point. They choose this configuration partly to keep training time manageable and recognize that it may give up some potential improvement. The ascent-batch ablation supports the choice for Base on SuperGLUE, where the aggregate changes little once the ascent batch reaches 32. That result speaks to the efficiency compromise in this particular run family. It does not measure the best possible score for every task under a larger ascent budget.

The multilingual experiments qualify the portability of the chosen radius. The authors reuse the SuperGLUE choices in the other English comparisons, but acknowledge that smaller radii were needed for good performance on TyDiQA-GoldP. Furthermore, the sensitivity experiments center on full-data SuperGLUE at Base. The radius, batch allocation, and number of ascent points are understood most clearly in that setting. The paper offers less direct evidence about interactions among them or about how their best values shift when labeled data becomes scarce.

#### Limits visible in the design

The experiment measures performance after fine-tuning public checkpoints. The paper’s broader motivation concerns generalization in language models, but the intervention begins after pretraining. The results therefore support the use of SAM as evaluated on downstream T5 and mT5 fine-tuning. They leave the effect of applying it throughout pretraining open. They also leave open how an architecture outside these checkpoint families would respond, including whether its useful radius and cost would resemble the ones reported here. Checkpoint size varies substantially within the family, while the architecture and training framework are still closely related.

The measured outcome is generalization to the paper’s held-out task evaluations. Reducing the training split changes how much supervision the optimizer sees, while leaving the assessment within the downstream task. The paper discusses previous robustness findings in vision, but it supplies no corresponding language experiments on corrupted inputs or broader distribution shifts. A higher development or test score answers a question about that evaluation. Performance after a systematic change in input conditions would need evidence that targets that change.

The study also distinguishes a plausible explanation from a measured performance effect. SAM is designed to make high loss near the current weights matter to the update, and the paper motivates the design with earlier findings about flatter minima. Its language experiments principally report task scores, runtime, and sensitivity to choices in the update. They do not directly trace the local loss geometry of the final language checkpoints in a way that links the amount of flattening to the gain on each task. The single-task ablation narrows the explanation by showing that the improvements can occur without downstream task mixing. It does not identify a complete causal account of why the held-out scores improve.

The metric-specific checkpoint procedure affects how to interpret the tables. The authors allow a different best checkpoint for each task and metric. A reader interested in one saved checkpoint that will serve the entire suite should therefore treat the rows as selected scores rather than a guarantee about the joint performance of a particular weight setting. Similarly, the lack of run-to-run estimates means that curves and hyper-parameter sweeps are best read as the outcomes of those comparisons. The highest observed setting is evidence for the choice made on that benchmark, with its stability across repetitions left unresolved.

The reported wall-clock overhead is a comparison between matched training setups using the authors’ efficient implementation. The runs have prescribed step budgets, and the time comparison depends on the ascent batch and the way gradients are distributed over TPU cores. An experiment comparing procedures at equal total wall-clock time, or matching them by the time required to attain a particular held-out score, would answer a different cost question. The paper’s figure of about 25% more training time establishes the overhead the authors observed with their setup. It does not give a hardware-independent runtime estimate or an equal-budget comparison.

Finally, the ordinary baseline already includes the paper’s other training choices, such as dropout and AdaFactor. This makes the comparison specific and interpretable. It shows what SAM adds to an otherwise matched procedure. The discussion of distillation, trust regions, and other regularizers describes the field around the experiment. Those approaches are not run as competing systems under a common budget in this study. The evidence supports the improvement over the matched baseline and the tested variations of SAM. A ranking of SAM against the broader set of optimization and regularization methods would require a separate comparison.

### What came after

The paper’s documented line of development ends with this application of SAM to language fine-tuning. The vision studies that informed its choice of an efficient ascent step and the earlier work on adaptive radii preceded it. How subsequent research tested the same gradient calculation in other language settings, measured its effect on loss geometry, or compared it under equal training budgets remains open here.

## Cite

Cite as Dara Bahri, Hossein Mobahi and Yi Tay. 2022. Sharpness-Aware Minimization Improves Language Model Generalization. Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.18653/v1/2022.acl-long.508](https://doi.org/10.18653/v1/2022.acl-long.508)

```bibtex
@inproceedings{bahri2022sharpness,
  title = {{Sharpness-Aware Minimization Improves Language Model Generalization}},
  author = {Dara Bahri, Hossein Mobahi and Yi Tay},
  booktitle = {Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
  year = {2022},
  doi = {10.18653/v1/2022.acl-long.508},
  url = {https://doi.org/10.18653/v1/2022.acl-long.508}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
