Agent skill · research science · davila7
pyvene-interventions
Provides guidance for performing causal interventions on PyTorch models using pyvene's declarative intervention framework. Use when conducting causal tracing, activation patching, interchange intervention training, or testing causal hypotheses about model behavior.
Why this skill is useful
Provides domain-specific knowledge on causal interventions in PyTorch models that the AI wouldn't reliably generate on its own.
What it needs
Requires pyvene, torch, transformers installed locally. About 6k tokens when loaded. Last updated 2026-08-06. 30,138 stars on the source repository.
What this skill does
pyvene: Causal Interventions for Neural Networks pyvene is Stanford NLP's library for performing causal interventions on PyTorch models. It provides a declarative, dict-based framework for activation patching, causal tracing, and interchange intervention training - making intervention experiments reproducible and shareable. GitHub: stanfordnlp/pyvene (840+ stars) Paper: pyvene: A Library for Understanding and Improving PyTorch Models via Interventions (NAACL 2024) When to Use pyvene Use pyvene when you need to: Perform causal tracing (ROME-style localization) Run activation patching experiments Conduct interchange intervention training (IIT) Test causal hypotheses about model components Share/reproduce intervention experiments via HuggingFace Work with any PyTorch architecture (not just transformers) Consider alternatives when: You need exploratory activation analysis → Use TransformerLens You want to train/analyze SAEs → Use SAELens You need remote execution on massive models → Use nnsight You want lower-level control → Use nnsight Installation Standard import: Core Concepts IntervenableModel The main class that wraps any PyTorch model with intervention capabilities: Intervention Types Type Description Use Case ------ ------------- ---------- VanillaIntervention Swap activations between runs Activation patching AdditionIntervention Add activations to base run Steering, ablation SubtractionIntervention Subtract activations Ablation ZeroIntervention Zero out activations Component knockout RotatedSpaceIntervention DAS trainable intervention Causal discovery CollectIntervention Collect activations Probing, analysis Component Targets Workflow 1: Causal Tracing (ROME-style) Locate where factual associations are stored by corrupting inputs and restoring activations. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills davila7/mechanistic-interpretability-pyvene