eap-ig

eap-ig is a skill for Claude Code from zjunlp/Mechanist. It costs 48 tokens per session (684 once invoked), scanned A, original, MIT.

A method for finding important computational paths inside autoregressive transformer language models, which generate text one token at a time. EAP-IG combines edge attribution patching with integrated gradients to score parts of the model.

In plain words
What is it for?
Use it to score model nodes or connections, select a circuit, and evaluate its effect on a task with TransformerLens models.
Why use it?
It helps researchers identify which model components affect a task and test whether a selected circuit changes the model's behavior.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the mechanist plugin — 54 skills, 4 agents shipped together

Good fit Use it to score model nodes or connections, select a circuit, and evaluate its effect on a task with TransformerLens models.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/zjunlp/mechanist/attribution-based-edge-scoring
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add zjunlp/Mechanist --skill attribution-based-edge-scoring
Clone the repo
git clone --depth 1 https://github.com/zjunlp/Mechanist

Made for: Claude Code.

Or install mechanist, the plugin that ships this one along with the rest of its 54 skills, 4 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for eap-ig

README.md
[![agentmods](https://agentmods.dev/badge/skills/zjunlp/mechanist/attribution-based-edge-scoring.svg)](https://agentmods.dev/skills/zjunlp/mechanist/attribution-based-edge-scoring)
Your own site
<a href="https://agentmods.dev/skills/zjunlp/mechanist/attribution-based-edge-scoring"><img src="https://agentmods.dev/badge/skills/zjunlp/mechanist/attribution-based-edge-scoring.svg" alt="Measured on agentmods" height="20"></a>
Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 684 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00048 $0.00684
Opus 5 $0.00024 $0.00342
Sonnet 5 $0.00010 $0.00137
Haiku 4.5 $0.00005 $0.00068

Measured 8d ago against content hash 9d4e3c5f0ffe, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

eap-ig scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/usage_example.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/mechanism-skills/circuit-discovery/attribution-based-edge-scoring/SKILL.md · 98 lines

How it starts

The opening of the file, as written. The whole thing — 98 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Demo Scripts

scripts/usage_example.py

#!/usr/bin/env python3
"""
Demonstration script for EAP-IG library usage.

This script constructs a computational graph for a TransformerLens GPT-2 model,
runs Edge Attribution Patching with Integrated Gradients (EAP-IG-inputs) to score
nodes or edges, selects a top-n circuit, and evaluates its impact on a simple task.

You must install this library and TransformerLens prior to running:
pip install . transformer_lens

Replace the model loading step with your preferred TransformerLens autoregressive model.
"""

import torch
from torch.utils.data import DataLoader
from transformer_lens import HookedTransformer

from eap.graph import Graph
from eap.attribute import attribute
from eap.evaluate import evaluate_graph
from eap.utils import EAPDataset


def accuracy_metric(preds: torch.Tensor, labels: torch.Tensor) -> torch.Tensor:
    """
    Simple accuracy metric.

    Args:
        preds: Model logits tensor of shape (batch, seq_len, vocab_size)
        labels: Ground truth labels tensor of shape (batch, seq_len)

    Returns:
        Tensor with scalar accuracy (fraction correct)
    """
    pred_tokens = preds.argmax(dim=-1)
    correct = (pred_tokens == labels).float()
    return correct.mean()


def main():
    # Load a pretrained GPT-2 small model from TransformerLens
    # This requires the transformer_lens package: pip install transformer_lens
    model_name = "gpt2-small"
    print(f"Loading TransformerLens model '{model_name}' ...")
    model = HookedTransformer.from_pretrained(model_name)

    # Prepare an example dataset for the "greater-than" synthetic task provided by EAPDataset
    dataset = EAPDataset("greater-than")
    dataloader = dataset.to_dataloader(batch_size=16, shuffle=True)

    # Build computational graph from the model
    print("Building computational graph from model ...")
    graph = Graph.from_model(model)

    # Compute attribution scores with EAP-IG on inputs mode (5 integrated gradient steps)
    print("Computing attribution scores with EAP-IG (inputs) ...")
    attribute(
        model=model,
        graph=graph,
        dataloader=dataloader,
        metric=accuracy_metric,
        method="EAP-IG-inputs",
        ig_steps=5,
        intervention="none",
    )

    # Select top 10 nodes/edges to define the circuit
    top_n = 10
    print(f"Selecting top {top_n} scoring components as circuit ...")
    graph.apply_topn(top_n)

    # Evaluate circuit by ablating outside nodes/edges and measuring accuracy
    print("Evaluating circuit faithfulness on dataset ...")
    results = evaluate_graph(
        model=model,
        graph=graph,
        dataloader=dataloader,
        metric=accuracy_metric,
        intervention="none",
    )
    print("Circuit evaluation results:", results)


if __name__ == "__main__":
    main()

Read the full file on GitHub · 98 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 98 lines · 48 tokens per session scan A 9d4e3c5f0ffe

Subscribe to this mod's changes

eap-ig is a skill published in the GitHub repository zjunlp/Mechanist (72 stars, last pushed 12d ago), licensed MIT. It adds 48 tokens to every session and 684 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.