Skip to content
Post-training and alignment Frontier 33 min read

Model merging and continual learning

Two fine-tuned copies of the same pre-trained model can often be averaged, weight by weight, into one model that does both jobs; yet fine-tuning one model on a second job usually wrecks the first. Both facts come from the same geometry — the shape of the loss landscape around a pre-trained model — and understanding it tells you when merging works, why models forget, and why learning continually is still one of the field's open problems.

10,000 ft

A neural network's knowledge lives in its weights, and post-training keeps changing them: SFT, preference optimisation, RL, domain fine-tunes, LoRA adapters. Two questions follow. Merging asks whether separately trained changes can be combined by arithmetic on the weights, without more training — and the surprising answer, for models fine-tuned from a shared pre-trained checkpoint, is often yes: Meta averaged models at every stage of Llama 3's post-training, and weight-averaged "soups" set ImageNet records. Continual learning asks whether one model can keep absorbing new tasks and facts over time, as people do, without forgetting old ones. The answer there is still mostly no: catastrophic forgetting, identified in 1989, remains the reason frontier models have a training cutoff and are periodically retrained rather than continuously updated. The tools that help — replay, regularisation, low-rank updates, on-policy learning, retrieval — all connect to other pages in this track.

2,000 ft

The geometry in one paragraph: a pre-trained model sits in a wide, low-loss basin. Fine-tuning moves it a short distance, and different fine-tunes from the same start move it in nearly orthogonal directions that stay inside the basin. Because the region between them is also low-loss, you can average or add their weight changes ("task vectors"). Training sequentially, by contrast, follows the new task's gradient wherever it leads, including along directions the old task depended on.

  1. Fine-tune copies of one pre-trained model \(\theta_0\) on different tasks, data or hyperparameters.
  2. Subtract the base to get task vectors \(\tau_i = \theta_i - \theta_0\).
  3. Combine: average (soups), add with weights (task arithmetic), or first resolve interference (TIES, DARE).
  4. Evaluate on every task and on general skills; tune the weights \(\lambda_i\).
  5. For continual learning, prevent the new update from leaving the old basin: replay old data, penalise movement in important directions, keep updates low-rank, or learn on-policy.

Merging: fine-tunes as vectors from a shared start
Merging: fine-tunes as vectors from a shared start. Pre-trained θ₀, Fine-tune on A θ_A, Fine-tune on B θ_B, Task vectors τ_A = θ_A − θ₀ τ_B = θ_B − θ₀, Combine average · task arithmetic TIES · DARE · SLERP, Merged model θ₀ + λ_A τ_A + λ_B τ_B, Evaluate on A, B and general skills, subtract, tune λ, densityMerging: fine-tunes as vectors from a shared start. Pre-trained θ₀, Fine-tune on A θ_A, Fine-tune on B θ_B, Task vectors τ_A = θ_A − θ₀ τ_B = θ_B − θ₀, Combine average · task arithmetic TIES · DARE · SLERP, Merged model θ₀ + λ_A τ_A + λ_B τ_B, Evaluate on A, B and general skills, subtract, tune λ, density

Ground level

Why averaging two networks should not work — and when it does

Take two networks with the same architecture, trained on the same data from different random initialisations. Both are good. Average their weights and you usually get garbage. The reason is permutation symmetry: the hidden units of a layer have no fixed order. Swap units 3 and 17 in a layer — their incoming weights, biases and outgoing weights together — and the network computes exactly the same function. Two independently trained networks may have learned similar features, but in different slots, so averaging unit 3 of one with unit 3 of the other blends two unrelated features.

Three findings turned this into a theory of when averaging works:

  • Linear mode connectivity. Frankle et al. (2019) trained two copies of a network from the same point with different SGD noise (data order, augmentation) and measured the loss along the straight line between them. Early in training the line crosses a barrier; after a short while the two copies become "stable to SGD noise" and the whole line is low-loss — they end up in one linearly connected basin.
  • Permutations explain most barriers. Entezari et al. (2021) conjectured that once permutations are accounted for, SGD solutions have essentially no barrier between them. Git Re-Basin (Ainsworth et al., 2022) gave algorithms to permute one network's units to match another's, and showed "zero-barrier linear mode connectivity between independently trained ResNet models on CIFAR-10" (with width mattering, and with counterexamples).
  • Pre-training is a shared start. Fine-tunes of one pre-trained model inherit its unit ordering and begin in its basin. WARM states the working assumption plainly: "fine-tuned weights remain linearly mode connected when sharing the same pre-training". This is why merging is a post-training technique.
independent inits (MSE 1.29 at midpoint) after permutation alignment (0.63) two runs from a shared start (0.027) θ_Aθ_B interpolation weight α from 0 to 1 loss (MSE)
Loss along $(1-\alpha)\theta_A + \alpha\theta_B$ for small MLPs, computed by the second script in Build it. Both endpoints have loss about 0.03. Independently initialised networks have a barrier 50× higher than the endpoints; permuting the second network's hidden units to match the first (a greedy version of Git Re-Basin's activation matching) halves it; two continuations of one shared checkpoint have no barrier at all.

