Self-rewriting: a 27B model rewrites its own weights and becomes more accurate on problems it never saw Figure 1: A 27B language model rewrites its own weights, with no training, and becomes significantly better on problems it never saw. (a) Accuracy over eight consecutive sessions. (b) Share of answers running out of tokens. (c) One held-out problem answered before and after the model’s own edit.

Alan Turing said it in 1947: “The possibility of letting the machine alter its own instructions provides the mechanism for this.” Seventy-nine years later, a team led by Jiajun Fan and Ge Liu at the University of Illinois Urbana-Champaign, with collaborators at Carnegie Mellon, Rutgers, Princeton, Stanford, and Yale, has shown that a language model can do exactly that — rewrite its own weights, by its own reasoning, and become better. No gradients. No training run. No larger model standing behind it.

The paper, https://arxiv.org/abs/2611.21885, introduces self-rewriting: a paradigm where the model is its own optimizer. It reads its weights, diagnoses where it fails, writes new values, tests the result, and keeps only what works. The gain lives in the weights — not in a prompt that vanishes when the task changes, and not in extra inference-time computation you pay for on every answer.

The Core Idea: A Third Way to Improve a Model

Until now, improving a language model meant one of two things:

  1. Train it again — pre-training, post-training, RLHF. Takes infrastructure, GPUs, and expertise only a few labs have.
  2. Spend more at inference — prompt engineering, chain-of-thought, test-time scaling. You pay for it on every single answer, and the benefit disappears when the conversation ends.

Self-rewriting is a third path. The model edits its own weights using only forward passes — the same computation as serving. One GPU, a few hours, and the improvement is permanent. Every answer after that costs exactly what it cost before.

How self-rewriting works: the model takes actions across turns — code, generate, read Figure 2: The model works in turns. Each turn it writes a rationale and takes one action: code to modify weights, generate to test answers, or read to inspect hidden states. No gradient flows. No optimizer runs.

How It Works

The setup is elegant. The model receives:

  • Its own weights (as readable, writable tensors)
  • Its graded answers on a set of practice problems (right/wrong, whether it ran out of tokens, whether it repeated itself)
  • A Python session where it can read weights, write new values, and run itself on practice problems

What it does not receive: gradients, an optimizer, a reward model, a judge, a teacher, or access to any larger model. Every value it changes is written by its own reasoning.

The model works in turns. Each turn it writes a short rationale and takes one action:

  • Code: Run Python to inspect or modify weight tensors. A helper function lets it weaken what a matrix writes along a specific direction in hidden state space (W - α·u·uᵀ·W).
  • Generate: Answer practice problems with edited or unedited weights (or both, as a paired test).
  • Read: Inspect its own hidden states on texts of its choosing.

A session uses about 20 forward passes and 200 code runs. When it ends, whatever edit is on disk gets submitted. Crucially, there is no teacher, no judge, no reward model, no larger model, no harness engineering, and no prompt engineering. From outside, the only feedback is which practice answers were right. The diagnosis, the edit, and the decision are all the model’s own.

Finding 1: It Surpasses Itself

The 27B model (Qwen3.5-27B) was given its own weights and its graded answers on math practice problems. It diagnosed its own failures — many were cases where the model got stuck repeating a single sentence hundreds of times until it hit the 16,384-token limit, never producing an answer.

After rewriting its own weights, the model became 6.6 points more accurate on 490 held-out problems it had never seen, in a paired test fixed in advance. The examples are striking:

  • Before: “I will write the response. I will write the response. I will write the response.” — repeated 549 times, cut at 16,384 tokens. No answer.
  • After: Correctly derives the answer in 5,341 tokens and outputs 110.

This wasn’t a fluke. The model fixes the repetition loops that were eating its token budget, and the answers it does produce are more often correct. The gain is statistically significant (p < 0.0001).

Finding 2: It Keeps Getting Better

The researchers ran eight consecutive sessions where the model checks its edit on reserved practice problems before submitting it. If the edit doesn’t help, it withdraws. If it does, it becomes the new model in use.

Over all eight sessions, accuracy only rises. Sessions 2 and 8 are statistically significant improvements (p < 0.0001 each). Five sessions withdrew and left the model as it was. The model is cautious — it submits only what its own tests support.

Finding 3: It Repairs a Damaged Copy of Itself

This is where it gets remarkable. The researchers took a copy of the 27B model and overwrote eight rows of one weight matrix with noise — enough to make the copy fail almost everything. The damaged copy would start thinking and never close, or repeat fragments endlessly.

