activation-patching
Causal intervention via activation patching to identify important model components. Use when determining which layers, heads, or positions are causally responsible for model behavior.
npx skills add majiayu000/claude-skill-registry --skill activation-patching --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.
# Activation Patching Activation patching is a causal intervention technique that identifies which model components are responsible for specific behaviors by swapping activations between different inputs. ## Core Concept 1. **Clean run**: Run model on prompt that produces desired behavior 2. **Corrupted run**: Run on modified prompt that changes the behavior 3. **Patch**: Replace corrupted activations with clean ones, measure if behavior is restored If patching a component restores the clean behavior, that component is causally important. ## Basic Setup ```python from nnsight import LanguageModel import torch model = LanguageModel("openai-community/gpt2", device_map="auto", dispatch=True) # Indirect Object Identification (IOI) task clean_prompt = "After John and Mary went to the store, Mary gave a bottle of milk to" corrupted_prompt = "After John and Mary went to the store, John gave a bottle of milk to" # Target tokens correct_token = model.tokenizer(" John")["input_ids"][0] # Clean answer incorrect_token = model.tokenizer(" Mary")["input_ids"][0] # Corrupted answer ``` ## Metric: Logit Difference ```python def logit_diff(logits, correct_idx, incorrect_idx): """Measure how much mo
- Core Concept
- Basic Setup
- Metric: Logit Difference
- Three-Run Patching Pattern
- Position-Specific Patching
- Attention Head Patching
- Noising (Reverse Patching)
- Visualization
- Interpretation
What does the activation-patching skill do?
Causal intervention via activation patching to identify important model components. Use when determining which layers, heads, or positions are causally responsible for model behavior.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill activation-patching --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.
