# 3Blue1Brown · Attention in Transformers · YouTube Transcript

This is a caption track snapshot for eMlx5fFNoYc. Read 80 timestamped excerpts from video eMlx5fFNoYc. The full caption track contains 4,903 words in 423 segments, with 12 chapters.

 [YouTube Transcript](<https://datatoll.app/youtube-transcript>) [Shopify Store Spy](<https://datatoll.app/shopify-spy>) [App Reviews Analyzer](<https://datatoll.app/app-reviews>) [Google Ads Spy](<https://datatoll.app/google-ads>) [Tech Jobs Radar](<https://datatoll.app/tech-jobs>)  

## Results · YouTube Transcript

Snapshot · 2026-12-01

## [Attention in transformers, step-by-step | Deep Learning Chapter 6](<https://www.youtube.com/watch?v=eMlx5fFNoYc>)

3Blue1Brown · 26:09 · English

4,903 words · 80 / 423 segments shown

Languages (20)

ar zh en fr de iw hu id it ja ko fa pt pt-BR ru es th tr uk vi

Chapters (12)

[00:00 Recap on embeddings](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=0s>) [01:39 Motivating examples](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=99s>) [04:29 The attention pattern](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=269s>) [11:08 Masking](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=668s>) [12:42 Context size](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=762s>) [13:10 Values](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=790s>) [15:44 Counting parameters](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=944s>) [18:21 Cross-attention](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=1101s>) [19:19 Multiple heads](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=1159s>) [22:16 The output matrix](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=1336s>) [23:19 Going deeper](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=1399s>) [24:54 Ending](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=1494s>)

[00:00](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=0s>) In the last chapter, you and I started to step

[00:01](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=1s>) through the internal workings of a transformer.

[00:04](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=4s>) This is one of the key pieces of technology inside large language models,

[00:07](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=7s>) and a lot of other tools in the modern wave of AI.

[00:10](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=10s>) It first hit the scene in a now-famous 2017 paper called Attention is All You Need,

[00:15](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=15s>) and in this chapter you and I will dig into what this attention mechanism is,

[00:19](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=19s>) visualizing how it processes data.

[00:26](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=26s>) As a quick recap, here's the important context I want you to have in mind.

[00:30](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=30s>) The goal of the model that you and I are studying is to

[00:32](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=32s>) take in a piece of text and predict what word comes next.

[00:36](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=36s>) The input text is broken up into little pieces that we call tokens,

[00:40](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=40s>) and these are very often words or pieces of words,

[00:42](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=42s>) but just to make the examples in this video easier for you and me to think about,

[00:47](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=47s>) let's simplify by pretending that tokens are always just words.

[00:51](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=51s>) The first step in a transformer is to associate each token

[00:54](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=54s>) with a high-dimensional vector, what we call its embedding.

[00:57](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=57s>) The most important idea I want you to have in mind is how directions in this

[01:02](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=62s>) high-dimensional space of all possible embeddings can correspond with semantic meaning.

[01:07](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=67s>) In the last chapter we saw an example for how direction can correspond to gender,

[01:11](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=71s>) in the sense that adding a certain step in this space can take you from the

[01:15](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=75s>) embedding of a masculine noun to the embedding of the corresponding feminine noun.

[01:20](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=80s>) That's just one example you could imagine how many other directions in this

[01:23](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=83s>) high-dimensional space could correspond to numerous other aspects of a word's meaning.

[01:28](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=88s>) The aim of a transformer is to progressively adjust these embeddings

[01:32](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=92s>) so that they don't merely encode an individual word,

[01:35](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=95s>) but instead they bake in some much, much richer contextual meaning.

[01:40](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=100s>) I should say up front that a lot of people find the attention mechanism,

[01:43](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=103s>) this key piece in a transformer, very confusing,

[01:46](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=106s>) so don't worry if it takes some time for things to sink in.

[01:49](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=109s>) I think that before we dive into the computational details and all

[01:52](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=112s>) the matrix multiplications, it's worth thinking about a couple

[01:55](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=115s>) examples for the kind of behavior that we want attention to enable.

[02:00](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=120s>) Consider the phrases American shrew mole, one mole of carbon dioxide,

[02:04](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=124s>) and take a biopsy of the mole.

[02:06](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=126s>) You and I know that the word mole has different meanings in each one of these,

[02:09](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=129s>) based on the context.

[02:11](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=131s>) But after the first step of a transformer, the one that breaks up the text

[02:15](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=135s>) and associates each token with a vector, the vector that's associated with

[02:18](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=138s>) mole would be the same in all of these cases,

[02:21](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=141s>) because this initial token embedding is effectively a lookup table with no

[02:24](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=144s>) reference to the context.

[02:26](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=146s>) It's only in the next step of the transformer that the surrounding

[02:29](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=149s>) embeddings have the chance to pass information into this one.

[02:33](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=153s>) The picture you might have in mind is that there are multiple distinct directions in

[02:38](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=158s>) this embedding space encoding the multiple distinct meanings of the word mole,

[02:42](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=162s>) and that a well-trained attention block calculates what you need to add to the generic

[02:47](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=167s>) embedding to move it to one of these specific directions, as a function of the context.

[02:53](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=173s>) To take another example, consider the embedding of the word tower.

[02:57](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=177s>) This is presumably some very generic, non-specific direction in the space,

[03:01](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=181s>) associated with lots of other large, tall nouns.

[03:04](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=184s>) If this word was immediately preceded by Eiffel,

[03:06](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=186s>) you could imagine wanting the mechanism to update this vector so that

[03:10](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=190s>) it points in a direction that more specifically encodes the Eiffel tower,

[03:14](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=194s>) maybe correlated with vectors associated with Paris and France and things made of steel.

[03:19](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=199s>) If it was also preceded by the word miniature,

[03:22](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=202s>) then the vector should be updated even further,

[03:24](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=204s>) so that it no longer correlates with large, tall things.

[03:29](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=209s>) More generally than just refining the meaning of a word,

[03:32](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=212s>) the attention block allows the model to move information encoded in

[03:35](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=215s>) one embedding to that of another, potentially ones that are quite far away,

[03:39](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=219s>) and potentially with information that's much richer than just a single word.

[03:43](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=223s>) What we saw in the last chapter was how after all of the vectors flow through the

[03:47](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=227s>) network, including many different attention blocks,

[03:50](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=230s>) the computation you perform to produce a prediction of the next token is entirely a

[03:55](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=235s>) function of the last vector in the sequence.

[03:59](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=239s>) Imagine, for example, that the text you input is most of an entire mystery novel,

[04:03](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=243s>) all the way up to a point near the end, which reads, therefore the murderer was.

[04:08](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=248s>) If the model is going to accurately predict the next word,

[04:11](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=251s>) that final vector in the sequence, which began its life simply embedding the word was,

[04:16](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=256s>) will have to have been updated by all of the attention blocks to represent much,

[04:20](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=260s>) much more than any individual word, somehow encoding all of the information

[04:24](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=264s>) from the full context window that's relevant to predicting the next word.

[04:29](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=269s>) To step through the computations, though, let's take a much simpler example.

[04:32](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=272s>) Imagine that the input includes the phrase, a

[04:35](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=275s>) fluffy blue creature roamed the verdant forest.

[04:38](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=278s>) And for the moment, suppose that the only type of update that we care about

[04:42](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=282s>) is having the adjectives adjust the meanings of their corresponding nouns.

[04:47](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=287s>) What I'm about to describe is what we would call a single head of attention,

[04:50](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=290s>) and later we will see how the attention block consists of many different heads run in

[04:54](<https://www.youtube.com/watch?v=eMlx5fFNoYc&t=294s>) parallel.

## Key Takeaways

3Blue1Brown · Attention in Transformers · 2026-12-01

- 00:00 · Recap on embeddings
- 01:39 · Motivating examples
- 04:29 · The attention pattern
- 11:08 · Masking

## Explore sample reports

### [YouTube Transcript](<https://datatoll.app/youtube-transcript>)

[3Blue1Brown · Neural Networks](<https://datatoll.app/youtube-transcript/3blue1brown-neural-networks>) [Andrej Karpathy · Intro to LLMs](<https://datatoll.app/youtube-transcript/karpathy-intro-to-llms>) [YC · How to Start a Startup](<https://datatoll.app/youtube-transcript/yc-how-to-start-a-startup>) [TED · Start With Why](<https://datatoll.app/youtube-transcript/simon-sinek-start-with-why>) [Andrej Karpathy · Let's Build GPT](<https://datatoll.app/youtube-transcript/karpathy-lets-build-gpt>) [3Blue1Brown · Attention in Transformers](<https://datatoll.app/youtube-transcript/3blue1brown-transformers-attention>)

## Frequently asked questions (FAQ)

**What does 3Blue1Brown say at the start?** “In the last chapter, you and I started to step through the internal workings of a transformer. This is one of the key pieces of technology inside large language models,”

**How much can I use for free?** Reading and exporting samples is free. Each IP can run 100 live searches per rolling 24 hours.

**Which formats can I export?** Save captions as .srt, .md or .txt. Download products, reviews, ads and jobs as Excel-compatible .csv, or copy a Markdown summary of low-rated reviews or open roles.

**How fresh are the results?** Each sample shows its capture date. Fetch Latest Live requests the public source again. Exports use the displayed sample and filters.

**What happens to my search?** Live searches send the target to DataToll and include it in the shareable page URL. Filtering, copying and downloads happen in your browser.
