ProLesson 2 of 37 min read

Attention: how transformers decide which words matter

Understand the attention mechanism in transformers, from queries, keys and values to the formula and a small worked calculation.

To predict the next word well, a model must use context. In "The trophy did not fit in the suitcase because it was too big", the word "it" refers to the trophy, and you need earlier words to work that out. Modern language models are built on the transformer architecture, and its key ingredient for using context is attention.

Vidi Pro

Keep going with Pro.

The first lesson of every class is free. Pro opens every lesson in IELTS, Programming, Mathematics, Science and Data and AI, with practice questions.

Already have Pro? Log in to keep reading.

Written with AI help. Spotted a mistake? Tell us.