Skip to main content

interp-lab

interp-lab is an open-source toolkit for criterion-driven mechanistic interpretability.

Give it a model, a plain-language criterion, and feature evidence. It ranks the internal features that track the criterion, explains them, tests their causal impact with interventions, and searches for equivalent features in other models, then grades how much each claim is supported by evidence.

python -m pip install interp-lab
interp-lab doctor
interp-lab quickstart        # a short guided walkthrough of the workflow and metrics

# A complete tour on toy models in one command — no GPU, no downloads:
interp-lab demo --out reports/demo   # then open reports/demo/index.html
interp-lab inspect \
  --model google/gemma-2-2b \
  --criterion "the model is aware it is being evaluated" \
  --backend toy \
  --out reports/eval-awareness

Features

  • Correlational vs. causal evidence are kept separate. Association comes from activation/criterion statistics; causal effect comes from ablation, amplification, clamp, patch, and steering runs. A feature that merely co-activates is not treated like one that moves the behavior.
  • Claims are graded, not asserted. validate-matches and validate-attribution-graph mark each result as validated, needs_causal_evidence, plausible, contradicted, or weak, with reason codes.
  • Controls and uncertainty are first-class. Intervention runs support random_feature, matched_frequency, and placebo controls, side-effect checks, sign-consistency, and confidence intervals.
  • Everything is reproducible and agent-friendly. Runs emit manifests with the tool version, platform, and input hashes; reports include agent_next_actions with exact follow-up commands; interp_lab.public_api_contract() exposes the stable surface as data.
  • The investigation loop drives itself. plan-evidence diagnoses each feature's evidence gaps and ranks the cheapest grade-moving interventions (with power-analysis sample sizes); dossier-update keeps a cumulative evidence dossier per (model, criterion) across runs — grade transitions, sign flips, contradictions.
  • The grading is audited, not trusted. calibrate plants synthetic ground truth (causal features, equally-correlated decoys, noise), runs the real pipeline blind, and reports what the verdicts are worth: precision/recall, decoy resistance, P(truly causal | tier). quant-diff applies the same discipline to precision studies — which intervention-validated features did quantization break?
  • Validated features become deliverables. export-steering packages an intervention-validated feature as a reusable steering-vector artifact, refusing unvalidated cards unless you explicitly accept a provenance: "unvalidated" stamp.

The workflow

  1. Compile a natural-language criterion into examples and scores — compile-criterion generates candidate prompts (templates, a local GGUF, or your own agent), scores them with a compact NLI cross-encoder, and gates the dataset (margins, balance, assay validation) before anything downstream trusts it.
  2. Collect candidate features from SAEs, NLA explanations, or feature dumps — or feed any latents (crosscoders included) through the model-agnostic activation-records path.
  3. Rank features by criterion association, specificity, causal evidence, and stability.
  4. Plan the cheapest evidence-gathering path (plan-evidence), intervene, and track each round in a cumulative dossier.
  5. Build a feature fingerprint that can be compared across models.
  6. Validate cross-model equivalents with interventions.
from interp_lab import compare, inspect, validate_matches

left = inspect("toy/model-a", "the model is aware it is being evaluated", backend="toy", out="reports/model-a")
right = inspect("toy/model-b", "the model is aware it is being evaluated", backend="toy", out="reports/model-b")
matches = compare(left.report, right.report, out="reports/matches.json")
validation = validate_matches(matches.report, out="reports/match-validation.json")

Evidence sources

interp-lab keeps portable JSONL evidence formats stable in the base package; heavier model tooling lives behind optional extras. Supported paths include toy, JSONL feature dumps, activation records, Neuronpedia, SAE Lens, Goodfire, Gemma Scope / Qwen-Scope, Hugging Face, TransformerLens, NNsight, contrast-direction, and on-demand SAE training. Each integration is an optional bridge (pip install "interp-lab[saelens]", [hf], [transformerlens], [nnsight], [goodfire], [modal], [publish], …).

Architecture

The core object is a FeatureFingerprint:

activation signature
+ text explanation embedding
+ decoder signature
+ causal effect vector
+ examples

