causal-tracing
Causal mediation analysis to identify which model components mediate specific behaviors. Use when investigating how information flows through the network and which neurons or layers are causally responsible for outputs.
npx skills add majiayu000/claude-skill-registry --skill causal-tracing --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Causal Tracing Causal tracing (causal mediation analysis) identifies which intermediate computations causally mediate the relationship between inputs and outputs. It reveals not just what correlates with behavior, but what causes it. ## Core Concepts ### Three Types of Causal Effects 1. **Total Effect**: Change in output when modifying input 2. **Direct Effect**: Effect of restoring a component from clean to corrupted run 3. **Indirect Effect**: Effect of corrupting a component in an otherwise clean run ### The Interchange Intervention Swap activations between two runs to test causal relationships: - **Source run**: Produces the activation value - **Base run**: Receives the swapped activation ## Setup ```python from nnsight import LanguageModel import torch model = LanguageModel("openai-community/gpt2", device_map="auto", dispatch=True) # Factual recall task base_prompt = "The Eiffel Tower is located in" # Expects: Paris source_prompt = "The Colosseum is located in" # Expects: Rome # Get target tokens paris_token = model.tokenizer(" Paris")["input_ids"][0] rome_token = model.tokenizer(" Rome")["input_ids"][0] ``` ## Computing Total Effect ```python with model.trace() as tracer: w
- Core Concepts
- Three Types of Causal Effects
- The Interchange Intervention
- Setup
- Computing Total Effect
- Direct Effect (Restoration)
- Indirect Effect (Corruption)
- Position-Specific Causal Tracing
- Noising-Based Causal Tracing
- MLP vs Attention Decomposition
- Visualization
- Interpretation Guidelines
What does the causal-tracing skill do?
Causal mediation analysis to identify which model components mediate specific behaviors. Use when investigating how information flows through the network and which neurons or layers are causally responsible for outputs.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill causal-tracing --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
