What If We Programmed Models Instead of Training Them?
When a model misbehaves, we fine-tune it. But if we already know what needs to change, do we still need the model to learn it? Experiments with weight-space programming and LoRA.
- Written by
- Puneet Bajaj
- Published
- Reading time
- 6 min read
When a model does not behave the way we want, our usual response is to fine-tune it. We collect examples, define a loss function, and let gradient descent figure out what needs to change.
But what if we already know what needs to change? Do we still need the model to learn it?
Recently, researchers demonstrated something called weight-space programming (WSP), where an LLM can inspect another model’s weights, understand parts of its computation, and directly modify them without gradient descent.
Coming from a software engineering background, I find this particularly interesting. Instead of teaching a system to behave differently through thousands of examples, we could potentially identify the problem and write a fix.
I wanted to understand how far this approach could go and where traditional fine-tuning would still be better.
Does the model need to learn something new?
I started experimenting with predicting human survey responses using a small language model. Both fine-tuning and weight-space programming improved upon the base model, but neither beat a simple statistical baseline that predicted the most common answer to each question.
The best programmed edit reached 45%, LoRA reached 42.8%, and the statistical baseline reached 47.1%.
What was interesting was how the programmer achieved this improvement. Rather than getting better at understanding individuals, it essentially wrote population-level answer distributions into the model’s weights.
This made me think about what we actually ask a model to do when we fine-tune it.
Sometimes the model already has the necessary knowledge but uses it incorrectly. Sometimes we have information that we simply want to store in the model. And sometimes we need the model to learn a relationship that we cannot explicitly write down.
These are different problems, so why should we expect the same approach to work best for all three?
Redirecting knowledge versus learning
Consider sentiment classification. What happens if we deliberately reverse the expected answers, so positive becomes negative and negative becomes positive?
The base Qwen2.5-1.5B model scored just 4% on this task. However, it had not lost its understanding of sentiment. We had changed what we expected it to output.
Across independent programming runs, agents discovered the same main fix: swap the embedding rows of two words, “negative” and “positive”. This alone brought accuracy to 46.2%. The same approach worked on a different model family, SmolLM2.
LoRA, under the default training budget, struggled to learn this task in two out of three runs on Qwen.
But when I tested ordinary sentiment classification, the results were reversed. Weight-space programming reached at most 48%, while LoRA reached 59%. Even with just 256 distinct training examples, LoRA performed better than the programmed edits.
The distinction is important. In the first case, there was a specific mistake that could be corrected. In the second, the model needed to get better at a mapping it only partially understood.
A model that scores 100% but stops working
The next question was whether programming could add information that did not exist in the model.
I created 900 facts about fictional people and asked programming agents to store them in the weights. Three independent runs achieved 100% accuracy, even when the questions were phrased differently from the training examples.
It looked like a great result until I evaluated the rest of the model.
| Model | Fact accuracy | MMLU accuracy |
|---|---|---|
| Base model | 21.1% | 59.6% |
| Programmed lookup circuit | 100% | 22.2% |
| Programmed memory edit | 76.9% | 59.6% |
The first edit had effectively built a lookup circuit inside the model, bypassing much of its existing computation. Its next-token prediction accuracy on ordinary text dropped to almost zero.

Another programmer took a different approach. It stored the facts through the model’s existing MLP pathway. It was less accurate at recalling the facts, but the model retained its measured general abilities.
Interestingly, changing the instructions to explicitly require preservation of existing abilities also changed the kind of edit an agent produced in the survey task.
This is something we need to consider when giving agents the freedom to modify models. If I only ask an agent to maximise accuracy on a task, I cannot assume it will preserve everything else.
Why not combine the two?
At this point, I was less interested in whether weight-space programming could beat fine-tuning and more interested in whether it could help fine-tuning.
If a programmer can solve part of the problem directly, can gradient descent learn the remaining part more efficiently?
Starting LoRA from the non-destructive factual-memory edit gave the following results:
| Approach | Training presentations | Fact accuracy |
|---|---|---|
| LoRA | 4,000 | 22.2% |
| LoRA | 40,500 | 98.8% |
| Programmed edit + LoRA | 4,000 | 99.0–99.7% |
The hybrid also retained general-knowledge performance across three seeds.
On reversed sentiment, starting from the embedding swap allowed LoRA to learn consistently across both model families. Ordinary LoRA eventually learnt the task with three times the training presentations on Qwen.

Even more interestingly, a simple hand-written swap worked just as well as the agent’s edit once LoRA was applied. The agent’s value was in discovering what needed to change.
The reduction here is in training presentations, not unique facts, and programming itself has a computational and API cost. Whether the entire process is cheaper depends on those costs.
Where I think this becomes useful
I don’t think weight-space programming should replace fine-tuning. What interests me is using it before fine-tuning.
When working with software, we don’t rewrite an entire system every time something behaves incorrectly. We try to understand where the problem is, what needs to change, and what should remain untouched.
Perhaps model adaptation can benefit from a similar approach. Identify the parts of a problem we can explicitly solve, modify the model accordingly, and use gradient descent for the parts we still need to learn.
These experiments are limited to small language models and a few tasks, so we don’t yet know how broadly this approach will work.
But they suggest a different question to ask before we start fine-tuning a model:
What does the model actually need to learn, and what can we already fix?
This article accompanies my working paper, Compile, Learn, or Both? When Weight-Space Programming Helps, What It Breaks, and Why Combining It with LoRA Matters.
For a longer walk-through where you can explore the recorded data yourself, read Weight-Space Programming, Step by Step.
Read the paper on Zenodo · GitHub repository, experiments and results