Skip to content

Guide · Agent skill

How to use the pyvene Causal Interventions agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

The pyvene-interventions skill gives your AI agent a structured guide to pyvene, a Python library for testing which internal parts of a PyTorch model cause a given behaviour. It is aimed at interpretability researchers, students and engineers reproducing intervention experiments. After this guide you will know how to install the skill, how to phrase requests that trigger it, and what it needs to run.

pyvene Causal InterventionsOrchestra-Research/AI-Research-SKILLs · MIT

Quick start

  1. 1Download and unzip the skill. Download the ZIP from this page and unzip it. Place the folder in ~/.claude/skills/ or in your project's .claude/skills/ folder.
  2. 2Install pyvene. Run pip install pyvene in your Python environment, and make sure PyTorch 2.0+ and transformers 4.30+ are available.
  3. 3Choose a model. Pick a model from HuggingFace, such as gpt2 for learning or gpt2-xl for the causal tracing example.
  4. 4Describe your experiment. Ask the agent in plain language, naming the technique (causal tracing, activation patching) and the behaviour you want to test.
  5. 5Review the generated code. Read the scripts the agent writes, since they run code and download weights over the network.
  6. 6Run and interpret. Run the experiment, then check the resulting values or heatmap to find which layers and positions have causal effect.

What does the pyvene-interventions skill make the agent do?

An agent skill is a folder of instructions and reference files that an AI agent loads when a task matches the skill's description. This one covers causal interventions on PyTorch models using pyvene's declarative, dict-based framework. Once loaded, the agent can write and explain intervention configs, swap or zero out activations between runs, sweep over layers and positions for causal tracing, and run activation patching for circuit analysis.

The skill is mainly reference material and code templates. It helps the agent write and explain these experiments correctly; it does not replace running them yourself.

  • Causal tracing (ROME-style localization of factual associations)
  • Activation patching for circuit analysis
  • Interchange intervention training (IIT)
  • Intervention types such as VanillaIntervention, ZeroIntervention and AdditionIntervention

How do you install the pyvene-interventions skill?

Download the ZIP for this skill from this page and unzip it. For a personal setup, place the unzipped folder in ~/.claude/skills/. For a single project, place it in that project's .claude/skills/ folder.

Alternatively, in the Claude apps, open Settings, go to Capabilities, and upload the skill under Skills.

  • Personal: ~/.claude/skills/
  • Project: .claude/skills/ inside your project folder
  • Claude apps: Settings → Capabilities → Skills

Install the pyvene library and its requirements

The skill's experiments need the pyvene library itself. The skill lists pyvene 0.1.8 or later, PyTorch 2.0 or later and HuggingFace transformers 4.30 or later. Model weights are downloaded from HuggingFace, for example gpt2 or gpt2-xl. A GPU is recommended for larger models.

  • Python with pyvene (version 0.1.8 or later)
  • PyTorch 2.0 or later
  • HuggingFace transformers 4.30 or later
  • Model weights from HuggingFace, such as gpt2 or gpt2-xl
pip install pyvene

How do you trigger the skill with natural requests?

You do not need a special command. Describe the experiment in plain language and mention the technique. The skill's description matches requests about causal tracing, activation patching, interchange intervention training, or testing causal hypotheses about model behaviour.

Name the model and the question you are testing. The more specific you are about the layer, position or behaviour, the more useful the agent's code will be.

  • Write a causal tracing sweep over GPT-2 layers and token positions for the Space Needle prompt.
  • Set up activation patching on attention outputs to find which layers carry an indirect object identification behaviour.
  • Explain how to configure a VanillaIntervention on block_output at layer 8.
  • Help me reproduce a patching experiment with pyvene on gpt2.

What examples does the skill cover?

The skill includes three workflows and a tutorial set. Causal tracing corrupts a prompt, restores clean activations at one layer and position at a time, and records the probability of the correct answer token. Activation patching swaps attention outputs between a clean and corrupted prompt and measures a logit difference. Interchange intervention training is covered as a trainable approach to discovering causal structure.

The basic activation patching tutorial swaps activations between two prompts, such as a base prompt about the Colosseum and a source prompt about the Eiffel Tower, by patching a block_output representation at layer 8.

What safety and network points should you know about?

This skill runs scripts and uses the network. The model weights are downloaded from HuggingFace, and the code loads models with from_pretrained calls. Read any script the agent writes before you run it, and check which model it downloads, especially for large models that need substantial GPU memory.

Sweeps over every layer and position are compute-heavy. Start with a small model such as gpt2 before scaling up.

  • Scripts are run as part of the experiment, so review generated code first.
  • Network access is needed to fetch model weights from HuggingFace.
  • Large sweeps can need significant GPU memory and time.

Tips for getting reliable results

The skill's own guidance says to consider alternatives for some tasks. For exploratory activation analysis, it points to TransformerLens. For training or analysing SAEs it points to SAELens, and for remote execution on massive models or lower-level control it points to nnsight.

Keep clean and corrupted prompts tokenised the same way so positions line up, and check the heatmap for hotspots rather than a single number.

  • Use TransformerLens for quick exploratory analysis, per the skill's guidance.
  • Start with gpt2 to learn causal tracing before trying gpt2-xl.
  • Use the checklist in the causal tracing workflow: clean prompt, corrupted prompt, config per layer and position, sweep, then identify hotspots.

What people use it for

  • Localising where a model stores a factual association, using a causal tracing sweep over layers and token positions.
  • Testing which attention outputs are needed for an indirect object identification task with activation patching.
  • Learning how block_output, mlp_output and attention_output interventions differ on GPT-2.
  • Writing a reproducible intervention config that can be shared alongside a research write-up.

Frequently asked questions

Is the pyvene-interventions skill free?

The skill is published under the MIT licence, as stated on this page. The pyvene library is a separate package installed with pip, and model weights are downloaded from HuggingFace.

What do I need to use this skill?

You need Python with pyvene 0.1.8 or later, PyTorch 2.0 or later, and HuggingFace transformers 4.30 or later. You also need model weights such as gpt2, and a GPU is recommended for larger models.

How do I install the pyvene skill for Claude?

Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use, or into a project's .claude/skills/ folder. In the Claude apps you can instead upload it under Settings, Capabilities, Skills.

What is the difference between pyvene and TransformerLens?

According to the skill's own guidance, TransformerLens is the better fit for exploratory activation analysis. pyvene is aimed at declarative causal interventions such as causal tracing, activation patching and interchange intervention training.

Can I use pyvene on large models?

You can, but sweeps over every layer and position are compute-heavy. Without suitable GPU memory, large models will be slow or fail, so start with a small model like gpt2.

Is pyvene suitable for production model safety decisions?

No. The skill covers research experiments rather than validated evaluation, so its results should not be the basis for production safety decisions.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use this skill if you are an interpretability researcher, student or engineer who wants an agent to write and explain pyvene causal tracing and activation patching experiments on small open models like GPT-2. Pick something else for quick exploratory probing, where the skill itself points to TransformerLens or nnsight, or for production safety decisions, which need validated evaluation.

Download the skill