Weight-Space Programming Writes In-Context Learning and Matches Fine-Tuning in Language Models

Konstantinos Skianis, Aristidis Likas

It’s late, you’ve had a long day, and the last thing you want is a dry lecture on backpropagation. So, let’s skip the calculus and talk about brain surgery—specifically, AI brain surgery performed by other AIs.

TL;DR

Instead of training a small AI model using traditional, math-heavy "learning," what if we just asked a smarter AI to "open the hood" and rewire the small one's brain? This paper demonstrates Weight-Space Programming: a frontier model (like Claude or GPT-4) can read a small model's weights, identify how it processes information, and surgically edit a tiny fraction of those weights to "bake in" new skills—matching the performance of traditional training while being thousands of times more precise.

What Problem Does This Paper Address?

We usually have two ways to make a Large Language Model (LLM) do something specific:

  1. In-Context Learning (ICL): You give it a few examples in the prompt. It’s fast but temporary; you have to pay for those examples in every single message.
  2. Fine-Tuning: You use gradient descent (the standard math of AI training) to update the weights. It’s permanent but "blunt"—it often changes millions of parameters, making it a black box that might accidentally break other skills.

The authors explore a third path: Weight-Space Programming (WSP). Can a powerful "Editor" model look at a "Target" model and simply write the necessary logic directly into its weights? This would combine the speed and few-example efficiency of ICL with the permanence of fine-tuning, all while being much more interpretable.

Methods

The researchers set up a fascinating "surgical theater":

  • The Editor: A frontier model (e.g., Claude 3.5, GPT-4, Gemini 1.5) is given a Python kernel.
  • The Target: A smaller model (like Qwen2.5-0.5B).
  • The Task: The Editor gets 16 examples of a task (like translating English to French).
  • The Surgery: The Editor is allowed to run the Target model up to 50 times to see how it "thinks." It then writes Python code to directly overwrite specific values in the Target's weight matrices. Crucially, no gradients are allowed. No standard training math—just pure, logical editing.

The Editors often discovered a clever trick: they found "near-silent" neurons (MLP units that rarely fire) and repurposed them. They turned these neurons into "format detectors" that trigger a specific "task vector" only when they see a particular prompt style (e.g., Input: [word] \nOutput:).

Figure 1: The update the editors most often write, drawn for one unit. An MLP hidden unit is a key-value pair (Geva et al., 2021): its key (row j of Wgate and Wup) decides when it fires, its value (column j of Wdown) is what it adds. The editor writes three vectors of length 896 per unit, with a median of four units per run. Section 5 gives the weights and checks them against the deltas.

Datasets

The study used a variety of word-mapping and logic tasks:

  • Simple Tasks: Antonyms, country-to-capital, tense conversion, and basic arithmetic ($n \to 2n$).
  • Complex Tasks: Converting snake_case to camelCase, Roman numeral conversion, sentiment analysis, and even "Pig Latin."
  • Benchmarks: They monitored WikiText-2 and ARC-Easy to ensure the "surgery" didn't lobotomize the model's general language abilities.

Key Insights and Ideas

  • Surgical Precision: One Editor (Fable 5.1) achieved 88.5% accuracy by changing just 8,512 parameters. That’s roughly 0.002% of the model. Traditional fine-tuning methods like LoRA often touch millions of parameters to get the same result.
  • The "Aha!" Moment: The Editors didn't just guess; they actively looked for the "task vector"—the internal mathematical direction that represents a specific skill. They then "injected" this vector into the weights so the model would follow it even without examples in the prompt.
  • Self-Supervised Surgery: In one experiment, the researchers gave the Editor inputs but no labels (no answers). The Editor used its own internal knowledge to figure out the answers, labeled the data itself, and then edited the Target model. It worked almost as well as having the ground-truth labels.
  • Alignment with ICL: The internal "shift" caused by these manual edits almost perfectly mirrors the shift that happens naturally when you give a model examples in a prompt.
Figure 2: Cosine similarity between the residual shift of the update and that of ICL (Section 3), by layer (0 = embedding): mean over completed Qwen2.5-0.5B runs, with the random-edit control for reference.

Key Results

  • Performance: WSP reached a mean accuracy of ~88-93% across tasks, putting it on par with both 16-shot ICL and traditional gradient-based fine-tuning.
  • Efficiency: WSP changed $10^2$ to $10^5$ times fewer parameters than full fine-tuning.
  • Safety: For smaller models, these surgical edits usually left the model's general knowledge (perplexity) completely untouched.

Limitations and Future Work

  • Brittleness: The edits are highly sensitive to formatting. If the Editor trained the model on Input: [x], and you test it with Q: [x], the performance collapses. The "detector" neurons are too specific.
  • Scaling Issues: As the Target models got larger (7B or 14B parameters), the Editors struggled to stay "sparse." They started writing much larger updates that occasionally damaged the model's general performance.
  • Cost: Using frontier models as "surgeons" is currently expensive. The study cost about $779 in API credits.
  • Future Direction: The authors suggest that WSP adds "legibility, not accuracy." It’s a tool for making model updates that humans (and other AIs) can actually read and understand, rather than relying on the mysterious "soup" of gradient descent.

Summary updated

Abstract

Weight-space programming is a frontier language model's recently reported ability to read and rewrite another network's weights without gradient descent. We investigate how examples can provide a weight update so that a weaker language model performs the task with nothing in the prompt, and study what it edits. Our experiments cover six tasks, four frontier editors and three families of weaker language models, without the editors being told anything about in-context learning (ICL). In most runs, the few-shot minus zero-shot residual is measured at the final prompt token, the ICL task vector, and write it into the weights, at its sparsest into near-silent MLP units keyed to the prompt format. Results reach the accuracy of ICL and of fine-tuning on the same examples, LoRA included, usually leaving perplexity untouched, with worse performance under changes of wording. We also qualify the comparison by counting unfinished runs, observing that one editor falls below fine-tuning; held only to the seen examples, without task pairs of their own, only the strongest editor has similar performance. Given a task and unlabelled inputs, that editor writes its own examples and does nearly as well on unseen items as with labels.
BibTeX
@misc{skianis2026weight,
  author = {Konstantinos Skianis and Aristidis Likas},
  title = {{Weight-Space Programming Writes In-Context Learning and Matches Fine-Tuning in Language Models}},
  year = {2026},
  eprint = {2611.26841},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.26841},
}
Figure