3Blue1Brown

Attention in transformers, step-by-step | Deep Learning Chapter 6

3Blue1Brown

Summary

The discussion centers on the inner workings of transformers, a crucial technology in large language models, particularly the attention mechanism introduced in the landmark paper "Attention is All You Need" in 2017. The attention mechanism processes input text by breaking it into tokens, which are then associated with high-dimensional vectors known as embeddings. This process allows the model to predict the next word in a sequence by progressively refining these embeddings to incorporate richer contextual meanings.

The attention mechanism operates by allowing words to influence each other's meanings based on their context. For example, the word "mole" has different meanings depending on the surrounding words, and the transformer adjusts its embedding accordingly. The mechanism involves creating query and key vectors for each token, which are used to determine the relevance of each word to others in the context. This relevance is quantified through dot products, leading to an attention pattern that informs how embeddings should be updated.

The complexity increases with the introduction of multi-headed attention, where multiple attention heads operate in parallel, each with distinct key, query, and value matrices. This design enables the model to learn various contextual influences on meaning, enhancing its predictive capabilities. The discussion also touches on the scalability of the attention mechanism and its role in the overall architecture of large language models, emphasizing its efficiency in handling vast amounts of data through parallel computations.

Show Notes

Learn more about your ad choices. Visit megaphone.fm/adchoices

More from 3Blue1Brown

Dec 6, 2026

Learn more about your ad choices. Visit megaphone.fm/adchoices

Dec 6, 2026

Learn more about your ad choices. Visit megaphone.fm/adchoices

Dec 6, 2026

Learn more about your ad choices. Visit megaphone.fm/adchoices

Dec 6, 2026

Learn more about your ad choices. Visit megaphone.fm/adchoices

Dec 6, 2026

Learn more about your ad choices. Visit megaphone.fm/adchoices

See all episodes →