Weight-space programming · case study

Weight-space programming: fixing a neural network without training it.

The usual way to improve a neural network is to train it on more examples. Weight-space programming tries something else: an AI agent looks inside the trained network, works out what is going wrong, and edits its weights directly. We tested it against classic fine-tuning on a real model, Tesseract's Hebrew text recognizer.

In short
The idea
Weight-space programming means letting an AI agent repair a trained neural network by editing its weights directly, instead of retraining it. The idea comes from Takehi, Teoh, Zhang and Khattab (MIT CSAIL, 2026).
What we did
We gave an AI agent Tesseract's Hebrew text recognizer and 2,000 practice lines, three separate times, and compared its edits with classic training on the same 2,000 lines.
What happened
Errors on modern Hebrew text fell from 4.18% to 2.64% on average (2.29% in the best run). That beat retraining only the network's last layer (3.31%). Classic fine-tuning did better still (1.77%).
Why it matters
Every change came with an explanation you can check, such as why the model swallowed numbers at the start of a line.
A grain of salt
One case study, on a small model of 378,000 weights. Large models may behave very differently.
01 — The idea

What is weight-space programming?

Weight-space programming is a way to improve a trained neural network without training it: an AI agent inspects the network, works out what specific parts of it do, and edits their weights directly.

The term comes from Rikiya Takehi, Jayden Teoh, Alex Zhang and Omar Khattab of MIT CSAIL, in Sparks of Weight-Space Programming: LLMs can natively read & write neural network weights (2 November 2026). They describe it as treating a network's weights "like a program written in a programming language", one that today's AI models can read and write. They present it as a new capability of AI models rather than a finished method. Their logs and edited weights are public.

To see what is new about it, start with the usual way. A trained network is a large table of numbers, its weights. Nobody writes those numbers by hand. Training sets them: show the network many examples, measure how wrong it is, and nudge every weight a little in the direction that makes it less wrong, thousands of times over. Fine-tuning is the same process, started from an already trained model.

An analogy: fine-tuning is like driving lessons, where many hours of practice slowly reshape every habit. Weight-space programming is like a mechanic opening the hood, finding the one loose wire, and fixing just that.

In weight-space programming the agent gets a sandbox, the network's weights and a few tools: run the model on practice examples and get back its error rate, or look at what individual units inside the network do on a handful of examples. It forms a hypothesis ("this unit fires when a number starts the line, and that is what erases the digits"), edits a few specific weights to test it, and keeps the change if the error goes down. There is no gradient and no training loop.

The original showcase was a language model, Qwen3.5-0.8B, with about 0.8 billion weights, roughly 2,000 times the size of the model we used. The agent traced the model's habit of looping endlessly to a single direction inside two of its internal layers and removed it, changing 131,072 weights (0.016% of the model). Its score on the MATH-500 benchmark rose from 7.9% to 48.1%, with no training at all.

Their own caution matters as much as the result. On a second, smaller model they found that "editing weights could remove an obstacle that hid an ability, but it could not add an ability the model lacked."

Weight-space programming is related to model editing (methods such as ROME and MEMIT, which rewrite specific facts stored in language models) and draws on mechanistic interpretability, the study of what individual parts of a network compute. The difference is that an AI agent chooses each edit through its own experiments, instead of a fixed algorithm. In a related experiment, the preprint Language Models Can Rewrite Their Own Weights (Fan et al., 2026) has a large language model diagnose its own failures and edit its own weights, instead of an outside agent editing a separate model.

Two ways to change a network
Fine-tuningWeight-space programming
How it changes the networkGradient descent on examplesAn agent edits chosen weights by reasoning
Which weights changeAll of them, each a littleA small share of them, each a lot
What it needsTraining data and many passes over itA sandbox, a look inside the network, a few test runs
ResultA better modelA better model, plus an explanation of each change
02 — Our test

A fair test on a small production model

The published examples were large language models. We wanted to know two things: does the idea work on a small model that is not a language model, and how does it compare with classic fine-tuning when both get exactly the same data?

We chose Google's tessdata_best Hebrew model for Tesseract (heb, float): a convolutional network followed by LSTM layers, 377,701 weights in all. An LSTM is a neural network layer with memory: it reads a sequence one step at a time and carries what it has seen forward, which suits reading a line of text slice by slice.

