Concepts / Model Merging

Model Merging

Full finetuning updates every weight, and its memory cost grows with the number of parameters being trained, which made it impractical as models grew.

  • Programming

The Every-Weight Assumption

Finetuning is the step where a pre-trained model is adapted to a specific task or dataset. Many learners picture it as a full retraining run in which every number inside the model is nudged toward the new goal. That picture is accurate for the early days of finetuning, but for large models it is usually the wrong one. This article starts from that picture, shows why it breaks down, and then traces the efficient alternatives that lead into model merging.

What do you think happens?

Can a pre-trained model only be adapted to a new task if every one of its weights is updated?

  • Yes, every weight must be updated

  • No, there are efficient alternatives that update fewer values

Reveal answer
Answer:

No. Efficient alternatives exist that do not update every weight.

The common belief is that a model can only be adapted if every weight is updated. The source presents full finetuning as one option, not the only one, and builds up parameter-efficient methods as alternatives. Keep your prediction in mind as you read the next section.

How Full Finetuning Consumes Memory

Finetuning updates a pre-trained model's weights so that the model fits a specific task. In the early days of finetuning, the process looked much like pre-training, because both updated the model's entire set of weights. As models grew larger, updating everything became impractical for most practitioners.

The reasoning is a simple chain. Each parameter that gets updated during finetuning costs memory, so the more parameters a run must update, the more memory it needs. As models grew, that cost grew with them. The source notes that most practitioners do not have enough hardware, time, and data to finetune a foundation model in full.

Worked example

Comparing Two Finetuning Runs by the Parameters They Update

Two hypothetical runs adapt the same pre-trained model. Run A updates a small number of parameters. Run B updates a much larger number of parameters. Which run needs more memory, according to the chain described in the source?

  1. 1
    Identify the cost driver

    The source ties finetuning memory to the number of parameters being trained. Each updated parameter costs memory.

  2. 2
    Compare the two runs

    Run B updates far more parameters than Run A, so by the same chain it needs more memory.

  3. 3
    Consider the scale of the model

    The source says this cost grew as models grew. A run that updates every weight of a very large model sits at the expensive end of this comparison.

Result

Run B needs more memory. Full finetuning, which updates every weight, is the most expensive end of this scale, and that is why it became impractical for most practitioners.

Three Levers Against the Memory Bottleneck

Many later techniques share one motivation: reach strong performance while keeping the memory footprint small. Three named approaches attack this problem, and the most useful way to read them is by the lever each one pulls. One lever changes how many values are trained. The other changes how much space each value takes up. The diagram below places the three approaches against the shared bottleneck.

PEFTfewer trainable parametersFinetuning memorycostthe shared bottleneckPartial finetuningsubset of parametersupdatedQuantized trainingfewer bits per valuetargetstargetstargets
Which lever does each method pull against the finetuning memory bottleneck, and how do the three differ?

How LoRA Adapts a Model

LoRA, which stands for Low-Rank Adaptation, is a PEFT technique. It adapts a pre-trained model by updating low-rank matrices rather than the model's full set of weights. The adjustment it learns is expressed compactly, using low-rank matrices, and it is best understood as a compact way of expressing an adjustment to a model rather than as a separate model built from scratch.

Original weightspre-trained model, notfully updatedCompact adjustmentexpresses a change to themodelAdapted modelpre-trained model plusadjustmentLow-rank matricessmall trainable piecesexpressed asapplied toadapted from
How do the low-rank matrices relate to the original weights, and how does the adjustment combine with the pre-trained model?
Key point

LoRA is described in the source as parameter-efficient, data-efficient, and modular. Parameter-efficient means it trains far fewer values than full finetuning. Modular means each adaptation is a separate, self-contained piece that can be served and combined with others. Modularity is the property that matters most for model merging, as the next section shows.

The source also connects LoRA to low-rank factorization, one of the fundamental ideas the chapter draws on. A detailed mathematical treatment is not given in the source material, so treat the low-rank idea as the reason LoRA can be compact and not as a procedure you can carry out from this article alone.

From Several Finetuned Models to One

Once several finetuned models exist, a natural question follows: must each one be deployed separately, or can the useful parts be gathered into a single model? Model merging is the family of techniques built around that question. It combines multiple models into one model intended to work better than the individual models did on their own.

Notice what this definition does not require. It does not say the merged model must be trained from scratch on all the original data. It describes an outcome: one model that replaces several, with the aim that the single model does at least as well, and ideally better, across the work the separate models handled. The inputs to merging are models that someone has already finetuned.

Pre-trained modelstarting point forfinetuningFinetuned model Aadapted for one purposeMerging methodcombines the inputsMerged modelone model replacing severalFinetuned model Badapted for another purposeFinetuned model Cadapted for a third purposefinetuned intofinetuned intofinetuned intoinputinputinputproduces
Where do the weights from each finetuned model go, and how do they combine into a single set of merged weights?
  1. 1
    Start with a pre-trained model and finetune it separately for each purpose, producing several finetuned models.
  2. 2
    Treat each finetuned model as an input to merging. Each one carries the adaptation made for its task.
  3. 3
    Apply a merging method that combines the inputs. The source names TIES and DARE as two such techniques.
  4. 4
    Obtain a single merged model, which is intended to work better than the separate models did on their own.

