In this post, we break down the new paper “Language Models Can Rewrite Their Own Weights”, which introduces Self-Rewriting, an approach where a large language model (LLM) edits its own weights to improve itself, without gradients or retraining.
From Weight-Space Programming to Self-Rewriting
Just a few weeks ago, a new idea called Weight-Space Programming introduced a fascinating possibility, where one AI model can directly edit another model’s weights, and by doing so improve its capabilities.

Why Editing Model Weights Matters
There’s a very good reason this idea is interesting. Think about what happens today. Once an AI model is trained and deployed, its weights are frozen. Improving it further usually requires another training or fine-tuning process.
Moreover, training capable AI models is an extremely expensive process, requiring huge amounts of compute, data, and specialized expertise. That kind of requirements is mostly available only to large well-funded organizations.
But what if an existing model could improve another model simply by editing its weights? This could provide an alternative to expensive training processes, and perhaps even open the door to a future where AI can create and improve models on its own.
What Is Self-Rewriting?

Now, what if we took this idea one step further? What if the model didn’t edit another model’s weights, but instead updated its own?
That’s exactly what’s being proposed in a new paper titled “Language Models Can Rewrite Their Own Weights”. The authors call this approach Self-Rewriting.In this approach, the model diagnoses its own failure and rewrites the weights behind them.

Kaiqu Liang, Shuaike Shen, Zetian Li, Ruihan Guo, Ge Liu (Source)
A Step Toward Recursive Self-Improvement
If a model can successfully edits its own weights, that could be an important step toward recursive self-improvement. Instead of remaining frozen after training, a model might eventually be able to learn from its experience and update is own weights over time.
Self-Rewriting vs. Weight-Space Programming
In Weight-Space Programming, The model doing the editing is a frontier model, while the model being edited is much smaller. On the other hand, in Self-Rewriting, a 27 billion parameter model is able to edit itself.
How Self-Rewriting Works
Let’s now see how this actually works, using the following figure from the paper, which describes the Self-Rewriting process at a high-level.

We start on the left, with what the model receives.
How the Model Accesses Its Own Weights
First, it gets access to its own weights. But what does that actually mean? The weights are not part of the prompt. Our model has 27 billion parameters, so there’s no way to fit all those numbers into its context.
Instead, the model gets access to a Python environment where it can inspect and modify the weights when it needs to. It also receives some details about the model’s architecture, such as the number of layers. So, for example, it can run Python code to read the weights of an attention block at layer number 20.
The Starting Diagnosis: How the Model Finds Its Failures
Second, it gets a starting diagnosis.
Before the session begins, the model answers a set of practice problems, and those answers are graded. The analysis is based on rules, so there’s no second AI model evaluating its performance.
The grading considers whether the answer is correct, and also whether the model reaches the token limit or gets stuck in a loop repeating itself. This lets the model see how it performs and also how it fails.
The Goal: Getting Better at Math
Now, what does the model actually do with these inputs? The model is assigned with a specific goal, to become better at math by directly changing its own weights.
The model works in a session made of turns. In each turn, it reasons about what it has learned so far, chooses one action, and gets back an observation. Based on that observation, it decides what to do next.
Three Actions: Writing Code, Reading Hidden States, and Testing
So what actions can it take?
- The first is writing code. The model runs Python code that reads its weights as numbers and writes new values. In the example here, it loads a weight matrix, slightly changes its values along a particular vector direction, and saves the result as a proposed edit.
- The second is reading its own hidden states. The model chooses which texts to inspect. It can, for instance, compare answers that finished properly with answers that ran out of tokens, and look for differences in their internal representations. Note that the hidden states aren’t added directly to the model’s context. Instead, the model loads them in Python and prints only what it needs, such as a few summary statistics.
- The third possible action is testing. The original model and the edited model answer the same problems, using the same random seeds. This is called a paired test. It allows the model to see whether its edit actually helps or makes things worse. If the edit hurts performance, the model can drop it and try something else.
Session Budget and Rules: No Gradients, No Optimizer
This process runs with a limited budget. The model can execute Python code up to 200 times, and it can use only 20 forward passes of the model, either for testing or for reading hidden states.
During a session, the weights the model uses to do its reasoning never change. The proposed edit is saved separately, and it only takes effect when the framework runs tests using the edited version.
To emphasize what’s missing here: there are no gradients, no optimizer, and no stronger model guiding the self-rewriting process. Every new weight value comes from the model’s own reasoning.
There are also rules against shortcuts. For example, the model can’t just rescale an entire matrix, which would act similarly to changing the sampling temperature. It’s also expected to improve its actual performance, rather than simply forcing itself to stop thinking earlier.
Submitting and Evaluating the Weight Edit
At the end of the session, the model submits its edit, marked here as delta. Applying it replaces some of the original weights with new ones, giving us an updated model. And if no edit is good enough, the model can submit nothing and leave the weights unchanged.
To measure whether the edit really helped, it’s evaluated on held-out problems the model never saw during the editing process.
Experimental Setup: Four Qwen 3.5 Model Sizes
The same task and tools are given to four sizes of the Qwen 3.5 model, ranging from 2 billion to 27 billion parameters. And as we’ll see soon, the results are quite different depending on the model size.
But before we move on to explore these results, the paper also tests a second scenario.
Second Scenario: Repairing Corrupted Model Weights
Here the model needs to repair a damaged copy of itself, where one small block of weights in one layer has been overwritten with random noise. The model is told that some values are corrupted, but not which ones.
In this experiment, the healthy model does the thinking and uses a similar session process to repair the damaged copy by editing its weights. Importantly, the repair process doesn’t give the model a clean reference copy of the damaged weights that it can compare against. All the measurements, weight inspections, and tests operate on the damaged copy itself. So it can’t simply copy the original values back. It has to figure out what went wrong and come up with its own repair.
The Ability to Rewrite Weights Emerges at Scale
In the following figure, we can see that the self-rewriting ability emerges as we increase the model size.

