transformer-lens-interpretability

Analyze and steer transformer activations with TransformerLens for mechanistic interpretability.

1.0k|117|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/OpenLAIR/dr-claw --skill transformer-lens-interpretability-openlair
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: transformer-lens-interpretability
Source: https://github.com/OpenLAIR/dr-claw/tree/main/skills/mechanistic-interpretability/transformer-lens
Command: npx skills add https://github.com/OpenLAIR/dr-claw --skill transformer-lens-interpretability-openlair

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TransformerLens provides a structured approach to probing transformer internals, enabling researchers to inspect activations, patch activations, and trace causal contributions to predictions.

Core Features & Use Cases

  • Activation caching and inspection of resid_post, pattern, and z activations
  • HookedTransformer and HookPoints for safe, controlled activation manipulation
  • Activation patching and causal tracing to quantify influence on outputs
  • Induction head and IOI circuit analysis to reveal circuit-level behavior
  • Logit attribution and visualization to understand contribution pathways
  • Ecosystem integration with related tooling and tutorials for guided workflows

Quick Start

Install transformer-lens, load a pretrained GPT-2 with HookedTransformer, run run_with_cache on an input to inspect activations, then apply a forward hook to patch activations and observe the impact on the output.

Frequently Asked Questions about transformer-lens-interpretability

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

FAQPage Schema
How do I perform activation patching on a GPT-style model to trace causal contributions?▼

You can discover IOI circuits by using HookPoints for controlled activation manipulation, running run_with_cache to inspect pattern and z activations, then applying activation patching to quantify how specific components influence the indirect object identification behavior.

What is mechanistic interpretability and how does TransformerLens expose transformer internals?▼

Mechanistic interpretability analyzes transformer behavior by inspecting and manipulating internal activations. TransformerLens exposes resid_post, pattern, and z activations through caching and hook utilities, allowing researchers to trace causal contributions to predictions across GPT-style models.

Can I inspect attention patterns and logit attribution across different pretrained transformer checkpoints?▼

Yes, you can inspect attention patterns and logit attribution by loading compatible pretrained model checkpoints into HookedTransformer, running run_with_cache to extract pattern activations, and visualizing the contribution pathways to understand prediction behavior.

How do I set up the environment for mechanistic interpretability experiments with transformer-lens?▼

Mechanistic interpretability experiments require installing the transformer-lens package and obtaining compatible GPT-style model checkpoints. You then load the model as a HookedTransformer and use run_with_hooks and run_with_cache utilities to execute patching and caching workflows.

What is the best way to analyze induction heads in transformer models?▼

Analyzing induction heads involves loading a pretrained model with HookedTransformer, using run_with_cache to extract and inspect attention pattern activations, and applying logit attribution to reveal the circuit-level behavior driving the induction mechanism.

When should I not use activation patching for interpreting transformer behavior?▼

Activation patching has limitations when used without compatible model checkpoints or the transformer-lens package. It is not suitable for non-GPT-style architectures, and researchers should avoid drawing conclusions without properly caching baseline activations for causal comparison.