$npx skillfedfor your agent

transformer-lens

An implementation of transformers tailored for mechanistic interpretability.

With conditionsPyPI Artificial IntelligenceReleased Aug 202688.2K downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — transformer_lens-3.7.1-py3-none-any.whl
v3.7.1 · released 2026-08-11 · Python <4.0,>=3.10 · 21 runtime deps: accelerate, beartype, better-abc, datasets, einops, fancy-einsum, huggingface-hub, jaxtyping

Yes, if you are doing mechanistic interpretability research or need to inspect transformer internals. The library is actively maintained, has low install friction, and is licensed permissively. No, if you only need standard inference or fine-tuning—the 21 dependencies and focus on activation inspection add complexity unnecessary for typical transformer use. Yes-with-conditions if you work with gated models: you must set HF_TOKEN in your environment.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.10 or later.
  • Gated models (Llama, Mistral, Gemma) require HF_TOKEN environment variable set with a HuggingFace API token.
  • Low friction installation with a pure-Python wheel.

License · maintenance · safety

MIT (permissive) — MIT license is permissive—you can use, modify, and distribute this package freely with minimal restrictions, making it suitable for both research and commercial projects.

last release 2026-08-11 (3 days)

0 known vulnerabilities (OSV.dev, 2026-08-14) · 88,225 downloads/mo, #13,740 on PyPI

Verify before relying

pip install transformer_lens

from transformer_lens.model_bridge import TransformerBridge

bridge = TransformerBridge.boot_transformers("gpt2", device="cpu")
logits, activations = bridge.run_with_cache("Hello World")
  • Whether the 15,000+ supported models across 140+ architecture families claim is current as of version 3.7.1
  • Performance characteristics and memory overhead when caching activations on large models
  • Compatibility guarantees with specific transformer architecture versions beyond the quick-start examples
Same gist for agents: .md · .json

What it is and what it does

TransformerLens is a library for mechanistic interpretability—the practice of reverse-engineering what algorithms a trained transformer learned by inspecting its weights and internal activations. It lets you load open-source language models, run them on text, and intercept the numerical values flowing through every layer and attention head. You can cache these activations, edit them mid-run, or replace them entirely to see how the model's output changes.

The library's main entry point is TransformerBridge, which handles loading models from HuggingFace and exposes their internal state. It depends on torch, transformers, and huggingface-hub for model loading, plus utilities like einops for tensor manipulation and wandb for experiment tracking. The core use case is research: studying how models solve specific tasks, finding which neurons or circuits are responsible for particular behaviors, and testing hypotheses about learned algorithms by ablating or patching activations.

Use it for

  • Identify which attention heads and neurons are responsible for specific model behaviors by ablating or patching their activations
  • Replicate published mechanistic interpretability research that studies induction heads, indirect object identification, or circuit discovery
  • Debug unexpected model outputs by inspecting intermediate layer activations and tracing information flow through the network
  • Train and analyze decision transformers or other custom architectures by hooking into their internal states during inference
  • Study how language models encode and process linguistic structure across different layers and attention patterns

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you are doing mechanistic interpretability research or need to inspect transformer internals.

The library is actively maintained, has low install friction, and is licensed permissively. No, if you only need standard inference or fine-tuning—the 21 dependencies and focus on activation inspection add complexity unnecessary for typical transformer use. Yes-with-conditions if you work with gated models: you must set HF_TOKEN in your environment.

Install

transformer-lens on PyPI

Before you install

Low friction installation with a pure-Python wheel. Active maintenance with a release 3 days old. Requires 21 runtime dependencies including torch, transformers, and huggingface-hub, which are substantial but standard for transformer work.

Requires Python 3.10 or later. Gated models (Llama, Mistral, Gemma) require HF_TOKEN environment variable set with a HuggingFace API token.

License in practice

MIT license is permissive—you can use, modify, and distribute this package freely with minimal restrictions, making it suitable for both research and commercial projects.

Quickstart

pip install transformer_lens

from transformer_lens.model_bridge import TransformerBridge

bridge = TransformerBridge.boot_transformers("gpt2", device="cpu")
logits, activations = bridge.run_with_cache("Hello World")

Verify before relying

  • Whether the 15,000+ supported models across 140+ architecture families claim is current as of version 3.7.1
  • Performance characteristics and memory overhead when caching activations on large models
  • Compatibility guarantees with specific transformer architecture versions beyond the quick-start examples

Package facts

LicenseMIT permissive
Python supportSupports the current Python release <4.0,>=3.10
Install frictionLow. Pure-Python wheel
Runtime dependencies
21 packages
acceleratebeartypebetter-abcdatasetseinopsfancy-einsumhuggingface-hubjaxtypingnumpypackagingpandasprotobufrichsentencepiecetorchtqdmtransformers-stream-generatortransformerstypeguardtyping-extensionswandb
MaintenanceActively maintained 3 days since the last release
First released
Downloads88,225 / month, #13,740 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14

Evidence: transformer_lens-3.7.1-py3-none-any.whl

Tags

Capabilities
transformer activation inspectionmechanistic interpretability librarylanguage model internals analysistransformer circuit debuggingneural network layer visualizationmodel weight reverse engineeringattention head analysis
Topics
mechanistic-interpretabilitytransformer-analysisneural-network-debugging

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “transformer activation inspection”

  • transformer-lensTransformerLens loads and inspects the internal activations of…
  • sae-lensSAE Lens trains and analyzes sparse autoencoders for mechanistic…
  • nvdlfw-inspectProvides debugging and instrumentation APIs for LLM training…

Give your agent the search over MCP, or paste the wish link into any chat.

More Artificial Intelligence packages

litellm With conditions
PyPI · Artificial Intelligence · released Aug 2026

LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.

Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.

MITcompiled wheel
682.8Mdownloads / mo
huggingface-hub Worth it
PyPI · Artificial Intelligence · released Aug 2026

Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.

Install it if you work with Hugging Face Hub models or datasets.

Apache-2.0pure Python · 3.10.0+
442.4Mdownloads / mo
langchain Worth it
PyPI · Python Modules · released Aug 2026

LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.

MITpure Python
315.4Mdownloads / mo
hf-xet With conditions
PyPI · Artificial Intelligence · released Aug 2026

hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.

Apache-2.0compiled wheel · 3.8+
258.4Mdownloads / mo
tokenizers Worth it
PyPI · Artificial Intelligence · released Apr 2026

Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.

Apache-2.0compiled wheel · 3.10+
222.9Mdownloads / mo
transformers Worth it
PyPI · Artificial Intelligence · released Aug 2026

Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.

Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.

permissive licensepure Python · 3.10.0+
186.6Mdownloads / mo

See also sae-lens · feature-engine · spacy-transformers · pytorch-pretrained-bert · local-attention · interpret · curated-transformers · vit-pytorch · transformer-engine