Blog
hedwigaihedwigaihedwigai

Weight-space programming

Can forward passes alone turn a small model into a router?

An AI agent spends much of its day on small, repeated decisions. It sorts a ticket. It picks a tool. It routes a request. A large model makes these decisions well and slowly. A small model is fast and cheap. It usually gets them wrong.

We asked whether a small model can be shaped for one such job without training. There are no gradients and no optimiser. There are only forward passes and a least-squares solve. We call the result a minion.

The model is Qwen3.5-0.8B. The task comes from MASSIVE. Each request to a voice assistant belongs to one of 18 scenarios, such as alarm, music or weather. We scored 600 test requests.

The short answer is yes. With 20 examples a scenario, the minion routes 83.2% of the requests correctly. The unedited model routes 8.7%.

Unedited, labels in the prompt8.7%
Unedited, one example a scenario in the prompt55.5%
Random neurons of the same size5.5%
Minion, 20 examples a scenario83.2%
Share of 600 MASSIVE test requests routed to the right one of 18 scenarios. The few-shot score is read from the first token. The others come from greedy generation.

The method

Each label becomes one neuron in the last layer

Every layer of the model ends with an MLP. Its neurons read the residual stream, and each writes one direction back into it. A new neuron can be added by appending one row to two input matrices and one column to the output matrix.

We add one neuron per label to the last MLP. The neuron is meant to fire only where the model is about to answer which label a request belongs to. When it fires, it writes toward the label’s first token.

Every part of the neuron comes from a least-squares solve. Shaping takes four steps.

  1. 1. Read

    One forward pass per example. We keep the last MLP's input at the position where the answer goes.

  2. 2. Gate

    Least squares finds a direction that is +1 at that position and -1 on every other position and on ordinary text.

  3. 3. Keys

    Least squares maps the same input to the right label. One key per label.

  4. 4. Write

    Each label becomes one new neuron. Its gate row is the gate, its up row is the key, and its down column writes the label's first token.

Three numbers remain to choose: the ridge penalty, the sharpness of the gate and the strength of the output. We tried 63 combinations on a separate set of 360 requests and kept the best one. Every combination had to leave at least 99% of next-token guesses unchanged on ordinary text.

The neurons sit in the last layer, and the label is read at the last position. So each candidate’s answer follows exactly from numbers already collected. The search needs no further forward passes.

The result

Twenty examples a scenario take the model from 8.7% to 83.2%

We gave the model the 18 scenario names in its prompt, then the request. The unedited model routes 8.7% of the requests correctly.

One labelled example per scenario in the prompt helps a great deal. It raises the score to 55.5%. The prompt then carries 18 extra requests and their answers.

The minion keeps the short prompt and routes 83.2%. Five examples a scenario already give 74%. Fifty give 84.7%.

5 examples a scenario74%

27 of 30 capitals right, 99.4% of ordinary text unchanged

10 examples a scenario75.2%

27 of 30 capitals right, 99.51% of ordinary text unchanged

20 examples a scenario83.2%

26 of 30 capitals right, 99.25% of ordinary text unchanged

50 examples a scenario84.7%

27 of 30 capitals right, 99.48% of ordinary text unchanged

Share of 600 test requests routed correctly by minions fitted on 5, 10, 20 and 50 examples a scenario.

The gate

Without a gate, the edit routes well and breaks everything else

Our first edit had no gate. It was a plain low-rank change to the last MLP’s output matrix, with the same keys and the same label directions.

It routed 76.5% of the test requests. It also fired at every position of every text. The model got 0 of 30 capitals right, and 0.16% of next-token guesses on ordinary text stayed the same.

We then fitted the same edit to stay at zero on 7,920 positions of ordinary text. No strength gave both jobs. A weak edit kept 89% of the text and routed 57%. A strong one routed 81% and kept almost none of it.

Weak edit, requests routed56.9%
Weak edit, ordinary text unchanged89.37%
Medium edit, requests routed81.1%
Medium edit, ordinary text unchanged57.97%
Strong edit, requests routed81.4%
Strong edit, ordinary text unchanged0.27%
The plain linear edit at three strengths. Routing is the share of 360 held-aside requests routed correctly. The second number is the share of next-token guesses on held-aside ordinary text that stayed the same.

The gate fixes this. Its average value is 0.994 where a routing answer goes and -0.001 on ordinary text. It never rises above 0.5 on ordinary text.

With the gate, the minion gets 26 of 30 capitals right. The unedited model gets 27. Of 16,906 next-token guesses on Wikipedia text that the search never saw, 99.25% stay the same.

The control

Random neurons of the same size do not route

A gain can come from the size of an edit rather than its content. So we added 18 random neurons, each row and column scaled to the size of the fitted ones.

They route 5.5% of the requests, less than the unedited model. They also do harm. The model then gets 7 of 30 capitals right, and 80.14% of next-token guesses on ordinary text stay the same.

The fitted neurons route because of what they read and what they write.

The cost

Shaping a minion takes seconds on one small GPU

All of the work is forward passes and matrix solves. There is no backward pass, and there is no optimiser state. The memory needed is what the model needs to run.

On one NVIDIA L4, all 1,430 forward passes took 9.2 seconds. They read the fitted examples twice, the held-aside requests and the ordinary text. The search over 63 candidate edits took 4 seconds.

The minion is the base model and a patch of 108 KB. Many minions can therefore share one copy of the base model, with each patch applied when its request arrives.

What it means

