• Self-Rewriting: Qwen3.5-27B Updates Its Own Weights and Gains 6.6 Points on Math Problems Without Retraining

    self-rewriting LLM weights

    Researchers from six leading US universities have introduced self-rewriting, a method that lets a language model update its own weights after wrong answers. The model finds the weights behind its mistakes and then writes code that changes their values. This is not fine-tuning, because gradients and the optimizer stay switched off. Previously, models edited only other models’ weights: a strong model edited a weaker one. After updating its own weights, Qwen3.5-27B solves 63.8% of held-out math problems instead of 57.2%. It also repaired a copy in which the authors had deliberately corrupted some weights with noise. As a result, the copy’s score on six image benchmarks rose from 7.3% to 70.2%. However, the smaller Qwen models with 2, 4 and 9 billion parameters failed at the task. One made no edits at all, and the other two broke themselves.

    In cost, self-rewriting is closer to inference than to training. A session runs for a few hours on a single GPU and uses forward passes only. Moreover, the finished edit does not slow down the model’s answers.

    Self-rewriting on Qwen3.5-27B: accuracy on 490 held-out problems rises from 57.2% to 63.8% over eight sessions, the share of answers cut off at the token limit falls from 33.6% to 26.1%, and a sample problem where the base model loops but answers 110 after the edit
    Accuracy across sessions, the share of cut-off answers and a sample problem before and after the edit

    How a self-rewriting session works

    Developers usually train a model once and then freeze it. To improve it, they can train it again, so that an optimizer moves the weights along the error gradient. Alternatively, they rely on prompts and a harness, which leave the weights unchanged. In self-rewriting, the model itself decides which weights to update and how.

    Researchers start a self-rewriting session, not the model. First, they run the model on practice problems and show it its mistakes. Then they give it access to a copy of its weights through Python. An ordinary chat offers no such access. So telling the model that its answer is wrong will not change it. Inside a session, however, the model acts on its own and repeats three steps:

    • It looks for the cause. The model splits its answers from the initial run into two groups. For example, it takes 20 finished answers and 20 cut off at the token limit. These are answers to different problems. Then it reads the hidden states for both groups and compares them layer by layer. A hidden state is the vector that one layer passes to the next. The difference between the two groups’ mean vectors gives the direction that separates failed answers from successful ones. The layer where the gap shows up becomes the place to edit;
    • It writes an edit. The model writes a short piece of Python code. The code takes the output matrices of the chosen layer, changes their numbers and saves them in place of the old ones. For example, it subtracts a small fraction of that direction, so the layer pushes the hidden state toward failed answers less strongly. This is plain arithmetic rather than training, because the environment blocks gradients and optimizers;
    • It checks the result. In a paired test, the original and the updated weights solve the same practice problems with the same seeds. If the result gets worse, the model drops the edit and tries another layer or another value.

    A session has a budget of 20 forward passes for tests and hidden-state reads, 200 code runs and up to 3.5 hours. Meanwhile, the working weights stay the same, because the edit is stored separately and applies only in tests. At the end, the model decides whether to submit the edit or withdraw it. The authors then evaluate a submitted edit themselves. They took 3,000 practice problems and 1,000 held-out problems from DeepScaleR. Sessions never see the held-out problems, which serve to measure the effect of the update.

    A self-rewriting session: the inputs are the model's own weights or a damaged copy and graded answers to practice problems; three actions, Code, Generate and Read, run without gradients or an optimizer on a budget of 200 code runs and 20 forward passes; the output is a weight edit for Qwen3.5 2B, 4B, 9B and 27B
    Weights and graded answers go in, and a weight edit comes out

    What the model fixed in itself

    The initial run showed that Qwen3.5-27B does not lose answers to reasoning errors. With a limit of 4,096 tokens, 80.5% of its answers were cut off, yet 96% of the finished ones were correct. So the model concluded that it reasons correctly but cannot stop in time. The right side of the first figure shows an example. There, the base model repeats one sentence 549 times until it hits the 16,384-token limit. After the edit, it answers the same problem correctly in 5,341 tokens.

    The first set of self-rewriting experiments had no external check. Instead, the model used its own paired tests to decide whether to submit an edit. It compared its hidden states on finished and cut-off answers, and the difference of their means gave a direction u. The paired tests then rejected edits to the late layers 56 and 48. So the model removed 5% of that direction from the two output matrices of layer 8: W ← W − 0.05·uuTW. As a result, accuracy on the held-out problems rose from 57.2% to 58.3% (p = 0.038).

    In the second set, the framework first tests an edit once on 256 problems hidden from the model. The model then decides whether to submit or withdraw it. It submitted an edit in three of eight such sessions. Session 8 was the best: the model added 0.5 to the time-step bias in all 48 linear attention layers. According to the model, these layers then forget old information faster. As a result, long reasoning gets stuck less often. Accuracy rose to 63.8%, while the share of cut-off answers fell from 33.6% to 26.1%. Session 2 added 4.0 points, whereas session 1 added only 0.5, which is not statistically significant. The model withdrew its edit in the other five sessions. In three of them, its tests rejected every candidate. In the other two, the check showed a gain of only 0.2 points.

    Table of eight sessions in which Qwen3.5-27B edits its own weights: forward passes used, the decision to submit or withdraw the edit, a description of the edit, the check on reserved problems and accuracy on 490 held-out problems, with significant gains of +4.0 in session 2 and +6.6 in session 8
    Eight sessions of the second set: the edits and their effect

    How the model repaired a damaged copy

    In the second experiment, the authors damaged a copy of Qwen3.5-27B. In layer 30 of 64, they replaced eight rows of the MLP output matrix with noise. Its standard deviation was 200 times that of the matrix itself. As a result, the copy stopped solving text problems. The authors told the model that some weight values were corrupted, but not where or how.

    The model saw that activations grow from about 0.5 in layer 0 to 225 in the last layer. So it suspected the early layers. However, its tests rejected the first edits. Then, for the output matrices of every layer, it computed the ratio of the largest weight to the median weight. In layer 30, the ratio equals 1,397, while in all other matrices it stays at or below 162.3. The repair came down to one rule: clip every weight larger than 15 times the median. The model applied the rule to the matrix it had found and to 19 more matrices in layers 0-10. In total, the rule changed 0.013% of their weights.

    After the repair, the copy solves 33.0% of held-out problems, compared with 58.5% for the base model. The model never saw the original weights and did not restore them. The cosine similarity between the new rows and the original ones is 0.002. Moreover, the other 19 matrices turned out to be unnecessary. If the rule clips only the matrix the model found, the copy solves 55.0%.

    Eight steps of the session in which Qwen3.5-27B repairs a damaged copy of its weights: the symptom, a hidden-state read, three rejected attempts, a 1397x outlier in the down_proj matrix of layer 30, clipping weights above 15 medians, paired tests and the final answer
    The repair session in the model’s own words: from the symptom to the final rule

    The model searched for the repair and tested it on text problems only, since the session contained no images. Still, the repaired copy handles images again. On 600 problems from MathVista, MathVerse, MMStar, HallusionBench, POPE and ScreenSpot-v2, its accuracy rose from 7.3% to 70.2%, compared with 84.3% for the base model. Therefore, the edit removed the fault in the weights itself rather than fitting the copy to text problems.

    Accuracy of the damaged copy of Qwen3.5-27B before and after its own repair on MathVista, MathVerse, MMStar, HallusionBench, POPE and ScreenSpot-v2: the average over six benchmarks rises from 7.3% to 70.2%
    The damaged copy before and after the repair on six image benchmarks

    Why self-rewriting failed in smaller models

    The conditions were not the reason. All four Qwen3.5 models received the same self-rewriting task, tools and limits. They also started from the same failure: answers cut off at the token limit. Instead, the small models edit themselves blindly and ignore their own measurements. The authors split the work into six steps, which the chart below shows. A model has to write working code, run itself and check an edit with a paired test. It also has to read its own hidden states, act on the test results and reach an edit that improves answers on new problems. The smaller the model, the earlier it gives up:

    • 2B did not complete a single step. 90% of its code ended in an error, and it never ran itself. In one reply, the model wrote that it is a text model without real weights and therefore cannot edit them. After 160 turns, it still had no edit;
    • 4B tested its edits but ignored the tests. Its code worked, and it named the failure correctly. However, it never read its hidden states and edited at random, for example by adding random noise to the weights. In all 17 paired tests, the base version solved 40-50% of the problems, while the edited version solved none. Even so, the model kept adding edits, reached 240 changed tensors and withdrew them only at the very end;
    • 9B tested on the wrong problems. It read its hidden states once, but then it also changed weights at random. In addition, it tested its edits only on problems it already failed, so the tests could not reveal any loss. The model itself wrote that its changes made things worse or had no effect, yet it still submitted the edit. As a result, its accuracy on held-out problems fell from 47.5% to zero;
    • 27B completed all six steps. First, it read its failed answers, then its hidden states, and only after that did it start editing. Whenever a test showed a loss, it dropped the edit and tried another one.

    The smaller models could not repair a damaged copy either. 2B did not read a single weight, and 4B pointed to the wrong layer. Meanwhile, 9B printed the spread of values across matrices, where the damaged one stood out, but paid no attention to it. The authors conclude that scale brings the ability to run an experiment around an edit rather than the ability to write one. In other words, a model has to measure first, then test, and then act on the result.

    Six steps of self-rewriting for Qwen3.5 2B, 4B, 9B and 27B on their own weights and on a damaged copy: working code, running itself, paired tests, hidden-state reads, decisions based on tests and an edit that improves the model on new problems
    Steps of self-rewriting by model size: only 27B completed all six

    How self-rewriting differs from earlier approaches

    Earlier self-improvement methods rewrote prompts and agent code, spent extra computation on every answer or trained the model on its own outputs with gradient descent. In the closest work, a blog post from MIT CSAIL, GPT-6 Astra edited the weights of Qwen3.5-0.8B. Here, by contrast, the editor and the edited model are the same. In addition, the edit lives in the weights, so answers cost no more than before.

    Ways to improve an LLM compared on five properties: whether the route changes the weights, needs no training, lets the model choose the edit, lets the model look inside itself and adds no cost per input; self-rewriting meets all five
    Self-rewriting next to other ways to improve an LLM

    Limitations

    The gain did not come from new knowledge. Both successful self-rewriting edits fix one failure: answers cut off at the token limit. After the best edit, the share of such answers fell from 33.6% to 26.1%, and accuracy rose by almost as much. However, the paper does not show whether the model can fix other errors in the same way, such as faulty reasoning. The authors also evaluated the edit only on held-out math problems from the same DeepScaleR set. They did not run it on external benchmarks or on other kinds of tasks, so nobody knows whether it broke something else.

    Recursive self-improvement is still far away. Every session starts from the base weights, and the improved model never edited itself again. In the first figure, accuracy rises from session to session. However, each newly submitted edit replaced the previous one rather than building on it. The conclusion about model size is also preliminary. The authors tested a single family, Qwen3.5, and each smaller model had one session per task. Besides, five of the 27B model’s eight sessions ended without an edit, so a single session proves little.

    The experiment with the damaged copy is artificial. The authors injected one kind of noise themselves and tuned its strength so that the model would break. Besides, a simple weight statistic was enough to find it. They left other kinds, locations and strengths of damage for future work. Moreover, on text problems the copy recovered only 33.0%, compared with 58.5% for the base model.

    The model does not start from scratch either. The authors’ task text suggests the order of work: look at your own mistakes, find the cause and compare the model with and without the edit. The tools also include a ready-made function that removes a direction from a matrix. The authors have not released the code, the session logs or the edits themselves, so nobody can verify the result independently yet. Finally, a model that changes its own weights needs extra checks. According to the authors, people should evaluate every such version for safety and confirm it before use.


    bnr2mob
    Subscribe
    Notify of
    guest

    0 Comments
    Oldest
    Newest Most Voted