pyvene-interventions

Apply pyvene interventions to swap, add, or patch activations in PyTorch models.

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/tadod12/fraud-detection-research --skill pyvene-interventions-tadod12
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pyvene-interventions
Source: https://github.com/tadod12/fraud-detection-research/tree/main/.agent/skills/04-mechanistic-interpretability/pyvene
Command: npx skills add https://github.com/tadod12/fraud-detection-research --skill pyvene-interventions-tadod12

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guides researchers in applying pyvene to perform causal interventions on PyTorch models, enabling controlled experiments on internal representations and causal mechanisms.

Core Features & Use Cases

  • Activation patching and causal tracing to identify how specific layers and components drive model outputs.
  • Interchange intervention training (IIT) and distributed alignment search (DAS) to discover trainable causal subspaces.
  • Model steering and generation-time interventions, with easy sharing of interventions via HuggingFace.
  • Reproducibility and learnings across architectures (GPT-2, LLaMA, Pythia, etc.).

Quick Start

Install pyvene, configure a target intervention with IntervenableConfig for a given layer and component, and run IntervenableModel against base and source inputs to observe effects.

Frequently Asked Questions about pyvene-interventions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I perform activation patching on PyTorch models to identify causal relationships?

Activation patching identifies causal relationships by swapping or patching activations between model runs. You configure a target intervention with IntervenableConfig for a specific layer and component, then run IntervenableModel against base and source inputs to observe the causal effects on outputs.

What is causal tracing and how does it work with neural network interpretability?

Causal tracing is an interpretability technique that identifies how specific layers and components drive model outputs. By applying targeted pyvene interventions to patch activations across runs, you can trace which internal representations are causally responsible for specific model behaviors.

Can I use pyvene interventions with LLaMA and GPT-2 architectures?

Yes, pyvene interventions support PyTorch architectures including GPT-2, LLaMA, and Pythia. The Skill applies IntervenableModel and RepresentationConfig across these compatible models to ensure reproducibility and shared learnings for causal experiments.

What is the best way to implement interchange intervention training (IIT) for discovering causal subspaces?

Interchange intervention training (IIT) discovers trainable causal subspaces by applying structured interventions to internal model representations. Using pyvene, you configure IntervenableConfig to swap activations between inputs, enabling the model to learn aligned causal mechanisms during training.

Do I need specific library versions to run pyvene causal interventions?

Yes, causal interventions require pyvene>=0.1.8, torch>=2.0.0, and transformers>=4.30.0. These dependencies provide the foundational IntervenableModel, IntervenableConfig, and RepresentationConfig classes needed to configure and execute activation patching and steering experiments.

How does model steering work with generation-time interventions in PyTorch?

Model steering applies generation-time interventions by modifying activations during inference to alter model outputs. Using pyvene, you configure interventions that add or swap activations on the fly, and these interventions can be easily shared via HuggingFace for reproducible steering experiments.