Attention in transformers, step-by-step | Deep Learning Chapter 6 @3blue1brown
Attention in transformers, step-by-step | Deep Learning Chapter 6  @3blue1brown
Uploaded April 2024 | Updated November 2026, 2 days ago
Demystifying attention, the key mechanism inside transformers and LLMs.
Instead of sponsored ad reads, these lessons are funded directly by viewers: 3b1b.co/support
Special thanks to these supporters: 3blue1brown.com/lessons/attention#thanks
An equally valuable form of support is to simply share the videos.

Demystifying self-attention, multiple heads, and cross-attention.
Instead of sponsored ad reads, these lessons are funded directly by viewers: 3b1b.co/support

The first pass for the translated subtitles here is machine-generated and, therefore, notably imperfect. To contribute edits or fixes, visit criblate.com

Звуковая дорожка на русском языке: Влад Бурмистров.

------------------

Here are a few other relevant resources

Build a GPT from scratch, by Andrej Karpathy
youtu.be/kCc8FmEb1nY

If you want a conceptual understanding of language models from the ground up, @vcubingx just started a short series of videos on the topic:
youtu.be/1il-s4mgNdI?si=XaVxj6bsdy3VkgEX

If you're interested in the herculean task of interpreting what these large networks might actually be doing, the Transformer Circuits posts by Anthropic are great. In particular, it was only after reading one of these that I started thinking of the combination of the value and output matrices as being a combined low-rank map from the embedding space to itself, which, at least in my mind, made things much clearer than other sources.
https://transformer-circuits.pub/2021/framework/index.html

Site with exercises related to ML programming and GPTs
gptandchill.ai/codingproblems

History of language models by Brit Cruise,  @ArtOfTheProblem 
youtu.be/OFS90-FX6pg

An early paper on how directions in embedding spaces have meaning:
arxiv.org/pdf/1301.3781.pdf

------------------

Timestamps:
0:00 - Recap on embeddings
1:39 - Motivating examples
4:29 - The attention pattern
11:08 - Masking
12:42 - Context size
13:10 - Values
15:44 - Counting parameters
18:21 - Cross-attention
19:19 - Multiple heads
22:16 - The output matrix
23:19 - Going deeper
24:54 - Ending

------------------

These animations are largely made using a custom Python library, manim. See the FAQ comments here:
3b1b.co/faq#manim
github.com/3b1b/manim
github.com/ManimCommunity/manim

All code for specific videos is visible here:
github.com/3b1b/videos

The music is by Vincent Rubinetti.
vincentrubinetti.com
vincerubinetti.bandcamp.com/album/the-music-of-3blue1brown
open.spotify.com/album/1dVyjwS8FBqXhRunaG5W5u

------------------

3blue1brown is a channel about animating math, in all senses of the word animate. If you're reading the bottom of a video description, I'm guessing you're more interested than the average viewer in lessons here. It would mean a lot to me if you chose to stay up to date on new ones, either by subscribing here on YouTube or otherwise following on whichever platform below you check most regularly.

Mailing list: 3blue1brown.substack.com
Twitter: twitter.com/3blue1brown
Instagram: instagram.com/3blue1brown
Reddit: reddit.com/r/3blue1brown
Facebook: facebook.com/3blue1brown
Patreon: patreon.com/3blue1brown
Website: 3blue1brown.com
Attention in transformers, step-by-step | Deep Learning Chapter 6The power tower puzzle | Ep. 8 Lockdown live mathOh, wait, actually the best Wordle opener is not “crane”…The most beautiful formula not enough people understandSimulating an epidemicHow to estimate the distance to the sunPrime spiralsTerence Tao continuing history’s cleverest cosmological measurementsSimulating and understanding phase change | Guest video by Vilas WinsteinBut how do AI images and videos actually work? | Guest video by Welch LabsBut what is a Laplace Transform?How AI connects text and images
3Blue1Brown |

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

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER