flâneur — a map of the web's best reading

transformer_lens.HookedTransformer - TransformerLens Documentation

transformerlensorg.github.io · saved by 1 readers

In common PyTorch model implementations (e.g. ones from HuggingFace) it’s fairly easy to extract model weights, but much harder to extract activations. TransformerLens aims to simplify this task by attaching hooks to every notable activation within the model. This enables the inspection and/or alteration of activations in individual components like attention heads and MLP layers, facilitating a deeper understanding of the internal workings of transformers like GPT-2. Bases: HookedRootModule Hooked Transformer. Implements a full Transformer using the components here, with a transformer_lens.hook_points.HookPoint on every interesting activation. TransformerLens comes loaded with >50 GPT-style models. Typically you initialise it with one of these via from_pretrained(), although it can also be instantiated with randomly initialized weights via __init__(). Once you’ve initialized the model, a common next step is to test it can do the task you’re investigating. This can be done with transfor

In common PyTorch model implementations (e.g. ones from HuggingFace) it’s fairly easy to extract model weights, but much harder to extract activations. TransformerLens aims to simplify this task by attaching hooks to every notable activation within the model. This enables the inspection and/or alteration of activations in individual components like attention heads and MLP layers, facilitating a deeper understanding of the internal workings of transformers like GPT-2. Bases: HookedRootModule Hooked Transformer. Implements a full Transformer using the components here, with a transformer_lens.hoo

Explore this link on the map →