Averaging along one run: SWA, EMA and checkpoint averaging

The oldest merging trick averages checkpoints of a single training run. Polyak averaging (1991) averaged the iterates of stochastic approximation; stochastic weight averaging (Izmailov et al., 2018) averaged SGD iterates late in training and found "wider optima and better generalization"; an exponential moving average of the weights is standard in diffusion models and in many LLM training runs. The Llama 3 team, for example, computed "the average of model checkpoints (Polyak (1991) averaging) during annealing to produce the final pre-trained model" (Llama Team, 2024). Successive checkpoints of one run are the easiest possible case of linear mode connectivity: they are already in the same basin, and the average sits nearer its centre than any single noisy iterate.

Model soups and WiSE-FT: averaging across runs

Model soups (Wortsman et al., 2022) applied the idea across a hyperparameter sweep. The usual recipe trains many fine-tunes and keeps the best on validation; the soup averages them instead. The uniform soup averages all; the greedy soup adds models in order of validation accuracy, keeping each only if the average improves. A greedy soup of fine-tuned ViT-G models reached 90.94% top-1 on ImageNet, a state of the art at the time, at no extra inference cost — unlike an ensemble, a soup is one model.

WiSE-FT (Wortsman et al., 2021) interpolates between a zero-shot model and its fine-tuned version, \(\theta = (1-\alpha)\theta_0 + \alpha\theta_{\text{ft}}\). Fine-tuning CLIP on ImageNet raises ImageNet accuracy but makes the model more brittle to distribution shift; the interpolated model kept the in-distribution gain while improving accuracy under shift by 4–6 points over prior work. Interpolating back towards the base model is the simplest way to buy back some of what fine-tuning cost.

Both ideas are now routine in LLM post-training. Llama 3's post-training section says it plainly: "we average models obtained from experiments using various versions of data or hyperparameters at each RM, SFT, or DPO stage". Google's WARM averages several fine-tuned reward models into one that is more robust to reward hacking (a policy trained with it won 79.4% of comparisons against one trained with a single reward model), and WARP merges RLHF policies at three points: an exponential moving average as the KL anchor, spherical interpolation of independently trained policies, and interpolation back towards the initialisation.

Task arithmetic

Ilharco et al. (2022) gave merging its algebra. Define a task vector as the change fine-tuning made, \(\tau = \theta_{\text{ft}} - \theta_0\). Then:

  • Addition builds multi-task models: \(\theta_0 + \lambda(\tau_A + \tau_B)\) does both tasks reasonably well.
  • Negation removes a behaviour: \(\theta_0 - \lambda\tau_{\text{toxic}}\), with \(\tau_{\text{toxic}}\) from fine-tuning on toxic text, reduced toxic generation "with little change in model behavior on control tasks".
  • Analogies transfer across domains: if A is to B as C is to D, then \(\tau_C + (\tau_B - \tau_A)\) improves D without any D data.

The scale \(\lambda\) matters and is tuned on validation data; \(\lambda = 1/n\) for \(n\) vectors is plain averaging, \(\lambda = 1\) is full addition. Why does addition work at all? Task vectors for different tasks are nearly orthogonal (in a space of billions of dimensions, random directions almost always are), and each lives mostly in directions the other task barely uses. Ortiz-Jimenez et al. (2023) named the precise condition weight disentanglement — each task vector changes the model's outputs only on its own task's inputs — and showed it holds best when fine-tuning stays close to the linearised regime (see the maths).

Interference, and the methods that resolve it

Addition degrades as you merge more models, because task vectors are not perfectly disentangled. Two kinds of interference dominate: many small, redundant changes that add noise, and parameters that one task pushed up and another pushed down. The main methods, each a small idea:

Method Idea When it helps
Averaging / soups \(\theta = \frac1n\sum\theta_i\) Same task, different hyperparameters or seeds
Task arithmetic \(\theta_0 + \lambda\sum\tau_i\) Different tasks, few of them
Fisher merging Weight each parameter by each model's Fisher information When models disagree on parameters that matter to only one of them
RegMean Per linear layer, solve for the weights that best reproduce every model's outputs, using input statistics When a little unlabelled data per task is available
TIES Trim small changes, elect a sign per parameter, average only agreeing values Many tasks with sign conflicts
DARE Randomly drop a fraction \(p\) of each delta and rescale the rest by \(1/(1-p)\) Large models whose deltas are highly redundant
SLERP Interpolate along the great circle between two weight vectors, per tensor Two models; preserves weight norms
TIES-merging in three steps
TIES-merging in three steps. Task vectors τ_1 … τ_n, 1. Trim keep each vector's top-k% entries by magnitude, zero the rest, 2. Elect sign per parameter, the sign with the largest total magnitude, 3. Disjoint mean average only entries that agree with the elected sign, θ₀ + λ · τ_mergedTIES-merging in three steps. Task vectors τ_1 … τ_n, 1. Trim keep each vector's top-k% entries by magnitude, zero the rest, 2. Elect sign per parameter, the sign with the largest total magnitude, 3. Disjoint mean average only entries that agree with the elected sign, θ₀ + λ · τ_merged

