How Transformer LLMs Work

by DeepLearning.AI

BeginnerCourseFree1 hour 44 minutes, self-paced (13 video lessons, two with code examples)

The clearest short walkthrough of what is actually inside a transformer — including the parts added since 2017.

Start LearningAdded Jul 4, 2026 · Updated Aug 4, 2026

Overview

The course is taught by Jay Alammar, Director and Engineering Fellow at Cohere and author of the widely-cited Illustrated Transformer explainers, together with Maarten Grootendorst, a senior clinical data scientist at the Netherlands Comprehensive Cancer Organisation (IKNL) and the maintainer of the open-source BERTopic and KeyBERT packages. The two co-wrote O'Reilly's Hands-On Large Language Models, and the course follows that book's illustrated pedagogy. Thirteen lessons run 1 hour 44 minutes: Introduction; a four-part Understanding Language Models sequence covering bag-of-words, word embeddings, encoding and decoding context with attention, and transformers; then Tokenizers, Architectural Overview, The Transformer Block, Self-Attention, a Model Example, Recent Improvements, Mixture of Experts (MoE) and a conclusion. Two lessons carry runnable code, worked through the Hugging Face Transformers library so you can inspect tokenizer output and intermediate activations rather than take the diagrams on trust. The Recent Improvements lesson is what dates this course correctly against older transformer explainers: it covers KV cache, multi-query attention, grouped-query attention and sparse attention — the changes that separate a 2017 paper diagram from a model actually serving traffic today. It is marked beginner level with no formal prerequisites, though the graded end-of-course quiz sits behind a Pro subscription and short courses issue a completion email rather than a formal certificate.

At a Glance

Topic
Models
Level
Beginner
Format
Course
Cost
Free
Duration
1 hour 44 minutes, self-paced (13 video lessons, two with code examples)
Provider
DeepLearning.AI
Hands-on
Yes — code/exercises
Certificate
None

What You’ll Learn

  • Trace how language models evolved from bag-of-words through embeddings to attention and transformers
  • Explain what a tokenizer actually produces and how strategies differ across modern LLMs
  • Describe the components of a transformer block and how they compose into a full model
  • Work through self-attention step by step rather than treating it as a black box
  • Understand KV caching, multi-query attention, grouped-query attention and sparse attention as serving optimisations
  • Explain how mixture-of-experts routing changes model capacity relative to inference cost
  • Inspect tokenizers and model internals directly using the Hugging Face Transformers library

Highlights

  • Taught by Jay Alammar, whose illustrated transformer explainers are the reference many engineers learned from
  • Covers post-2017 architecture changes (KV cache, GQA, sparse attention, MoE) that most transformer tutorials skip entirely
  • Follows the structure of the authors' O'Reilly book Hands-On Large Language Models, so it maps onto a fuller text
  • Visual-first pedagogy with two code lessons on Hugging Face Transformers — explanation and execution, not one or the other
  • Under two hours, and genuinely accessible without a machine learning background

Who It’s For

Best For

  • Application developers who use LLM APIs and want to understand what they are calling
  • Engineers evaluating serving trade-offs who need to reason about KV cache and attention variants
  • Anyone who has read the original Attention Is All You Need paper and found it dense
  • Career switchers building the vocabulary to read modern model cards and architecture papers

Prerequisites

  • None formally required — the course is pitched at beginner level and builds from bag-of-words upward
  • Basic Python helps for the two code lessons, which use the Hugging Face Transformers library

FAQ

What is How Transformer LLMs Work?

A visual, ground-up explanation of transformer architecture from the authors of O'Reilly's Hands-On Large Language Models. It walks from bag-of-words and embeddings through attention, the transformer block and tokenization, then keeps going into the efficiency work that modern LLMs actually ship — KV caching, multi-query and grouped-query attention, sparse attention and mixture-of-experts. Aimed at developers who use LLMs daily and want to stop treating them as opaque.

Is How Transformer LLMs Work free?

How Transformer LLMs Work is free to access.

What level is How Transformer LLMs Work for?

How Transformer LLMs Work is aimed at a beginner audience. Recommended background: None formally required — the course is pitched at beginner level and builds from bag-of-words upward, Basic Python helps for the two code lessons, which use the Hugging Face Transformers library.

How long does How Transformer LLMs Work take?

Expect roughly 1 hour 44 minutes, self-paced (13 video lessons, two with code examples). Most learners work through it at their own pace.

What will I learn from How Transformer LLMs Work?

You'll learn: Trace how language models evolved from bag-of-words through embeddings to attention and transformers; Explain what a tokenizer actually produces and how strategies differ across modern LLMs; Describe the components of a transformer block and how they compose into a full model; Work through self-attention step by step rather than treating it as a black box; Understand KV caching, multi-query attention, grouped-query attention and sparse attention as serving optimisations; Explain how mixture-of-experts routing changes model capacity relative to inference cost; Inspect tokenizers and model internals directly using the Hugging Face Transformers library.

Topics

transformersllmattentiontokenizationmixture-of-experts

Sources

This page was written from 3 sources, 2 on domains other than deeplearning.ai.

  1. 1.deeplearning.aihow transformer llms workvendor
  2. 2.llm-book.comllm-book.com
  3. 3.community.deeplearning.ai555594