Agent skill · AI & Agents

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.

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill activation-patching --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 6 KB
Bundled scripts: none
Path: skills/ai-ml/activation-patching/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 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

What's inside
Steps it walks through
  1. Core Concept
  2. Basic Setup
  3. Metric: Logit Difference
  4. Three-Run Patching Pattern
  5. Position-Specific Patching
  6. Attention Head Patching
  7. Noising (Reverse Patching)
  8. Visualization
  9. Interpretation
Ships with 1 file
  • metadata.json
More from claude-skill-registry
All skills →
About this skill
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.

Keep going