Soft Computing project · Thapar Institute of Engineering & Technology · Jul–Dec 2026

Evolving a merge recipe for Hindi math reasoning

We combine two 1.5-billion-parameter language models into one, with no training, by mixing their weights layer by layer. A genetic algorithm searches for the mixing weights, using accuracy on Hindi GSM8K word problems as its fitness. This is a small-scale reproduction of Akiba et al., Evolutionary Optimization of Model Merging Recipes (Sakana AI, 2024).

TeamNaman Kundra · 102315069Abhyuday Mishra · 102315138
Submitted toDr. Mayank AgarwalDept. of Computer Science & Engineering
The GA's best recipe: 60 genes
Top row: weight on the Instruct parent. Bottom row: weight on the math parent. Columns: embeddings, layers 0–27, final norm. 02
26.0%Best test accuracy, from a plain 50/50 average of the two parents
+4.0 ptsGain from merging over the better parent (22.0%)
39.1% → 21.2%CMA-ES recipe: fitness during search, then on unseen test problems
r = −0.05Correlation between search fitness and validation accuracy, 30 candidates
1 · The idea

Two fine-tunes of one base model, merged by weighted task vectors

Both parents were fine-tuned from the same base model, so their weights are still close to the base. Each parent's difference from the base (its task vector) carries what it learned. We add both task vectors back onto the base, with a separate weight for every layer group.

Parent A · generalQwen2.5-1.5B-InstructMultilingual, follows instructions, often answers in Hindi
+
Parent B · mathQwen2.5-1.5B-GRPO-MATHGRPO reinforcement learning on MATH, answers in English
→
ChildMerged modelScored on Hindi GSM8K (bingbangboom/gsm8k-hindi)
θg = baseg + · (θA,g − baseg) + wB,g · (θB,g − baseg)

The chromosome

Group g is the embeddings, one of the 28 transformer layers, or the final norm: 30 groups. Two parents × 30 groups = 60 real-valued genes, each in [0, 2]. A weight above 1 scales a task vector up.

Base model: Qwen/Qwen2.5-1.5B. Math parent: sunblaze-ucb/Qwen2.5-1.5B-GRPO-MATH-1EPOCH.

The fitness function

Build the merged model on the GPU, ask it 64 Hindi GSM8K training problems with greedy decoding (at most 512 new tokens), and count how many final answers match. One evaluation takes about 90 seconds on a Kaggle T4.

Final comparison: 250 held-out test problems, 1024 new tokens.

2 · The genetic algorithm

Written from scratch, compared against CMA-ES and random search

Every optimizer got the same budget of 170 fitness evaluations, with a population of 16. The demo below runs the same GA operators on a 2-gene toy problem (the Rastrigin function), so you can watch selection, crossover and mutation work.

ComponentOur choice
Chromosome60 real-valued genes in [0, 2]
Initial populationBoth parents, their 50/50 average, the rest uniform random
Selection3-way tournament
CrossoverBLX-α blend crossover, α = 0.3, rate 0.9
MutationGaussian, per-gene rate 0.15, σ = 0.15 decaying 5% per generation
ElitismBest 2 kept unchanged
Budget170 fitness evaluations (about 4.5 hours on one T4)

Live demo: our GA on Rastrigin

Each dot is one individual. Lighter ground is better; the global optimum is the ring at the centre, surrounded by many local optima. With σ-decay on (our setting), the population's diversity collapses and it often settles on a local optimum, as our real run did at generation 9. Turn decay off, or use a population of 48, to compare.

0Generation
–Best f (0 is optimal)
–Diversity (mean σ)

Diversity over generations (mean standard deviation of the genes).

4 · Evolved recipes

What each optimizer's best merge looks like, layer by layer

Blue cells take less than the full task vector, white cells take exactly 1, red cells amplify it up to 2×. A uniform 50/50 average would be a flat row of 0.5 for both parents.

01→ 2