We picked it because it is small. Every contender, from the quick refits to the full fine-tune and each agent run, took about an hour or less on one ordinary computer, so we could run them all properly. It is also widely used, has known repeatable mistakes, and can be scored exactly by the real Tesseract program.

Every contender started from the same stock model and the same 2,000 synthetic practice lines:

  • Weight-space programming: Claude Opus 5.5 as the agent, three separate runs.
  • Output-layer refit: classic gradient training of only the last layer, the one that turns the network's internal signals into letters, with everything else frozen. It is the cheapest way to adapt a model. We also tried refitting only that layer's biases.
  • Fine-tune: classic training of the whole network with Tesseract's own training tool, on the same 2,000 lines.
  • Random edits: changes of the same size as each agent edit, but random, to check the agent isn't just lucky.

The agent worked in a locked sandbox, with no internet except the AI service, and never saw any test data. It had two tools. Run loads the edited weights into the real Tesseract program, reads all 2,000 practice lines, and returns what it read on each one plus the error rate, so every idea was tested on every line. Probe looks inside the network: it shows what individual units do on up to 64 lines of the agent's choice per call. Each use of a tool counted against a budget of 50. The agent was not allowed to fit weights to data with an optimiser: every change had to be a value it chose by reasoning.

We scored everything on three test sets the agent never saw:

  • Modern text: 403 real line crops of present-day Hebrew, with and without numbers.
  • Old print: 4,013 lines of a 19th-century Hebrew newspaper.
  • Fresh receipts: 502 lines from a small collection of Israeli receipts and invoices, prepared and manually checked line by line.
03 — Results

It works, and fine-tuning still wins

All three agent runs improved the model on every test set. On modern text and receipts they beat the output-layer refit. On old print the refit did better. None of the runs caught up with fine-tuning.

4.18%
Stock
2.64%
Agent, average of 3 runs
3.31%
Output-layer refit
1.77%
Fine-tune

Character error rate on modern text: the share of characters read wrong. Lower is better.

Error rate (%), lower is better
ModelModern textOld printFresh receipts
Stock Tesseract Hebrew4.1817.375.07
Refit: last layer's biases3.6715.345.21
Refit: whole output layer3.3114.254.94
Weight-space programming: average of 3 runs, with best–worst below2.642.29–2.8615.8615.46–16.284.033.70–4.55
Fine-tune on the same 2,000 lines1.7712.783.12

Every agent run beat stock and the output-layer refit on modern text and receipts, with 95% bootstrap intervals that exclude zero. Random edits of the same size always made the model worse: 7.9–9.2% on modern text for edits the size of runs 2 and 3, while edits the size of run 1's broke it. The edited models keep their gains after 8-bit compression.

Figure 118 calls were nearly as good as 25 or 30
Best error on the practice lines after each tool call, three agent runs All three runs fall from 6.78% to below the output-layer refit (5.28%) within about 10 calls. Best scores: run 3 after 18 calls at best 4.80%, submitted 4.89%, run 2 after 25 calls at best 4.78%, run 1 after 30 calls at best 4.66%. The budget allowed 50. 4.5% 5.0% 5.5% 6.0% 6.5% 7.0% 0 10 20 30 40 50 tool calls used budget: 50 calls stock: 6.78% stock: 6.78% output-layer refit: 5.28% output-layer refit: 5.28% run 1: best so far run 2: best so far run 3: best so far
Best error on the practice lines after each tool call, three agent runs All three runs fall from 6.78% to below the output-layer refit (5.28%) within about 10 calls. Best scores: run 3 after 18 calls at best 4.80%, submitted 4.89%, run 2 after 25 calls at best 4.78%, run 1 after 30 calls at best 4.66%. The budget allowed 50. 4.5% 5.0% 5.5% 6.0% 6.5% 7.0% 0 25 50 tool calls used budget: 50 calls stock: 6.78% stock: 6.78% output-layer refit: 5.28% output-layer refit: 5.28% run 1: best so far run 2: best so far run 3: best so far
Run 3: 18 calls, best 4.80%, submitted 4.89%Run 2: 25 calls, best 4.78%Run 1: 30 calls, best 4.66%
The best error on the 2,000 practice lines after each tool call. We allowed each run up to 50 tool calls, its budget, and each run decided by itself when it had done enough. Run 3 stopped after 18 calls and ended within a quarter of a point of the runs that used 25 and 30; on the modern-text test set it even beat run 2. Most of the gain came in the first 10–12 calls. Each run took 29–52 minutes and $5–9.50 in API usage.
04 — What the agent found

