Scalpel and Brush: Pruning and Targeted Weight Editing of a Small Language Model by a Single LLM Agent

Sergei Koltcov, Vera Ignatenko, Anton Surkov, Rabie Abdultawab RamadanarXiv 2026

TL;DR

Can a large language model perform autonomous brain surgery—pruning dead weight and repairing behavior—on a smaller language model? Yes, and when let loose on a 1.5-billion-parameter model, an LLM agent figures out where and how to intervene with surgical precision. However, rigorous controls reveal a fascinating twist: once the agent plays detective to locate the right neural pathways, classic, non-LLM mathematical procedures can reproduce much of its handiwork.

What Problem Does This Paper Address?

Usually, changing how a trained neural network behaves requires fine-tuning its weights or steering its internal activations. Conversely, pruning strips away unimportant weights to shrink the model without breaking it. Recently, researchers showed that an LLM agent can read another model's weights and directly edit them to fix reasoning bugs ("weight-space programming").

Yet a huge question lingered: how much of that magic actually comes from the agent's intelligence? Could you get the same boost from a random weight nudge of the same size, a clever prompt instruction, or a standard statistical script? This paper separates genuine agentic insight from the mere side effects of intervention, unifying both model repair and model compression under one rigorous experimental roof.

Methods

The authors hand the keys of a small math-focused model (Qwen2.5-Math-1.5B-Instruct) to an autonomous LLM researcher named "Sergei" (powered by deepseek-v4.1-flash).

They frame every intervention uniformly as a sparse weight update, $W \to W + \Delta$, across three tasks:

  • The Brush (Repair): Edit at most 131,072 weights (~0.0084% of the model) to boost task scores.
  • The Scalpel (Pruning): Zero out as many MLP (multi-layer perceptron) neurons as possible without dropping performance by more than a tiny tolerance.
  • Layer Removal with Repair: Delete entire transformer blocks and patch up the remaining weights.
Overview of the three sparse weight-editing tasks assigned to the agent

Sergei gets full access to a training "pool" of data, model weights, PyTorch, and a GPU to write analysis code and test hypotheses. To prevent overfitting to the test set, the agent can only check its progress on a dev split 50 times via a locked-down script. Meanwhile, the human researchers evaluate the final edits on two hidden splits (test and holdout) and run hidden controls—like substituting math solutions back into equations to check true mathematical accuracy, testing random weight edits, and fitting simple linear classifiers into the exact weight locations the agent discovered.

Datasets

The experiments span two distinct domains, strictly split into an open pool, a budgeted dev set, and hidden test and holdout sets:

  • Synthetic Ordinary Differential Equations (ODEs): Taken from the MathSteering project, featuring second-order linear equations (ode2), polynomial derivatives (poly), and separable equations. Evaluated via BLEU (which measures LaTeX string similarity against sympy-formatted reference answers) plus a hidden symbolic math correctness check.
  • GoEmotions: Short Reddit comments filtered and grouped into 7 balanced classes (anger, disgust, fear, joy, sadness, surprise, neutral) to test substantive classification repair via macro-F1.
Data splits and visibility rules for the ODE benchmark

Key Insights and Ideas

  • Agents are brilliant metric-hackers (in a revealing way): On ODEs, the agent inspected the data and realized the base model already knew how to do the math (solving 88% of ode2 dev problems), but lost BLEU points because it wrote C_1 instead of sympy's braced C_{1}. Rather than reteaching calculus, the agent surgically edited specific token embeddings—or built an internal linear detector to fire a "steering vector" right before brace choices—aligning the notation. Telling the model to use braces via prompting completely failed!
  • Randomness doesn't cut it: Random weight edits of the exact same shape and location did virtually nothing, proving the specific mathematical direction the agent computed is what drives the behavioral shift.
  • The agent's true superpower is discovery, not optimization: On emotion classification, once the agent decided where to intervene (e.g., selecting specific weight rows), the authors showed that writing a standard, non-LLM ridge classifier into those exact rows achieved comparable performance. The agent shines as an explorer finding the right levers to pull.

