causal-attribution

Identify causally responsible model components through patching, ablation, and attribution patching interventions.

75|7|Updated May 2, 2026
One-click install
npx skills add https://github.com/zjunlp/Mechanist --skill causal-attribution-zjunlp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: causal-attribution
Source: https://github.com/zjunlp/Mechanist/tree/main/skills/mechanism-skills/causal-attribution
Command: npx skills add https://github.com/zjunlp/Mechanist --skill causal-attribution-zjunlp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch, transformers, numpy, matplotlib, transformer-lens, and includes scripts (resource) and references (resource) components.

What problem does it solve? Correlation-based analyses like magnitude analysis cannot distinguish components that merely activate strongly from those that actually drive model behavior. This Skill provides causal attribution methods that intervene on internal model objects to determine which attention heads, MLP layers, and edges are causally responsible for specific behaviors in transformer models like GPT-2 and GPT-J. ## Core Features & Use Cases - Patching: Replace activations from a clean run with counterfactual activations to localize where task-specific information (e.g., factual knowledge) is introduced, including causal tracing and Rank-One Model Editing (ROME) demos. - Ablation: Zero out attention or MLP sublayers and measure performance drops to determine causal necessity, with demos for dissecting factual recall via attention knockout and hidden state analysis. - Attribution Patching: Approximate full patching with a single backward pass using the inner product of gradients and activation differences, enabling fast circuit discovery and edge attribution across heads and MLP layers. - Use Case: A researcher investigating how GPT-2 recalls "The capital of France is Paris" can run sublayer knockout experiments to find critical layers, then use attribution patching to efficiently map the responsible circuit before applying ROME to edit the factual association. ## Quick Start Ask the agent to run a causal tracing experiment on GPT-2 to localize which layers are responsible for a factual prediction like "The capital of France is Paris".

Frequently Asked Questions about causal-attribution

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

FAQPage Schema
How do I find which attention heads cause a model behavior?

Use causal attribution methods that intervene on individual components and measure output changes. Patching swaps activations between clean and counterfactual runs, ablation zeros out components to measure performance drops, and attribution patching approximates these effects with a single backward pass.

What is the difference between patching and attribution patching?

Patching replaces an activation with a counterfactual one and re-runs the model, costing one forward pass per component. Attribution patching approximates this with a first-order Taylor expansion using gradients, reducing cost from O(n) forward passes to a few backward passes for fast circuit screening.

How to edit factual knowledge in GPT-2 without retraining?

Use Rank-One Model Editing (ROME), which applies a rank-one update to a specific MLP layer's weights to change a factual association. The included demo shows the workflow: locate the critical layer via causal tracing, then apply the edit and verify the new prediction.

Does causal attribution work on large models like GPT-J?

Yes, but exact interventions scale linearly with the number of components analyzed, making dense sweeps expensive. The recommended workflow is to screen with gradient-based attribution patching first, then run fine-grained patching or ablation only on promising components. GPT-J-6B experiments require an A100-class GPU.

What are the limitations of causal attribution methods?

Verifying causality requires intervening on objects individually with a separate forward pass each, so cost scales linearly with the number of objects analyzed. This makes exhaustive searches over large models prohibitively expensive without gradient-based approximations.