Circuit

Discovers minimal causal subgraphs in transformer models via ablation and gradient attribution.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Understanding why a transformer produces a specific behavior requires more than scoring individual neurons or heads in isolation. This Skill localizes the minimal subgraph of a model's computational graph — the attention heads, MLPs, and the edges connecting them — that is causally responsible for a given behavior, yielding a verifiable mechanism-level explanation. ## Core Features & Use Cases - Exact Iterative Search (ACDC): Prunes edges via activation patching with corrupted inputs, walking the graph in reverse topological order until a minimal faithful circuit remains. - Fast Gradient-Based Attribution (EAP-IG): Scores every edge in a few forward/backward passes using Edge Attribution Patching with Integrated Gradients, then thresholds scores to obtain a circuit. - Faithfulness Evaluation: Recovered circuits are validated on a held-out task distribution to confirm they actually implement the behavior rather than merely correlating with it. - Use Case: A researcher studying the 'greater-than' task in GPT-2 can run the EAP-IG demo to score all edges, select the top-n circuit, and measure the performance drop when components outside the circuit are ablated. ## Quick Start Ask the agent to run the EAP-IG demo on a TransformerLens GPT-2 model to score edges, extract a top-n circuit, and evaluate its faithfulness on the greater-than task.

Frequently Asked Questions about Circuit

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

FAQPage Schema
How do I discover circuits in a transformer model?

Use either exact iterative search (ACDC), which prunes edges by activation patching with corrupted inputs, or fast gradient-based attribution (EAP-IG), which scores all edges in a few passes and thresholds the scores. Both produce a minimal subgraph evaluated for faithfulness on a task distribution.

What is the difference between ACDC and EAP-IG for circuit discovery?

ACDC performs exact iterative edge pruning via per-edge activation patching, giving causal, intervention-grounded circuits at high compute cost. EAP-IG approximates edge effects with gradients and integrated gradients, trading some exactness for dramatically lower cost.

Does circuit discovery work with TransformerLens models?

Yes. The EAP-IG demo builds a computational graph directly from a TransformerLens HookedTransformer such as gpt2-small using Graph.from_model, then attributes, selects a top-n circuit, and evaluates it. ACDC similarly targets TransformerLens-style hooked models.

What are the limitations of circuit discovery methods?

Ablation-based search scales poorly with model and graph size, while gradient-based approximations can miss edges with non-linear effects. Results also depend on the task distribution, corrupted inputs, and faithfulness metric, so different configurations can yield different circuits.

How is circuit faithfulness evaluated?

Faithfulness is measured by ablating components outside the recovered circuit and checking whether the task metric is preserved on a held-out distribution. The EAP-IG evaluate_graph function reports metric values and the drop from baseline under interventions such as zero or mean ablation.