Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 01 · AI · Neurons to a language model · about 21 min to read

Watch: Attention from scratch: the mechanism that ate the field
▶ VideoPlay it as a journeyTutor comes with a plan

Attention & the Transformer

Attention and the Transformer
Attention and the Transformer · Open board

The keystone board of the How LLMs Work track. It tells the story of a translation machine that forgot the beginning of every long sentence, and of the fix that became modern AI.

Before you start. Tokens & Embeddings turned every word into a list of numbers, each looked up on its own, so the “bank” in river bank and the “bank” in bank loan get the identical list. You also want the one unit from What a Neural Network Is: each input is multiplied by its own dial and the results are added up. Nothing in the story half is harder than that multiply and add.

Lesson 9 of 83 in AI

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 2014: the bottleneck, one fixed-size note for a whole sentence
  • Montreal, 2014: attention, letting it look back at the page
  • 2017: the transformer, attention with the reading-in-order thrown out
  • Query, key and value: what a word asks for, shows, and gives
  • The causal mask: why the future has to be hidden
  • The block: attention plus a small network, stacked 96 deep
  • What attention costs: n × n scores, and the context window
  • What sat asks
  • Shrink, hide, share
  • sat takes its share
  • The board’s one line, in the cards
  • What one block adds around the glance
  • The bill for a long page
  • All of it in code

Terms it explains: How LLMs Work, attention, it, query, key, value, causal mask, block, question, label, contents, softmax, head, residual connection, layer norm, attention matrix, cross-attention, feed-forward (FFN/MLP), multi-head, O(n²), positional encoding, Query/Key/Value, scaled dot-product attention, self-attention, stack of N blocks, transformer block.

Related papers

Review AI