递归式自我编辑:大语言模型编程修改自身权重以实现自我改进(阅读需 1 分钟)
摘要
该论文提出了 SelfWrite 框架,让大语言模型研究自身的推理过程和激活值,然后通过编程对自身权重进行低秩编辑,无需任何梯度更新,从而在五代迭代中提升了 Qwen3.8-27B 的数学准确率(gate 73.95%→76.45%)。
查看缓存全文
缓存时间: 2026/11/24 15:08
# Recursive Self-Editing: LLMs Program Their Own Weight Edits for Self-Improvement
Source: [https://arxiv.org/html/2611.29513](https://arxiv.org/html/2611.29513)
###### Abstract
Recursive self\-improvement asks a system to improve the very system that improves it\. Today’s language models improve themselves through data, training recipes or scaffolds; whenever their weights change, gradient descent writes the update, not the model\. We let the model write its own weights\. InSelfWrite, each generation the current model studies its own reasoning on fresh training problems, inspects its own weights and activations in a persistent Python session, and writes a program that constructs a low\-rank weight edit for itself from white\-box primitives \(singular directions, activation contrasts between its right and wrong answers, rank\-one projections, tensor computations\), with no training or gradient tool\. Every candidate is graded once on a hidden gate set against the current model; the best strictly improving edit is merged into the weights, and the edited model writes the next edit\. On Qwen3\.8\-27B and math problems from DAPO\-Math, five generations ofSelfWriteraise gate accuracy from 73\.95% to 76\.45% and accuracy on a held\-out test split that the loop never sees from 76\.30% to 77\.75% \(avg@4\) and from 82\.60% to 84\.80% \(pass@4\), without a single gradient step\. A language model can author useful changes to its own weights without gradients, and the edited model keeps writing useful edits\.
## 1Introduction
A recursively self\-improving system improves the very system that does the improving\[[7](https://arxiv.org/html/2611.29513#bib.bib7),godelmachine\]\. Large language models now improve themselves along three routes: they generate and judge their own training*data*\[selfrewarding,[12](https://arxiv.org/html/2611.29513#bib.bib12),absolutezero\], choose*training recipes*for themselves or other models\[seal,metarsi,ftdojo,posttrainbench\], or rewrite the*scaffolds and harnesses*around a model\[stop,godelagent,dgm,aide2,hase,selfhpo\]\. In SEAL\[seal\], for example, the model writes synthetic data and hyper\-parameters, and LoRA fine\-tuning\[[9](https://arxiv.org/html/2611.29513#bib.bib9)\]turns them into a weight change: the model decides what to train on, and SGD decides how every parameter moves\.
We take the other route: the model writes its own weights\. A model that has just answered a batch of math problems reads its own outputs, contrasts the activations of one of its layers on the problems it failed and the ones it solved, and removes the contrast direction from the layer’s output matrix with a rank\-one edit\. If the edited model solves more held\-out problems, the edit is merged, and the edited model, now reading its own changed weights, writes the next edit\. No tool computes a gradient and no training step is taken \([Figure1](https://arxiv.org/html/2611.29513#S1.F1)\)\.
Existing: self\-improvement through data or training recipesSelfWrite\(ours\): the model writes its own weightsmodelMMwrites data or pickshyper\-parametersSGDθ←θ−η∇θℒ\\theta\\leftarrow\\theta\-\\eta\\,\\nabla\_\{\\theta\}\\mathcal\{L\}modelM′M^\{\\prime\}the gradient writes the weightsthe model only chooses the inputsMgM\_\{g\}= editor= edited modelreads its own answers ×\\boldsymbol\{\\times\}\#217: 41 \(gold 45\) ✓\\boldsymbol\{\\checkmark\}\#032: 12 \(gold 12\) with full reasoning traceswrites a program w = acts\(m, wrong, "own"\) r = acts\(m, right, "own"\) u = direction\(w, r\) return project\_out\(m, u\)×\\timesrank\-1ΔW\\Delta Whidden gate500 problemsΔ𝒢\>0\\Delta\_\{\\mathcal\{G\}\}\>0✓\\boldsymbol\{\\checkmark\}Mg\+1M\_\{g\+1\}merged∇\\nablano gradient step, no trainingthe edited modelMg\+1M\_\{g\+1\}writes the next edit
Figure 1:The gradient writes the weights, or the model does\.Top: in existing self\-improvement the model writes data or chooses hyper\-parameters, and SGD computes the weight change\. Bottom: inSelfWritethe model reads its own wrong and right answers, contrasts its activations on them, and writes a program that projects the contrast direction out of one of its layers \(code simplified\)\. The rank\-one edit is merged only if it improves the model on a hidden gate set, and the edited modelMg\+1M\_\{g\+1\}writes the next edit\. No gradient tool is used and no training step is taken\.This route addresses two gaps in prior work\. First,*the gradient writes the weights\.*In data\- and recipe\-level self\-improvement the model chooses the inputs of an optimiser\[seal,selfspecialization,mass,metarsi\]; methods that emit weights directly rely on generators trained for that purpose\[[5](https://arxiv.org/html/2611.29513#bib.bib5),[4](https://arxiv.org/html/2611.29513#bib.bib4),transformer2\]; and gradient\-free weight programs are written by an external model for a different network\[wsp\]or applied to a fixed base model\[[14](https://arxiv.org/html/2611.29513#bib.bib14)\]\. Second,*the improved model rarely improves its own weights next\.*SEAL discards the adapted weights after each episode, MetaRSI retrains from the base model\[seal,metarsi\], and where the updated model does take over, its weights are still changed by fine\-tuning\[mass\]or it edits harnesses rather than weights\[hase,selfhpo\]\.
We formulate*gradient\-free recursive self\-editing*: in generationggthe current modelMgM\_\{g\}writes a program that constructs a weight editΔg\\Delta\_\{g\}for itself; ifΔg\\Delta\_\{g\}improvesMgM\_\{g\}on a gate set the editor never sees, it is merged,Mg\+1=Mg⊕ΔgM\_\{g\+1\}=M\_\{g\}\\oplus\\Delta\_\{g\}, andMg\+1M\_\{g\+1\}writes the next edit\. The editor has no gradient tool and no stronger external model, grading is deterministic, and edits are capped in rank and norm\. The setting is demanding: among hundreds of weight matrices the editor must find the few directions that help reasoning, every candidate must be graded at 27B scale on long sampled reasoning traces, and the signal the editor reads must be kept apart from the decision that accepts an edit\.
SelfWritemeets these requirements with four components \([Figure2](https://arxiv.org/html/2611.29513#S3.F2)\)\.\(i\) Observe\.Each generation,MgM\_\{g\}answers 500 freshly drawn training problems four times in thinking mode, and the editor can read every one of its own answers, including the full reasoning, and compute activation statistics on them\.\(ii\) Write\.The editor works in a persistent Python session for up to 30 tool rounds, with a white\-box toolkit over its own weights: truncated SVD of any module, activation statistics on its own right and wrong answers, rank\-one constructions and projections, singular\-direction rescaling, LoRA operators, and sandboxed tensor computations on any weight; it then returns a self\-contained program that builds the edit\.\(iii\) Select on a hidden paired gate\.Eight independent sessions per generation each produce one candidate; every candidate is graded once on a fixed 500\-problem gate set, paired item by item withMgM\_\{g\}, and later generations see only the statistics of earlier gate results, never a gate problem’s statement or answer\.\(iv\) Merge and succeed\.The candidate with the largest strictly positive paired gain is merged into the weights, and the merged model becomes the next editor, with a searchable history of every earlier attempt\.
We studySelfWriteon Qwen3\.8\-27B\[qwen38\]for five generations on DAPO\-Math\-17K\[dapo\], tracking gate accuracy after every generation and reporting a held\-out test split that is never screened, gated or shown to the editor\. Our contributions are:
- •Setting\.We formulate gradient\-free recursive self\-editing, in which the current model writes the program that constructs its own weight edit and the merged model edits next, under a protocol with no gradient tool, disjoint screen, gate and test data, and deterministic grading \([Section3\.1](https://arxiv.org/html/2611.29513#S3.SS1)\)\.
- •Method\.SelfWritecombines self\-observation of the model’s own reasoning, an agentic editing session with a white\-box weight toolkit, a hidden paired gate, and a merge\-and\-succeed loop, made affordable at 27B by hot\-loading candidate LoRAs on data\-parallel replicas \([Section3](https://arxiv.org/html/2611.29513#S3)\)\.
- •Experiments\.On math, five generations ofSelfWriteraise gate accuracy from 73\.95% to 76\.45% and held\-out test accuracy from 76\.30% to 77\.75% \(avg@4\) and from 82\.60% to 84\.80% \(pass@4\), with every gain produced by an edit the model wrote for itself \([Section5](https://arxiv.org/html/2611.29513#S5)\)\.
## 2Related Work
#### Recursive self\-improvement\.
[Good \[7\]](https://arxiv.org/html/2611.29513#bib.bib7)imagined machines that improve the machinery that improves them, and the Gödel machine\[godelmachine\]accepts a self\-rewrite once it is proven useful\. Recent LLM systems replace the proof with an empirical check and act on code: STOP\[stop\]improves a scaffold with a fixed model, Gödel Agent\[godelagent\]rewrites its runtime logic, the Darwin Gödel Machine\[dgm\]evolves coding agents around a frozen foundation model, and AIDE2\[aide2\]accepts agent rewrites that win on private held\-out tasks\. Closer to weights, MASS\[mass\]merges a LoRA trained on a model’s self\-evaluated trajectories, SIA\[[8](https://arxiv.org/html/2611.29513#bib.bib8)\]lets an external agent choose between harness edits and LoRA reinforcement\-learning updates, and MetaRSI\[metarsi\]proposes LoRA training recipes from a bounded space\. In all of them a fixed optimiser makes any weight change; inSelfWritethe model writes the change itself, and the edited model is the next editor\. Because recursive self\-training can drift over rounds\[recursivecollapse\], we follow AIDE2and accept an edit only on a fixed external check whose problems the editor never sees\.
#### Self\-improvement through data and recipes\.
Models produce their own training signal by judging their responses\[selfrewarding\], proposing and solving their own tasks\[absolutezero,[12](https://arxiv.org/html/2611.29513#bib.bib12)\], training experts on self\-generated instructions\[selfspecialization\], or fitting temporary adapters at test time\[[1](https://arxiv.org/html/2611.29513#bib.bib1)\]\. SEAL\[seal\]writes self\-edits \(synthetic data and optimisation settings\) that a fixed fine\-tuning step applies, and searching over self\-edit strategies extends this to templates and LoRA settings\[[6](https://arxiv.org/html/2611.29513#bib.bib6)\]\. Agents also run post\-training pipelines\[ftdojo,posttrainbench\], write merging algorithms\[[14](https://arxiv.org/html/2611.29513#bib.bib14)\], or alternate harness edits with fine\-tuning\[hase,whale,selfhpo\]\. In each case the model chooses the inputs of an optimiser and gradient descent writes the weights; inSelfWritethe program the model writes*is*the weight edit\.
#### Generated weights, LoRA editing and weight\-space programming\.
Generative Adapter\[[5](https://arxiv.org/html/2611.29513#bib.bib5)\]and Text\-to\-LoRA\[[4](https://arxiv.org/html/2611.29513#bib.bib4)\]train a generator that maps a context to low\-rank weights; Transformer2\[transformer2\]learns singular\-value scaling vectors, Self\-MoE\[selfmoe\]routes among self\-specialised experts, and SOLAR\[solar\]trains a policy that proposes weight\-adaptation strategies\. LoRA\[[9](https://arxiv.org/html/2611.29513#bib.bib9)\]and PiSSA\[pissa\]write updates as low\-rank products, intruder directions characterise how LoRA changes the spectrum\[intruder\], and adapters are combined in closed form\[[13](https://arxiv.org/html/2611.29513#bib.bib13),ties,dare,[16](https://arxiv.org/html/2611.29513#bib.bib16)\], by searching merge coefficients\[[11](https://arxiv.org/html/2611.29513#bib.bib11),[3](https://arxiv.org/html/2611.29513#bib.bib3),[15](https://arxiv.org/html/2611.29513#bib.bib15),[2](https://arxiv.org/html/2611.29513#bib.bib2)\], or edited by fixed rules\[para,tada,slora\]; ROME and MEMIT write closed\-form rank\-one factual edits\[rome,memit\]\. Weight\-space programming lets an LLM write code that edits network weights\[wsp,[10](https://arxiv.org/html/2611.29513#bib.bib10),wsprobots,weightloop\]\.SelfWritebuilds on these operators but changes who uses them and on what: the edited model itself composes them, guided by its own reasoning traces, and each accepted edit changes the model that writes the next one\.
## 3Method
1Observe2Write: 8 independent sessions3Select: hidden gateMgM\_\{g\}answers 500fresh problems,4 samples eachreads its own answers ×\\boldsymbol\{\\times\}wrong✓\\boldsymbol\{\\checkmark\}right with full reasoning traces screen\_results screen\_output acts\(source="own"\)editor=Mg=M\_\{g\}\(thinking\),≤\\leq30 tool roundsin a persistent Python sessions1ΔW1\\Delta W\_\{1\}s2ΔW2\\Delta W\_\{2\}s3ΔW3\\Delta W\_\{3\}s4ΔW4\\Delta W\_\{4\}s5ΔW5\\Delta W\_\{5\}s6ΔW6\\Delta W\_\{6\}s7ΔW7\\Delta W\_\{7\}s8ΔW8\\Delta W\_\{8\}white\-box toolkitread⋅\\cdotconstruct⋅\\cdotcompute⋅\\cdotedit ops∇\\nablanogradient0s1s2s3s4s5s6s7s8bestΔ𝒢\>0\\Delta\_\{\\mathcal\{G\}\}\>0paired gainΔ𝒢\\Delta\_\{\\mathcal\{G\}\}vs\.MgM\_\{g\}, 500 problemsmerge the best editW′=W\+BA⇒Mg\+1W^\{\\prime\}=W\+BA\\;\\Rightarrow\\;M\_\{g\+1\}test \(500\):never shown to the editorgate statistics \(no problem content\)→\\tosessions of later generationssuccession:Mg\+1M\_\{g\+1\}is the next editor \(new screen, same gate\)
Figure 2:One generation ofSelfWrite\.\(1\) Observe:the current modelMgM\_\{g\}answers 500 freshly drawn problems four times, and the editor reads its own answers, reasoning included \([Section3\.2](https://arxiv.org/html/2611.29513#S3.SS2)\)\.\(2\) Write:eight independent sessions of the editorMgM\_\{g\}, each with up to 30 tool rounds over a white\-box toolkit for its own weights, each return a program that builds one LoRAΔWk\\Delta W\_\{k\}\([Section3\.3](https://arxiv.org/html/2611.29513#S3.SS3)\)\.\(3\) Select:every candidate is graded once on the hidden gate, paired problem by problem withMgM\_\{g\}; the largest strictly positive gain is merged, andMg\+1M\_\{g\+1\}becomes the next editor \([Section3\.4](https://arxiv.org/html/2611.29513#S3.SS4)\); gate statistics reach the sessions of later generations\. Bars are schematic\. The test split is never shown to the editor\.### 3\.1Setting
LetM0M\_\{0\}be the original model andMgM\_\{g\}the model afterggaccepted generations\. In generationgg,MgM\_\{g\}acts as the editor and writes programs whose output is a LoRAΔg=\{\(Am,Bm\)\}m∈ℳg\\Delta\_\{g\}=\\\{\(A\_\{m\},B\_\{m\}\)\\\}\_\{m\\in\\mathcal\{M\}\_\{g\}\}over a set of linear modulesℳg\\mathcal\{M\}\_\{g\}\. A candidate must pass the checks
rank\(BmAm\)≤64,‖BmAm‖F/‖Wg\(m\)‖F≤τ=0\.1∀m∈ℳg,\\operatorname\{rank\}\(B\_\{m\}A\_\{m\}\)\\leq 64,\\qquad\\\|B\_\{m\}A\_\{m\}\\\|\_\{F\}\\,/\\,\\\|W\_\{g\}^\{\(m\)\}\\\|\_\{F\}\\leq\\tau=0\.1\\quad\\forall m\\in\\mathcal\{M\}\_\{g\},\(1\)whereWg\(m\)W\_\{g\}^\{\(m\)\}is the current weight of modulemm, and returning no edit \(keepingMgM\_\{g\}\) is always allowed\. An accepted edit is merged,
Wg\+1\(m\)=bf16\(Wg\(m\)\+BmAm\),m∈ℳg,W\_\{g\+1\}^\{\(m\)\}=\\mathrm\{bf16\}\\big\(W\_\{g\}^\{\(m\)\}\+B\_\{m\}A\_\{m\}\\big\),\\qquad m\\in\\mathcal\{M\}\_\{g\},\(2\)with accumulation in FP32, and the merged modelMg\+1M\_\{g\+1\}is the editor of generationg\+1g\+1\.
#### Data roles\.
All problems come from one decontaminated training pool, split once into three disjoint parts: a*gate*set𝒢\\mathcal\{G\}of 500 problems that decides acceptance, a*test*set of 500 problems that is reported and never fed back, and the rest\. Each generation draws a fresh*screen*setSgS\_\{g\}of 500 problems from the rest; the remaining problems form the generation’s*train*set, whose statements and gold answers programs may read\. Scoring samples four answers per problem in thinking mode \(temperature 0\.6, top\-pp0\.95, top\-kk20, up to 16,384 tokens, fixed seed\), and a problem’s scores\(x\)∈\[0,1\]s\(x\)\\in\[0,1\]is the fraction of correct answers under deterministic answer matching\. For a candidateccand the current modelMgM\_\{g\}, the paired gain on𝒢\\mathcal\{G\}is
Δ𝒢\(c\)=1\|𝒢\|∑x∈𝒢\(sc\(x\)−sMg\(x\)\),\\Delta\_\{\\mathcal\{G\}\}\(c\)=\\frac\{1\}\{\|\\mathcal\{G\}\|\}\\sum\_\{x\\in\\mathcal\{G\}\}\\big\(s\_\{c\}\(x\)\-s\_\{M\_\{g\}\}\(x\)\\big\),\(3\)which editors of later generations receive as feedback together with a 95% paired\-bootstrap confidence interval and the counts and ids of the problems fixed and broken\.
### 3\.2Observe: the model reads its own answers
At the start of each generationMgM\_\{g\}answers the 500 screen problems once \(four samples each\)\. Every editing message carries a summary of this run: accuracy, the distribution of correct samples per problem, the truncation rate, and a few failed problems with statement, gold answer and extracted answer\. Two free tools expose the full record:screen\_resultsfilters problems by outcome \(all; wrong, unstable or right: 0, 1–3 or 4 of 4 samples correct\), andscreen\_outputpages through any sampled answer including its reasoning\. The same answers feed activation statistics:acts\(source=’own’\)runs the current weights on the problem*plus the model’s own answer*\(its first sample\), so the editor can contrast how a layer behaves when it reasons correctly and when it fails\.
### 3\.3Write: agentic editing sessions
Each candidate is written in one session of the editorMgM\_\{g\}in thinking mode\. The session offers three chat tools:run\_pythonexecutes code in a sandboxed Python process that persists across calls \(variables, handles and imports survive\),read\_recordopens the program and feedback of any earlier candidate, andsearch\_historylists every candidate tried in this and all earlier generations with its modules, rank, tools used and gate outcome\. Insiderun\_pythonthe editor calls the toolkit in[Table1](https://arxiv.org/html/2611.29513#S3.T1)through anapiobject\. After at most 30 tool rounds the editor returns a self\-contained programmain\(api\)that rebuilds the edit; the program runs in a fresh sandbox and its LoRA is checked against[Equation1](https://arxiv.org/html/2611.29513#S3.E1)\. Intermediate edits can be stored withsave\_editand reloaded by the final program\.
Table 1:The editor’s toolkit \(full signatures in[Table3](https://arxiv.org/html/2611.29513#A1.T3)\)\.WW: current weight of a module;\(ui,σi,vi\)\(u\_\{i\},\\sigma\_\{i\},v\_\{i\}\): its singular triplets\. No tool computes a gradient or trains\.Observescreen\_results,screen\_output\(own answers, reasoning included\),train\_example,diagnosticsReadsvd\(top\-kktriplets ofWW\),acts\(activation statistics on own answers or prompts\),tensors,output\_matricesConstructrank1\(suv⊤s\\,uv^\{\\top\}\),from\_direction\(ΔWk=αd\\Delta Wk=\\alpha d\),scale\_singular\(∑i\(fi−1\)σiuivi⊤\\sum\_\{i\}\(f\_\{i\}\{\-\}1\)\\sigma\_\{i\}u\_\{i\}v\_\{i\}^\{\\top\}\),project\_out\(−αuu⊤W\-\\alpha\\,uu^\{\\top\}W\),direction,unitComputetensor\_compute: sandboxed CPU PyTorch on up to four FP32 weight tensors→\\tostatistics, vectors or LoRA factorsOperatescale,interpolate,combine,drop,truncate\_rank,intruder\_scale,orthogonalize,ties, …Checkinspect,train\_loss\(forward\-only NLL on train problems\),compare\(fixed / broken problems\)The toolkit supports edits that are grounded in the model’s own behaviour\. A typical construction, suggested in the editor’s prompt, collects activations of one layer on the model’s own correct and incorrect answers, forms the normalised differenced=\(a¯wrong−a¯right\)/‖a¯wrong−a¯right‖d=\(\\bar\{a\}\_\{\\text\{wrong\}\}\-\\bar\{a\}\_\{\\text\{right\}\}\)/\\\|\\bar\{a\}\_\{\\text\{wrong\}\}\-\\bar\{a\}\_\{\\text\{right\}\}\\\|, and removes it from the layer’s output matrices withproject\_out, which adds the rank\-one termB=−αdB=\-\\alpha d,A=d⊤WA=d^\{\\top\}W\. Other programs rescale a few singular directions of selected modules, add activation directions withfrom\_direction, or compute exact factors withtensor\_compute;train\_lossprovides a cheap forward\-only check on train problems before a candidate is graded\. Activation statistics and losses are charged to a GPU\-time budget, while observation, reading and construction are free\.[Figure3](https://arxiv.org/html/2611.29513#S3.F3)shows a program of this kind\.
```
def main(api):
wrong = [r["id"] for r in api.screen_results(filter="wrong", limit=64)]
right = [r["id"] for r in api.screen_results(filter="right", limit=64)]
lora = api.new_lora()["lora"]
for layer in (44, 48, 52):
mod = f"layers.{layer}.mlp.down_proj"
a = api.acts(module=mod, ids=wrong, source="own")
b = api.acts(module=mod, ids=right, source="own")
d = api.direction(a=a["handle"] + ".out_mean",
b=b["handle"] + ".out_mean")
for m in api.output_matrices(layer=layer):
lora = api.project_out(target=lora, module=m["module"],
u=d["vector"], alpha=0.5)["lora"]
# forward-only sanity check on train problems
if api.train_loss(lora=lora, n=64)["delta"] > 0:
lora = api.scale(lora=lora, s=0.5)["lora"]
return {"lora": lora}
```
Figure 3:An illustrativeSelfWriteprogram \(real tool names and signatures; layers and constants are examples\): contrast the model’s activations on its own wrong and right answers, and project the contrast direction out of the layers’ output matrices\.
### 3\.4Select: hidden gate, merge and succession
Algorithm 1One generation ofSelfWrite\.1:current model
MgM\_\{g\}; gate set
𝒢\\mathcal\{G\}; test set; clean pool
PP; archive and history
𝒜\\mathcal\{A\}
2:
Sg←S\_\{g\}\\leftarrow500 problems drawn afresh from
P∖\(𝒢∪test\)P\\setminus\(\\mathcal\{G\}\\cup\\text\{test\}\); train set
Tg←P∖\(𝒢∪test∪Sg\)T\_\{g\}\\leftarrow P\\setminus\(\\mathcal\{G\}\\cup\\text\{test\}\\cup S\_\{g\}\)
3:
MgM\_\{g\}answers
SgS\_\{g\}\(4 samples, thinking mode\); store answers, reasoning and summary
4:score
MgM\_\{g\}on
𝒢\\mathcal\{G\}\(4 samples, same decoding and seed\)
5:for
k=1,…,8k=1,\\dots,8do⊳\\trianglerightindependent sessions, run in parallel
6:editor
MgM\_\{g\}explores withrun\_python,read\_record,search\_history\(
≤30\\leq 30tool rounds\)
7:editor returns program
pkp\_\{k\}; run
pkp\_\{k\}in a fresh sandbox
⇒\\RightarrowLoRA
ckc\_\{k\}
8:if
ckc\_\{k\}passes the caps \([Equation1](https://arxiv.org/html/2611.29513#S3.E1)\)then
9:hot\-load
ckc\_\{k\}on all replicas; score on
𝒢\\mathcal\{G\};
Δk←Δ𝒢\(ck\)\\Delta\_\{k\}\\leftarrow\\Delta\_\{\\mathcal\{G\}\}\(c\_\{k\}\)\([Equation3](https://arxiv.org/html/2611.29513#S3.E3)\)
10:record
Δk\\Delta\_\{k\}, its CI and fixed / broken counts and ids for later generations
11:
k⋆←argmaxkΔkk^\{\\star\}\\leftarrow\\arg\\max\_\{k\}\\Delta\_\{k\}over candidates with
Δk\>0\\Delta\_\{k\}\>0
12:if
k⋆k^\{\\star\}existsthen
13:
Mg\+1←Mg⊕ck⋆M\_\{g\+1\}\\leftarrow M\_\{g\}\\oplus c\_\{k^\{\\star\}\}\([Equation2](https://arxiv.org/html/2611.29513#S3.E2)\)
14:else
15:
Mg\+1←MgM\_\{g\+1\}\\leftarrow M\_\{g\}
16:add the generation’s programs and outcomes to
𝒜\\mathcal\{A\}; score
Mg\+1M\_\{g\+1\}on the test set \(logged, never shown to the editor\)
A generation runs eight independent sessions in parallel, each producing one candidate\.[Algorithm1](https://arxiv.org/html/2611.29513#alg1)summarises one generation\. Every candidate is graded once on𝒢\\mathcal\{G\}\(500 problems, four samples each\) and compared withMgM\_\{g\}by[Equation3](https://arxiv.org/html/2611.29513#S3.E3); the scores ofMgM\_\{g\}on𝒢\\mathcal\{G\}are computed once per generation with the same decoding and seed\. The editor never reads a gate problem: sessions of later generations see only each earlier candidate’s accuracy, paired gain, confidence interval and the counts and ids of fixed and broken problems, and no tool accepts a gate id\. At the end of the generation, the candidate with the largest strictly positive paired gain is accepted and merged by[Equation2](https://arxiv.org/html/2611.29513#S3.E2); if none improves,MgM\_\{g\}is kept\. The loop stops after three consecutive generations without an accepted edit\. After each generation the current model is also scored on the test split for logging; these scores are never shown to the editor, and we reportM0M\_\{0\}and the final model\. Earlier generations’ best programs are shown to the next editor and every attempt stays searchable, so experience accumulates while the editing model itself changes\.
#### Safe self\-modification\.
The loop changes weights only through programs that run in a sandbox without network access, read only train and screen problems, and produce edits that pass the caps in[Equation1](https://arxiv.org/html/2611.29513#S3.E1)\. Acceptance is decided by deterministic grading on data the editor cannot read, never by the model’s own judgement, and every accepted edit is a stored program plus a low\-rank tensor that a human can audit or revert\.
### 3\.5Implementation
The editor writes each LoRA from zero; nothing is trained at any point\. Seven data\-parallel vLLM\[vllm\]replicas ofMgM\_\{g\}serve the editor, hot\-load candidate LoRAs and split the gate problems, and one GPU holds a Transformers copy ofMgM\_\{g\}for SVD, activation statistics, forward losses and merging \([AppendixA](https://arxiv.org/html/2611.29513#A1)\)\.
## 4Experimental Setup
#### Model and data\.
We use Qwen3\.8\-27B\[qwen38\], a dense model with full\-attention and Gated DeltaNet layers, asM0M\_\{0\}; the same model is the first editor\. All problems come from DAPO\-Math\-17K\[dapo\]after decontamination against MATH, GSM8K, AIME, AMC and OlympiadBench \(exact match after normalisation, or at least half of the 13\-grams shared\) and removal of internal duplicates, which leaves 14,738 problems\. From this pool we fix a gate set of 500 problems and a test set of 500 problems, pairwise disjoint by id and by statement\. Each generation draws a fresh screen set of 500 problems from the rest; the remaining 13,238 problems are that generation’s train set\.
#### Protocol\.
We run five generations ofSelfWrite\. Each generation has eight independent editing sessions with up to 30 tool rounds each; tool turns and the final turn are capped at 16,384 output tokens, and the editor samples in thinking mode \(temperature 0\.6, top\-pp0\.95, top\-kk20\)\. Screen, gate and test scoring use the same thinking\-mode decoding with four samples per problem \(avg@4\) and a fixed seed\. The candidate with the largest strictly positive paired gain on the gate set is merged\. Runs use one node with eight GPUs: seven vLLM\[vllm\]replicas ofMgM\_\{g\}and one tool GPU \([Section3\.5](https://arxiv.org/html/2611.29513#S3.SS5)\); all settings are listed in[Table4](https://arxiv.org/html/2611.29513#A2.T4)\.
#### Metrics\.
We report the gate accuracy \(avg@4\) of the current model after every generation, the paired gainΔ𝒢\\Delta\_\{\\mathcal\{G\}\}of each accepted edit over the model that wrote it \([Equation3](https://arxiv.org/html/2611.29513#S3.E3)\), and the test accuracy ofM0M\_\{0\}and of the final model on the 500 test problems, both as avg@4 \(mean accuracy over the four samples\) and as pass@4 \(a problem counts as solved if any of its four samples is correct\)\.
## 5Results
GateTestModelavg@4Δ𝒢\\Delta\_\{\\mathcal\{G\}\}avg@4pass@4M0M\_\{0\}\(Qwen3\.8\-27B\)73\.95–76\.3082\.60M1M\_\{1\}75\.15\+1\.20––M2M\_\{2\}75\.65\+0\.50––M3M\_\{3\}75\.75\+0\.10––M4M\_\{4\}76\.45\+0\.70––M5M\_\{5\}\(final\)76\.450\.0077\.7584\.80M5−M0M\_\{5\}\-M\_\{0\}\+2\.50\+1\.45\+2\.20
Table 2:Self\-editing raises gate accuracy by 2\.50 points, and the final model gains 1\.45 points avg@4 and 2\.20 points pass@4 on the held\-out test split\.Gate accuracy after each generation and final test accuracy \(%\)\.Δ𝒢\\Delta\_\{\\mathcal\{G\}\}: paired gain over the previous model on the gate set \(points\)\. The test split is reported forM0M\_\{0\}and the final model\.
Figure 4:Gate accuracy rises from 73\.95% \(M0M\_\{0\}\) to 76\.45% \(M5M\_\{5\}\)\.Gate accuracy \(%, avg@4\) of the current modelMgM\_\{g\}after each generation; dashed:M0M\_\{0\}\.
### 5\.1Gains across generations
[Table2](https://arxiv.org/html/2611.29513#S5.T2)and[Figure4](https://arxiv.org/html/2611.29513#S5.F4)follow the current model through five generations ofSelfWrite\. Each generation the edited model writes the next edit, and an edit is merged only when it beats the model that wrote it on the hidden gate, so every accepted step is a paired gain the model produced by editing itself\.SelfWriteraises gate accuracy from 73\.95% forM0M\_\{0\}to 76\.45% for the final modelM5M\_\{5\}, a cumulative gain of 2\.50 points\. The accepted edits gain \+1\.20, \+0\.50, \+0\.10 and \+0\.70 points\. The first edit brings the largest step, and every later generation, written by a model that has already edited itself, still finds a further improvement; the fourth generation, written byM3M\_\{3\}, brings the second\-largest step: the edited model remains an effective editor of its own weights\.
### 5\.2Held\-out test accuracy
The test split is never screened, gated or shown to the editor, so it measures whether the self\-written edits generalise beyond the problems that selected them\. On these 500 problems, avg@4 accuracy rises from 76\.30% forM0M\_\{0\}to 77\.75% forM5M\_\{5\}\(\+1\.45 points\) and pass@4 from 82\.60% to 84\.80% \(\+2\.20 points;[Table2](https://arxiv.org/html/2611.29513#S5.T2)\) without a single gradient step\. The edited model both answers more reliably per sample and solves problems thatM0M\_\{0\}missed in all four samples, so the self\-written edits carry over to problems that played no part in selecting them\.
## 6Conclusion
We introduced gradient\-free recursive self\-editing, in which a language model writes the program that changes its own weights and the edited model writes the next change\.SelfWritegrounds each edit in the model’s own reasoning on fresh problems, explores its weights in an agentic session with a white\-box toolkit, accepts an edit only on a hidden paired gate, and merges it so the improved model becomes the next editor\. On Qwen3\.8\-27B, five generations raise gate accuracy by 2\.50 points \(73\.95% to 76\.45%\) and held\-out test accuracy by 1\.45 points avg@4 \(76\.30% to 77\.75%\) and 2\.20 points pass@4 \(82\.60% to 84\.80%\) without a single gradient step\.
#### Discussion\.
The loop needs no reward model, no gradient and no human\-written edit: the model decides where and how to change its weights from its own answers, and a fixed paired gate decides whether the change is kept\. Every gain in[Table2](https://arxiv.org/html/2611.29513#S5.T2)is therefore a change the model chose for itself, stored as a short program and a low\-rank tensor that can be read, rerun or reverted\. Because the improved model writes the next edit, the editor improves together with the model it edits\. The cost of a generation is dominated by sampling the screen and grading eight candidates, so the loop scales with inference rather than with training\.
#### Future work\.
Next steps are self\-editing across several domains at once, longer horizons with more generations, larger editors, and richer edit spaces beyond low\-rank updates, such as edits that change several modules jointly\.
## References
- \[1\]Emre Can Acikgoz, Cheng Qian, Heng Ji, Dilek Hakkani\-Tür, and Gokhan Tur\.TT\-SI: Self\-Improving LLM Agents with Test\-Time Training\.In*Findings of the Association for Computational Linguistics: ACL 2026*, pages 9483–9508, 2026\.doi:10\.18653/v1/2026\.findings\-acl\.462\.
- \[2\]Lenny Aharon, Neta Glazer, and Lior Aharon\.Audit Before You Merge: Provenance, Probing, and Continual LoRA Composition\.In*ICML 2026 Workshop on Continual Adaptation at Scale \(CATS\)*, 2026\.arXiv:2611\.10684\.
- \[3\]Takuya Akiba, Makoto Shing, Yujin Tang, Qi Sun, and David Ha\.Evolutionary Optimization of Model Merging Recipes\.*Nature Machine Intelligence*, 7:195–204, 2025\.doi:10\.1038/s42256\-024\-00975\-8\.
- \[4\]Rujikorn Charakorn, Edoardo Cetin, Yujin Tang, and Robert Tjarko Lange\.Text\-to\-LoRA: Instant Transformer Adaption\.In*International Conference on Machine Learning \(ICML\)*, 2025\.
- \[5\]Tong Chen, Hao Fang, Patrick Xia, Xiaodong Liu, Benjamin Van Durme, Luke Zettlemoyer, Jianfeng Gao, and Hao Cheng\.Generative Adapter: Contextualizing Language Models in Parameters with A Single Forward Pass\.In*International Conference on Learning Representations \(ICLR\)*, 2025\.
- \[6\]Alistair Cheong, Haolin Cong, Tyler Yang, and Dustin Miao\.Search over Self\-Edit Strategies for LLM Adaptation\.*arXiv preprint arXiv:2601\.14532*, 2026\.
- \[7\]Irving John Good\.Speculations Concerning the First Ultraintelligent Machine\.In*Advances in Computers*, volume 6, pages 31–88\. Academic Press, 1966\.doi:10\.1016/S0065\-2458\(08\)60418\-0\.
- \[8\]Prannay Hebbar, Yogendra Manawat, Samuel Verboomen, Alesia Ivanova, Selvam Palanimalai, Kunal Bhatia, and Vignesh Baskaran\.SIA: Self Improving AI with Harness & Weight Updates\.*arXiv preprint arXiv:2605\.27276*, 2026\.
- \[9\]Edward J\. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen\-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen\.LoRA: Low\-Rank Adaptation of Large Language Models\.In*International Conference on Learning Representations \(ICLR\)*, 2022\.
- \[10\]Junru Hu, Cheng Tang, Wei Li, Hongze Zhu, Chun\-Mei Feng, Qi Zhang, Yirong Chen, and Ming Hu\.Exploring Weight\-Space Programming: Capabilities, Generalization, and Limitations\.*arXiv preprint arXiv:2611\.09382*, 2026\.
- \[11\]Chengsong Huang, Qian Liu, Bill Yuchen Lin, Tianyu Pang, Chao Du, and Min Lin\.LoraHub: Efficient Cross\-Task Generalization via Dynamic LoRA Composition\.In*Conference on Language Modeling \(COLM\)*, 2024\.
- \[12\]Chengsong Huang, Wenhao Yu, Xiaoyang Wang, Hongming Zhang, Zongxia Li, Ruosen Li, Jiaxin Huang, Haitao Mi, and Dong Yu\.R\-Zero: Self\-Evolving Reasoning LLM from Zero Data\.In*International Conference on Learning Representations \(ICLR\)*, 2026\.
- \[13\]Gabriel Ilharco, Marco Tulio Ribeiro, Mitchell Wortsman, Suchin Gururangan, Ludwig Schmidt, Hannaneh Hajishirzi, and Ali Farhadi\.Editing Models with Task Arithmetic\.In*International Conference on Learning Representations \(ICLR\)*, 2023\.
- \[14\]Yoichi Ishibashi, Taro Yano, and Masafumi Oyamada\.Can Large Language Models Invent Algorithms to Improve Themselves?: Algorithm Discovery for Recursive Self\-Improvement through Reinforcement Learning\.In*Proceedings of the 2025 Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics \(NAACL\)*, 2025\.
- \[15\]Tao Jiang, Xinmeng Yu, Chenhao Yi, Yiling Wu, Yan Li, Ran Cheng, Dongmei Jiang, and Jianguo Zhang\.EvoGM: Learning to Merge LLMs via Evolutionary Generative Optimization\.In*International Conference on Machine Learning \(ICML\)*, 2026\.
## Appendix AMethod Details ofSelfWrite
### A\.1Tools
[Table3](https://arxiv.org/html/2611.29513#A1.T3)lists the program tools with their costs; every tool takes keyword arguments and returns handles to objects held by the trusted runtime\. Exploration throughrun\_pythonuses the same tools, and GPU tools draw on a separate 600\-second exploration budget per generation, shared by the eight sessions; no tool evaluates a candidate\.
Table 3:Program tools\. “Free” tools cost nothing; GPU tools draw on the generation’s 7,200\-second GPU budget, shared by its eight programs;tensor\_computeruns on CPU within the program’s wall clock\.ToolPurposeCostscreen\_results\(ids, filter, limit, offset\)own screen answers: statement, gold, extracted answers, scoresfreescreen\_output\(id, sample, offset\)one full answer, reasoning included, pagedfreetrain\_ids,train\_example\(id\)train problems with gold answersfreemodules,tensors,output\_matricesmodule and tensor names and shapesfreediagnostics\(module, layer, top, sort\)per\-module norms, singular values, merged\-edit norm, effective rank, intruder score, relative changefreesvd\(module, k\)top\-kksingular triplets of the current weightfreeacts\(module, ids, k, source\)activation means and principal directions on train prompts, screen prompts or own answersGPUnew\_lora,rank1,from\_direction,scale\_singularclosed\-form low\-rank constructionsfreeunit,direction,project\_outvector algebra;W←W−αuu⊤WW\\leftarrow W\-\\alpha uu^\{\\top\}Was a rank\-one termfreetensor\_compute\(code, tensors, vectors\)sandboxed CPU PyTorch on up to four FP32 tensorsCPU timescale,interpolate,combine,drop,truncate\_rank,intruder\_scale,relchange\_prune,orthogonalize,tiesLoRA operatorsfreestack,candidate\(cid\)merged edits of earlier generations; earlier candidatesfreesave\_edit,load\_edit,list\_edits,drop\_editkeep edits between exploration and the final programfreeinspect\(lora\)modules, rank, cap checkfreetrain\_loss\(lora, ids, n\)forward\-only answer NLL on train problems vs\. without the editGPUcompare\(cid, other\)fixed / broken problems between evaluated models \(ids and statistics\)free
### A\.2What the editor sees
The system prompt describes the setting \(the editor is the model being edited; edits are merged if they win on the hidden gate\), the caps, the toolkit with signatures, the number of tool rounds, and that the session is one of eight independent sessions\. Every message carries the summary of the current model’s screen answers, the diagnostics table, the gate outcomes of earlier generations’ candidates \(accuracy, paired gain and interval, fixed and broken counts;search\_historyandread\_recordalso list the ids of fixed and broken problems, never their content\), and the best programs of earlier generations\. Long sessions are compacted: older tool outputs and reasoning are elided once the prompt exceeds 60% of the 131,072\-token context\.
### A\.3Sandbox and data boundaries
Programs andrun\_pythoncode run in a separate process with memory and time limits and no network access; tools are reached only through theapiobject, and objects are referred to by handles\. Activation tools accept only train or screen ids, the statements and answers of gate and test problems are never readable, and the final program must be self\-contained: it is re\-run from scratch and its output is checked before grading\.
## Appendix BHyper\-parameters and Compute
[Table4](https://arxiv.org/html/2611.29513#A2.T4)lists the settings of the main run \(math\)\.
Table 4:Hyper\-parameters ofSelfWrite\(main run\)\.SettingValue*Model and decoding*ModelM0M\_\{0\}Qwen3\.8\-27B, BF16Editorcurrent modelMgM\_\{g\}, thinking mode; temperature 0\.6, top\-pp0\.95, top\-kk20Editor output caps16,384 tokens per tool turn and for the final turn; context 131,072 tokensEditor session limits30 tool rounds, 100 tool calls, 160,000 completion tokens, 2,400 s per candidateScreen / gate / test decodingthinking mode, temperature 0\.6, top\-pp0\.95, top\-kk20,≤\\leq16,384 tokens, 4 samples \(avg@4\), seed 42Gradingdeterministic math answer equivalence*Data*PoolDAPO\-Math\-17K, 14,738 problems after decontamination and de\-duplicationGate set𝒢\\mathcal\{G\}500 problems, fixed, never readableTest set500 problems, fixed, reported onlyScreen set500 problems, drawn afresh each generationTrain setremaining 13,238 problems per generation \(statements and gold answers readable\)*Edits*LoRA rank cap64 per moduleNorm capτ\\tau‖ΔW‖F/‖Wg‖F≤0\.1\\\|\\Delta W\\\|\_\{F\}/\\\|W\_\{g\}\\\|\_\{F\}\\leq 0\.1per moduleMergeW′=bf16\(W\+BA\)W^\{\\prime\}=\\mathrm\{bf16\}\(W\+BA\), FP32 accumulation, edited shards only*Search and gate*Sessions per generation8 independent sessions, 1 candidate eachAcceptancelargest strictly positive paired gain on𝒢\\mathcal\{G\}Generations5; stop after 3 consecutive generations without acceptanceGPU budgetper generation, shared by the 8 sessions: 7,200 s for programs, 600 s for explorationtensor\_compute≤\\leq4 tensors per call, 300 s, 16 GB, CPU onlyProgram sandbox1,800 s, 16 GB, no network*Hardware*GPUs8 per run: 7 vLLM replicas ofMgM\_\{g\}\(editor, scoring, LoRA hot\-loading\) \+ 1 tool GPU \(SVD, activations, losses, merge\)相似文章
权重空间编程:一个大语言模型直接编辑了另一个模型的权重,将其数学得分从 7.9% 提升至 48.1%
麻省理工学院的研究人员展示了一个大语言模型(GPT-6 Astra)能够直接编辑另一个模型的权重,以纠正其重复性行为。在无需训练的情况下,仅修改约 0.016% 的参数,就将一个小型 Qwen 模型的数学得分从 7.9% 提升至 48.1%,但这一结果仍存在一些局限,且尚待独立复现。
语言模型可以改写自身的权重
一篇由伊利诺伊大学厄巴纳-香槟分校、卡内基梅隆大学、罗格斯大学、普林斯顿大学、斯坦福大学和耶鲁大学联合发表的论文表明,一个拥有270亿参数的开放语言模型仅凭推理就能改写自身权重,无需梯度或训练,在未见过的问题上将准确率提高6.6个百分点,并修复自身受损的副本。这种能力只有在模型规模足够大时才会涌现,表明这可能是迈向递归式自我改进的一步。
权重空间编程的火花:LLM 能够原生读写神经网络权重
一篇研究博客文章发现,前沿 LLM 能够原生读写神经网络权重——诊断训练后的策略、编辑权重以修复推理循环并将 Qwen3.5-0.8B 在 MATH-500 上的成绩从 7.9% 提升至 48.1%、以及手工编写小型游戏网络——作者将这一能力称为「权重空间编程」(Weight-Space Programming)。
谷歌在大语言模型方面的自我改进(阅读需18分钟)
谷歌研究人员提出了一种无需数据的同策略自蒸馏框架,让大语言模型根据粗略的主题描述,自行合成由查询和特权推理轨迹组成的训练课程,从而在无需外部监督的情况下,在文本和多模态基准测试中实现自我提升。
大模型何时应信任自己的修改?一项关于内在自我纠正的风险感知研究
这篇 arXiv 论文在 BoolQ、GSM8K 和 Corr2Cause 三个基准上,对 29 个开源权重 LLM 的内在自我纠正能力进行了研究,发现修改可能会将原本正确的答案翻转为错误,并指出自我纠正应当被视为一种选择性的修改策略,而非普遍有益的第二轮处理。