The Ability to Rewrite Weights Emerges at Scale
The first chart measures accuracy on math problems, comparing each original model with its self-edited version.
The smaller models fail to improve.
- The 2B model makes no edit at all.
- The 4B and 9B models experiment with poorly guided changes to their weights, and their tests show that these edits actually hurt performance.
- The 4B model eventually withdraws its edits, while the 9B model submits its edit, leaving it with zero accuracy on the held-out problems.
Only the 27B model gets better. The gain here is modest, about one point, but it is based on a single session.
Soon we’ll see it do even better when it gets multiple opportunities to rewrite itself.
Repairing Damaged Model Weights
The second chart looks at the repair scenario, measuring each damaged copy before and after the repair attempt. All the copies start at zero, and again, only the 27B model manages to bring its copy back. It’s not a full recovery, but it regains more than half of the original model’s accuracy.
Does the Repair Transfer to Image Benchmarks?
The last chart digs deeper into the 27B repaired model.
Recall that the model was repaired using only text math problems as input. But here, the evaluation checks whether that repair also help with images.
And on six image benchmarks, the damaged copy mostly fails, while the repaired copy gets back to 70.2% accuracy, which is more than 80% of the original model’s accuracy.
This suggests that the model repaired something fundamental in its weights, rather than simply optimizing for one particular type of task.
Self-Rewriting Over Multiple Sessions
Now let’s see how the 27B model does over multiple sessions.
There’s one addition to the setup. Before the model decides whether to submit its edit, the framework tests it on 256 reserved practice problems that the model cannot directly inspect or use during its session. The model receives the results of this test and then decides whether to submit or withdraw its edit.
The chart on the left shows the accuracy across eight sessions, measured on 490 problems the model never saw. One important detail is that each session starts from the original weights, so the edits don’t build on top of one another. When the model submits an edit, it replaces the model currently in use. If it doesn’t improve, we just continue using the current model.
- The first session brings only a tiny gain.
- In the second, the model finds an edit that improves accuracy by 4 points compared to the original model.
- Sessions three to seven are withdrawn, which is why the line stays flat.
- And then session eight delivers the best result, 6.6 percentage points above the original model.
Fewer Answers Cut Off at the Token Limit
The second chart shows how often answers get cut off because they reach the token limit.
With the original weights, this happens in about a third of the answers. Both of the strong edits, from sessions two and eight, bring this number down.
And this is exactly the kind of failure the model diagnosed in itself and tried to address.
Example: Fixing a Repetition Loop
On the right, we can see an example of what that looks like. The model gets a question about counting in base four. The original model gets stuck repeating the sentence “I will write the response” until it runs out of tokens.
After its own edit, using the same random seed, the model completes its reasoning and gets the correct answer.
What Did the Model Actually Change?
So what did the model actually change?
Let’s start with the repair.
How the Model Repaired the Corrupted Weights
The model inspected the weights of different matrices and looked for ones whose values stood out as abnormal. One matrix stood out by far, which is the one that was corrupted.
The model’s solution was to cap its extreme values. Interestingly, capping just that matrix brings back almost all of the original accuracy. But the model also applied the same cap to other matrices, and that’s what pulled the final result down.
And importantly, it didn’t restore the original weight values. It simply capped the extreme values and wrote values of its own.
How the Model Edited Its Own Weights
On the other scenario where the model changes its own weights, the edits to its own weights were surprisingly simple.
- In the first edit, the model slightly weakened a direction in two output matrices at layer 8, which it had identified as being associated with answers that run out of tokens.
- The strongest edit was by increasing a time-step bias in the linear-attention layers. In the model’s own words, this makes these layers forget faster, helping it get stuck less often.
References & Links
- Paper Page
- Join our newsletter to receive concise 1-minute read summaries for the papers we review – Newsletter
All credit for the research goes to the researchers who wrote the paper we covered in this post.