TIES's authors found that "keeping only the top-20% of values delivers comparable results to retaining all parameters", and their validation-free recipe is exactly that: keep 20%, \(\lambda = 1\). DARE went further: supervised fine-tuning deltas are tiny (its authors report value ranges "typically small (within 0.002)") and so redundant that 90% or even 99% can be dropped at random, provided the survivors are rescaled; dropping first and then merging reduces interference. Both methods lean on redundancy, which grows with model size — on a tiny network every delta matters, and trimming hurts (one of the Build it exercises shows this).

Merging in practice

Open-weight model builders turned merging into an ecosystem. mergekit (Goddard et al., 2024) implements all the methods above with a YAML configuration and runs on a CPU, since merging is arithmetic, not training. DARE's authors used merging to produce a 7B model that ranked first among 7B models on the Open LLM Leaderboard. Three extensions are worth knowing:

  • Evolutionary merging. Akiba et al. (2024) at Sakana AI searched merge recipes automatically, in both weight space and "data flow space" (which layers of which model run in what order), producing a Japanese maths model from a Japanese model and an English maths model.
  • Layer stacking. "Passthrough" merges concatenate layers of models rather than averaging them. SOLAR 10.7B's depth up-scaling duplicated and stacked layers of a 7B model and then continued pre-training — a reminder that stacking needs training to heal.
  • Adapters as task vectors. A LoRA update \(\frac{\alpha}{r}BA\) is a task vector, stored in low-rank form. Adapters can be added, weighted and merged with the same methods (LoraHub learns the weights from a few examples), and PEFT implements TIES and DARE for adapters directly.

Merging has sharp limits. It needs a shared base (or an alignment step); it cannot combine models with different architectures or tokenizers; the merged model is usually worse than each specialist on its own task, though better than the base on all of them; and leaderboard-tuned merges can overfit benchmarks. Treat a merge as a cheap candidate that still has to pass your evals.

Catastrophic forgetting

Now the other face of the geometry. In 1989 McCloskey and Cohen trained a network on one set of arithmetic facts and then another, and found that learning the second set erased the first — catastrophic interference. A person who learns Spanish does not forget English; a network fine-tuned on Spanish may. The cause is that gradient descent on task B follows B's loss surface wherever it slopes, with no knowledge of which directions task A needed.

It happens in LLMs at every scale. Luo et al. (2023) found forgetting of domain knowledge, reasoning and reading comprehension during continual instruction tuning of models from 1B to 7B parameters, and found it intensified with scale in that range. Every practitioner sees the small version: fine-tune an assistant on your domain and it gets worse at following formatting instructions, or loses some of its safety behaviour, or forgets how to do arithmetic it used to do.

Continual-learning research distinguishes three settings, which differ in what the model is told at test time (van de Ven and Tolias, 2019): whether the task identity is given (task-incremental), whether only the input distribution changes (domain-incremental), or whether new classes appear that must be told apart from old ones (class-incremental, the hardest). For language models the practical settings are continual pre-training (new data, new language, new time period), continual post-training (new skills, new behaviours) and knowledge updates (new facts).

Defences against forgetting

