pyvene-interventions

Perform causal interventions on PyTorch models with declarative activation patching.

1|Updated Feb 21, 2026
One-click install
npx skills add https://github.com/tianhao909/AI-Research-SKILLs-cn --skill pyvene-interventions-tianhao909
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pyvene-interventions
Source: https://github.com/tianhao909/AI-Research-SKILLs-cn/tree/main/04-mechanistic-interpretability/pyvene
Command: npx skills add https://github.com/tianhao909/AI-Research-SKILLs-cn --skill pyvene-interventions-tianhao909

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pyvene, torch, transformers, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill enables researchers and developers to perform precise causal interventions on PyTorch models, facilitating a deeper understanding of their internal workings and decision-making processes.

Core Features & Use Cases

  • Causal Tracing: Identify specific model components responsible for factual recall (e.g., ROME-style localization).
  • Activation Patching: Test hypotheses by swapping activations between different model runs.
  • Trainable Interventions: Discover and learn causal subspaces using methods like DAS.
  • Use Case: Debugging a language model's tendency to hallucinate by pinpointing and intervening on the specific activations that lead to incorrect outputs.

Quick Start

Use the pyvene-interventions skill to perform causal tracing on a transformer model by restoring clean activations at layer 8, position 5.

Frequently Asked Questions about pyvene-interventions

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

FAQPage Schema
How do I perform causal tracing on a transformer model to identify factual recall components?

Causal tracing identifies specific model components responsible for factual recall by restoring clean activations at targeted layers and positions during a forward pass. This Skill supports ROME-style localization to pinpoint exactly where factual information is retrieved.

Can I use activation patching to debug why my language model hallucinates?

Activation patching tests hypotheses by swapping activations between different model runs. You can debug hallucinations by pinpointing and intervening on the specific activations that lead to incorrect outputs, comparing clean and corrupted model runs.

What types of causal interventions does pyvene support for PyTorch models?

Causal interventions include Vanilla, Addition, Zero, and trainable RotatedSpace intervention types. These are executed via a declarative framework supporting activation patching, causal tracing, and interchange intervention training across diverse architectures.

Does this framework support causal interventions on state-space and vision models?

Causal interventions are supported across diverse model architectures including transformers, vision, and state-space models. The declarative framework adapts to various PyTorch model structures, enabling activation patching and causal tracing regardless of architecture.

How do I train a model to discover causal subspaces using interchange interventions?

Trainable interventions discover and learn causal subspaces using methods like DAS (Distributed Alignment Search). This allows you to identify rotated representational spaces where specific causal mechanisms operate within the neural network.

What is the difference between activation patching and causal tracing for model interpretability?

Activation patching swaps activations between different model runs to test specific hypotheses, while causal tracing localizes responsible components by restoring clean activations. Both are causal intervention techniques for understanding model decision-making processes.