pyvene-interventions

Automate causal interventions on PyTorch models using pyvene.

1.0k|117|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/OpenLAIR/dr-claw --skill pyvene-interventions-openlair
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pyvene-interventions
Source: https://github.com/OpenLAIR/dr-claw/tree/main/skills/mechanistic-interpretability/pyvene
Command: npx skills add https://github.com/OpenLAIR/dr-claw --skill pyvene-interventions-openlair

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Pyvene provides a declarative framework to perform causal interventions on PyTorch models, enabling researchers to systematically test causal hypotheses via activation patching, causal tracing, and interchangeable training interventions.

Core Features & Use Cases

  • Declarative configuration with IntervenableConfig and RepresentationConfig to specify layer, component, and intervention type.
  • Support for multiple intervention types (VanillaIntervention, AdditionIntervention, SubtractionIntervention, CollectIntervention, RotatedSpaceIntervention, LowRankRotatedSpaceIntervention).
  • End-to-end workflows for causal tracing, activation patching, IIT, and generation-time steering, with model saving/loading and HuggingFace sharing.

Quick Start

Install pyvene, configure an IntervenableConfig with a representation targeting a layer and component, and run an intervention on a PyTorch model.

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 like GPT-2 or LLaMA?

Activation patching on PyTorch models is automated by defining an IntervenableConfig with RepresentationConfig entries to target specific layers and components. This declarative configuration specifies the intervention type, enabling systematic causal hypothesis testing on models like GPT-2 and LLaMA.

What causal intervention types does pyvene support for neural network interpretability?

Causal interventions for neural network interpretability include VanillaIntervention, AdditionIntervention, SubtractionIntervention, CollectIntervention, RotatedSpaceIntervention, and LowRankRotatedSpaceIntervention. These configurable types enable diverse causal tracing and interchange intervention training workflows.

Can I use causal tracing to test hypotheses in transformer models?

Causal tracing in transformer models is supported through declarative interventions that patch activations across targeted layers. By configuring representation parameters, researchers can systematically test causal hypotheses and trace specific model behaviors during generation.

How do I configure interchange intervention training for PyTorch models?

Interchange intervention training for PyTorch models requires defining an IntervenableConfig with RepresentationConfig entries specifying the target layer and component. The framework supports end-to-end workflows for training, generation-time steering, and saving or loading the intervened models.

Does this framework support saving and sharing intervened models on HuggingFace?

Saving and sharing intervened models on HuggingFace is fully supported. After applying causal interventions or interchange intervention training, the framework provides end-to-end workflows to save and load model states and share them via HuggingFace.

What is the best way to set up declarative causal interventions on PyTorch models?

Declarative causal interventions on PyTorch models are set up by installing pyvene and configuring an IntervenableConfig with RepresentationConfig entries. This approach targets specific layers and components, providing a structured framework for activation patching and causal tracing.