A library for training and analysing transformer models, focused on mechanistic interpretability. Provides tools to probe, edit, and visualise model internals. Current version 3.1.0, released with support for Python >=3.10, <4.0. Active development.
pip install transformer-lensVerified import paths — ran on the pinned version, not inferred.
Load a pretrained model and run a forward pass.
Change all imports to use underscores: 'import transformer_lens'.
Check the changelog for the new location of utility functions.
Cache tensors are of shape (batch, pos, d_model). Use cache['blocks.0.hook_mlp'].shape to verify.
No dependency data recorded yet.