What a neuron node is
Inside each MLP block, a SwiGLU model computes, for every token, one number per neuron:(layer, neuron index, position). It uses
circuitcheck’s usual FeatureNode, with feature holding the neuron index, so every tool reads it unchanged. Two
things differ from a transcoder feature:
- a neuron is almost never exactly zero, so every neuron of a layer counts as active at every position. The random controls are uniformly random neurons of the same layer and position, and the matched-norm controls are the neurons whose write, |activation| × ‖W_down column‖, is closest in size;
- a neuron has two ends, or poles: what makes it fire strongly positive and what makes it fire strongly negative.
Labels describe one pole at a time, written
12:n345+or12:n345-.
Install
install
Until neuronkit is on PyPI, install it from GitHub first:
pip install "git+https://github.com/albertlieyingadrian/neuronkit".Try it on the toy (CPU, no downloads, no key)
The toy is a real two-layer Qwen2 with a one-character-per-token tokenizer and a few neurons set by hand. The letters stand for cities:D is Dallas, O is Oakland, A is Austin and S is Sacramento.
L0/N0is a switch: it fires onDand writes the direction the output reads asA.L1/N0is a readout: it fires just as hard onD, because it reads what the switch wrote, but it writes into a direction nothing downstream uses.L0/N2is a relay source: it fires onTand writes a direction the unembedding cannot see. OnlyL1/N7reads that direction, andL1/N7writesA.
neurons
--html report.html --json report.json to any of them for the reports.
validate: switch or readout?
NeuronBackend wraps any Hugging Face causal LM and its tokenizer. Pass it to validate like any other backend.
backend.nodes(prompt, specs) turns "layer:neuron@position" strings into nodes that carry their real activations
(position -1 is the last token).
neurons
A neuron’s subcircuit
neuronkit traces what drove one firing: with the norm in front of the MLP frozen, every earlier head and neuron contributes an exact share of the activation.subcircuit_group keeps the k strongest earlier neurons as a group,
so you can ask whether a neuron’s drivers are themselves a switch:
neurons
label: does the description hold up?
A label is only worth as much as its test.label_neuron writes a description of one pole from its strongest
firings, or takes one you give it, and then tests it three ways:
1
Predict
A judge gets the description and a shuffled mix of held-out firing excerpts and random windows of the corpus,
and says which ones fire. Scores: balanced accuracy and AUROC.
2
Simulate
The judge predicts a 0-10 activation for every token of held-out excerpts. Those predictions, scaled to the
pole’s p99.9 magnitude, are patched in for the real activations, and the result is compared with zero-ablating
the neuron on the same tokens: recovered = 1 - KL(simulated) / KL(ablated). 1.0 means the description
carries everything the neuron’s activations carry there; 0.0 means it does no better than deleting the neuron.
3
Write (optional)
With
n_write, the judge writes texts meant to fire the pole, and the report says whether one beats the corpus
maximum.label.score) is recovered: it is measured in the model’s own output, so a description that
only sounds right does not earn it. The excerpts the explainer saw are never scored. This runs neuronkit’s
score_description, which uses circuitcheck’s excerpt format and simulation prompt, so feature labels and neuron
labels are tested the same way.
neurons
recovered is None, and its ablation_kl is about 0. Deleting it changes nothing, so there is no
damage for a description to recover. The predict test alone would have scored its (correct) description well.
toy.judge() is a scripted judge for the toy. On a real model, pass any circuitcheck LLM, for example
make_llm("anthropic") (Claude Haiku 5.5, with a reply cache) or make_llm("openai", "gpt-5-mini").
lens: is a neuron a steering vector you can read?
Returning to the Neuron Basis for Interpretability reads a SwiGLU neuron as a context-gated steering vector. When it fires ata, it adds a × w to the residual stream,
where w is its column of the down projection. The gate g · x decides whether it fires, and the sign of
u · x decides which way: along +w or along -w. So each pole is a fixed direction that can be read from the
weights alone, with a lens. The applications post
uses those reads to find and steer neurons without labels.
circuitcheck’s lens check tests that reading. Does the lens read of ±w predict what adding c × w
actually does to the next-token distribution, better than random neurons of the same layer pushed at the same write
norm? NeuronLensBackend provides the neuron version of each piece:
neurons
- The switch
L0/n0+writes the Austin direction, so both lenses readA, and so does its steering. - The relay source
L0/n2+writes a direction the unembedding cannot see. Its logit lens reads nothing and is flaggedlens misses (logit). Its Jacobian lens follows the write throughL1/N7and readsA, which is what steering with it does. This is the case the Jacobian lens is for: later layers transform what a neuron writes. - The switch’s negative pole
L0/n0-reads fine as a direction, but it is flaggedgate closed: on these contexts the neuron never fires with that sign, so the model never pushes along-w.
readout.jacobian_direction (a finite difference at the last token of each
context) when the installed neuronkit has it, and an exact Jacobian-vector product otherwise. The two agree, and a
test checks it.
A SwiGLU neuron is quadratic at zero (
silu(g) × u), so its Jacobian vanishes where it is silent. A Jacobian lens
only sees through a later neuron whose gate is open on the contexts. Pick contexts like the ones you care about.diff: which neurons did fine-tuning change?
Fine-tuning updates the same weights, so neuronL12/N345 exists before and after and can be compared directly.
diff_neurons runs the same prompts through both models and gives every neuron one number per prompt. By default
that number is its tail rate: the share of tokens where it fires beyond the before model’s p99 or below its p1.
The thresholds come from the before model and are used for both models, so a change in rate is a change in
behaviour on a fixed scale. With stat="mean", the number is the mean activation instead.
The numbers then go through circuitcheck’s diff: gained, lost, up and down statuses, the paired swap
null with a Benjamini-Hochberg correction, bootstrap intervals, the split-half check and, with control=, the
control-run contrast.
neurons
On a real model
The neuron indices below are placeholders: pick yours from a probe, a graph, or a diff.gpu
gpu
How it relates to neuronkit
neuronkit does the neuron measurements: finding the MLP sites of any dense or mixture-of-experts Hugging Face model, capturing and editing activations with plain PyTorch hooks, per-neuron percentiles, subcircuit traces and description scores. circuitcheck adds what it adds to circuit-tracer: matched controls with printed verdict rules, a statistically checked diff, and trust scores reported next to every label. The two share code instead of copying it. neuronkit’s judge steps use circuitcheck’s excerpt format and prompts, and circuitcheck imports neuronkit only insidecircuitcheck.neurons, so the base install stays light.