Skip to content
The Daily Triptych139 / 365
Inference cost, same architecture

An ensemble’s serving cost grows with the number of fine-tunes; a soup collapses those fine-tunes into one forward pass.

Try it in the local lab

Average two compatible checkpoints

If you already have two fine-tunes of the same open-weight architecture, this builds a uniform soup on disk. Swap the paths for your own files; both must share identical tensor names and shapes.

$ python - <<'PY'
import torch
a = torch.load('ft_a.pt', map_location='cpu')
b = torch.load('ft_b.pt', map_location='cpu')
# support raw state_dict or common {'state_dict': ...} wrappers
sa = a['state_dict'] if isinstance(a, dict) and 'state_dict' in a else a
sb = b['state_dict'] if isinstance(b, dict) and 'state_dict' in b else b
assert sa.keys() == sb.keys(), 'architectures differ'
soup = {k: 0.5 * sa[k].float() + 0.5 * sb[k].float() for k in sa}
torch.save(soup, 'soup_uniform.pt')
print('wrote soup_uniform.pt', len(soup), 'tensors')
PY

Evaluate soup_uniform.pt on your held-out set the same way you evaluate either ingredient. If accuracy drops, the two runs may have diverged too far for a uniform average; try omitting the weaker run rather than forcing the blend.

II · THE IDEA · ARTIFICIAL INTELLIGENCE

Model Soups: Weight Averaging for Improved Robustness

optimization · model soups · weight averaging · 2203.05482

▶ Listen · narrated

Ensembling many fine-tunes raises accuracy and also multiplies inference cost. Weight averaging keeps the gain and leaves the bill unchanged: one forward pass, one model.

At a glance

What it is
Element-wise average of weights from several fine-tuned models
Payoff
Higher accuracy than the separate ingredients
Inference cost
Same as a single model, not an ensemble
Ingredients
Models fine-tuned from a shared initialisation

Think of several cooks who all started from the same basic sauce and then seasoned it slightly differently. Instead of tasting each sauce in turn and voting, you pour them into one pan and stir. What you serve is still a single bowl — not five bowls — yet the blend can taste more balanced than any one cook’s version.

That is a model soup. You fine-tune the same starting model several times, average the learned numbers inside it, and deploy the average as one model. You do not run the separate models at answer time. You pay for one.

Look closer

  1. The average is in weight space, not output space

    A classical ensemble runs every model and combines predictions. A soup never does that. The fine-tuned parameter tensors are averaged once, offline, into a single new tensor. At serving time only that tensor is loaded. Accuracy moves; latency and memory stay those of one network.

  2. Shared starting point matters

    The method is built on models that begin from the same pre-trained initialisation and then diverge under different fine-tuning runs. Averaging unrelated trained networks is a different, less reliable act. The soup inherits the geometry of one optimisation basin explored several times, not a blend of distant solutions.

  3. Uniform is not the only recipe

    A uniform average of every fine-tune is the simplest soup. Selective recipes keep only some ingredients, or weight them unequally, when a held-out slice of data suggests that certain runs pull the average the wrong way. The finished object is still one model, not a committee at inference.

The story

Fine-tuning the same pre-trained network several times is ordinary practice. Learning rate, data order, augmentation strength and the random seed all shift the final weights a little. Each run is a usable model; some are better than others on a given test set. The usual ways to spend that diversity are to keep the single best checkpoint, or to keep them all and ensemble their predictions.

Model soups take a third route. The weights themselves are averaged. If several fine-tunes share an architecture and a common initialisation, their parameters can be combined element-wise into one new parameter set. That set is the soup. It is stored, loaded and executed exactly like any other checkpoint of the same architecture.

The practical distinction from ensembling is sharp. An ensemble’s cost grows with the number of members: each input is forwarded through every network before the outputs are merged. A soup’s cost does not. After the average has been taken, inference is a single forward pass. The central empirical claim is that this averaged model often exceeds the accuracy of the individual fine-tunes that went into it, and does so without the inference penalty an ensemble would incur.

Why averaging can help at all is tied to how those fine-tunes relate. Starting from one pre-trained point, moderate fine-tuning tends to land in a region of parameter space where the loss surface is relatively well behaved. Different runs explore slightly different paths inside that region. Their average can sit in a flatter, more central place than any single endpoint, which shows up as better accuracy and, in reported experiments, improved robustness under distribution shift. None of that requires changing the architecture or the serving stack.

Recipes vary in how much care they take over the ingredients. The uniform soup simply averages every fine-tune with equal weight. Greedier procedures add models one at a time when doing so improves held-out accuracy, and skip those that do not. In either case the product is still a single weight tensor. The hyperparameter search that produced the fine-tunes is no longer a list of discarded runners-up; it becomes the material from which the deployed model is mixed.

Why it mattered then

By the early 2020s it had become cheap to launch many fine-tuning runs from one strong pre-trained checkpoint, and expensive to serve all of them. Practitioners already kept tables of validation scores and threw most checkpoints away. Model soups gave those discarded runs a second use: instead of choosing a single winner or paying for a full ensemble, the laboratory could fold the search into one artefact whose inference cost matched the cheapest option. That mattered wherever accuracy under shift was valued and latency budgets were fixed.

Why it matters now

Fine-tuning remains the default way to specialise open-weight and closed models, and teams still produce more checkpoints than they can afford to serve. Weight averaging turns that surplus into a free accuracy lever: no new architecture, no extra GPUs at inference, no change to the tokenizer or the API shape. Wherever several fine-tunes already exist from a shared base, a soup is a low-ceremony experiment that can be tried before more elaborate distillation or routing schemes.

The surprising detail

The method’s thrift is almost blunt. Nothing clever happens at runtime. The ingenuity is entirely in refusing to treat fine-tuning diversity as either a leaderboard or a committee, and in noticing that an arithmetic mean of weights can inherit the strengths of several endpoints while remaining one file on disk.

What is disputed

Reported gains assume fine-tunes that share an initialisation and remain in a compatible region of weight space. Averaging models trained from scratch with different seeds, or fine-tunes that have diverged sharply, is not guaranteed to help and can degrade accuracy. The word “consistently” in the editorial angle should be read as “often, under the paper’s training regime,” not as a universal law.

Remember this

A model soup averages fine-tuned weights into one network, keeping ensemble-like gains without ensemble inference cost.

Test yourself

You have five fine-tunes of the same pre-trained model and a hard latency budget that allows only one forward pass. Why might a uniform soup still underperform the single best fine-tune, and what change to the recipe addresses that without returning to a multi-model ensemble?

Go deeper

Image: Original diagram, The Daily Triptych. Licence: Original work. Source.

← Back to day 139