transformer_lens.hook_points - TransformerLens Documentation
HookPoint is a dummy module that acts as an identity function by default. By wrapping any intermediate activation in a HookPoint, it provides a convenient way to add PyTorch hooks. Hook format is fn(activation, hook_name) Change it into PyTorch hook format (this includes input and output, which are the same for a HookPoint) If prepend is True, add this hook before all other hooks Defines the computation performed at every call. Should be overridden by all subclasses. Note Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them. Bases: Module A class building on nn.Module to interface nicely with HookPoints. Adds various nice utilities, most notably run_with_hooks to run the model with temporary hooks, and run_with_cache to run the model on some input and return a cache of all activations. Notes: The main
transformer_lens.hook_points module ¶ transformer_lens.hook_points. HookFunction ¶ alias of _HookFunctionProtocol class transformer_lens.hook_points. HookIntrospectionMixin ¶ Bases: object list_hooks() mixins for any class exposing a hook_dict . Accessed via getattr so subclasses can provide hook_dict as either an instance attribute ( HookedRootModule ) or a @property ( TransformerBridge ). list_hooks ( name_filter : Callable [ [ str ] , bool ] | Sequence [ str ] | str | None = None , dir : Literal [ 'fwd' , 'bwd' , 'both' ] = 'both' , including_permanent : bool = True ) → dict [ st
Explore this link on the map →related reading
- Implementing activation steering — LessWronglesswrong.com
- The Annotated Transformernlp.seas.harvard.edu
- Circuit Tracing: Revealing Computational Graphs in Language Modelstransformer-circuits.pub
- Transformer Explainer: LLM Transformer Model Visually Explainedpoloclub.github.io
- PyTorch internals : ezyang's blogblog.ezyang.com
- Chapter 1: Transformer Interpretability - ARENAlearn.arena.education
- Exploratory Analysis Demo - TransformerLens Documentationtransformerlensorg.github.io
- Tuned Lenstuned-lens.readthedocs.io
- Hooks | Cursor Docscursor.com
- Chapter 1: Transformer Interpretability - ARENAlearn.arena.education
- The Annotated Transformernlp.seas.harvard.edu
- Jacobian Lens – Qwen3.6-27B | Neuronpedianeuronpedia.org