Four ways to learn something new without forgetting the old
Four ways to learn something new without forgetting the old. New data arrives (task, domain, facts, behaviour), Constrain the update EWC, KL anchor to the old model, LoRA (low-rank), small LR, Replay the old distribution mix old data in; for pre-training, re-warm + re-decay LR, Isolate the new knowledge adapters per task, new experts, retrieval instead of weights, Learn on-policy RL forgets less (Four ways to learn something new without forgetting the old. New data arrives (task, domain, facts, behaviour), Constrain the update EWC, KL anchor to the old model, LoRA (low-rank), small LR, Replay the old distribution mix old data in; for pre-training, re-warm + re-decay LR, Isolate the new knowledge adapters per task, new experts, retrieval instead of weights, Learn on-policy RL forgets less (

Regularise the update. Elastic weight consolidation (Kirkpatrick et al., 2017) remembers old tasks "by selectively slowing down learning on the weights important for those tasks": a quadratic penalty on moving each weight, weighted by its Fisher information for the old task (derived below). In LLM post-training the everyday version is the KL penalty to a reference model in RLHF and DPO — a regulariser on outputs rather than weights. LoRA is a third form: Biderman et al. (2024) found it "mitigates forgetting more than common regularization techniques such as weight decay and dropout", because a low-rank update simply cannot move the model very far (see LoRA).

Replay. Mix a sample of old data into the new training. It is crude, effective and almost always the strongest baseline (Rolnick et al., 2018). For LLM continual pre-training, Ibrahim et al. (2024) showed that "a simple and scalable combination of learning rate (LR) re-warming, LR re-decaying, and replay of previous data is sufficient to match the performance of fully re-training from scratch on all available data", at 405M and 10B parameters, for both a mild (English to English) and a strong (English to German) distribution shift. The LR detail matters: a cosine schedule ends at a tiny learning rate, so new data barely moves the model unless you warm the rate back up — and warming it up is itself what causes forgetting, which replay then counters.

Learn on-policy. Shenfeld et al. (2025), "RL's Razor" compared SFT and RL fine-tuning to the same new-task accuracy and found RL "preserves prior knowledge and capabilities significantly better". The amount forgotten was predicted by one number: the KL divergence between the fine-tuned and base policy, measured on the new task. On-policy RL is implicitly biased towards the KL-minimal way of solving the new task, because it only reinforces outputs the model already produces; SFT can pull the model towards an arbitrary target distribution far from where it started. The same logic underlies using on-policy distillation to repair forgetting: Thinking Machines restored most of a model's lost instruction-following after domain fine-tuning by distilling from its own earlier checkpoint on the student's samples.

Isolate. Give new knowledge its own parameters: a separate adapter per task, new experts in a mixture of experts, or no parameters at all — keep changing facts in a database and fetch them at inference time with retrieval. Branch-Train-Merge combines isolation with merging: branch expert models per domain, train them independently, and ensemble or average them back.

Why Jarvis keeps facts out of the weights

A financial assistant's facts change daily: prices, rules, a user's own balance sheet. Jarvis never asks a model to remember them. The FIRE engine computes, the data lives in services, and the model routes requests and explains results (see the Jarvis case study). That is the isolation defence taken to its limit: if knowledge changes faster than you can safely retrain, keep it out of the weights entirely.

Editing facts directly

A narrow kind of continual learning is changing one fact: "the CEO of X is now Y". ROME (Meng et al., 2022) located factual associations in middle-layer MLPs and edited them with a rank-one update; MEMIT scaled this to thousands of edits at once. Knowledge editing is a beautiful demonstration that some facts are stored in localised, linear-algebraic form, and a cautionary one: edits often fail to propagate to paraphrases and implications, and they can damage neighbouring facts. In production, retrieval remains the reliable way to keep facts current.

Where the frontier is (as of 2026)

Frontier models are still trained in discrete generations: pre-train to a data cutoff, post-train, release, and later train a successor, with continued pre-training and further post-training in between. Continuous learning from deployment — a model that improves from every conversation without forgetting or drifting — is not how production models work, and it raises safety questions as well as technical ones, because a model that learns from users can also be taught by them. The research directions to watch are the ones on this page: replay and learning-rate schedules that make continued pre-training cheap, low-rank and on-policy updates that move the model as little as possible, merging that lets independently trained skills be combined, and memory systems (context engineering and memory) that let a fixed model use knowledge it was never trained on.

History

Catastrophic interference was named by McCloskey and Cohen (1989) and studied by Ratcliff (1990); French's 1999 review framed it as the stability–plasticity dilemma that brains solve with complementary learning systems (a fast hippocampal learner replaying into a slow cortical one). For two decades it was a known limitation of connectionist models rather than an active field. Deep RL revived it: an agent learning a second Atari game forgot the first, and DeepMind's EWC paper (2017) addressed exactly that, inspired by synaptic consolidation in neuroscience. Replay and gradient-projection methods such as GEM (Lopez-Paz and Ranzato, 2017) followed.

Weight averaging has a separate lineage, from Polyak and Juditsky's averaged stochastic approximation (early 1990s) to SWA (2018). Mode connectivity was the bridge: in 2018 Garipov et al. and Draxler et al. independently showed that independently trained minima are joined by simple low-loss curves, Frankle et al. (2019) found linear connectivity after early training, and Entezari et al. (2021) and Ainsworth et al. (2022) attributed the remaining barriers to permutation symmetry. In parallel, the fine-tuning community at the University of Washington and elsewhere found that averaging fine-tunes simply worked: WiSE-FT (2021), model soups and task arithmetic (2022). 2023 brought interference-aware merging (TIES, DARE), and in early 2024 mergekit made merging a community sport on open-weight leaderboards. By 2024–2025 merging was a standard, mostly unadvertised step in frontier post-training (Llama 3's report is unusually explicit), and RL's Razor (2025) gave a principled account of why on-policy training forgets less.

First principles

Forgetting is curvature

Let \(\theta_A\) minimise the old task's loss \(L_A\). Any later change \(\delta\) costs, to second order,

\[ L_A(\theta_A + \delta) \approx L_A(\theta_A) + \tfrac12\, \delta^\top H_A\, \delta, \]

because the gradient at a minimum is zero. Forgetting is the quadratic form \(\tfrac12\delta^\top H_A\delta\): moving along directions where \(L_A\) is sharply curved is expensive; moving along flat directions is free. A network has billions of parameters and the old task's Hessian has a small number of large eigenvalues and a vast number of near-zero ones, so there is plenty of room to learn task B in A's flat directions. Plain gradient descent on \(L_B\) does not look for that room: it moves along \(-\nabla L_B\), which generally has components along A's sharp directions. Every defence on this page is a way of steering \(\delta\) into A's flat subspace (EWC, LoRA, small learning rates), of re-measuring \(L_A\) while training (replay), or of choosing the solution to B that moves the model least (on-policy RL).

Merging is the same quadratic, read the other way

Add task B's vector to a model fine-tuned on A. Expanding \(L_A\) around \(\theta_A\) again,

\[ L_A(\theta_A + \tau_B) \approx L_A(\theta_A) + \tfrac12\, \tau_B^\top H_A\, \tau_B . \]

The merge preserves task A exactly when \(\tau_B\) lies in A's flat directions, and symmetrically for B. Sequential training and merging differ in which \(\delta\) they use: sequential fine-tuning uses a \(\delta\) chosen by B's gradient starting from \(\theta_A\), which has no reason to respect \(H_A\); merging uses \(\tau_B\), which was computed from \(\theta_0\) and never saw A at all — and which, because it is short and lives mostly in B-specific directions, often happens to be nearly flat for A. Neither is guaranteed. That is why merges are evaluated, not trusted.

Why the shared start is non-negotiable

Permutation symmetry means the weight space contains \(H!\) equivalent copies of every solution for each hidden layer of width \(H\). Two independent runs land in different copies, and the straight line between copies passes through regions that compute nothing in particular. Fine-tunes of one pre-trained model all start in the same copy and move only a short distance, so they stay in it. Pre-training is thus doing two jobs for merging: providing features, and fixing a coordinate system.

The maths

Permutation symmetry and the loss barrier

For a one-hidden-layer network \(f(x) = W_2\,\sigma(W_1 x + b_1)\) and any permutation matrix \(P\),

\[ W_2 P^\top\, \sigma(P W_1 x + P b_1) = W_2 P^\top P\, \sigma(W_1 x + b_1) = f(x), \]

because an elementwise nonlinearity commutes with permutation. So \((PW_1, Pb_1, W_2P^\top)\) is the same function. (For odd activations such as tanh there is a second symmetry: flip the sign of a unit's incoming weights, bias and outgoing weights.) The loss barrier between \(\theta_A\) and \(\theta_B\) is

\[ B(\theta_A, \theta_B) = \max_{\alpha \in [0,1]}\; L\big((1-\alpha)\theta_A + \alpha\theta_B\big) - \big[(1-\alpha)L(\theta_A) + \alpha L(\theta_B)\big], \]

and two solutions are linearly mode connected when \(B \approx 0\). Git Re-Basin chooses \(P\) for each layer to maximise \(\langle \theta_A, \pi_P(\theta_B)\rangle\) (weight matching) or the correlation of activations (activation matching), each layer a linear assignment problem.

Fisher merging and EWC are one derivation

Treat each fine-tuned model as a Gaussian posterior over weights, centred at its solution with precision equal to its Fisher information \(F_i\) (the Laplace approximation). The most probable weights under all of them at once maximise

\[ \sum_i \log \mathcal N\big(\theta;\, \theta_i,\, F_i^{-1}\big) = -\tfrac12 \sum_i (\theta - \theta_i)^\top F_i\, (\theta - \theta_i) + \text{const}. \]

Setting the gradient \(\sum_i F_i(\theta - \theta_i)\) to zero gives the Fisher merge

\[ \theta^\star = \Big(\sum_i F_i\Big)^{-1} \sum_i F_i\, \theta_i , \]

which with diagonal Fishers is a per-parameter weighted average: each model gets a say in proportion to how much that parameter matters to it. With \(F_i = I\) it is the plain average — "simple parameter averaging corresponds to making an isotropic Gaussian approximation" (Matena and Raffel, 2021).

EWC is the same approximation applied sequentially. By Bayes' rule, \(\log p(\theta \mid \mathcal D_A, \mathcal D_B) = \log p(\mathcal D_B \mid \theta) + \log p(\theta \mid \mathcal D_A) + \text{const}\). Replace the intractable second term with its Laplace approximation around \(\theta_A\), keep the Fisher's diagonal, and the loss to minimise on task B becomes

\[ \mathcal L(\theta) = \mathcal L_B(\theta) + \frac{\lambda}{2} \sum_j F_{A,j}\, (\theta_j - \theta_{A,j})^2 , \]

a spring on every weight whose stiffness is that weight's importance to task A. The diagonal Fisher is computed from squared gradients of the log-likelihood on A's data: \(F_{A,j} = \mathbb E\big[(\partial_{\theta_j} \log p(y\mid x,\theta_A))^2\big]\), an estimate of the curvature \(H_A\) from First principles.

Task arithmetic in the linear regime

Linearise the network around the pre-trained weights: \(f(x;\theta_0 + \tau) \approx f(x;\theta_0) + J_{\theta_0}(x)\,\tau\). In this regime adding task vectors adds their effects exactly,

\[ f(x;\theta_0 + \tau_A + \tau_B) \approx f(x;\theta_0) + J(x)\tau_A + J(x)\tau_B, \]

and the merged model behaves like the A-specialist on A's inputs whenever \(J(x)\,\tau_B \approx 0\) for those inputs: task B's change is invisible on task A's data. That is weight disentanglement. Real fine-tuning is not exactly linear, which is why Ortiz-Jimenez et al. found that fine-tuning in the tangent space (training the linearised model) makes task arithmetic work better.

DARE is unbiased, and its noise scales with the delta

DARE replaces each delta entry \(\tau_j\) with \(\tilde\tau_j = m_j \tau_j / (1-p)\), where \(m_j \sim \text{Bernoulli}(1-p)\). Then \(\mathbb E[\tilde\tau_j] = \tau_j\), and for one output of a linear layer, \(\Delta h = \sum_j \tilde\tau_j x_j\) has

\[ \mathbb E[\Delta h] = \sum_j \tau_j x_j, \qquad \operatorname{Var}[\Delta h] = \frac{p}{1-p}\sum_j \tau_j^2 x_j^2 . \]

At \(p = 0.9\) the variance factor is 9. The method is harmless only when \(\sum_j \tau_j^2 x_j^2\) is small next to the output itself — tiny deltas, spread across many redundant parameters — which is the situation the DARE authors measured in fine-tuned LLMs, and not the situation in a small network.

SLERP

For two weight tensors flattened to vectors with angle \(\Omega\) between them (\(\cos\Omega = \frac{\theta_A\cdot\theta_B}{\lVert\theta_A\rVert\lVert\theta_B\rVert}\)),

\[ \operatorname{slerp}(\theta_A, \theta_B; t) = \frac{\sin((1-t)\Omega)}{\sin\Omega}\,\theta_A + \frac{\sin(t\Omega)}{\sin\Omega}\,\theta_B , \]

which keeps the interpolated vector's norm between the endpoints' instead of shrinking it, as the linear average does when the vectors are not parallel.

Build it

Two NumPy experiments. The first shows forgetting, its two main cures (replay and multi-task training) and two merges, on one small problem. The second reproduces the loss-barrier figure above.

import numpy as np
rng = np.random.default_rng(0)
D, H = 8, 256
def train(p, X, y, steps=2000, lr=0.05):
    p = [w.copy() for w in p]                          # p = [W1 (H,D), b1 (H,), W2 (1,H)]
    for _ in range(steps):
        a = np.tanh(X @ p[0].T + p[1]); e = 2 * ((a @ p[2].T).ravel() - y) / len(y)
        da = (e[:, None] * p[2]) * (1 - a**2)
        p[2] -= lr * e[None] @ a; p[0] -= lr * da.T @ X; p[1] -= lr * da.sum(0)
    return p
def mse(p, X, y): return np.mean(((np.tanh(X @ p[0].T + p[1]) @ p[2].T).ravel() - y) ** 2)

# Two input regions (sign of x0). Pre-training learns `base` everywhere; task A rewrites
# the function in region A, task B in region B.
XA = rng.normal(size=(512, D)); XA[:, 0] = np.abs(XA[:, 0]) + 0.5
XB = rng.normal(size=(512, D)); XB[:, 0] = -np.abs(XB[:, 0]) - 0.5
base = lambda X: np.sin(X[:, 1]) + 0.5 * X[:, 2]
yA, yB = base(XA) + 0.8 * np.cos(2 * XA[:, 3]), base(XB) - 0.4 * XB[:, 4] ** 2

r = np.random.default_rng(1)
p0 = [r.normal(0, 1/np.sqrt(D), (H, D)), np.zeros(H), r.normal(0, 1/np.sqrt(H), (1, H))]
theta0 = train(p0, np.vstack([XA, XB]), np.concatenate([base(XA), base(XB)]), 4000)
thA, thB = train(theta0, XA, yA), train(theta0, XB, yB)
tA = [a - w for a, w in zip(thA, theta0)]; tB = [b - w for b, w in zip(thB, theta0)]

rows = {"pre-trained theta0": theta0, "fine-tuned on A": thA, "fine-tuned on B": thB,
        "sequential A then B": train(thA, XB, yB),
        "sequential + 25% replay of A": train(thA, np.vstack([XB, XA[:128]]), np.concatenate([yB, yA[:128]])),
        "multi-task (A and B jointly)": train(theta0, np.vstack([XA, XB]), np.concatenate([yA, yB])),
        "merge: average": [(a + b) / 2 for a, b in zip(thA, thB)],
        "merge: task arithmetic": [w + a + b for w, a, b in zip(theta0, tA, tB)]}
for name, p in rows.items():
    print(f"{name:<30} task A mse={mse(p, XA, yA):.3f}   task B mse={mse(p, XB, yB):.3f}")
pre-trained theta0             task A mse=0.333   task B mse=0.556
fine-tuned on A                task A mse=0.008   task B mse=0.926
fine-tuned on B                task A mse=0.511   task B mse=0.008
sequential A then B            task A mse=0.334   task B mse=0.007
sequential + 25% replay of A   task A mse=0.071   task B mse=0.019
multi-task (A and B jointly)   task A mse=0.025   task B mse=0.022
merge: average                 task A mse=0.214   task B mse=0.188
merge: task arithmetic         task A mse=0.237   task B mse=0.103

Read the rows in order. Fine-tuning on A also damages region B (0.556 → 0.926): a small network has no spare directions, so the change leaks. Sequential training forgets A completely (0.008 → 0.334, back to where the pre-trained model was). Replaying a quarter of A's data during B recovers most of it; joint training is the ceiling. The two merges, which never saw both tasks together, beat the pre-trained model on both tasks but fall well short of the specialists — because in a 2,300-parameter network the task vectors are not disentangled. This is the honest small-scale picture; in billion-parameter models the merges get much closer to the specialists, for the reasons in First principles.

import numpy as np
rng = np.random.default_rng(0)
D, H = 8, 128
X = rng.normal(size=(1024, D)); y = np.sin(2 * X[:, 0]) * X[:, 1] + np.cos(X[:, 2] * X[:, 3])
def init(seed):
    r = np.random.default_rng(seed)
    return [r.normal(0, 1/np.sqrt(D), (H, D)), np.zeros(H), r.normal(0, 1/np.sqrt(H), (1, H))]
def train(p, X, y, steps, lr=0.05, seed=0):
    p = [w.copy() for w in p]; r = np.random.default_rng(seed)
    for _ in range(steps):
        i = r.choice(len(y), 256)                        # minibatch SGD: the data order is the "noise"
        a = np.tanh(X[i] @ p[0].T + p[1]); e = 2 * ((a @ p[2].T).ravel() - y[i]) / 256
        da = (e[:, None] * p[2]) * (1 - a**2)
        p[2] -= lr * e[None] @ a; p[0] -= lr * da.T @ X[i]; p[1] -= lr * da.sum(0)
    return p
def loss(p): return np.mean(((np.tanh(X @ p[0].T + p[1]) @ p[2].T).ravel() - y) ** 2)
def path(pA, pB):                                        # loss along (1-a)·pA + a·pB
    return [loss([(1 - a) * u + a * v for u, v in zip(pA, pB)]) for a in np.linspace(0, 1, 5)]
def align(pA, pB):                                       # permute B's hidden units to match A's
    hA, hB = np.tanh(X @ pA[0].T + pA[1]), np.tanh(X @ pB[0].T + pB[1])
    C = np.corrcoef(hA.T, hB.T)[:H, H:]; perm = -np.ones(H, int)
    for _ in range(H):                                   # greedy matching on activation correlation
        i, j = np.unravel_index(np.argmax(C), C.shape); perm[i] = j; C[i, :] = C[:, j] = -np.inf
    return [pB[0][perm], pB[1][perm], pB[2][:, perm]]    # same function, different coordinates

A = train(init(1), X, y, 6000, seed=1); B = train(init(2), X, y, 6000, seed=2)
B_al = align(A, B)
theta0 = train(init(3), X, y, 1500, seed=3)              # a shared "pre-trained" start
F1, F2 = train(theta0, X, y, 4500, seed=4), train(theta0, X, y, 4500, seed=5)
print("permuted B computes the same function:", np.isclose(loss(B), loss(B_al)))
for name, (p, q) in {"independent inits A<->B": (A, B), "after permutation alignment": (A, B_al),
                     "two runs from shared start": (F1, F2)}.items():
    print(f"{name:<29}", "  ".join(f"{v:.3f}" for v in path(p, q)), "  (alpha = 0, .25, .5, .75, 1)")
permuted B computes the same function: True
independent inits A<->B       0.025  0.765  1.291  0.657  0.028   (alpha = 0, .25, .5, .75, 1)
after permutation alignment   0.025  0.328  0.629  0.369  0.028   (alpha = 0, .25, .5, .75, 1)
two runs from shared start    0.028  0.027  0.027  0.027  0.028   (alpha = 0, .25, .5, .75, 1)

Permuting the hidden units leaves the function unchanged (first line) but halves the barrier. The two continuations of one checkpoint — same architecture, same data, different SGD noise for 4,500 steps — are linearly connected: every point on the line between them is as good as either end. That is linear mode connectivity, and it is the property every merge relies on. (The first script takes about 13 seconds, the second about 6.)

Things to try

  • In the first script, sweep \(\lambda\) in theta0 + λ(tA + tB) from 0 to 1.5. Where is the best trade-off? Is it the same for both tasks?
  • Implement EWC: estimate a diagonal Fisher for task A from squared per-example gradients at thA, add the penalty while training on B, and compare with replay.
  • Implement TIES (trim to the top 20% by magnitude, elect signs, disjoint mean). On this small dense network it does worse than plain task arithmetic. Use the DARE variance formula to explain why.
  • In the second script, extend align to handle tanh's sign symmetry (match on the absolute correlation and flip signs where it is negative). How much of the remaining barrier goes?
  • Shorten the shared pre-training from 1,500 steps to 50. At what point do the two continuations stop being linearly connected? This is Frankle et al.'s experiment.

In practice

  • Average your own runs. If you fine-tune with several seeds or hyperparameters, try a uniform and a greedy soup before picking a single winner. It costs one evaluation.
  • Interpolate back towards the base (WiSE-FT) when a fine-tune has gained the task but lost general behaviour. Sweep \(\alpha\) and evaluate both.
  • Merge with mergekit, evaluate like a new model. Merges can silently break chat templates, tool-calling formats or safety behaviour; run your full eval suite, not just the target tasks.
  • For continued pre-training, re-warm and re-decay the learning rate and replay some of the original distribution. For post-training, mix in general instruction data with domain data.
  • Prefer updates that move the model least: LoRA for narrow adaptations, on-policy methods over SFT where you can, and a KL anchor to the reference model.
  • Measure forgetting explicitly. Keep a held-out set of the old tasks and general benchmarks in every evaluation, and track the KL divergence between the new and old model on the new task's prompts — RL's Razor suggests it predicts forgetting.
  • Keep fast-changing facts out of the weights. Use retrieval and tools; reserve weight updates for skills and behaviour.

Common misconceptions

“You can merge any two models with the same architecture”

Only models that share a pre-trained ancestor (or have been permutation-aligned) are reliably linearly connected. Averaging two independently pre-trained models of the same shape produces nonsense, because their hidden units are in different orders.

“Bigger models don't forget”

Larger models have more room to learn without interference, and merges work better at scale, but forgetting during fine-tuning is observed at every size, and Luo et al. found it increased from 1B to 7B in their setting.

“A merged model is as good as each of its parents”

Usually it is worse than each specialist on that specialist's task and better than the base on all tasks. Merging trades peak performance for breadth and zero training cost.

Check yourself

Why does averaging two independently trained networks usually fail, while averaging two fine-tunes of one pre-trained model often works?

Hidden units can be permuted without changing the function, so two independent runs encode similar features in different unit positions; averaging blends unrelated units. Fine-tunes of one pre-trained model share its unit ordering, start in the same basin and move only a short distance, so the line between them stays low-loss (linear mode connectivity).

What is a task vector, and what do negation and addition do?

\(\tau = \theta_{\text{ft}} - \theta_0\), the weight change made by fine-tuning. Adding scaled task vectors to \(\theta_0\) gives a model with several abilities; subtracting one removes or reduces the corresponding behaviour (for example, toxic generation) with little effect on control tasks.

Write the EWC penalty and say where each piece comes from.

\(\frac{\lambda}{2}\sum_j F_{A,j}(\theta_j - \theta_{A,j})^2\). It is the Laplace approximation of the old task's posterior \(\log p(\theta\mid\mathcal D_A)\) as a Gaussian centred at \(\theta_A\) with diagonal precision equal to the Fisher information \(F_A\), which estimates the curvature of task A's loss. \(\lambda\) trades old-task retention against new-task learning.

Fisher merging with identity Fishers reduces to what?

Plain averaging: \(\theta^\star = (\sum_i I)^{-1}\sum_i \theta_i = \frac1n\sum_i\theta_i\). Simple averaging assumes every parameter is equally important to every model.

Continued pre-training on new data barely changes a model trained with a cosine schedule unless you re-warm the learning rate. Why, and what does re-warming cost?

A cosine schedule ends near zero, so new gradients produce tiny steps. Re-warming the learning rate lets the model learn the new data but also moves it out of its old minimum, which causes forgetting; Ibrahim et al. counter that with replay of old data and a re-decay of the rate.

According to RL's Razor, what predicts how much a fine-tune forgets, and why does on-policy RL forget less than SFT?

The KL divergence between the fine-tuned and base policies, measured on the new task's inputs. On-policy RL only reinforces outputs the current model already samples, so among all solutions to the new task it drifts towards ones close in KL to the base; SFT pulls the model towards a fixed target distribution that can be far from it.

Hard: using the second-order expansion, when does adding \(\tau_B\) to \(\theta_A\) preserve task A, and why is that more likely in a large model?

\(L_A(\theta_A + \tau_B) \approx L_A(\theta_A) + \frac12\tau_B^\top H_A\tau_B\), so task A survives when \(\tau_B\) lies in A's low-curvature directions. In a large model \(H_A\) has a few large eigenvalues among billions of near-zero ones, task vectors are short and nearly orthogonal, and a random-ish short vector almost certainly has little projection on A's few sharp directions. In a small network, as in Build it, there are few spare directions and the projection is large.

Hard: DARE drops 90% of delta parameters and rescales the rest by 10. Show it is unbiased and explain when it is safe.

With \(m_j\sim\text{Bernoulli}(0.1)\), \(\mathbb E[m_j\tau_j/0.1] = \tau_j\), so every layer's expected output change is unchanged. The variance of a layer output's change is \(\frac{p}{1-p}\sum_j\tau_j^2x_j^2 = 9\sum_j\tau_j^2x_j^2\), so it is safe only when the deltas are tiny relative to the weights and the effect is spread over many redundant parameters — true of LLM fine-tuning deltas, false of a small network where each parameter matters.

Go deeper

Papers

Articles and blog posts

Videos and lectures

Code

Where this leads