Chapter 1: Transformer Interpretability - ARENA
The input tokens 𝑡 t are integers. We get them from taking a sequence, and tokenizing it (like we saw in the previous section). The token embedding is a lookup table mapping tokens to vectors, which is implemented as a matrix 𝑊 𝐸 W E . The matrix consists of a stack of token embedding vectors (one for each token). The residual stream is the sum of all previous outputs of layers of the model, and is also the input to each new layer. It has shape [batch, seq_len, d_model] (where d_model is the length of a single embedding vector). The initial value of the residual stream is denoted 𝑥 0 x 0 in the diagram, and 𝑥 𝑖 x i are later values of the residual stream (after more attention and MLP layers have been applied to the residual stream). The residual stream is really fundamental. It's the central object of the transformer. It's how model remembers things, moves information between layers for composition, and it's the medium used to store the information that attentio
2️⃣ Clean Transformer Implementation Learning Objectives Understand that a transformer is composed of attention heads and MLPs, with each one performing operations on the residual stream Understand that the attention heads in a single layer operate independently, and that they have the role of calculating attention patterns (which determine where information is moved to & from in the residual stream) Learn about & implement the following transformer modules: LayerNorm (transforming the input to have zero mean and unit variance) Positional embedding (a lookup table from position indices to resi
Explore this link on the map →related reading
- A Mathematical Framework for Transformer Circuitstransformer-circuits.pub
- The Illustrated Transformer – Jay Alammar – Visualizing machine learning one concept at a time.jalammar.github.io
- Transformer Explainer: LLM Transformer Model Visually Explainedpoloclub.github.io
- Transformers from Scratche2eml.school
- A Conceptual Guide to Transformers: Part Ibenlevinstein.substack.com
- The Annotated Transformernlp.seas.harvard.edu
- The Illustrated Transformer – Jay Alammar – Visualizing machine learning one concept at a time.jalammar.github.io
- Everything About Transformerskrupadave.com
- Transformer Circuits Threadtransformer-circuits.pub
- Chapter 1: Transformer Interpretability - ARENAlearn.arena.education
- Transformer (deep learning) - Wikipediaen.wikipedia.org
- The Annotated Transformernlp.seas.harvard.edu