Cross-model equivalence is scored by fingerprint similarity; validate-matches turns candidates into explicit evidence grades. The pipeline is built around four small adapter interfaces, so new backends are easy to add:

  • FeatureProvider — returns candidate features.
  • Verbalizer — adds NLA-style text explanations.
  • InterventionRunner — ablates, amplifies, patches, or estimates causal effects.
  • CriterionCompiler — turns natural-language criteria into examples and scoring hints.

Text matching: lexical by default, semantic when you want it

The text component of a fingerprint defaults to a dependency-free lexical vector (token hashing) — deterministic, offline, and comparable across versions, but it matches shared words, not meaning. For real cross-model and cross-vocabulary matching, opt into a semantic embedder:

pip install "interp-lab[embeddings]"

# Local MiniLM (sentence-transformers): free, offline, no API key.
interp-lab inspect ... --text-embedder minilm
# or set once for a whole pipeline:
export INTERP_LAB_TEXT_EMBEDDER=minilm

Each fingerprint records the embedder that produced it, and matching refuses to compare vectors from different embedders (it drops the text component and renormalizes rather than silently cosine-ing across incompatible axes). interp-lab doctor shows the active embedder and whether the extra is installed.

Note: ranking importance weights are heuristic — treat scores as evidence-weighted rankings, not probabilities.

See docs/ARCHITECTURE.md for the full design.

For AI agents

AGENTS.md is the operating manual for coding agents driving interp-lab: the evidence rules, the canonical agent_next_actions shape, and the core loop as runnable commands. interp-lab capabilities --json returns the whole surface — command specs, the Python API contract, environment, and conventions — in one machine-readable payload, and interp-lab mcp serves the workflow as Model Context Protocol tools over stdio, including a full investigation loop an agent can drive end to end: plan-evidence → intervene (dry-run by default) → dossier, with calibrate as the trust anchor for what the grades mean.

Documentation

Common entry points:

interp-lab demo --out reports/demo            # full toy tour (open reports/demo/index.html)
interp-lab quickstart                         # guided getting-started walkthrough
interp-lab inspect ... --csv-out features.csv # ranked features as a spreadsheet
interp-lab compare-runs --left a/report.json --right b/report.json --out diff.json  # rank/score drift
interp-lab plan-evidence --report a/report.json --out a/plan.json  # cheapest grade-moving interventions
interp-lab quant-diff --left-report f16/report.json --right-report q4/report.json --out qd.json  # what quantization broke
interp-lab calibrate --out reports/calibration.json  # audit the grading against planted ground truth
interp-lab studio --serve --reports-dir reports   # local browser command-builder + runner (persistent job history)
interp-lab release-check --strict             # stable-release readiness

Roadmap

  • Richer Natural Language Autoencoder explanation audits.
  • Crosscoder training and import.
  • Distributed SAE training manifests.
  • Remote causal validation workers.
  • Feature transfer tests across model families.
  • Public example gallery with archived real-model reports (started — see examples/real_model_demos/).

Development

python -m pip install -e ".[dev]"
python -m pytest

MIT licensed. Contributions welcome — see the issue tracker.

Metadata

Release files for interp-lab 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for interp-lab 3.1.0
File Size Uploaded
interp_lab-3.1.0.tar.gz 1.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for interp-lab 3.1.0
File Interpreter ABI Platform
interp_lab-3.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.4 MB

Release files / interp_lab-3.1.0.tar.gz

Download URL interp_lab-3.1.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
fe2734829af75717b1338783f7b74e82c953917be771dd3ac66935b9057c4b2e
BLAKE2b-256 checksum
How to use checksums
c6f029fa0ff08c26718d8bd95f3ce708c09020e6bb1b2066bcb7abc9e9c3dcf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

Release files / interp_lab-3.1.0-py3-none-any.whl

Download URL interp_lab-3.1.0-py3-none-any.whl
Size 363.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c764f38a79c2012487868f5f755f501115655731a605854739a5431079e13a70
BLAKE2b-256 checksum
How to use checksums
9053943d643c68095e94be72dd27e656e486bbcf0d4551faa9a6a9c1f309944a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

3.1.0 This release

2 release files

3.0.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page