Two start-up faults, and how the agent fixed them

Tesseract cuts a line image into thin vertical slices, one every 3 pixels (a typical line has 70 to 150), and reads them with memory layers, one going left to right and one right to left. Each starts with an empty memory at its own edge of the image. All three runs independently found that the model's two worst habits come from that cold start.

Fault 1: inventing a punctuation mark at the end of a line

Hebrew reads right to left, so a line ends on the left. The left-to-right layer starts there, in the blank margin, with nothing in memory, and often writes a punctuation mark that isn't on the page: usually a full stop, sometimes a dash or a colon. We tested why on synthetic lines. The trigger is blank paper where the network starts reading: with a tight margin the stray mark almost never appears; with a margin a third of the line's height or wider, it appears on most lines. The last word makes no difference: a line ending in של, which can never end a Hebrew sentence, gets a stray full stop as often as one ending in a noun. The only Hebrew-specific part is which mark appears: usually a full stop, because Hebrew lines end on the left, even on English or digit lines.

The fix: a switch that waits for ink

The agent found two units in that layer that almost never did anything: on practically every line they stayed close to zero, which made them safe to reuse. By changing their weights, it turned them into a switch that is off at the start of the line, flips on at the first ink and stays on. It then connected the switch to the output so that, while the switch is off, writing a punctuation mark is heavily penalised. Once ink has been seen, the model reads exactly as before. Think of a motion-sensor light: nothing is announced until something is actually there.

Figure 2The switch at work
A synthetic practice line of Hebrew text in a grey sans-serif font: הנחה: השפיע צליחה בזריזות. There is no punctuation mark at its left end.
switch off (blank margin)switch on (from the first ink)where stock wrote a full stop
Stock readsהנחה: השפיע צליחה בזריזות .
Run 1 readsהנחה: השפיע צליחה בזריזות
A practice line (synthetic, so the words are random). The end of the line is on the left. Stock was 97% sure there was a punctuation mark in the thin blank margin there and wrote a full stop; with run 1's switch still off, the edited model wrote nothing. The fine-tuned model also reads this line correctly.

Fault 2: swallowing a number at the start of a line

The right-to-left layer starts at the right edge, where a Hebrew line begins. If the line begins with a number, the number sits at that edge, and because digits are written left to right even inside Hebrew text, the digit touching the edge is the number's last digit. In Figure 3 the line starts with 1108, so the layer meets the 8 first, then 0, 1 and 1. Its memory works like a running tally: Hebrew letters push it toward "this is text", digits toward "this isn't text, write nothing". Mid-line the tally is already full of Hebrew, so a number can't tip it. At the edge it starts from zero. The 8 is written before the tally tips; by the 0 it has tipped, so the 0, 1 and 1 are dropped: 1108 becomes 8.

The fix: a warm start

The agent pre-loaded two memory units in the right-to-left layer with the values they normally have after reading some Hebrew, so a number at the edge no longer tips them into "write nothing". Think of a GPS given its last known position when it is switched on, so it doesn't wander while it finds its bearings; GPS makers call that a warm start too. As a backup, it also disconnected three units that carry the "write nothing" signal. Our checks later showed that the backup did little for numbers, because the warm start did the work, although it unexpectedly helped on old print.

Figure 3A number at the start of a line
A synthetic practice line: the number 1108 at the right edge, then the Hebrew word הנגרמים and a full stop at the left end.
Stock reads8 הנגרמים.
Run 1 reads1108 הנגרמים.
A practice line that starts with the number 1108. Stock keeps only the 8, the digit touching the right edge; run 1, with its warm start, reads the whole number. The fine-tuned model reads it too.

Whose explanations are these?

