Category · Models and how they work
What is the Transformer?
The Transformer is the architecture of almost all large language models, described by Google researchers in 2017. For each token, its attention mechanism looks at which other tokens matter to understand it. The longer the text, the higher the cost.
By Laurent Poupet, Claude trainer and artificial intelligence architect · Updated
How it works
- Each token is turned into three vectors: a query, a key and a value. A token’s query is compared with the keys of the others, and the resulting scores weight their values.
- Several attention heads work in parallel, each capturing one type of relation, and dozens of layers are stacked. Today’s large language models use only the decoder part.
- The cost of attention grows with the square of the text length, hence the price of long contexts. The attention cache avoids recomputing the beginning for each new token.
- The model does not know word order by itself. Position information is added, often through a rotation of the vectors called RoPE (Rotary Position Embedding).
Related terms
- TokenModels and how they work
- EmbeddingData and retrieval-augmented generation
- TemperatureModels and how they work
Where this is taught
This idea comes up throughout the lessons; we work on it with your own examples during a lesson.
Lesson content (step-by-step instructions, exercises with solutions, quizzes) is for students only, with an access code received after the first lesson.