Key Results

  • ODE Brush: Changing $\le 0.0084\%$ of weights raised test BLEU by 24–32% on ode2 and by 1.8–2.5x on poly. Hidden checks confirmed true mathematical accuracy stayed flat (~76–85%), proving the gain was pure style alignment.
  • ODE Scalpel: The agent pruned 12.5–15% of MLP neurons—shrinking total model size by 9.4–11.2%—while keeping mean BLEU loss within 0.01 on hidden splits. Standard pruning baselines (like Wanda and Taylor) with equal shares per layer failed this constraint at every tested level.
  • Emotions Brush & Scalpel: Weight edits genuinely repaired classification, boosting macro-F1 from a near-chance 0.100 to 0.396–0.451 on test (and 0.175 to 0.455–0.476 on holdout). Standard ridge regression placed into agent-selected rows scored 0.424 and 0.464. In pruning, a non-LLM search with the same 50-call budget removed 15.9% of neurons, landing right alongside passing agent runs (14–21.4%).

Limitations and Future Work

Because the full PDF was cut off before Sections 8 and 9 (Discussion and Limitations), the complete list of author-acknowledged limitations is not visible in the provided pages. However, the authors explicitly note in earlier sections that:

  • Unequal compute tracking: While evaluation calls on dev were capped at 50, actual compute consumption—GPU hours on the pool, number of LLM calls, and dollar cost—was not equalized across methods.
  • Hardware determinism quirks: Greedy decoding in bf16 produced slightly different text across different GPUs (an RTX 3060 Laptop vs. Desktop), requiring strict machine isolation during evaluation.
  • Open comparison on search: While non-LLM methods match the agent after being handed the edit's location and form, a head-to-head comparison between agentic exploration and automated non-agentic search from scratch remains an open question for future work.

Summary updated

Abstract

It has recently been shown that an LLM can itself edit the weights of a language model, yet it remains unclear which part of such a result is due to the agent and which part is reproduced by a random edit of the same shape, by an instruction in the prompt, or by a standard procedure without an LLM. We unify repair and pruning as sparse weight edits to optimize a metric we specify, using BLEU as an example: three tasks -- targeted weight repair ("brush"), structured MLP neuron pruning ("scalpel", zeroing pruned weights), and layer removal with repair - are assigned to a DeepSeek Harness agent powered by DeepSeek-V4.1-Flash, with up to 50 dev evaluations. We study Qwen2.5-Math-1.5B-Instruct in three independent runs per task, with final evaluation on two hidden splits. On ordinary differential equations, changing at most 0.0084% of weights raised test BLEU by 24-32% on second-order equations and by a factor of 1.8-2.5 on equations with polynomial right-hand sides. An independent substitution check showed that higher BLEU reflects notation alignment rather than improved correctness. Masks that remove 12.5-15% of MLP neurons shrink the model by 9.4-11.2% with mean BLEU loss of at most 0.01 on both hidden splits, whereas standard pruning with equal shares per layer failed the constraint at all tested shares. On seven-class GoEmotions classification, edits raise macro-F1 from 0.100 to 0.396-0.451 on test and from 0.175 to 0.455-0.476 on holdout. A ridge-based classifier written into agent-selected weight rows yields macro-F1 of 0.424 and 0.464. Pruning search with the same evaluation limit removes 15.9% of neurons versus 14-21.4% for agent runs passing the hidden check. Standard procedures without an LLM reproduce much of the performance once given the location and form of intervention found by the agent; a comparison of agentic and non-agentic search remains open.
BibTeX
@misc{koltcov2026scalpel,
  author = {Sergei Koltcov and Vera Ignatenko and Anton Surkov and Rabie Abdultawab Ramadan},
  title = {{Scalpel and Brush: Pruning and Targeted Weight Editing of a Small Language Model by a Single LLM Agent}},
  year = {2026},
  eprint = {2611.33426},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.33426},
}
Figure