The material lists several use cases for merging, including on-device deployment and model upscaling. On-device deployment connects directly to the memory concerns from earlier: a single merged model can be easier to store and run on a device than several separate models. The material names these use cases without detailing their procedures, so treat them as the motivations that make merging worth studying.

LoRA connects to this topic through modularity. Because each LoRA adaptation is a self-contained piece, multiple LoRA models are much easier to combine than full finetuned models. That modularity is one reason the idea of combining finetuned models became practical to explore.

TIES and DARE as Two Answers

TIES and DARE are two model merging techniques named in the material. The names themselves give a map of each method before you learn its details. TIES abbreviates TrIm, Elect Sign, and merge, so it lists three operations in order. DARE abbreviates Drop And REscale, so it names two actions followed by the combining of models.

Both methods work with task vectors, and both involve pruning them. A helpful way to hold them together is to treat them as two different answers to one design problem: how should the contributions of several finetuned models be selected and combined? TIES answers by trimming, electing signs, and merging. DARE answers by dropping and rescaling before the models are combined.

AspectTIESDARE
NameTrIm, Elect Sign, and mergeDrop And REscale
Operations named in the nameTrim, elect sign, then mergeDrop, rescale, then combine the models
Pruning of task vectorsYes, the trim stepYes, the drop step
Core design answerTrimming and sign election select contributionsDropping and rescaling adjust contributions before combining
Stated purpose of pruningImproving performanceImproving performance

A high-level comparison of TIES and DARE based only on the names and the material's stated facts. The material does not give their detailed procedures.

Pruning and Model Size Misconceptions

Pruning is the place where most readers' intuition about size goes wrong. The material makes an observation that reverses a common expectation: when task vectors are pruned, they become more sparse, but the finetuned model itself does not. Pruning in these merging methods is aimed at improving performance, not at reducing the size or inference latency of the finetuned model.

What do you think happens?

If the task vectors of a finetuned model are pruned, does the finetuned model become smaller?

  • Yes, pruning shrinks the finetuned model

  • No, the task vectors become sparser but the finetuned model itself does not

Reveal answer
Answer:

No. The task vectors become more sparse, but the finetuned model itself does not change in size.

The source states that pruning in these merging methods targets performance, not the size or inference latency of the finetuned model.

Task vectordense before pruningSparse task vectorafter pruningFinetuned modelbefore pruningFinetuned modelafter pruning, same sizepruned
How does the size of the finetuned model compare before and after its task vector is pruned?
  • Common mistake

    Assuming that pruning task vectors makes the merged or finetuned model smaller

    What it looks like

    A team prunes the task vector and expects the stored finetuned model to shrink on disk.

    Why it fails

    The source says the task vectors become more sparse but the finetuned model itself does not. Pruning is not aimed at shrinking the model.

    Do this instead

    Treat pruning as a way to improve performance. Do not count on it to reduce model size.

  • Common mistake

    Assuming that pruning reduces inference latency

    What it looks like

    A reader expects a pruned merging method to make the model respond faster at inference time.

    Why it fails

    The material explicitly says the pruning is not aimed at reducing inference latency.

    Do this instead

    Look for speed or memory gains elsewhere. In this context, the stated purpose of pruning is performance.

  • Common mistake

    Assuming that merging requires retraining the combined model from scratch

    What it looks like

    A reader thinks a merged model must be trained again on all the original data.

    Why it fails

    The definition of merging describes an outcome, one model that works better than the separate models, and does not require training from scratch.

    Do this instead

    Think of merging as combining existing finetuned models into one, not as a new training run.

  • Common mistake

    Confusing PEFT with quantized training because both reduce memory: PEFT reduces how many values are trained, while quantized training reduces the bits used per value.

Practice: Choosing the Right Lever

MEDIUM

A small team wants to adapt a large pre-trained model to a new task. Their hardware is limited. One option is to update every weight. Another is to update only the layers closest to the output. A third is to keep the full set of values but store each one using fewer bits. For each option, name the lever it pulls (number of values trained or bits per value), name the memory bottleneck it targets, and say which option matches LoRA's approach of updating low-rank matrices.

Hints
  • Ask first whether the option changes how many values are trained or how much space each value takes.
  • Partial finetuning updates a subset of existing parameters, chosen as the layers closest to the output.
  • LoRA is a PEFT technique that adapts a model by updating low-rank matrices instead of the full set of weights.
EASY

Three finetuned models each handle a different purpose. Describe, in order, how their inputs become a single merged model, and state which of the two named techniques (TIES or DARE) has a name that begins with the operation trim and which one begins with drop.

Hints
  • Start from the pre-trained model, then follow each finetuned model as an input to merging.
  • The name TIES lists trim first; the name DARE lists drop first.

Key Takeaways

  • Full finetuning updates every weight, and its memory cost grows with the number of parameters being trained, which made it impractical as models grew.
  • PEFT reduces the number of trainable parameters, while quantized training reduces the bits used per value; both target the same memory bottleneck through different levers. Partial finetuning updates a subset of parameters, often the layers closest to the output.
  • LoRA adapts a pre-trained model by updating low-rank matrices, expressing an adjustment compactly, and is parameter-efficient, data-efficient, and modular.
  • Model merging combines several finetuned models into one model intended to work better than the separate models; TIES stands for trim, elect sign, and merge, and DARE stands for drop and rescale.
  • Pruning in these merging methods aims to improve performance, not to shrink the finetuned model or reduce inference latency.

Related concepts

More concepts starting with M