0:00Intro: MOFUSA Tech Academy
Welcome to MOFUSA Tech Academy. Beyond learning, towards mastery.
0:09Can you merge two fine-tuned models?
Brightcart now has two fine-tuned versions of the same base model: one that writes in the Brightcart voice, and one that routes tickets accurately. Dev wants a single model that does both. Must he train again from scratch? Surprisingly, there's another option: combine the models by doing arithmetic directly on their weights. It's called model merging, and sometimes it works remarkably well, and sometimes the skills cancel each other out. Today: training on several tasks at once, merging models, and the practical knobs that matter most when fine-tuning.
0:48Where this fits in the course
Season Five, Module Nineteen, final stop: multi-task fine-tuning, model merging, and fine-tuning tactics.
0:59Multi-task fine-tuning: sequential vs mixed
One way to get a model with several skills is to train on several tasks. If you train one after another, voice first, then routing, the model tends to forget the first skill while learning the second: catastrophic forgetting again. Mixing the tasks together in one training run, with the examples shuffled, largely avoids that, and the tasks can even help each other. The downside: you need all the data at once, you have to balance the mixture carefully, and every time you want to add or change a skill, you retrain.
1:35Model merging: averaging weights
Model merging combines models directly, without more training. It only makes sense for models fine-tuned from the same base model, with the same architecture and starting weights. The simplest version: average the corresponding weights. With three toy weights, the base is zero point one, minus zero point four, zero point eight. The voice model moved to zero point two, minus zero point five, zero point nine. The router moved to zero point four, minus zero point three, zero point seven. Their average is zero point three, minus zero point four, zero point eight.
Why might averaging work at all? Models fine-tuned from the same starting point often end up in the same broad valley of the loss landscape, so the points between them can be good too. Researchers have reported that averaging several fine-tuned models can sometimes outperform each of them alone.
2:34Task vectors and task arithmetic
A more powerful view uses task vectors. A task vector is what a fine-tune changed: the fine-tuned weights minus the base weights. For the voice model, that's zero point one, minus zero point one, zero point one. For the router: zero point three, zero point one, minus zero point one. Task arithmetic then builds a new model by adding task vectors to the base, each scaled by a chosen strength. Add both, at full strength, and we get zero point five, minus zero point four, zero point eight. You can also scale a task vector to make a skill stronger or weaker, or even subtract one to reduce a behaviour, with care.
3:20Interference: when skills cancel out
But look closely at the result. Compared with the base, the second and third weights haven't moved at all. Why? On the second weight, the voice fine-tune moved it down by zero point one, and the router fine-tune moved it up by zero point one. They cancel. The same happens on the third weight. Both models' changes there are simply lost. This is called interference, and it's why naive merging can produce a model that's worse at both tasks. Researchers have developed smarter merging methods. One idea: trim away each task vector's tiny changes, which are mostly noise, keeping only its largest updates.
Another: for each weight, decide which direction has the stronger combined push, and keep only the updates that agree. Methods like these reduce interference considerably. Whatever method you use, evaluate the merged model on every task it's supposed to do, plus general abilities and safety. Merging can fail quietly.
4:24Combining LoRA adapters
With LoRA adapters, you have similar choices. You can keep separate adapters and switch between them for each request, merge them by adding their low-rank updates, with the same interference risks, or train a single adapter on a mixture of both tasks. For Brightcart, the router is already a separate, small step in the prompt chain from episode sixty-two, so the simplest and safest option is to keep two adapters and switch between them. Merging can be revisited later, if serving cost or speed demands it.
5:01Fine-tuning tactics: the knobs that matter
A few practical knobs matter most when fine-tuning. Start from the strongest base model that fits your constraints, usually an instruction-tuned one for chat tasks. Use LoRA or QLoRA first, and full fine-tuning only if needed. The learning rate is the most sensitive setting: too high and the model forgets and becomes unstable, too low and nothing changes, so use a warm-up and a decay. A small number of passes through the data is often enough; watch the validation loss for overfitting. If memory is tight, accumulate gradients over several small batches to simulate a bigger one.
Compute the loss only on the responses, and use exactly the same chat template in training and in production. Save checkpoints, and evaluate on your scorecard regularly during training, not just the loss. Mature open-source libraries handle most of this for you. Keep in mind that details like these change fast. They were correct when this video was published, so treat them as a snapshot, not a permanent fact.
6:10Try it yourself: averaging is task arithmetic
Take the base model, and add half of the voice task vector and half of the routing task vector. What do you get? Pause and compute each weight. Zero point three, minus zero point four, zero point eight: exactly the simple average of models A and B from earlier. That's no coincidence. Averaging two models fine-tuned from the same base is the same as adding half of each skill to the base. Task arithmetic just lets you choose different amounts of each.
6:48Try it yourself: resolving conflicts by sign
Let's add a third skill, catalogue tagging, and merge all three. Simply adding the task vectors piles up large, partly conflicting pushes. A smarter approach votes on each weight. For the first weight, all three skills push upwards, so we average them: zero point two. For the second, two skills push down and one pushes up, but the downward push is stronger, so we keep only the downward values and average them: minus zero point two. For the third, upward wins: zero point one five. Conflicts are resolved by majority direction instead of cancelling each other out.
7:28Mixing tasks in one training run
Instead of merging, you can train on several tasks at once. Brightcart has fifteen hundred voice examples, six hundred routing examples and three hundred extraction examples, so extraction makes up only one eighth of the data. The model might under-learn it. Common fixes: repeat the smaller task's examples more often, or give its loss more weight. Then check each task's score separately, because an improvement in the overall average can hide a task that got worse.
8:01Try it yourself: batches and gradient accumulation
Brightcart's combined dataset has two thousand four hundred examples. The GPU only fits four at a time, so gradients from eight small batches are added up before each update, a trick called gradient accumulation. That's an effective batch of thirty-two. How many updates per pass through the data? Pause.
Two thousand four hundred divided by thirty-two: seventy-five updates. Gradient accumulation lets a small-memory card behave as if it were training with a much bigger batch, at the cost of more time per update.
8:41The fine-tuning knobs, in order of importance
Fine-tuning has many settings, but they're not equally important. Data quality and the task mix matter most. Then the learning rate, usually with a warm-up and a gradual decay; LoRA often uses a larger rate than full fine-tuning. Then the number of passes over the data, often just one to three. Then LoRA's rank and targets, the batch size, and the maximum sequence length. Change one knob at a time, log every run, and let the validation results decide.
9:15Pause & Predict: will these models merge?
Will these merge well? Two LoRA fine-tunes of the same base model, on different tasks. A fine-tune of one base model with a fine-tune of a completely different base model. Two fine-tunes of the same base, one trained much harder than the other. Pause.
The first is promising, though you must test it. The second won't work at all: models with different starting points don't have aligned weights, so averaging them produces nonsense. The third is risky: the heavily trained model's large task vector may swamp the other. Merging works because models share a starting point; without one, there's nothing to merge.
10:03How to evaluate a merged model
A merged model is a hypothesis, not a result. Brightcart scores the merged model on each task's own test set, compares it with each specialist, and re-runs the safety tests. If it matches the specialists, that's one model to serve instead of three. If one task drops beyond the noise, the team can adjust the scaling factors, or simply keep that task as a separate adapter. The evaluation decides.
10:32Merging, adapters or multi-task: which when?
So which approach when? If you know all the tasks up front and have the data together, train them at once. If different teams trained skills separately from the same base, try merging: it's cheap, and needs no extra training. If tasks change often, or must be kept isolated, like a style for one particular partner, keep separate adapters and swap them per request. Each option trades simplicity, flexibility and quality differently.
11:03Pause & Predict: averaging LoRA adapters
Here's a subtle trap. Two tiny adapters each produce a weight update from a pair of small matrices. To merge them, can we average their B matrices, average their A matrices, and multiply? Or must we average the updates themselves? Pause and test it on the numbers.
Averaging the updates gives a half on the diagonal and zeros elsewhere. Averaging the factors first gives a quarter everywhere, including cross-terms that neither adapter ever learned. They're completely different. So when merging LoRA adapters, combine the actual weight updates, the products, not the small matrices separately.
11:49Model soups
Merging has a cheerful cousin called the model soup. Fine-tune the same task several times from the same base, with slightly different settings, and instead of keeping only the best run, average their weights. Researchers reported that these averages can match or beat the best single run, and handle unfamiliar inputs more robustly, at no extra cost when serving. It works when the runs stay close to one another, and, as always, the evaluation has the final word.
12:21Myth vs Fact: does merging always work?
Myth: merging two good models always gives a model that's good at both. Fact: conflicting changes can cancel each other out. In our tiny example, both skills were lost on two of the three weights. Use merging methods that handle interference, and always evaluate every task.
12:42One-minute recap
Let's recap. Training on tasks one after another causes forgetting, while mixing tasks in one run lets them share skills. Models fine-tuned from the same base can be merged by averaging, or by adding task vectors, the changes each fine-tune made. When those changes conflict, they cancel, so trim small updates, agree on directions, and evaluate every task. And the knobs that matter most: a strong base, efficient methods first, a careful learning rate, few epochs, and evaluation throughout training. One sentence to remember: a fine-tune is a direction, and merging adds directions, so watch for ones that point against each other.
13:30Next: dataset engineering
Mission complete. Brightcart keeps separate voice and routing adapters, switching between them as needed, with a documented fine-tuning recipe and an understanding of when merging helps, and when it hurts. That completes Module Nineteen, fine-tuning. But every fine-tune is only as good as its data. Brightcart has forty thousand old support conversations: which are good enough to learn from? Next, dataset engineering, starting with data quality, coverage and quantity. See you on the map.