AI Base

Course 06 of 10

Transformers

The architecture behind modern generative models: how attention becomes a full block, scales, and specializes.

9 chapters · 33 lessons · builds on Neural Networks · About this course

01Tokenization4 lessons

Before a transformer sees a single vector, raw text has to become a sequence of discrete symbols it can look up in a fixed vocabulary. Chapter overview

  1. 1Byte Pair Encoding 5 min
  2. 2WordPiece and SentencePiece 5 min
  3. 3Vocabulary Size and Out-of-Vocabulary Trade-offs 5 min
  4. 4Tokenizing Beyond Text 4 min
02Embeddings and Masking3 lessons
03The Transformer Block6 lessons
04Positional Information Beyond Sinusoids3 lessons

The fixed sinusoidal encoding from Deep Learning was the original transformer's answer to "where is this token in the sequence?" — but it was never the only answer, and modern models mostly use… Chapter overview

  1. 1Learned Positional Embeddings 4 min
  2. 2Relative Position and RoPE 5 min
  3. 3ALiBi and Length Extrapolation 5 min
05Architectural Families4 lessons

The same transformer block supports three very different overall shapes, depending on which direction information is allowed to flow. Chapter overview

  1. 1Encoder-Only Architectures 5 min
  2. 2Decoder-Only Architectures 5 min
  3. 3Encoder-Decoder Architectures as a Pattern 5 min
  4. 4Choosing an Architecture Family for a Task 5 min
06Efficient and Scaled Attention5 lessons

Plain multi-head attention gets expensive fast: its cost grows with the square of sequence length, and its memory traffic during inference grows with every token generated. Chapter overview

  1. 1Multi-Query and Grouped-Query Attention 4 min
  2. 2KV-Caching for Autoregressive Inference 5 min
  3. 3Sparse and Local (Windowed) Attention 5 min
  4. 4Linear Attention Approximations 5 min
  5. 5IO-Aware Attention Computation 5 min
07Scaling the Block3 lessons

Making a transformer bigger raises three separate questions: whether every parameter has to run on every input, how big "bigger" actually is in concrete numbers, and how a single block's… Chapter overview

  1. 1Mixture-of-Experts Transformer Blocks 5 min
  2. 2Counting a Transformer's Parameters and FLOPs 4 min
  3. 3Splitting a Transformer Across Devices 5 min
08Transformers Beyond Text3 lessons

Nothing about the transformer block is specific to language — it only needs a sequence of vectors to attend over. Chapter overview

  1. 1Vision Transformers 5 min
  2. 2Graph Transformers 5 min
  3. 3Multimodal Transformers as an Architecture Pattern 5 min
09Transformers in Practice2 lessons

This last section is about running a trained transformer well, and a capstone that walks the whole subject in one place. Chapter overview

  1. 1Inference Serving Trade-offs 5 min
  2. 2Capstone: Assembling a Tiny Transformer from the Ground Up 5 min
Transformers glossaryEvery key term from this course in one alphabetical list. Next course · 07Generative AI