weight-space-programming-autoresearch

Interpretable weight-space programming builds transparent transformers and brain encoding models

Yash Mehta1,2  路  Chandan Singh1  路  Weijia Xu1  路  Richard J. Antonello3  路  Adeen Flinker4  路  Nima Mesgarani3  路  Michael F. Bonner2  路  Nebojsa Jojic1  路  Jianfeng Gao1

1  Microsoft Research     2  Johns Hopkins University     3  Columbia University     4  New York University

arXiv 2611.18114 Toy-examples report BibTeX

Animated overview of interpretable weight-space programming (iWSP): an LLM agent writes an interpretable brain encoding model directly in code with no training, evaluates it against recorded brain activity, and iteratively keeps the best revisions.

Overview

Neural networks predict well but are hard to understand, which is a serious problem in science, where explanation is the goal. Encoding models in neuroscience can predict brain responses to natural stimuli, yet they struggle to say which features of the stimulus drive those responses.

Interpretable weight-space programming (iWSP) takes a different route: an LLM agent builds the model by writing its weights and features directly in code, and training is not allowed. At each iteration the agent sees only a single validation score, so it has to use what it already knows. It writes interpretable features, reuses known ones, scores them and revises them. The result is a model you can read, because every part of it was written on purpose.

This repo holds the code, agent prompts and full logs behind the paper.

Results

Domain What iWSP built Result in the paper
Algorithmic tasks Hand-written transformers for tasks such as addition, sorting and GCD All 26 Opus runs reach 100% accuracy on the hidden set
NLP tasks Hand-written transformers for classification 87.3% on TREC; well above a majority baseline on 3 of 4 tasks, with no gain on paraphrase detection
Visual cortex (macaque electrophysiology) Encoding models of Utah-array spiking responses (TVSD), tested on held-out images and zero-shot on Neuropixels (Triple-N) Beats all seven interpretable baselines on every split: held-out TVSD early (0.852 versus 0.674) and ventral (0.669 versus 0.506), and zero-shot Triple-N early (0.403 versus 0.316) and ventral (0.279 versus 0.210). Exceeds AlexNet in early visual cortex on both datasets (0.728 and 0.350), trails it in ventral (0.716 and 0.351), and reaches 24.0% versus 12.5% linear-readout ImageNet top-1 accuracy
Visual cortex (human fMRI) Encoding models of 7 T fMRI (LAION-fMRI), tested zero-shot on NSD Beats all seven interpretable baselines on NSD in early (0.443 versus 0.400) and ventral visual cortex (0.317 versus 0.256); matches AlexNet in early visual cortex, trails it in ventral (0.391), and reaches 22.9% linear-readout ImageNet top-1 accuracy
Story-listening fMRI Encoding models of language responses A readable model exposed a confound at the edges of each scan: position features alone lift the correlation from 0.067 to 0.104, above GPT-2 XL (0.079). With the edges trimmed, iWSP is on par with GPT-2 XL
ECoG responses to audio Interpretable raw-waveform features 0.074 versus 0.082 for Whisper on the hidden set, above textbook features (0.059); combining iWSP with Whisper reaches 0.087

The models also hold up to a direct test of readability. An LLM describes each model in at most 200 words, and fresh sessions rebuild it from that description alone. All rebuilt models of the 13 algorithmic tasks reach 100% hidden accuracy, and rebuilt NLP models lose about 1.4 points of hidden accuracy on average.

These findings point to iWSP as a way to align highly predictive scientific models with human-interpretable scientific theories.

Quickstart

You need uv and, to run the agent, Claude Code.

git clone https://github.com/csinva/weight-space-programming-autoresearch
cd weight-space-programming-autoresearch
uv sync

Run the agent on one task. It writes a transformer鈥檚 weights by hand, scores them and iterates:

uv run experiments/evolve/launch_claude.py --model opus55 --tasks gcd-three-digits --seeds 1 --workers 1

Each run gets its own folder, such as experiments/runs/opus55/gcd-three-digits-opus55-s1/, with every model it tried and the agent鈥檚 transcript. To see the evaluator work without an agent:

uv run experiments/evolve/setup_run.py demo
cd experiments/runs/manual/demo
uv run interpretable_transformer.py --task addition-five-digits

Reproducing the experiments

Experiment Where Details
Algorithmic and language transformers experiments/evolve/ Experiments guide
Text bottleneck experiments/nl-bottleneck/ Experiments guide
Story-listening fMRI experiments/evolve-neuro/ Experiments guide
Visual cortex (macaque electrophysiology and human fMRI) experiments/vision/ Its README
ECoG responses to audio experiments/ecog/ Experiments guide
Reading a real model鈥檚 weights experiments/systematic-tests/ Experiments guide

Repository layout

experiments/
  evolve/             harness, prompt and audits for the transformer runs
  evolve-neuro/       harness and prompt for the story-listening fMRI runs
  vision/             harness for the visual cortex searches, with its own history
  ecog/               ECoG searches, analyses and new test set results
  nl-bottleneck/      text bottleneck: describe a model, rebuild it, compare
  systematic-tests/   tests of whether an LLM can read a real model's weights
  runs/               every run: opus55, sonnet55, haiku55 and may15 (transformers), neuro (story fMRI)
analyze/              reports and figures built from the runs

The hosted reports cover the runs in more depth. Runs live in folders and do not use commits, so every model an agent tried is saved as a snapshot next to its logged score.

Acknowledgements

This work is pretty similar to Sparks of Weight-Space Programming! We were working on it at the same time, but a little more focused on the interpretability angle and applying it to neuroscience.

Citation

If you use this code, please cite the paper (also in citation.bib):

@misc{mehta2026interpretableweightspaceprogrammingbuilds,
      title={Interpretable weight-space programming builds transparent transformers and brain encoding models}, 
      author={Yash Mehta and Chandan Singh and Weijia Xu and Richard J. Antonello and Adeen Flinker and Nima Mesgarani and Michael F. Bonner and Nebojsa Jojic and Jianfeng Gao},
      year={2026},
      eprint={2611.18114},
      archivePrefix={arXiv},
      primaryClass={cs.CE},
      url={https://arxiv.org/abs/2611.18114}, 
}