sarvesh.
Projects

Interpretability · Local experiment

Gemma Microscope

A local lab for tracing and testing how a language model arrives at its next prediction.

I built a local interface to inspect Gemma’s attention heads, MLP updates, and next-token probabilities. A baseline run and a controlled intervention use the same prompt.

The local Gemma Microscope interface, with model components, attention patterns, and a retained intervention result.
The local workspace: choose a component, change its contribution, and compare the prediction with the original run.

Turn an explanation into an experiment

I wanted to understand what happens between a prompt and the next predicted token. The microscope lets me inspect attention heads—the parts that combine information across token positions—and MLPs, the small neural networks that transform each position’s representation.

I can switch off a contribution or replace it with one from another prompt, then measure the change. The original run stays available for comparison.

Could a Germany prompt change a France answer?

In an October 18 study, Gemma 3 4B IT assigned “Paris” an 82.80% probability after The capital city of France is. I kept that prompt fixed and copied selected internal values from a run with “Germany” in place of “France.”

The first eight patches did not transfer the answer. One made “Paris” more likely. A wider scan of 204 layer interventions, followed by 48 head tests, found a much more specific route.

Next-token probabilities on the same France prompt
InterventionParisBerlin
Original run82.80%0.0066%
Copy Germany’s head output0.0958%76.85%
Copy only its country-token value0.1055%74.66%
Copy only its attention routing80.51%0.0077%

Layer 25, head 2 (one-based labels). Native BF16 model; probabilities use the full vocabulary. These are saved measurements from one local study, not a live demo.

Changing the information carried from the country token changed the winning answer to “Berlin.” Changing only where the head looked did not. Copying a head from an identical prompt left every output score unchanged—a check that the intervention itself was not introducing an error.

What I learned

  • Attention is a clue, not an explanation. A bright connection suggests a place to investigate. A controlled change tests whether it affects the answer.
  • A failed patch can be useful. A value produced by a Germany prompt does not simply mean “Germany.” Its effect depends on where it enters the computation.
  • Keep the claim as small as the evidence. The head patch also transferred answers on two additional short prompt pairs. That supports a partial route in this model; it does not establish a universal “country head” or a complete circuit.

Research notes

Working notes from the experiments and related model-file inspection.