5 · Held-out test: 250 unseen problems

Merging beats both parents. Evolved recipes do not beat simple merging.

Whiskers show ±1 standard error (about ±2.7 points at n = 250). The evolved recipes looked best during search and fell furthest on the test set.

Test accuracy

Search set vs test set

Hollow dot: accuracy on the 64 search problems. Solid dot: accuracy on the 250 test problems.

Fixed merges barely move between the two sets. The higher a recipe's search score, the larger its drop: GA −10.4, random −15.9, CMA-ES −17.9 points.

How certain? Exact McNemar test, paired on the same 250 problems

ComparisonOnly first rightOnly second rightp
50/50 average vs Instruct (A)35150.007
50/50 average vs GRPO-MATH (B)25150.15
50/50 average vs GA26170.22
50/50 average vs CMA-ES25130.07
50/50 average vs random search29180.14
GA vs CMA-ES20170.74

Only "merging beats the Instruct parent" is significant at 5%. All three evolved recipes score below the average, but no single gap is significant.

6 · Follow-up experiment: re-ranking on a validation set

Search fitness carries no information about unseen accuracy

We took each search's 10 best candidates and scored them on 250 fresh validation problems. If the searches had found better recipes, the points would rise to the right. They do not.

Re-picked winners on the test set

SearchOriginal pickRe-picked

Re-ranking helped CMA-ES and hurt the other two. No re-picked winner reaches the plain 50/50 average (26.0%). With fitness noise of about ±5.4 points at n = 64, the optimizers were fitting noise: the winner's curse.

7 · Answer explorer

Read what each model actually wrote

All 250 test problems, with the raw output of all nine models from our test run. Pick a filter to find the interesting cases.

–
Loading 250 test problems…
8 · A negative result: not every pair can be merged

The official Qwen2.5-Math model moved too far from the base

Our first choice of math parent was Qwen/Qwen2.5-Math-1.5B-Instruct. Every merge with it collapsed into repeated tokens. Measuring each task vector's size relative to the base weights showed why.

Instruct GRPO-MATH (used) Official Qwen2.5-Math (rejected)

Relative task-vector size ‖θk − base‖ / ‖base‖ per parameter group, log scale. The red band is the official Math model's range across layers (0.53–1.41).

Why it fails

A light fine-tune changes about 1% of the weights, so all three models still sit in one low-loss region and interpolating between them is safe. Qwen2.5-Math went through large-scale continued pretraining: its task vector is about as large as the base model itself, and it also uses a different RoPE base (10,000 vs 1,000,000).

Weights (Instruct, Math)Correct of 8
(1, 0.1)2
(1, 0.25)0, repeated tokens
(1, 0.5)0, repeated tokens
(0.5, 1)0

Lesson: check a pair before searching. python -m evomerge.diagnose reports these sizes for any two models.

9 · Takeaways

What we learned

Merging works

With zero training, a uniform merge scored 26.0% against 22.0% and 18.0% for the parents. It also solved problems neither parent could, partly by reading the Hindi question and answering in shorter English steps.

Evolution fit the noise

A fitness measured on 64 problems has about ±5.4 points of noise. The best of 170 noisy scores is mostly the luckiest candidate. Search gains of +8 to +14 points vanished on unseen data.

CMA-ES explored better

Our GA's σ-decay, a population of 16 and elitism of 2 made it collapse at generation 9. CMA-ES keeps adapting its step size, which is why the original paper uses it. On test, the two tie.

Check parents first

Merging needs light fine-tunes of a shared base. A model with heavy continued pretraining cannot be interpolated with its sibling.

Next steps with more compute

  • A fitness set of 500+ problems, so its noise is smaller than the effects being searched for
  • A lower-dimensional genome, e.g. 2 parents × 4 layer blocks instead of 2 × 30
  • A GA without σ-decay, or with restarts when diversity drops
  • The paper's data-flow-space merging, which reorders layers instead of mixing them