Checking how many agents are working

How this works
Kontakt
← Blog
A dark brass microscope pointing at a glowing lattice of olive points with a few lit teal neurons, the AMARBARO mark centered in the lens.
✎Post blogowy

mojo-neuron: a microscope for a language model

The short version

mojo-neuron reads a layer's neurons and steers them through mojo-baro faster than gguf-neuron-explorer, and its research tools report their failed bars as failures.

Part 9 of 20 in Tools we built and why. Previous: mojo-baro: our chat engine for one AMD card · Next: mojo-ablate: turning one model behavior up or down

What this is about

A language model is built from layers, and each layer holds many small units called neurons. Each neuron takes in numbers and passes a number on. No one wrote what each neuron should do. It was learned. So the model is a black box, until you look inside.

mojo-neuron is a tool for looking inside. It opens a model file, and for one layer it shows you what each neuron pushes the model to say. It shows where a neuron lights up on your own text. It can also turn a neuron up or down and watch the answer change. Everything is written in Mojo, and every tool has a check with a planted defect, so a check that cannot fail gets caught.

Why it matters

Results about the insides of models are easy to overstate. A tool that works on one prompt can look like a discovery. A neuron that seems to mean "cats" may be an accident of three examples.

So mojo-neuron was built the other way round. It fixes a bar before each experiment, then publishes the result against that bar, whether it passed or missed. The README lists the misses next to the passes. That habit is the main thing a beginner can take from this tool: a claim is only as good as the test it was allowed to fail.

How it works

There are three things to know.

  1. The logit lens. For a chosen layer, the lens maps each neuron onto the model's output vocabulary and keeps the words it pushes up and the words it pushes down. That is a plain list for each neuron: "this neuron raises these words."
  2. Where it fires. A forward pass on the CPU shows the activation of one neuron on each token of your text. It covers dense llama, qwen2 and granite models, and its output is checked against llama.cpp.
  3. Steering. Using our engine mojo-baro on a GPU, a neuron's activation can be raised, lowered or zeroed, and the effect on the answers compared with random-direction controls.

The same calls come as a command line called nx, as an MCP server so that an AI agent can use them, and as a small desktop window with a neuron map and a dial.

A quick check keeps the lens honest. It runs a slow, exact brute-force computation on a sample of neurons. The rank order must match. A reversed copy and a neighbor-neuron copy, both planted mutants, must differ.

A first session, step by step

The project page shows the first command.

  1. Get a small GGUF model. The example uses Qwen2.5 0.5B Instruct in Q4_K_M form.
  2. Build the lens program with Mojo, pointing at the GGUF and JSON libraries that live beside it.
  3. Run it on a layer: lens MODEL LAYER K [CHECK]. The page's example runs layer 12 of the 0.5B model.
  4. Read the output. Each neuron has a short list of words it raises and words it lowers.
  5. Search a saved lens for a word with nx search_lens. See which neurons raise it.
  6. Check where one neuron fires on a sentence of your own with nx fires.

On a CPU, the lens and its check took 11 seconds for layer 12 of that model.

For steering there are more commands. sweep runs many neurons, doses and prompts in one resident engine. ablate-scan zeroes neurons one at a time with a noise-floor pass. cvec writes a control vector for llama.cpp.

What we measured, and what missed

Steering through our engine ran 4.3 times faster than gguf-neuron-explorer on the same model. The check is the steer-lens benchmark in the repository.

The misses matter just as much. A tuned lens, which learns a small correction for each layer, lowered its held-out KL divergence from 3.94 to 1.19, against 6.66 to 4.36 for the plain logit lens. It beat the plain lens at all six layers we tested. But that was on narrow data, 256 positions. We do not claim it holds elsewhere. And most of the research tools built on top of the lens missed their bars. We list them as failures.

What it does not do

  • A neuron's word list tells you what the neuron pushes. It does not tell you what the model "thinks".
  • Many neurons are mixed. One neuron may do several jobs.
  • The CPU path covers a few model families. Steering needs the GPU engine, which is built separately.
  • Results on a 0.5B model do not carry over to a 9B one without a new test.

Words you may not know

  • Neuron: one small unit in a layer that takes numbers in and passes one number on.
  • Layer: a group of neurons that work at the same step.
  • Logit: a raw score the model gives each possible next word.
  • Logit lens: a way to read a neuron by asking which words it raises.
  • Ablate: to switch something off to see what changes.
  • Control: a comparison run that should not change the result, used to catch fooling ourselves.
  • GGUF: a file format for storing a model's numbers.

Try it

Komentarze

Brak komentarzy.

Zaloguj się aby skomentować.