An agent can shape its own minions

The method needs only examples and a few seconds. An agent already has both. It can collect the decisions it makes again and again, shape a minion from them, and hand the job over.

We built the shaper as a program an agent can call. It takes labels and examples, and it returns a scorecard and the patch. The scorecard always includes the unedited model and random neurons, scored on examples the fit never saw. So an agent cannot fool itself about how good its minion is.

Two limits matter. The minion’s probabilities are not calibrated. They sit near 1, even when it is wrong. An agent cannot yet use them to decide when to answer a request itself. We also tested routing only. A label is a choice the model can already express. We did not test skills the model lacks.

Try it yourself

Can your labels become a minion?

  • Two tasks recorded and free to look at, a support inbox and home-assistant requests
  • Your own labels and examples, five or more a label
  • A scorecard against the unedited model and random neurons, and the patch to download

Three runs free, then 5 cents a run.

Shape a minion
Continue in
Notes
  • Qwen3.5-0.8B is revision 2fc06364 on Hugging Face, in bf16. The neurons are added to layer 23, the last of its 24 layers.
  • MASSIVE is the English part of Amazon’s MASSIVE dataset (CC BY 4.0), in its scenario form. The 600 test requests are a fixed random sample of the test split. The fitted examples come from the train split and the 360 held-aside requests from the validation split.
  • The prompt lists the scenario names, then gives the request and asks for the scenario. Routing is scored by greedy generation: the answer is right if it starts with the scenario’s name. The 18 names start with 18 different tokens.
  • The gate is fitted on 7,920 positions that are not answers. These are other positions of the same prompts, the answer’s own tokens, and 300 Wikipedia paragraphs from WikiText-2. The text check uses 100 other paragraphs from WikiText-2. The 30 capitals are asked as “The capital of France is”.
  • The few-shot prompt has one example per scenario, drawn from the fitted examples. Its score is the share of requests whose most likely first token, among the 18, is the right one. Scored that way, the unedited model with no examples routes 7.7%. Each count in this post is from one run with seed 0.

More head-to-head evals

GLM-5.3 against DeepSeek V4.1 Flash on 75 questionsTwo models answer the same 75 questions; one is always right, the other 14× cheaper.
MeasureGLM-5.3DeepSeek V4.1 Flash
Right, of 757571
Seconds a question, median3.91.8
Read the comparison
How we made a long-running AI agent for knowledge work 4× fasterOne cited knowledge work task through 13 experiments: 937 s to 233 s, with the model held constant.
MeasureFirst runBest since
Landscape, seconds937233
Memo, seconds759602
Read the report
Ten models plan a change to a spreadsheet: which do it in under a minute, traced call by callTen models drive one agent harness through the same spreadsheet request; six write the plan, timed and traced call by call.
MeasureQwen3 235BGLM-5.2Gemini 3.8 FlashClaude Opus 5
Seconds to the plan, median27485794
Plans written, of three runs2333
Read the comparison
SubQ, jev, Perplexity's Decider and Bespoke's Nimble on biotech diligence memos: finding the sentences a column is aboutFour decision models judge every sentence of ten biotech diligence memos for five columns, scored against sentences a person marked.
MeasureSubQjevDeciderNimble
Found, mean of five columns at section length64%65%66%68%
Mechanism of action, found at section length57%51%61%54%
Read the comparison
Leads with a reason to write: hedwigai ask, Apollo and treg on one brief40 leads each, every one checked: the right person, an inbox that accepts, and a dated reason to write.
MeasureaskApollotreg
Usable leads13 of 407 of 406 of 28
Cost per usable lead$0.037$0.27$0.23
Read the comparison
Self-hosted decisions for ask: Perplexity's open Decider in place of jev on 92 company questionsThe decisions inside hedwigai ask made by Perplexity's open Decider on two NVIDIA RTX 3090s, against jev.
Measureask with jevask with Decider
Questions right, of 928989
Wrong answers12
Read the comparison
Clinical decisions: jev and ask on System One, PubMedQA, SciFact and a 370-decision setEdgeEvals' System One board, PubMedQA, SciFact, and a clinical set built to System One's rules.
Measurejevask
Our 370 clinical decisions, right94.6%93.0%
PubMedQA, right (best EdgeEvals scored: 62.2%)77.0%74.4%
Read the comparison
Executive lookup for US-listed companies: Claude Opus 5.5 and ask on 95 questionsWho runs a public company, and how to email them: a frontier model from memory against hedwigai ask.
MeasureaskClaude Opus 5.5
Questions right, of 955963
Small companies right, of 20139
Read the comparison
Rental comps: floor-plan rents and amenities on 14 listings, five assistants comparedRent per floor plan and amenities for US rentals: hedwigai realestate-us against Claude, GPT, Gemini and Perplexity with web search.
Measurerealestate-usBest of four assistants
Floor-plan rents right, of 262623
Amenities claimed the listing doesn't state12129
Read the comparison
Company screening from SEC filings: jev, Vela 2.0 and ask on 92 yes/no questionsYes-or-no questions about public companies, answered by two decision models alone and by hedwigai ask.
Measureaskjev
Right, of the questions answered98%79%
Wrong answers, of 92219
Read the comparison
Defect localization in industrial images: four frontier models and a trained localizerFour frontier models asked to put a box around what they just described.
MeasureTrained localiserBest of four frontier models
Mean overlap with the defect (IoU, 0 to 1)0.4210.109
Read the comparison