The agent's own: it wrote them in a report at the end of each run. We then tested them independently, by removing one change at a time and scoring again on the test sets. The switch and the warm start held up. Removing the switch costs 1.16 points on modern text, the largest share of run 1's gain. Two smaller claims did not hold up: the backup above, and a final step that sharpened the whole output by ×1.25, which made no measurable difference.

Were the reused units really idle?

Not all of them. Run 1 reused eight units in all, for the switch and the units that support it. We switched those eight off in the original model. Seven were spare. One, idle on modern text, turned out to help with old print: it switches on for most old-print lines and helps tell similar letters apart, and switching it off alone costs 0.29 points there. The agent judged it idle from its practice lines, which held no old print, so it could not have seen this. Run 1 still gained 1.91 points on old print, so it traded a small skill for a much larger fix.

Did the agent teach Tesseract something new?

No. Like the MIT team's Qwen result, it removed an obstacle instead of adding an ability. Qwen could already do much of the maths, but a habit of looping kept it from finishing; removing the habit let the ability show. Here, Tesseract could already read the swallowed digits: inside the network their signal was still there, but the "write nothing" state was pushing it down, and the agent removed that obstacle. Both fit the original authors' caution: editing can uncover an ability, but not add one the model lacks. Fine-tuning, by contrast, also improved skills the model was weak at, such as telling similar letters apart.

The three runs agree on what is wrong but not on how to fix it. That is the point of separate runs: the same task, the same agent and the same budget, with each run free to choose its own path.

Three runs, three sets of fixes
Run 1Run 2Run 3
Tool calls / time30 / 42 min25 / 52 min18 / 29 min
Weights changed8.1% (43% of it one rescale of the output layer)0.6%1.6%
End-of-line fixa switch that waits for inka timer that mutes punctuation for the first few slicesa relay that keeps the output blank while the margin is empty
Leading-number fixwarm start, plus the backupswitched off the unit causing itthe same warm start as run 1, found independently
05 — Against fine-tuning

Mostly the same fixes, with a story attached

Fine-tuning here means classic training of the whole network on the same 2,000 practice lines the agent used, so both had exactly the same data. We compared the individual errors each one fixed. Of the 338 errors on modern text that run 1 fixed, fine-tuning also fixed 327. Fine-tuning fixed many more besides, mostly letters read as the wrong letter: scattered, one-off confusions that only many examples can teach. The agent went after systematic faults with a clear cause and left the rest alone.

Two places show the agent's precision:

  • Stray marks at the end of old newspaper lines (4,013 lines): stock adds one to 27.8% of lines, fine-tuning to 12.1%, and all three agent runs to 7.3–9.0%.
  • Numbers at the start of a receipt line (Figure 4): run 1 misreads 5 of 35 number-led receipt lines (14%), fine-tuning 8 (23%). Take this one as a hint, not a finding: 35 lines is a small sample, and runs 2 and 3 misread more than fine-tuning.

Figure 4 also shows why the agent beats the output-layer refit on modern text. The leading digits are lost deep inside the network, in the right-to-left memory, where retraining only the last layer cannot reach: the refit misreads as many number-led lines as stock does, or more. On old print the refit wins instead, by fixing mid-line punctuation errors the agent never targeted.

Figure 4Lines that start with a number: share misread
Modern text (60 lines)Receipts (35 lines)
Stock
85%
83%
Output-layer refit
90%
86%
Fine-tune (same 2,000 lines)
17%
23%
Agent, run 1
18%
14%
Agent, run 2
30%
60%
Agent, run 3
35%
34%
The share of lines starting with a number whose first number comes out wrong. Retraining only the last layer cannot fix this; the agent's warm start and fine-tuning can. Run 2, which switched a unit off instead of warming the memory, does worst of the three on receipts.
06 — What it means

A promising tool, with a grain of salt

One case study, one small model

This is a single case study on a model of 378,000 weights: about 2,000 times smaller than the language model in the original post, and millions of times smaller than today's largest models. Large networks are far harder to read, and their failures are less tidy, so results there could be very different, better or worse. Three runs is a small sample, our practice data is synthetic, and most of our test data cannot be shared, so we report totals only.

