Language Models and Attention
Connect next-token prediction, sequence-to-sequence tasks, and attention.
artificial intelligence, language models, attention, sequencePredict a continuation
A language model estimates probabilities for tokens given context. If a toy model gives “tea” probability 0.6 and “milk” probability 0.4 after “drink”, “tea” is more likely under that model; the probabilities are illustrative, not universal facts. A generated sequence can be built one token at a time, although language models can also be used in other ways.
Translate with a sequence model
- An encoder represents an input sequence such as “red house”.
- A decoder produces an output sequence, one token at a time; it need not have the same number of tokens as the input.
- Attention can weight input representations differently at each output step, helping the decoder use relevant context. A high weight is not a complete explanation of the model's decision.
See the reasoning
Follow the example one step at a time
Follow a simplified sequence-to-sequence translation. This is a prepared teaching demonstration, not live code execution.
Encode
input: red | house → input representations
The encoder produces representations of the input sequence.
Why context matters
Sequence-to-sequence models are used for translation and other transformations. Earlier encoder-decoder models used recurrent networks; attention improved their ability to access different input positions. Transformers use attention as a central building block, explored later in this module.
Probable and fluent output is not necessarily accurate. Tokenisation, training data, context limits, decoding choices and language differences affect behaviour. Evaluate outputs against appropriate references and real task outcomes, including cases where the model should say it is unsure.
Reflect on the concept
Four fixed questions to reinforce the reasoning. Answers are not saved or scored.
