Weight-space programming and mechanistic interpretability for model editing in particle physics

Raphaël Bonnet-Guerrini, Johann Ioannou-Nikolaides, Troels PetersenarXiv 2026

TL;DR

Even the most powerful AI "foundation models" in physics can fall for cheap tricks, like misclassifying a high-energy particle jet just because a single, tiny photon was added to the mix. This paper uses "mechanistic interpretability" to find the specific "brain cells" (attention heads) responsible for this confusion and demonstrates that we can surgically repair the model's weights—sometimes using an LLM as the surgeon—without the need for traditional, heavy-duty retraining.

What Problem Does This Paper Address?

In particle physics, we often deal with jets: narrow cones of particles produced in high-energy collisions. A fundamental rule in physics is Infrared (IR) Safety. Simply put, if you add an extremely low-energy ("soft") particle to a jet, your physical observables (like the jet's mass or its classification) shouldn't change. It’s the physics equivalent of saying a scale shouldn't change its reading of a person's weight just because a single dust mote landed on their shoulder.

However, modern AI foundation models like OmniLearned, which are trained on massive, diverse datasets, often fail this test. The authors discovered that adding a single soft photon (carrying just 0.1% of the jet's energy) caused the model to flip its classification for about a third of the jets it saw.

The culprit? Dataset artifacts. Because the model was trained on a mix of datasets with different "reconstruction thresholds" (the minimum energy a particle needs to be recorded), it learned to use soft particles as a "shortcut" to identify which dataset a jet came from, rather than learning the underlying physics.

Figure 1. An infrared-safe tagger does not change its prediction when a soft particle is added. We observe for all pretrained OmniLearned taggers (W/Z/H/t vs QCD) that adding a soft photon carrying 0.1% of jet pT leads to the tagger rejecting the W jet hypothesis for about a third of the W jets it previously selected (Sec. 2.1).

Methods

The researchers didn't just want to hide the problem; they wanted to perform surgery on the model's weights. They employed three main strategies:

  1. Mechanistic Interpretability & Activation Patching: Think of this as a diagnostic MRI. By systematically replacing the activations of specific attention heads with "clean" versions, they localized the flaw to just three specific heads (labeled b7/6, b4/0, and c1/2).
  2. Sparse Autoencoders (SAEs): SAEs are used to "disentangle" the messy internal representations of a model into human-understandable concepts. They found a specific "latent direction" in the weights that fired almost exclusively on these unwanted soft particles. They then performed a rank-one edit to the weight matrices to effectively "blind" the model to that specific direction.
  3. Weight-Space Programming (WSP): This is the most novel approach. They gave an LLM agent (Claude 3.5 Opus) access to the model's code and weights. Without using gradients or backpropagation, the agent was asked to inspect the weights and propose direct numerical edits to fix the flaw. The agent was limited to just 50 queries to an evaluation tool.

Datasets

  • JetClass: A large-scale public dataset for jet tagging.
  • JetClass-II: A similar dataset but produced with lower reconstruction thresholds. The discrepancy between these two was the primary source of the model's learned "shortcut."

Key Insights and Ideas

  • The "Provenance" Shortcut: The model wasn't being "dumb"; it was being too clever. It realized that the presence of very soft particles was a unique signature of the JetClass-II dataset. It hijacked its internal physics representation to perform dataset classification.
  • Surgical Precision: You don't need to retrain a billion-parameter model to fix a specific bug. The SAE approach showed that removing just three latent directions could fix the IR safety violation while leaving the rest of the model's performance untouched.
  • LLMs as Weight Editors: Perhaps the most surprising finding is that LLM agents can successfully navigate the "weight space" of a physics model. By looking at the math and the weights, the agent built a "soft particle detector" inside the model's early layers and then edited later layers to ignore those detections.
Figure 3. Left: mean attention of the summary tokens on one added photon at f = 10−3 for every head of the backbone. Right: share of |∆FW| removed when the output of one head is restored to its value on the clean jet, for one added photon at f = 10−3. b7/6 and c1/2 attend strongly to the particle through their summary tokens, while b4/0 through the particle tokens.

Key Results

  • Restoring Efficiency: For the "W-boson" tagger, adding a soft photon originally dropped the model's efficiency from 80% to 54%. After the repairs (SAE or WSP), the efficiency was restored to 78-79%.
  • Parameter Efficiency: While standard fine-tuning changed over 63,000 parameters, the SAE-guided edit achieved similar results by changing only 1,533 parameters.
  • Generalization: Even though the edits were designed using only two types of jets (W and QCD), the fix automatically carried over to all nine other signal classes the model handles, as well as its generative and regression heads. This proves the flaw was indeed rooted in the model's shared "backbone" representation.

Limitations and Future Work

  • Not "Perfectly" Safe: While the edits removed the excess sensitivity caused by the dataset shortcut, the models are still not mathematically "IR safe" in the formal sense. The authors suggest that true IR safety might need to be baked into the neural network architecture itself.
  • WSP Variability: The LLM agent's performance varied between runs. Sometimes it found a 142-parameter fix; other times it changed 10,000. Reliability and "trustworthiness" of these automated edits remain an open question.
  • Scaling to Larger Models: While the methods worked on models up to 0.4 billion parameters, the SAE edits became slightly less effective as the model size increased, because the "flaw" tended to spread out across more attention heads.

Summary updated

Abstract

We demonstrate that weight-space programming and edits guided by sparse autoencoders can remove unwanted aspects of a particle-physics foundation model through direct edits to its weights. In a foundation model trained on jets, we observe that adding a single soft neutral particle causes large changes in jet classification, violating infrared safety. We locate the responsible attention heads with mechanistic analysis and trace the flaw's origin to pretraining on datasets with different reconstruction thresholds. We then propose two targeted approaches to repair the flaw: by removing three latent directions identified with sparse autoencoders, and by letting language-model agents edit the weights directly, without gradients and with only 50 queries to the model. Both their edits individually remove almost the entire flaw and leave the rest of the model's response nearly unchanged. Compared to fine-tuning, both methods change far fewer parameters. Although built only on $W$ and QCD jets, the edits carry over to all signal classes, the pretrained generator, and a newly trained regression head.
BibTeX
@misc{bonnetguerrini2026weight,
  author = {Raphaël Bonnet-Guerrini and Johann Ioannou-Nikolaides and Troels Petersen},
  title = {{Weight-space programming and mechanistic interpretability for model editing in particle physics}},
  year = {2026},
  eprint = {2611.27079},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.27079},
}
Figure