Introduction
We are given a released language model, the parent, and a set of specialists fine-tuned from the same model family on different domains: instruction following, mathematics, coding, multilingual understanding and safety. The goal is one model with the parent's architecture that keeps as much of each specialist's in-domain ability as possible, without joint multi-task training, routing or added modules. What the merge may use is the checkpoint lineage itself, activation statistics and gradients from the models, and a labelled calibration split, within a fixed merge budget.
The field offers two families of answers. Weight-space rules are pure functions of the checkpoints: averaging the fine-tuned weights [1], adding scaled task vectors to the parent [2], resolving sign and magnitude conflicts between those vectors [3], dropping and rescaling most of each update [4], or localising which parameters carry each task [5, 6]. Data-based rules use the models on inputs: Fisher-weighted averaging [7], closed-form regression of each linear layer onto the specialists' outputs [8, 9], learned merge coefficients [10], and optimisation driven by the task vectors themselves [11, 12]. Merging has also been studied for reinforcement-learned agentic models [13], and a benchmark now exists for merging domain-specialised language models [14].
Three properties make this setting hard, and our method is built around them.
Each specialist only needs to act on its own domain. A specialist's update matters on inputs from its domain; on inputs from other domains, it is interference. Rules that sum or average the task vectors let every specialist act everywhere, and a single global strength cannot fix that: in our development measurements, the update of one specialist was about 2.5 times the size of several others'.
Full-matrix closed forms are fragile. Regressing each layer onto the specialists' outputs [8] requires inverting activation second-moment matrices estimated from a small calibration sample, and poorly observed directions are amplified by that inverse.
The specialists need not descend from the deployed parent. In a lineage, a specialist may have been trained from the pretrained base rather than from the post-trained parent. A flat task vector then contains the negative of the parent's own post-training update, and adding it to the parent partly undoes that post-training.
Method
Our method, which we call neuron-span merging (NSM), has four parts: lineage-gated task vectors, a per-neuron activation-matched quadratic problem, a capped correction outside the span, and merge strengths chosen on validation responses. Throughout, is the parent (the lineage's target), indexes the specialists and their domains, and the linear layers are treated one at a time.
Lineage-gated task vectors
For specialist let be its lowest common ancestor with the parent in the lineage. If , the specialist descends from the parent and its task vector is the usual . Otherwise we consider the transported specialist , which carries the specialist's own update onto the parent, and compare it with the specialist itself on the specialist's own domain, using the length-normalised response negative log-likelihood on up to 16 labelled validation rows,
If , transport is rejected and the anchor falls back to the parent, ; otherwise (including a tie) the anchor stays at the ancestor, . Transport is the right choice when the parent's post-training is compatible with the specialist's update; the gate exists because we found cases where it is not.
A = []
for e, domain in zip(experts, lineage.domains):
ancestor = lineage.lca(e, target)
if ancestor != target:
E = lineage.nodes[e].weights
C = lineage.nodes[ancestor].weights
transported = {k: (E.get(k, dtype=torch.float32) + P.get(k, dtype=torch.float32)
- C.get(k, dtype=torch.float32)).to(P[k].dtype) for k in P.keys()}
expert_score = teacher_nll(e, domain)
transported_score = teacher_nll(transported, domain)
del transported
if transported_score > expert_score:
ancestor = target
A.append(lineage.nodes[ancestor].weights)A per-neuron quadratic problem over the span of the task vectors
For a linear layer with weight , we run the parent on 32 calibration examples of each domain and accumulate the second moment of the layer's inputs over the non-padding tokens,
each domain normalised by its own token count , so that no domain dominates by length. The objective we want is functional: on domain 's activations, the merged update should produce what specialist 's update produces, and the other specialists' updates should be silent,
Instead of solving it over all of , which requires inverting , we restrict each output row of to the span of the specialists' rows at that neuron, , with . The objective then decouples into one -dimensional problem per output neuron,
Both and are accumulated domain by domain while the calibration statistics are collected, so each is discarded after use.
for name in names:
k = param[name]
g = G[name] / norm
taus = torch.stack([w.get(k, device=dev, dtype=torch.float32)
- a.get(k, device=dev, dtype=torch.float32)
for w, a in zip(W, A)])
if k == param.get("lm_head"):
taus = taus * head_scale
c = torch.matmul(taus, g)
H[name] += torch.einsum("doi,eoi->ode", c, taus)
b[name] += torch.einsum("doi,oi->od", c, taus[di])
if use_residual:
GA[name].add_(g)
GT[name].addmm_(taus[di], g)
del g, taus, cWe solve the box-constrained problems for all neurons at once by projected coordinate descent from the uniform point , with 20 sweeps of
with the denominator floored at . The problem has the limits one wants. With one specialist it recovers that specialist's update; when every domain has the same statistics the minimiser is , the average of the task vectors; and when a neuron's inputs separate the domains, the coefficients move toward applying each specialist's row at full strength. The upper bound of 1 means no coefficient extrapolates a task vector, and, apart from the correction below, the restriction to the span means no direction is created that a specialist did not move.
if name in H:
h, y = H[name], b[name]
a = torch.full_like(y, 1.0 / nd)
for _ in range(SWEEPS):
for d in range(nd):
residual = y[:, d] - (h[:, d] * a).sum(-1) + h[:, d, d] * a[:, d]
a[:, d] = (residual / h[:, d, d].clamp(min=1e-20)).clamp(0.0, 1.0)
taus = torch.stack([w.get(k, device=dev, dtype=torch.float32)
- aa.get(k, device=dev, dtype=torch.float32)
for w, aa in zip(W, A)])
if k == param.get("lm_head"):
taus = taus * head_scale
weighted = a.t().unsqueeze(-1) * taus
delta = weighted.sum(0)Parameters that are not linear-layer weights (normalisation scales, biases) receive the average of the task vectors, . The output head is handled by the same problem: an untied head enters it as a linear layer, and with tied embeddings the head module is aliased to the shared embedding matrix, so the tied matrix is merged through the head's statistics. For a parent whose last stage is pretraining, the head's task vectors are scaled by 0.1, which, since and both scale with the square, leaves the coefficients unchanged and shrinks the head update by the same factor. Token embeddings that do not serve as a head are kept from the parent.
allow_head = True
head_scale = 0.1 if lineage.nodes[target].stage == "pretrain" else 1.0
untied_head = (allow_head and "lm_head.weight" in P
and not lineage.nodes[target].config.get("tie_word_embeddings", False))
model = ctx.build_model(target)
mods = dict(model.named_modules())
param = {name: name + ".weight" for name, mod in mods.items()
if isinstance(mod, torch.nn.Linear) and name + ".weight" in P
and "embed" not in name and (untied_head or "lm_head" not in name)}
if allow_head and not untied_head and "lm_head" in mods and "model.embed_tokens.weight" in P:
param["lm_head"] = "model.embed_tokens.weight"
names = list(param)
inverse = {param[name]: name for name in names}
include_head = untied_head or "lm_head" in paramA capped correction outside the span
The span restriction can be too narrow: the full-matrix minimiser of the functional objective is , which is regression-mean merging applied to task vectors [8], and it may use directions outside the span. We take one ridge-damped Newton step from the span solution toward it,
and cap its size relative to the span update, . The ridge equal to the mean diagonal and the 10% cap are what keep this step from repeating the amplification that a plain inverse produces. The correction is applied only when the parent's last stage is not pretraining, every specialist's common ancestor with the parent is the parent itself, and the extra statistics fit comfortably in free GPU memory.
if use_residual:
ga = GA[name]
rhs = GT[name] - delta @ ga
regularizer = ga.diagonal().mean().clamp(min=1e-12)
eye = torch.eye(ga.shape[0], dtype=torch.float32, device=dev)
chol = torch.linalg.cholesky(ga + regularizer * eye)
correction = torch.cholesky_solve(rhs.t(), chol).t()
cap = 0.1 * delta.norm()
correction *= (cap / correction.norm().clamp(min=1e-20)).clamp(max=1.0)
delta += correction
del ga, rhs, regularizer, eye, chol, correction, cap
del GA[name], GT[name]
merged[k] = (P.get(k, device=dev, dtype=torch.float32) + delta).to("cpu", dtype=P[k].dtype)Merge strength chosen on validation responses
The span coefficients decide how each neuron divides its update among the specialists; they do not decide how strongly to apply the merged update. We choose that on the labelled validation split. Writing for the full merged update and for the mean over domains of on 16 validation rows each, we first pick a global strength,
where returns the parent unchanged. Then, if each specialist's component of the update fits in GPU memory, we run one coordinate pass over the domains starting from unit strengths, choosing for each domain the strength of its component that minimises the same mean-over-domains objective with the other strengths held fixed. Choosing each on the mean over all domains, rather than on domain 's own loss, is the point: a strength that helps one domain at the expense of the others is rejected. The jointly scaled model is returned unless the best global strength validated strictly better, in which case the globally scaled model is returned. In the joint pass the correction outside the span is not part of any domain's component and stays at unit strength; in the global choice it is scaled with the rest of the update.
scores = []
for scale in (0.0, 0.5, 1.0, 1.5, 2.0):
if scale:
with torch.no_grad():
for k in msd:
if k in delta:
msd[k].copy_(base[k].to(device=dev, dtype=msd[k].dtype) + scale * delta[k].to(device=dev, dtype=base[k].dtype))
per_domain = [validation_nll(validation[d], lengths[d]) for d in lineage.domains]
scores.append((sum(per_domain) / len(per_domain), scale))
global_score, global_scale = min(scores, key=lambda x: x[0])
scales = [1.0] * nd
current = {k: delta[k] for k in keys}
joint_score = global_score
if use_parts:
for di, domain in enumerate(lineage.domains):
comp = parts[di]
without = {k: current[k] - scales[di] * comp[k].cpu() if k in comp else current[k]
for k in keys}
candidates = sorted(set((0.5, 1.0, 1.5, 2.0, scales[di])))
scores = []
for scale in candidates:
with torch.no_grad():
for k in msd:
if k in comp:
msd[k].copy_(base[k].to(device=dev, dtype=msd[k].dtype) + without[k].to(device=dev)
+ scale * comp[k].to(device=dev))
elif k in without:
msd[k].copy_(base[k].to(device=dev, dtype=msd[k].dtype) + without[k].to(device=dev, dtype=base[k].dtype))
per_domain = [validation_nll(validation[d], lengths[d]) for d in lineage.domains]
scores.append((sum(per_domain) / len(per_domain), scale))
joint_score, scales[di] = min(scores, key=lambda x: x[0])
current = {k: without[k] + scales[di] * comp[k].cpu() if k in comp else without[k]
for k in keys}
parts[di] = None
del comp, without
if not use_parts or global_score < joint_score:
current = {k: global_scale * delta[k] for k in keys}Results
| Method | ① | ② | ③ | ④ | ||||
|---|---|---|---|---|---|---|---|---|
| Normalised performance ↑ | TriviaQA retention ↑ | Normalised performance ↑ | TriviaQA retention ↑ | Normalised performance ↑ | TriviaQA retention ↑ | Normalised performance ↑ | TriviaQA retention ↑ | |
| Kimi K3.1 Pro | 70.58 | 0.445 | 82.46 | 0.300 | 66.37 | 0.409 | 91.21 | 0.124 |
| Unmerged parent model | 55.29 | 0.506 | 83.67 | 0.203 | 50.55 | 0.508 | 96.12 | 0.335 |
| Instruction specialist alone | 71.48 | 0.475 | 87.18 | 0.325 | 69.88 | 0.386 | 91.83 | 0.172 |
| Math specialist alone | 69.03 | 0.463 | 89.38 | 0.238 | 69.67 | 0.340 | 92.20 | 0.152 |
| Coding specialist alone | 66.89 | 0.487 | 84.44 | 0.356 | 63.83 | 0.495 | 93.28 | 0.290 |
| Multilingual specialist alone | 52.43 | 0.385 | 71.39 | 0.341 | 50.23 | 0.456 | 94.79 | 0.267 |
| Safety specialist alone | 67.25 | 0.424 | 81.82 | 0.318 | 62.62 | 0.392 | 88.06 | 0.211 |
| Weight average | 68.06 | 0.490 | 88.49 | 0.346 | 61.65 | 0.473 | 99.12 | 0.254 |
| Task arithmetic | 76.90 | 0.353 | 82.34 | 0.279 | 73.62 | 0.311 | 91.63 | 0.151 |
| TIES | 73.09 | 0.423 | 85.74 | 0.310 | 67.22 | 0.415 | 96.92 | 0.200 |
| DARE | 74.41 | 0.353 | 81.24 | 0.273 | 74.85 | 0.296 | 89.67 | 0.154 |
| Consensus TA | 75.68 | 0.398 | 84.40 | 0.304 | 73.60 | 0.352 | 93.91 | 0.165 |
| Localize-and-Stitch | 74.74 | 0.386 | 86.04 | 0.279 | 63.66 | 0.368 | 93.32 | 0.188 |
| RegMean | 76.96 | 0.461 | 90.13 | 0.346 | 71.03 | 0.459 | 101.6 | 0.233 |
| Fisher merging | 60.71 | 0.451 | 86.60 | 0.334 | 71.73 | 0.464 | 100.4 | 0.209 |
| RegMean++ | 76.14 | 0.468 | 89.80 | 0.337 | 70.34 | 0.468 | 102.2 | 0.250 |
| WUDI | 74.13 | 0.413 | 84.38 | 0.321 | 78.74 | 0.428 | 100.5 | 0.223 |
| DOGE-TA | 75.09 | 0.419 | 87.95 | 0.329 | 71.04 | 0.397 | 99.10 | 0.189 |
| AdaMerging | 73.38 | 0.382 | 77.61 | 0.186 | 73.15 | 0.382 | 98.78 | 0.162 |
| RAM | 74.24 | 0.455 | 86.77 | 0.323 | 69.47 | 0.433 | 98.69 | 0.210 |
| Localize-and-Stitch, tuned | 74.99 | 0.387 | 85.81 | 0.280 | 63.74 | 0.368 | 93.09 | 0.187 |
- ① Gemma-2-2B base pool (parent + 5 specialists)
- ② Gemma-2-2B-it pool (parent + 5 specialists)
- ③ Llama-3.2-3B base pool (parent + 5 specialists)
- ④ Llama-3.2-3B-Instruct pool (parent + 5 specialists)
NSM does not reach the published merging methods. On Gemma2-2B it scores 70.58, clearly above the parent (55.29) and the plain weight average (68.06), but below every other published merging method, the strongest being RegMean [8] at 76.96; only the weight average and the Fisher-weighted merge (60.71) are below it. On L3.2-3B the picture is similar: 66.37 against 50.55 for the parent, above the weight average (61.65) and both Localize-and-Stitch rows, and below the remaining merging methods, led by WUDI-Merging [11] at 78.74.
On Gemma2-2B-it and L3.2-3B-Inst NSM is below the unmerged parent: 82.46 against 83.67 on Gemma2-2B-it, and 91.21 against 96.12 on L3.2-3B-Inst. On Gemma2-2B-it it is above task arithmetic (82.34), DARE and AdaMerging, and below the other merging methods; the best there is RegMean [8] at 90.13. On L3.2-3B-Inst only DARE (89.67) among the merging methods is below it, while RegMean++ [9] reaches 102.20.
The closest point of comparison for our method is regression-mean merging, which solves the same functional objective over the full matrix [8]. It is ahead of NSM on every setting: 76.96, 90.13, 71.03 and 101.62 on Gemma2-2B, Gemma2-2B-it, L3.2-3B and L3.2-3B-Inst. Our development measurements, on lineages we built ourselves and on a response-likelihood proxy, had found the span restriction slightly ahead of it on the larger lineage's held-out data (below); the measured results do not bear that out.
How we got here
Our starting diagnosis was that the reference rules treat every update as relative to the target and let every specialist influence every domain. We therefore set out to merge in function space: preserve the parent off-domain and reproduce each specialist on its own domain. All our development was done on lineages we assembled ourselves (a small lineage whose specialists we fine-tuned, a larger lineage of publicly released specialists, a lineage whose parent is the same family's pretrained model with released specialists fine-tuned from it, mixed lineages in which one specialist branches from the pretrained base, and lineages from two further model families), scored by length-normalised response likelihood, for most decisions on held-out training-source data that neither the merge nor its validation step saw. Every number below is our own development measurement; the likelihood figures are on that proxy, where lower is better.
- The full-matrix closed form blew up. Our first implementation solved the functional objective per layer with the full activation covariance. On real fine-tunes it amplified poorly observed directions: task arithmetic reached a mean NLL of 1.74 while the unbounded solve collapsed to 2.34, with updates more than 1,000 times larger than the specialist vectors in some layers.
- Restricting each neuron to the span fixed it. Expressing each output neuron's update in the span of its task vectors turns the inverse into a tiny bounded problem per neuron. After fixing a tensor-index ordering bug, the span merge reached 1.706 against 1.741 for task arithmetic on the small lineage. Strongly shrinking the off-diagonal covariance terms hurt, milder shrinkage was better, and the full covariance was best. On the larger lineage the span merge's held-out NLL of 1.4081 was slightly ahead of regression-mean merging's 1.4105, and with 32 calibration examples it was level with TIES at 1.40663.
- Unbounded strength selection overfitted. Validation first kept choosing the largest strength we offered; on the independent held-out data a validation-selected strength of 4 reached only 1.814 against 1.727 at a fixed strength of 2. We dropped validation tuning, then found on the larger lineage that strength 2 gave back too much in instruction following, multilingual understanding and safety while strength 1 was slightly ahead of the weight average (1.3985 against 1.4009). That is why the global grid is bounded at 2 and includes the parent itself.
- Blind lineage transport failed. On our small mixed lineage, transporting the base-trained specialist added a post-training update about 50 times its own task norm and worsened its own likelihood; on the larger mixed lineage, the base-trained specialist's NLL was 0.409 on its own and 0.505 after transport. The validation gate in the final method rejects transport in both cases.
- Per-domain strengths had to be chosen jointly. Regression-mean merging was much stronger than the span merge on mathematics and coding when the parent was pretrained. Selecting each domain's strength on its own loss did not improve held-out data on the pretrained-parent or small lineage, because gains in mathematics and coding were offset by interference elsewhere (on the second model family it did help); selecting on the mean over domains did, from 1.43218 to 1.40495 on the pretrained-parent lineage. Starting the coordinate pass from the best global strength gave back part of that gain, so the final rule starts from unit strengths and compares with the global choice at the end (1.40558 on the pretrained-parent lineage; 1.39943 against 1.40690 for global strength alone on the larger lineage).
- The output head was worth merging, but gently for a pretrained parent. Merging an untied head improved the larger lineage from 1.39943 to 1.39842, and aliasing a tied head to the embedding matrix to 1.39798. On the pretrained-parent lineage, a full head update worsened the result to 1.42292 from 1.40558; scaling it by 0.25 gave 1.41166 and by 0.1 gave 1.40359, and 0.1 also won under a second calibration sampling (1.40767 against 1.40869 with the head preserved).
- The correction outside the span was nearly discarded on a stale control. The capped correction improved the larger lineage substantially (1.38690 against 1.39798) but worsened the pretrained-parent lineage, and it first appeared to worsen the small lineage too. That comparison was against an older result produced by different code; against a matched run of the current code the correction improved the small lineage (1.73535 against 1.73715). It also improved the third model family slightly (1.60076 against 1.60203), was neutral on the second, and worsened the mixed lineage (1.36743 against 1.36024). The correction is therefore gated to post-trained parents whose specialists all descend directly from the parent.
Several other ideas did not survive. Applying the same quadratic problem to normalisation scales, taking each domain's statistics from its specialist instead of the parent, propagating statistics through a two-pass merge, solving separate problems per input block, a second coordinate pass over the strengths, 50 coordinate sweeps instead of 20, 64 calibration examples instead of 32, 32 validation rows instead of 16 and contexts of 2048 tokens instead of 1024 all either did not help on held-out data or did not justify their cost. Letting the span coefficients extrapolate up to 2 did help the larger lineage, but less than the correction outside the span, which we kept instead. Prompted by a paper on separating task-specific from instruction-following updates [15], we also measured how much of each specialist's update lies along the parent's post-training direction; it was mostly below 0.1% of the update's energy, so we did not project it out. The progressive layer-wise distillation approach to merging, which we read after settling on the functional objective, also matches layer activations to each task's model, but optimises coefficients by gradient; we solve closed-form problems instead.
Limitations
- The measured results are weak. NSM is behind most published merging methods on every setting, and below the unmerged parent on Gemma2-2B-it and L3.2-3B-Inst. Whatever the per-neuron division of the update achieves, it is not reflected in the task's metric on those settings.
- Every design choice was made on a likelihood proxy. The strengths, the transport gate and all our ablations were decided by length-normalised response likelihood. Our development showed the span merge ahead of task arithmetic and, on the larger lineage's held-out data, slightly ahead of regression-mean merging on that proxy; the measured results put regression-mean merging ahead on every setting and task arithmetic ahead on Gemma2-2B, L3.2-3B and L3.2-3B-Inst. The proxy, not the evaluation, is what NSM optimises.
- The selection uses very little data. The global and per-domain strengths and the transport gate are decided on 16 validation rows per domain, and the activation statistics on 32 calibration examples per domain. Our development already showed strength selection overfitting when the grid was not bounded.
- The gates are empirical. The 0.1 head scale for a pretrained parent, the 10% cap and the mean-diagonal ridge of the correction, and the lineage condition under which the correction is applied were each chosen by hand and checked on a handful of development lineages, not derived.
- The method's behaviour depends on free GPU memory. Whether the correction is applied and whether per-domain strengths are searched both depend on how much GPU memory is free at merge time, so the same lineage can be merged differently on different hardware.
- The span cannot extrapolate. With coefficients bounded to , a neuron can never apply more than a specialist's own update; apart from the capped correction, only the strength selection can amplify it, and only uniformly over a domain's component.
- The final file was not fully verified in development.
References
- Mitchell Wortsman, Gabriel Ilharco, Samir Yitzhak Gadre et al. (2022). Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time. ICML.
- Gabriel Ilharco, Marco Tulio Ribeiro, Mitchell Wortsman et al. (2023). Editing Models with Task Arithmetic. ICLR.
- Prateek Yadav, Derek Tam, Leshem Choshen et al. (2023). TIES-Merging: Resolving Interference When Merging Models. NeurIPS.
- Le Yu, Bowen Yu, Haiyang Yu et al. (2024). Language Models are Super Mario: Absorbing Abilities from Homologous Models as a Free Lunch. ICML.
- Ke Wang, Nikolaos Dimitriadis, Guillermo Ortiz-Jimenez et al. (2024). Localizing Task Information for Improved Model Merging and Compression. ICML.
- Yifei He, Yuzheng Hu, Yong Lin et al. (2024). Localize-and-Stitch: Efficient Model Merging via Sparse Task Arithmetic. TMLR.
- Michael Matena, Colin Raffel (2022). Merging Models with Fisher-Weighted Averaging. NeurIPS.
- Xisen Jin, Xiang Ren, Daniel Preotiuc-Pietro et al. (2023). Dataless Knowledge Fusion by Merging Weights of Language Models. ICLR.
- The-Hai Nguyen, Dang Huu-Tien, Takeshi Suzuki et al. (2025). RegMean++: Enhancing Effectiveness and Generalization of Regression Mean for Model Merging. TMLR.
- Enneng Yang, Zhenyi Wang, Li Shen et al. (2024). AdaMerging: Adaptive Model Merging for Multi-Task Learning. ICLR.
- Runxi Cheng, Feng Xiong, Yongxian Wei et al. (2025). Whoever Started the Interference Should End It: Guiding Data-Free Model Merging via Task Vectors. ICML.
- Yongxian Wei, Anke Tang, Li Shen et al. (2025). Modeling Multi-Task Model Merging as Adaptive Projective Gradient Descent. ICML.
- Xiangchi Yuan, Dachuan Shi, Chunhui Zhang et al. (2026). Behavior Knowledge Merge in Reinforced Agentic Models.
- Yifei He, Siqi Zeng, Yuzheng Hu et al. (2025). MergeBench: A Benchmark for Merging Domain-Specialized LLMs. NeurIPS.
- Yan-Lun Chen, Yi-Ru Wei, Chia-Yi Hsu et al. (2025). Layer-Aware Task Arithmetic: Disentangling Task-Specific and Instruction-Following Knowledge. ACL.