3Blue1Brown · Transformer 注意力机制 · YouTube 字幕
视频 eMlx5fFNoYc 的完整字幕共有 4,903 词、423 段,章节数为 12。此快照展示其中 80 段,可按时间戳跳转至原片核对上下文。
查询结果 · YouTube 字幕
快照日期 ·

Attention in transformers, step-by-step | Deep Learning Chapter 6
3Blue1Brown · 26:09 · English
4,903 词 · 80 / 423 段字幕已展示
00:00In the last chapter, you and I started to step
00:01through the internal workings of a transformer.
00:04This is one of the key pieces of technology inside large language models,
00:07and a lot of other tools in the modern wave of AI.
00:10It first hit the scene in a now-famous 2017 paper called Attention is All You Need,
00:15and in this chapter you and I will dig into what this attention mechanism is,
00:19visualizing how it processes data.
00:26As a quick recap, here's the important context I want you to have in mind.
00:30The goal of the model that you and I are studying is to
00:32take in a piece of text and predict what word comes next.
00:36The input text is broken up into little pieces that we call tokens,
00:40and these are very often words or pieces of words,
00:42but just to make the examples in this video easier for you and me to think about,
00:47let's simplify by pretending that tokens are always just words.
00:51The first step in a transformer is to associate each token
00:54with a high-dimensional vector, what we call its embedding.
00:57The most important idea I want you to have in mind is how directions in this
01:02high-dimensional space of all possible embeddings can correspond with semantic meaning.
01:07In the last chapter we saw an example for how direction can correspond to gender,
01:11in the sense that adding a certain step in this space can take you from the
01:15embedding of a masculine noun to the embedding of the corresponding feminine noun.
01:20That's just one example you could imagine how many other directions in this
01:23high-dimensional space could correspond to numerous other aspects of a word's meaning.
01:28The aim of a transformer is to progressively adjust these embeddings
01:32so that they don't merely encode an individual word,
01:35but instead they bake in some much, much richer contextual meaning.
01:40I should say up front that a lot of people find the attention mechanism,
01:43this key piece in a transformer, very confusing,
01:46so don't worry if it takes some time for things to sink in.
01:49I think that before we dive into the computational details and all
01:52the matrix multiplications, it's worth thinking about a couple
01:55examples for the kind of behavior that we want attention to enable.
02:00Consider the phrases American shrew mole, one mole of carbon dioxide,
02:04and take a biopsy of the mole.
02:06You and I know that the word mole has different meanings in each one of these,
02:09based on the context.
02:11But after the first step of a transformer, the one that breaks up the text
02:15and associates each token with a vector, the vector that's associated with
02:18mole would be the same in all of these cases,
02:21because this initial token embedding is effectively a lookup table with no
02:24reference to the context.
02:26It's only in the next step of the transformer that the surrounding
02:29embeddings have the chance to pass information into this one.
02:33The picture you might have in mind is that there are multiple distinct directions in
02:38this embedding space encoding the multiple distinct meanings of the word mole,
02:42and that a well-trained attention block calculates what you need to add to the generic
02:47embedding to move it to one of these specific directions, as a function of the context.
02:53To take another example, consider the embedding of the word tower.
02:57This is presumably some very generic, non-specific direction in the space,
03:01associated with lots of other large, tall nouns.
03:04If this word was immediately preceded by Eiffel,
03:06you could imagine wanting the mechanism to update this vector so that
03:10it points in a direction that more specifically encodes the Eiffel tower,
03:14maybe correlated with vectors associated with Paris and France and things made of steel.
03:19If it was also preceded by the word miniature,
03:22then the vector should be updated even further,
03:24so that it no longer correlates with large, tall things.
03:29More generally than just refining the meaning of a word,
03:32the attention block allows the model to move information encoded in
03:35one embedding to that of another, potentially ones that are quite far away,
03:39and potentially with information that's much richer than just a single word.
03:43What we saw in the last chapter was how after all of the vectors flow through the
03:47network, including many different attention blocks,
03:50the computation you perform to produce a prediction of the next token is entirely a
03:55function of the last vector in the sequence.
03:59Imagine, for example, that the text you input is most of an entire mystery novel,
04:03all the way up to a point near the end, which reads, therefore the murderer was.
04:08If the model is going to accurately predict the next word,
04:11that final vector in the sequence, which began its life simply embedding the word was,
04:16will have to have been updated by all of the attention blocks to represent much,
04:20much more than any individual word, somehow encoding all of the information
04:24from the full context window that's relevant to predicting the next word.
04:29To step through the computations, though, let's take a much simpler example.
04:32Imagine that the input includes the phrase, a
04:35fluffy blue creature roamed the verdant forest.
04:38And for the moment, suppose that the only type of update that we care about
04:42is having the adjectives adjust the meanings of their corresponding nouns.
04:47What I'm about to describe is what we would call a single head of attention,
04:50and later we will see how the attention block consists of many different heads run in
04:54parallel.
没有匹配的结果。
数据摘要
3Blue1Brown · Transformer 注意力机制 ·
- 00:00 · Recap on embeddings
- 01:39 · Motivating examples
- 04:29 · The attention pattern
- 11:08 · Masking
浏览样本报告
常见问题 (FAQ)
- 3Blue1Brown 在开头说了什么?
- “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,”
- 免费额度是多少?
- 浏览和导出快照免费。每个 IP 在滚动 24 小时内可以实时查询 100 次。
- 可以导出哪些格式?
- 字幕支持 .srt、.md 和 .txt。商品、评价、广告与职位可导出为 Excel 兼容的 .csv,差评摘要和职位列表可复制为 Markdown。
- 数据是什么时候采集的?
- 预设样本标有采集日期。点击“获取最新数据”可重新查询公开来源,导出范围取决于当前样本和筛选条件。
- 查询会发送哪些信息?
- 实时查询会将目标发送至 DataToll,并写入可分享的网址。筛选、复制和下载均在本地完成。