This page is the shortest useful path through NeuronScope: install the library, record a single activation from a real model, and read the resulting artifact. Every subsequent chapter builds on the primitives introduced here.
Install
A one-line install is enough for the quickstart. See Installation for the full matrix.
$ pip install "neuronscope[torch]==0.9.2"$ ns doctorpython 3.12 · neuronscope 0.9.2 · adapter torch okRecord an activation
A recording has three inputs — a model, a prompt, and a probe — and one output: a sealed.nsz artifact. This program records the residual stream of a small BERT model on a single prompt.
import neuronscope as ns
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("google-bert/bert-base-uncased")
tok = AutoTokenizer.from_pretrained("google-bert/bert-base-uncased")
prompt = ns.Prompt("The quick brown fox jumps over the lazy dog.")
probe = ns.probes.LayerActivations(layers="encoder.layer.*")
with ns.record(model=model, probe=probe, out="fox.nsz") as run:
run.forward(**tok(prompt.text, return_tensors="pt"))
print(run.artifact.fingerprint)
# fp:experiment:5a7c...Inspect the artifact
Artifacts are self-describing. ns inspect prints the input fingerprints, the recorded tensors, and a per-layer summary — enough to verify a recording without loading a framework.
$ ns inspect fox.nszexperiment fp:experiment:5a7c...
model fp:model:b3c2... google-bert/bert-base-uncased
prompt fp:prompt:8f10...
probe LayerActivations (glob: encoder.layer.*)
recorded 12 layers · 9 216 activations · 1.4 MBWhere to go next
- Read Fingerprinting — the primitive every other guarantee builds on.
- Try Compare two models — the first realistic recipe.
- Skim System architecture to see what the library is doing on your behalf.