For now, on a small model like this one, fine-tuning is the better choice. In our test it was better on every set, fixed almost everything the agent fixed, and cost far less: under an hour on an ordinary desktop processor, against about $22 at API prices for the three agent runs. If you have the data and the compute to fine-tune, fine-tune.

Still, we think weight-space programming points to where working with models is heading. In under an hour per run, with no training, an AI agent found real faults inside a production network, explained them, and fixed them with changes small enough to read. As agents get better at reading networks, that kind of targeted, explainable repair could become a normal tool next to training: for diagnosing a model, for quick repairs where retraining is costly, and for finding out what a model can already do but is held back from doing. We expect the gaps in accuracy and cost to shrink as agents improve and get cheaper; on large models, where fine-tuning needs costly hardware and lots of data, the balance could even tip the other way.

If you need Hebrew OCR today, use heb_rivok 2.0, the best Tesseract model we have for Hebrew: a full fine-tune of Google's Hebrew model on far more data than this study's 2,000 lines, free under Apache-2.0. We also tried weight-space programming on top of an earlier version, 1.0.1: four runs each removed debris that the model reads as a vertical bar. Old print improved, and modern text got slightly better or slightly worse, depending on whether it contained genuine bars. That is a small trade-off rather than a free gain.

We'd love to hear what you think. Weight-space programming is new, and the interesting questions are open: which models and faults it suits, how far it scales, and where it breaks. If you have ideas, criticism, results of your own or a model you'd like us to try, write to us, or share this with someone who would enjoy the debate. We read everything, and the best ideas will shape our next round.

We may write up the method and statistics in more detail later; tell us if there's a part you'd like to see first. The agent under study is Claude Opus 5.5 by Anthropic, and Claude Code helped us build the test harness and write this article.

07 — Questions

Common questions

What is weight-space programming?

Weight-space programming is a way to improve a trained neural network without training it: an AI agent inspects the network's internal activity, works out what specific units do, and edits their weights directly, testing each change with a small budget of evaluations. The term comes from Takehi, Teoh, Zhang and Khattab (MIT CSAIL), Sparks of Weight-Space Programming, November 2026.

How is weight-space programming different from fine-tuning?

Weight-space programming changes a few chosen weights by reasoning, with no gradients; fine-tuning changes all the weights a little, by gradient descent on examples. In our test on Tesseract's Hebrew model, fine-tuning on the same 2,000 lines won on every test set (1.77% against an average of 2.64% on modern text), but the agent's changes were far smaller and each came with an explanation.

Is weight-space programming the same as model editing?

Weight-space programming is related but not the same. Model editing usually means fixed algorithms, such as ROME and MEMIT, that rewrite specific facts stored in a language model. In weight-space programming an AI agent decides what to change through its own experiments, and the target can be any behaviour, such as the start-up faults in our text recognizer.

Does weight-space programming need gradients or training data?

Weight-space programming uses no gradients. In our setup the agent used the same 2,000 practice lines as the trained baselines, but only to score its ideas and to look inside the network on up to 64 lines at a time. We allowed at most 50 tool calls per run, and the runs needed only 18 to 30. The agent was not allowed to fit weights to the data.

Does weight-space programming work outside large language models?

Weight-space programming worked in our one case study outside language models: on Tesseract's Hebrew text recognizer, a 378,000-weight CNN + LSTM, the agent edited the LSTM layers, not just the output layer, and the gains held on test data it never saw. One small model is not proof that it works everywhere.

When would you use weight-space programming instead of fine-tuning?

Weight-space programming suits a specific, systematic failure that you want to understand and fix without retraining: a model you cannot easily retrain, a fault you need explained, or a check of whether a model already has an ability that something is suppressing. When you have the data and the compute, fine-tuning gave better accuracy in our test.

What is the best Tesseract model for Hebrew?

For Hebrew documents today, use heb_rivok 2.0, our free Apache-2.0 model for Tesseract, fine-tuned from Google's Hebrew model on far more data than this study used. It reads modern documents, old print and niqqud; results and downloads are on the heb_rivok page.

Ideas, criticism, or a model you'd like us to try?

Write to us here. We read everything, and the best ideas shape our next round.

We use your details only to reply (privacy). Or email [email protected].