They gave the model the damaged copy and told it only that “some values were corrupted.” No information about which matrix, which rows, or what the original values were. The model:

  1. Located the corrupted matrix by reading hidden states and comparing behavior
  2. Diagnosed the failure mode — the corrupted rows were disrupting the model’s ability to complete its reasoning
  3. Wrote its own replacement values — not the originals, which it never saw
  4. Brought the copy from 7.3% to 70.2% accuracy on six image benchmarks it had never seen

Before and after self-repair on image tasks Figure 3: Before and after, on images it never saw. The repair found on text problems alone restores the damaged copy’s ability to answer visual questions — from failing almost everything to 83% of the undamaged model’s accuracy.

That last point is critical: the repair was found entirely on text math problems, but it carried over to image tasks — MathVista, MathVerse, MMStar, HallusionBench, POPE, and ScreenSpot-v2. On ScreenSpot-v2, the repaired copy went from 0% to 89% (the undamaged model scores 93%). This means the model repaired the copy itself, not a specific task. Like a broken robot that fixes itself without being rebuilt.

Finding 4: It Emerges With Scale

The researchers tested four sizes of the same model family — Qwen3.5 at 2B, 4B, 9B, and 27B parameters — all given the same task and tools:

Self-rewriting emerges with scale: only the 27B model improves itself Figure 4: Only at scale does a language model improve itself, repair itself, and carry the repair over to images. Each row is a session, each column a step in rewriting oneself. Only the 27B model climbs the whole ladder.

  • 2B: Made no edit at all. Said “Since I’m a text model without actual neural network weights, I cannot directly edit weights.” It didn’t recognize its own weights as something it could change.
  • 4B: Its code ran, but every edit made the model worse. “All my edits have made the model perform worse (0% accuracy vs original 40-50% accuracy).” It withdrew.
  • 9B: Got further — it could run itself and read hidden states — but couldn’t find edits that worked. “Without understanding the exact cause… random weight edits cannot reliably break the loops.”
  • 27B: The only size that climbed the entire ladder. It ran code, tested edits, read hidden states, acted on its test results, and improved itself. “The differences grow with depth. Let me try a very small edit on an earlier layer (layer 8) to see if that helps.”

This is the first evidence that the ability to rewrite one’s own weights scales with model size. Stronger models may be stronger self-improvers.

Why This Matters

The gain lives in the weights. Test-time scaling (chain-of-thought, many samples, voting) gives you a better answer by spending more compute per question — but you pay that cost on every single question forever. Self-rewriting pays once. The edited model is deployed as-is, and every answer costs what it always did.

No training infrastructure. No GPUs running backpropagation, no optimizer, no loss function, no training pipeline. Just forward passes — the same computation as serving. Each session ran in a few hours on a single GPU.

The model is both the improver and the improved. This is real recursive self-improvement, not a larger model fixing a smaller one. The same model that fails is the one that examines the failure and changes what produces it.

Open, not frontier. This isn’t GPT-5 editing a 1B toy model. It’s an open 27B model editing itself. The capability is accessible to anyone who can run the model.

The Bigger Picture

The paper’s closing argument is worth taking seriously: “The wall between training and inference is a limit of our tools, not a property of intelligence.” Humans don’t separate learning from doing — the same brain that works also improves itself from each success and failure. A language model that can rewrite its own weights blurs that line for the first time.

If self-rewriting continues to scale, the implications are significant. A model could keep upgrading itself over its lifetime with no retraining, no harness engineering, and no prompt engineering. Improving a model might come to take a conversation rather than a training run — open to anyone who can say what goes wrong.

That said, the current results are modest: 6.6 points on math problems, repair of a specific corruption pattern, one model family showing scaling. The 4B and 9B models broke themselves. The paper is careful not to overclaim. But as a proof of concept — that a language model can be its own optimizer — it’s a genuine first.

The authors believe self-rewriting is a necessary step toward recursive self-improvement: a model that, like a human, does not separate training from inference could keep upgrading itself for life, with no larger model, no harness or prompt engineering, and no pre- or post-training.

The Team

The work is by Jiajun Fan, Neil He, Changyi Yang, Andy Mao, Xi Zhu, Chaoran Cheng, Kaiqu Liang, Shuaike Shen, Zetian Li, Ruihan Guo, and Ge Liu, across UIUC, CMU, Rutgers, Princeton, Stanford, and Yale.


Paper: https://arxiv.org/abs/2611.21885 Project page (with interactive examples): https://www.jiajunfan.com/projects/self-rewriting/ Video: https://www.jiajunfan.com/film/video/self-rewriting.mp4