# What Is Model Merging?

> What model merging is, how two fine-tuned models become one, where it breaks, and what to test first, explained simply for your AI interview.

**In short:** Model merging combines the weights of two or more fine-tuned models that share one base into a single model, with no new training run. It is quick and cheap, but a merged model can lose skills, so you test it on every job it must still do.

AI and LLM interview question Q304, Fine-tuning and adaptation. Advanced, occasional (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/what-is-model-merging

## Say it in 30 seconds

Model merging takes two or more models fine-tuned from the same base and blends their weights into one model. There is no new training run. The changes from each fine-tune are averaged or sign-checked. It is quick and cheap, but skills can clash and weaken, so I test the merged model on every job it must still do before release.

## Say it in 2 minutes

A fine-tuned model is a base model that got extra training on one job, so its weights, the numbers that hold what it learned, now differ a little from the base. Model merging takes two or more fine-tuned models that share a base and blends their weights into one model. There is no new training run, so it is quick and cheap.

The simplest method is averaging. Each fine-tune's change from the base is a task vector, and the changes are combined onto the base. This needs the models to share one starting point. When two changes push the same weight in opposite directions, a plain average shrinks both, and a skill can get weaker. Newer methods reset the tiny changes and merge only the changes that agree.

Merging differs from an ensemble in one main way. An ensemble runs every model on each request, so you pay for all of them. A merged model is one model, so serving it costs the same as serving one. The catch is that one job can get better while another falls, so each job's test set is the real cost of the method.

A real case: an insurer merges a claims-summary model and a policy Q&A model. Policy answers drop on the test set. I would try a sign-aware merge, give the policy model more weight, rerun both tests, and keep a human check on policy answers until the numbers hold.

## What is model merging, in plain words?

A fine-tuned model is a base model that got extra training on one job, such as reading insurance claims. Its weights, the numbers that hold what it learned, now differ a little from the base. Model merging takes two or more fine-tuned models that share a base and blends their weights into one model, with no new training run.

Picture two senior claims adjusters who each learned one region's files well. Merging is like blending their notes into one handbook. It saves a hire, but a rule from one region can contradict a rule from the other, and the handbook may then get both wrong.

The AI case is the same. A team fine-tunes one model for claims summaries and another for policy questions, then merges them, so one model serves both jobs.

- **Base model:** The pre-trained model you start from. Every fine-tune grows from it.
- **Weights:** The numbers inside a model that store what it has learned.
- **Task vector:** One fine-tune's change: its weights minus the base model's weights.
- **Interference:** Changes that clash in direction, or that are redundant noise, cancel out or corrupt each other in the merged model.

## How are the weights combined?

The simplest method is averaging. Each fine-tune's change from the base is a task vector, and the changes are added or averaged onto the base. The Task Arithmetic paper showed that adding task vectors together can help several tasks at once, and that the vectors can be negated or added like arithmetic.

> "We build task vectors by subtracting the weights of a pre-trained model from the weights of the same model after fine-tuning on a task." (Task Arithmetic paper (ICLR 2023))
>
> "fine-tuned models often appear to lie in a single low error basin" (Model soups paper (ICML 2022))

Averaging needs the models to share one starting point, because each change is measured against it. The model soups paper averaged models fine-tuned with different settings, and accuracy often went up with no extra cost at inference. The authors write that fine-tuned models often appear to lie in a single low error basin.

The rule that matters for these methods: every change is measured against one shared base, so they merge fine-tunes of the same model, and changes from different bases do not line up.

*Diagram, Two fine-tunes from one base, merged: Both fine-tunes start from one base and learn their own job. The merge step combines the two sets of changes into one model. Test that model on both jobs before release.*
1. The base model goes into the claims fine-tune.
2. It goes into the policy fine-tune too.
3. The claims changes go to the merge step.
4. The policy changes go to the merge step as well.
5. The merge gives one model, which must then be tested on both jobs.

## Why can a merged model lose a skill?

Two fine-tunes can change the same weight in opposite directions. A plain average then shrinks both changes, and each skill can weaken. The TIES paper (NeurIPS 2023) says earlier merging methods lose information from two sources: redundant parameter values, and disagreement on the sign of a parameter's values across models.

> "existing merging methods often ignore the interference between parameters of different models, resulting in large performance drops when merging multiple models" (TIES-Merging paper (NeurIPS 2023))

TIES, a published merge method, fixes this in three steps. This is a simplified version of its idea, not the full method:

1. **Reset the small changes:** Tiny changes are mostly redundant, so set them back to the base value.
2. **Elect a sign:** For each weight, the direction with the bigger total push wins.
3. **Merge only what agrees:** Average only the changes that point the elected way.

The DARE method (drop and rescale, accepted at ICML 2024) takes another route: it randomly drops a share of the changes, whatever their size, and rescales the ones it keeps. Its authors say fine-tune changes are small and highly redundant, that DARE can eliminate 90% or even 99% of them, and that it can merge task-specific models into one with diverse capabilities.

Here is a small, simplified sign-aware merge. Sign-aware means the merge checks each weight's direction before it averages. The numbers are made up. Real models have far more weights, but the idea is the same.

```python
base = [0.50, -0.20, 0.10, 0.80, 0.00, -0.40]
claims = [0.60, -0.35, 0.10, 0.75, 0.01, -0.10]  # tuned on claims summaries
policy = [0.45, -0.05, 0.12, 0.90, 0.00, -0.70]  # tuned on policy Q&A

# A task vector is the change one fine-tune made to the shared base.
tv_claims = [round(f - b, 2) for f, b in zip(claims, base)]
tv_policy = [round(f - b, 2) for f, b in zip(policy, base)]

# Plain average: every change counts, even when the two teams pushed opposite ways.
naive = [round(b + (a + p) / 2, 2) for b, a, p in zip(base, tv_claims, tv_policy)]

def sign_aware(base, changes, keep=0.05):
    out = []
    for i, b in enumerate(base):
        vals = [c[i] for c in changes if abs(c[i]) >= keep]  # 1. ignore tiny changes
        if not vals:
            out.append(b)
            continue
        up = sum(v for v in vals if v > 0)
        down = -sum(v for v in vals if v < 0)
        sign = 1 if up >= down else -1  # 2. the bigger push picks the direction
        agree = [v for v in vals if v * sign > 0]  # 3. keep only changes that agree
        out.append(round(b + sum(agree) / len(agree), 2))
    return out

merged = sign_aware(base, [tv_claims, tv_policy])
print("claims change:  ", tv_claims)
print("policy change:  ", tv_policy)
print("plain average:  ", naive)
print("sign-aware:     ", merged)
```

Output:

```text
claims change:   [0.1, -0.15, 0.0, -0.05, 0.01, 0.3]
policy change:   [-0.05, 0.15, 0.02, 0.1, 0.0, -0.3]
plain average:   [0.53, -0.2, 0.11, 0.83, 0.01, -0.4]
sign-aware:      [0.6, -0.05, 0.1, 0.9, 0.0, -0.1]
```

Read the last two lines. For the first weight, the claims change (+0.1) and the policy change (-0.05) disagree. The plain average gives 0.53, but the sign-aware merge keeps the bigger push and gives 0.6. For the last weight, the two changes are equal and opposite. This simple rule breaks the tie toward the positive change, here the claims side. The second weight is a tie too, and it goes to the policy side. A real method needs a tie rule too, which is one more reason to test.

## How is merging different from an ensemble, and what does it cost?

An ensemble is a set of models that all answer, and their answers are combined. Serving means running the model for users.

- **Ensemble: Run every model.** Each request goes to all the models, and their answers are combined. You pay for every model on every call.
- **Merge: Combine once.** The changes are combined ahead of time, so serving looks like one model. The cost is paid once, during the merge and its tests.

*Diagram, Two ways to use two models: An ensemble and a merge both give one answer from two models. An ensemble pays for both models on every request. A merge pays once, before serving, and the served model is one model.*
1. Each request is sent to every model, then the answers are combined.
2. The merged model is the only one that gets the request.

The catch: a merged model can match one job and fall on another, so each job's test set is the real cost of merging.

Merging still needs inputs. The DARE authors stress that the method needs no retraining or GPUs, but you still need the source fine-tunes, a test set for each job, and time to check the result.

A worked case with made-up numbers. An insurer has a claims-summary model and a policy Q&A model, both fine-tuned from one base. The merged model still gets 9 in 10 claims summaries right on the team's test set, but policy answers fall from 9 in 10 to 7 in 10. The team tries a sign-aware merge and gives the policy model more weight. Policy answers come back to 8 in 10, still below the single model's 9 in 10. So the team ships with a human check on policy answers, and that check is the cost of the trade-off.

### How would you merge two team models safely?

1. **Check the base:** Confirm both fine-tunes come from the same base model, with the same design. For these methods, changes from different bases can't be added together.
2. **Score each source first:** Test each fine-tune on its own job, so you know the starting line.
3. **Try plain averaging first:** If a job drops, try a sign-aware method and compare again.
4. **Test every job again:** Run every source test set on the merged model. A drop must be fixed, or covered by a human check you have agreed on, before release.
5. **Keep the sources:** Keep both fine-tunes, so you can roll back or merge again with other weights.

Merging often works, but when it fails, the drop can go unnoticed. The test is what makes a merge safe.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain definition: combine fine-tuned models from one base into one model, with no new training run.
- [ ] Task vectors: each fine-tune's change from the base.
- [ ] The same-base rule, and why it matters.
- [ ] Interference: why a plain average can lose skills, and one fix.
- [ ] Merge versus ensemble: one model's serving cost against several.
- [ ] Testing every source job, because the drop can go unnoticed.

**Common traps**

- Trap: "Merging two models gives you both skills for free." Better: Each skill can weaken. Merging is a guess until you test every job it must still do.
- Trap: "You can merge any two models." Better: For these methods, only fine-tunes of the same base have changes you can combine.
- Trap: "Merging is always cheaper than training." Better: It skips a training run, but you still pay for the source fine-tunes and the tests.

## Can you spot the problem?

**Spot the problem:** A team merges two fine-tunes for its support assistant. Which plan step is the risk?

A. Both fine-tunes start from the same base model and design.
B. Merge the weights, then run every source task's test set.
C. The support-ticket test passes after the merge, so we ship it today.
D. Keep both fine-tunes, so the merge can be redone with other weights.

**Answer:** C. One job passing says nothing about the others. A merge can lose a skill quietly, so every source test set runs before release.

**Quick check:** Two fine-tunes change the same weight in opposite directions. What does the sign-aware merge in the code above do?

A. It adds both changes in full, so each push counts.
B. It picks the direction with the bigger total push and averages only the changes that agree with it.
C. It drops the weight and keeps the base value every time.
D. It doubles the smaller change so both sides count the same.

**Answer:** B. The bigger push picks the direction, and only matching changes are averaged. That stops the two teams' changes from cancelling each other out.

## Can you answer these from memory?

**Flash cards**

- **What is model merging?** Combining fine-tuned models from one base into one model, with no new training run.
- **What is a task vector?** One fine-tune's change: its weights minus the base model's weights.
- **Why must the base match?** Changes are measured against one shared base, so they only add up within it.
- **What is interference?** Two models' changes push the same weight in opposite directions and cancel.
- **Merge or ensemble?** Merge: one model, one serving cost. Ensemble: every model runs on each request.
- **Is a merge safe to ship?** Not without tests: run every source job on the merged model first.

## Likely follow-up questions

- Q300 How do you evaluate a fine-tuned model? https://designervenkat.online/interview/ai/how-do-you-evaluate-a-fine-tuned-model
- Q296 What is catastrophic forgetting? https://designervenkat.online/interview/ai/what-is-catastrophic-forgetting
- Q303 How do you serve many LoRA adapters? https://designervenkat.online/interview/ai/how-do-you-serve-many-lora-adapters
- Q305 Prompt/prefix tuning vs LoRA? https://designervenkat.online/interview/ai/prompt-prefix-tuning-vs-lora
- Q293 What is distillation? https://designervenkat.online/interview/ai/what-is-distillation
