Embeddings give each token a fixed meaning, but language is contextual. In "the cat sat because it was tired", the word "it" only makes sense once you know it refers to the cat. The mechanism that lets a model resolve this — and that turned out to scale astonishingly well — is attention.
Every word looks at every word
Attention lets each token gather information from all the other tokens in the sequence, keeping what is relevant and ignoring the rest. For the token "it", the model learns to look at "cat" and copy in its meaning. It does this for every token simultaneously, in parallel.
How a weight is computed
For each token, the model derives three vectors from its embedding: a query (what am I looking for?), a key (what do I offer?), and a value (what I'll hand over if chosen). To decide how much token A should attend to token B:
score(A, B) = (queryA · keyB) / √d
weights = softmax(scores over all tokens) # sum to 1
output(A) = Σ weights · valueB
The dot product measures how well A's query matches B's key; dividing by √d keeps the numbers stable; softmax turns the raw scores into a clean distribution that sums to 100%. Each token's new representation is the weighted blend of everyone's values — context, folded in.
See attention resolve a pronoun
Below, click any word to make it the query and watch where its attention goes. By default "it" is the query, and its attention concentrates on "cat" — the model has resolved the reference. (The token vectors here are hand-set toy features so the maths is visible; a real model learns them.)
From attention to transformers
A transformer is what you get when you stack this: many attention layers, and within each layer several attention "heads" that look for different kinds of relationship at once (one head might track grammar, another long-range topic). Between attention layers sit ordinary feedforward neurons — the same weighted sums and activations from the Foundations track. Add embeddings at the bottom and a prediction head at the top, train the whole thing by backpropagation on oceans of text, and you have a large language model.
That is the arc of this track in one sentence: a neuron, stacked into networks, trained by gradient descent and backpropagation, fed language through embeddings, and given context by attention. Everything else in modern AI is scale, data, and refinement on top of these foundations.