← All posts
Self-Improving AI · Consumer Hardware

A tiny model that
teaches itself.

No teacher model. No human feedback. No GPU cluster. A 0.8B parameter model that gets better at coding by studying its own mistakes — running entirely on a MacBook Air with 6GB of RAM.

16 → 28 tests passing 6GB RAM 0 → 3 on hardest problems MacBook Air M4
↓ scroll
The Idea

What if a model could learn from its own wrong answers?

Not from a dataset someone else built. Not from a bigger model showing it the right way. Just from the gap between what it tried and what actually worked.

This is how humans learn to code. You write something, run it, see the error, understand why, fix it. The fix is more valuable than any tutorial — because it's specific to exactly the mistake you made.

TinyForge applies the same idea to a language model. The model tries to solve a coding problem. It fails. It sees exactly what failed — which test, what input, what it returned, what was expected. It tries again. When the second attempt is better, we extract that weak→strong pair and train on it. The model literally teaches itself from its own failures.

Self-play works for Go (AlphaGo). It works for math (AlphaProof). Here it works for code — on hardware anyone can afford.

The Loop

Five steps. Repeating forever.

Each coding task runs through an evolutionary loop before training. The model isn't just trying once — it's competing against itself.

🌱
Seed
Generate multiple candidate solutions
→
🧪
Test
Run each against test cases in a sandbox
→
💥
Fail
Capture exact failure: input, expected, got
→
🔀
Mutate
Generate new attempts using the failure as context
→
🎓
Learn
Pair weak solution with strong. Train on the difference.

The key is step three. Most systems just score a solution as "right" or "wrong." TinyForge captures the specific failure: input=[15] expected='FizzBuzz' got='Fizz'. That evidence is far more useful than a score. The model knows exactly what to fix.

What the model learns

Not answers. Repair patterns.

This is the most important insight. The model isn't trained on the correct solution. It's trained on the transformation from broken to working.

✗ Weak solution — 3/6 tests
def fizzbuzz(n): if n % 3 == 0: return "Fizz" if n % 5 == 0: return "Buzz" return str(n)
Fails: n=15 → "Fizz" (expected "FizzBuzz")
✓ Strong solution — 6/6 tests
def fizzbuzz(n): if n % 15 == 0: return "FizzBuzz" if n % 3 == 0: return "Fizz" if n % 5 == 0: return "Buzz" return str(n)
All 6 tests pass

The training prompt is: here's the broken code, here's the test failure, fix it. The training target is the working code. The model learns: when I see this kind of failure, I should fix it like this. It learns how to debug, not just what the answer is.

That's why it generalises. Memorising answers doesn't transfer to new problems. Learning repair patterns does.

Results

Numbers from a MacBook Air.

All tests are on fresh holdout slices the model never saw during training. No cherry-picking.

SetupPublic TestsHidden HumanEval+Change
Base model, single-pass
16/50
2/8 baseline
🔥 Repair-trained, single-pass
28/50
4/8 +75%
Base model + evolutionary search
42/50
5/8 +163%
🔥 Repair-trained + evolutionary search
44/50
6/8 +175%

The 75% single-pass improvement came from training on just 13 self-generated repair pairs. Thirteen examples. No human labelling. No external data.

The hard problems tell the real story.

SetupPublic TestsHidden HumanEval+
Base model, single-pass 28/70 0/8
🔥 Repair-trained + search + feedback 53/70 3/8

On the hardest unseen problems, the base model scored zero. After repair training: three. Not magic. But real — on a laptop.

Hardware

The whole thing fits on a MacBook Air.

6GB
Peak RAM
3min
LoRA training
0.8B
Parameters
13
Training pairs needed
🔥 tinyforge
A model teaching itself to code better.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📝 BEFORE (single-pass baseline)
[1/5] fizzbuzz ............ 4/6
[2/5] valid_parens ........ 2/5

🧬 EVOLVING (search + feedback)
[1/5] fizzbuzz ............ 6/6 ✓ (gen=2)

🎓 TRAINING on 8 self-generated repair pairs
Mixing with 40 rehearsal samples...
Training for 20 iterations...

🏁 AFTER (trained model + search)
Before: 12/26 ████░░░░░░ 46%
Search: 22/26 ████████░░ 85%
After: 24/26 █████████░ 92%
What We Discovered

Six things that surprised us.

Finding 01

Repair beats final-answer training

Training on "here's the broken code, fix it" works better than "here's the problem, here's the solution." Small models learn fixing patterns, not memorised answers — and patterns transfer.

Finding 02

Evolutionary search is the biggest jump

Generating multiple attempts, testing them, keeping the best, mutating using failure feedback — this single mechanism accounts for more of the gain than fine-tuning alone.

Finding 03

Specific failure feedback matters a lot

expected='FizzBuzz' got='Fizz' helps more than 3/6 tests passed. Evidence beats scores every time.

Finding 04

The model learns to be a repair partner

The biggest overnight finding: the trained model writes much better code inside the feedback loop. It didn't just learn solutions — it learned how to respond to failure.

Finding 05

More compute ≠ better results

Wider search, colder sampling, extra generalisation layers — we tried them. They didn't reliably help. The simple loop outperformed every elaboration.

Finding 06

Hard problems benefit most

On easy problems where the base model already does well, the gains are small. On the hardest unseen problems — where it scored zero — repair training plus search produced real, measurable improvement.

The Bigger Picture

Code was just the test case.

The loop is simple: generate something → check if it's right → learn from what went wrong → try again. That works anywhere you can measure the output.

🗃️

SQL queries

Run the query, check if results match expectations.

test = query output
🔢

Math proofs

Verify the proof mechanically with Lean or SymPy.

test = proof verifier
🧪

Drug molecules

Check binding properties via physics simulation.

test = simulation score
📣

Ad copy

A/B test it. Did people click? Click rate is automatic feedback.

test = click rate
📧

Email outreach

Did they open? Did they reply? Open rate = the verifier.

test = reply rate
🤖

Robotics

Run the policy in simulation. The physics engine tells you if it worked.

test = simulation score

If you can score the output — even roughly — the model can learn from its own mistakes. No labelled dataset. No expert in the loop. The model makes its own training data by failing and fixing. Your data never leaves your machine.

The Real Question

If a 0.8B model can do this on a laptop — what happens at scale?

The technique is the contribution, not the model size. A 0.8B model teaching itself to code better is interesting. A 70B model with a real cluster doing the same thing might be something else entirely.

The hardware barrier to this kind of research just dropped to zero. A MacBook Air and an afternoon is enough to start.