跟读练习: Encoder-Only Transformers (like BERT) for RAG, Clearly Explained!!! - 通过视频学习英语口语

选择练习模式

每种模式都会打开全屏练习室。

172 句
如果句子过短或过长,请点击 Edit 进行调整。
1
Encoder -only transformers can cluster things and classify things that's cool.
2
StatQuest.
3
Hello, I'm Josh Starmer and welcome to StatQuest.
4
Today we're going to talk about encoder -only transformers and they're going to be clearly explained.
5
This StatQuest is brought to you by the letters A, B, and C.
6
A always, B, B, C curious always be curious.
7
Note, this stat quest assumes that you are already familiar with the main ideas of how neural networks work.
8
If not, check out the quest.
9
Also note, this stat quest focuses on the main ideas of how encoder -only transformers work
10
and what we can do with them.
11
That said, if you want to see the nitty -gritty details, check out these fine quests.
12
Okay,
13
way back in 2017 the first transformer ever made had one part called an encoder and a second part called a decoder.
14
And the encoder and the decoder were connected to each other so they could work together.
15
This first transformer was based on something called a seek -to -seek or an encoder -decoder model.
16
Encoder -decoder models were designed to translate text in one language, like English, into another language, like Spanish.
17
For example, Squatch might say, Pizza is great!
18
And the encoder would crunch a lot of numbers to encode the input, and the decoder would crunch a lot of numbers,
19
including the output from the encoder, and, ultimately, decode those numbers into a translation.
20
La pizza es magnifico.
21
Bam!
22
However, it wasn't long after this first encoder -decoder transform was published
23
that people realized that both parts could work just fine on their own.
24
It turned out that we could generate text, including translations of text, with just a decoder.
25
And these models, which formed the basis for ChatGPT, were named decoder -only transformers.
26
Likewise, models based entirely on the encoder started to be very useful on their own.
27
And these models, which formed the basis for BERT and many other models, were named encoder -only transformers.
28
However, over the years, the models based on decoder -only transformers kind of stole the show.
29
Pretty much everyone has used, or at least heard of, ChatGPT or Gemini or any of the other countless decoder -only transformers out there.
30
And I've heard some super smart people, who keep up with AI and everything, ask me if people still used encoder -only transformers.
31
So, in this stat quest, I want to dive deep into encoder -only transformers so we can understand their significant, but understated, power.
32
And that means starting with a deep dive into the first thing a transformer does, which is create word embeddings.
33
Word embedding converts words, bits of words, and symbols, collectively called tokens, into numbers.
34
We need to convert tokens into numbers because transformers are a type of neural network and neural networks only operate on numbers.
35
One super easy way to convert words into numbers is to just assign each word to a random number.
36
For example, if Squatch just ate a delicious pizza, they might say, Pizza is great!
37
And we could assign a random number to each word.
38
Now, if Norm came along and said, Pizza is awesome!
39
Then we could reuse the random numbers that we already assigned to pizza and is, and assign a new random number to awesome.
40
In theory, this is fine.
41
But it means that even though great and awesome mean similar things and are used in similar ways,
42
they have very different numbers associated with them.
43
And that means the neural network will probably need a lot more complexity
44
and training because learning how to correctly process the word great won't help the neural network correctly use the word awesome.
45
So it would be nice if similar words that are used in similar ways could be given similar numbers.
46
So that learning how to use one word will help learn how to use the other at the same time.
47
And because the same words can be used in different contexts, or made plural, or used in some other way,
48
it might be nice to assign each word more than one number, so that the neural network can more easily adjust to different contexts.
49
For example, the word great can be used in a positive way, like, pizza is great.
50
And it can also be used in a sarcastic negative way, like, my cell phone's broken.
51
Great.
52
And it would be nice if we had one number that could keep track of the positive ways that great is used,
53
and a different number to keep track of the negative ways.
54
Hey Josh, deciding what words are similar and are used in similar contexts sounds like a lot of work.
55
And using more than one number per word to account for different contexts sounds like even more work.
56
Don't worry Squatch, the good news is
57
that we can get a relatively simple neural network to do all of the work for us.
58
For example, let's imagine we have two phrases.
59
Pizza is great and pizza is awesome.
60
The first thing we do is create inputs to a relatively simple neural network for each unique word.
61
Then we create an output for each word.
62
Then we connect all of the inputs to at least one activation function.
63
And in this example, we'll connect the inputs to two activation functions.
64
The number of activation functions determines how many numbers we will use to represent each word.
65
In this case, since we have two activation functions, we'll end up with two numbers or word embeddings representing each word.
66
Then we add weights to the connections from the inputs to the activation functions.
67
These weights are initialized with random numbers, so right now they're not very useful.
68
But the plan is to train them and thus change them using this data.
69
Lastly, we connect the activation functions to the outputs with some boring details that we don't need to worry about right now.
70
Because we have one word embedding for each word going to the activation function on the top,
71
and one word embedding for each word going to the activation function on the bottom,
72
we can plot each word on a graph that has the top word embeddings on the x -axis
73
and the bottom word embeddings on the y -axis.
74
For example, the word pizza goes here because its top word embedding is negative 0 .11,
75
and its bottom word embedding is 0 .10.
76
Likewise, the word is goes here, great goes here, and awesome goes here.
77
Now, with this graph, we see that the words great
78
and awesome are currently no more similar to each other than they are to any of the other words.
79
However, because both words appear in the same context in the training data, we hope that training the network will make their word embeddings more similar.
80
The idea is that we want each word in the training data to predict the next word.
81
For example, we want the first word in each sentence, pizza, to predict the word that comes after it, is.
82
And we want the word IS to predict the words that come after it, GREAT and AWESOME.
83
So, in order to see which word the network predicts should come after PIZZA, we put a 1 in the input for PIZZA,
84
and we put 0s in all of the other inputs.
85
Then we do the math with the randomly initialized parameters, and we end up predicting GREAT,
86
because it has the largest output value, 0 .45.
87
Thus, with the randomly initialized parameters, the network does not correctly predict IS, the word that comes after PIZZA.
88
However, after we train the model, we end up with these new word embeddings.
89
And PIZZA correctly predicts IS and is correctly predicts great and awesome.
90
Now when we graph the words with the new word embeddings, great and awesome cluster together.
91
This result is great and awesome because great and awesome are similar words used in similar contexts,
92
and they ended up with similar word embeddings.
93
So far, we've seen the simplest way to create word embeddings.
94
We used a simple network that we trained to predict the word that comes after the input.
95
However, just predicting the next word doesn't give us a lot of context to determine the optimal word embeddings.
96
In contrast, if we had a more complicated training data set, then we would have more inputs and outputs for our neural network.
97
And we could connect everything like we did before.
98
But now, because we have more inputs and outputs, and longer sentences in the training data,
99
we can add more context to the training process.
100
For example, we can use the pizza came out to predict the next word of.
101
In other words, instead of just using one word to predict the next, we can use the preceding four words to predict the next.
102
Increasing the context can help create better word embedding values.
103
But I want to point out that the way we are doing things right now ignores word order.
104
And because we are not currently keeping track of word order, any jumble is just as good as anything else.
105
In other words, the pizza came out of would give us the same inputs an output, as the jumbled up phrase,
106
pizza out came the of.
107
So it would be nice if there were some way to create word embedding values that also took word order into account.
108
And that leads us to the part of a transformer that comes after the initial word embedding layer, called positional encoding.
109
Positional encoding helps keep track of word order.
110
For example, if Norm said, Squatch eats pizza, then Squatch might say, yum.
111
In contrast, if Norm said, pizza eats Squatch, then Squatch might say, yikes.
112
So these two phrases, Squatch eats pizza and pizza eats squash use the exact same words but have very different meanings.
113
So, keeping track of word order is super important.
114
There are a bunch of ways to implement positional encoding, but these details are out of the scope of this quest.
115
Anyway, now we know that positional encoding helps keep track of word order.
116
However, it would be great if there was also a way to keep track of the relationships among words.
117
For example, if the input sentence was this, The pizza came out of the oven and it tasted good.
118
Then this word, it, could refer to pizza or potentially it could refer to the word oven.
119
Josh, I've heard of good tasting pizza but never a good tasting oven.
120
I know, Squatch, that's why it's important that the transformer correctly associates the word it with pizza.
121
And that leads us to the part of a transformer that comes after positional encoding, called attention.
122
And, specifically, in an encoder -only transformer, it's called self -attention.
123
Attention helps keep track of the relationships among words.
124
Going back to our example about pizza coming out of an oven, attention can help correctly associate the word it with the word pizza.
125
Note, there are different types of attention, but encoder -only transformers only use self -attention, so we'll focus on that.
126
In general terms, self -attention works by seeing how similar each word is to all of the other words in the sentence, including itself.
127
For example, self -attention calculates the similarity between the first word,
128
the, and all of the other words in the sentence, including itself.
129
And self -attention calculates these similarities for every word in the sentence.
130
Once the similarities are calculated, they are used to determine how the transformer encodes each word. For example,
131
if you looked at a lot of sentences about pizza and the word it was more commonly associated with pizza than oven,
132
then the similarity score for pizza will cause
133
it to have a larger impact on how the word it is encoded by the transformer.
134
Bam.
135
Now that we understand the ideas behind self -attention,
136
we understand the ideas behind the three fundamental building blocks that make up an encoder -only transformer.
137
Word embedding converts the input into numbers, positional encoding helps keep track of word order,
138
and self -attention helps establish relationships among words.
139
Combining all three layers creates a new kind of embedding for each token that takes position and relationships among words into account.
140
And this new type of embedding is sometimes called context -aware embedding or contextualized embedding.
141
Because context -aware embeddings include information about the position of each word as well as the relationships among the words,
142
Context -aware embeddings can help cluster similar sentences or even similar documents.
143
Bam!
144
To summarize, encoder -only transformers like BERT that only use self -attention can create context -aware embeddings.
145
And just like plain old word embeddings can help cluster similar words that are used in similar ways,
146
Context -aware embeddings can help cluster similar sentences or similar documents.
147
Note, the ability to cluster similar sentences in documents is the foundation for something called Retrieval Augmented Generation, or RAG.
148
RAG works by breaking a document into blocks of text
149
and then using an encoder -only transformer to create context -aware embeddings for each one.
150
Then, when someone gives an AI a prompt like, what is pizza?
151
RAG generates embeddings for what is pizza and finds the chunks of text that are the most similar.
152
Double bam!
153
Now that we understand the main ideas behind encoder -only transformers and context -aware embeddings,
154
let's talk about another cool thing we can do with them.
155
One thing that we can do is use the context -aware embeddings as inputs to a normal neural network
156
that classifies the sentiment of the input.
157
For example, we might want to see if people are posting positive or negative sentiments about pizza on LinkedIn.
158
And the context -aware embeddings are great inputs for a neural network that can do that type of classification.
159
Alternatively, we could use the context -aware embeddings as variables in a logistic regression model that does classification.
160
Anyway, even though decoder -only transformers like ChatGPT get all the hype, the context -aware embeddings
161
that encoder -only transformers create can be used in a wide variety of settings to do very cool things triple bam.
162
Now it's time for some shameless self -promotion.
163
If you want to review statistics and machine learning offline, check out the StatQuest PDF study guides and my books,
164
the StatQuest Illustrated Guide to Machine Learning, and the StatQuest Illustrated Guide to Neural Networks and AI at StatQuest .org.
165
There's something for everyone.
166
Hooray!
167
We've made it to the end of another exciting StatQuest.
168
If you like this StatQuest and want to see more, please subscribe.
169
And if you want to support StatQuest, consider contributing to my Patreon campaign, becoming a channel member, buying one or two of my original songs,
170
or a t -shirt, or a hoodie, or just donate.
171
The links are in the description below.
172
All right, until next time, quest on!

下载应用

流利口语所需的一切

AI 发音评分逐句打分
音标练习掌握每个音
词汇学习建立你的词库
词汇游戏边玩边学

同频道

FOR YOU

推荐视频

本课的词汇与口语要点

这节口语课以视频“Encoder-Only Transformers (like BERT) for RAG, Clearly Explained!!!”为素材。 视频中反复出现的词有:word, embedding, pizza, transformer, encoder。 这段视频共有 172 个句子、2494 个单词可供跟读。 讲话部分时长为 18:50。 说话人语速平稳,每分钟约 132 个词,很适合跟读。 只有 80% 的单词属于英语最常用的 3,000 词,词汇难度较高。

视频中的重点词汇

视频中 15 个值得学习的单词,附发音和释义:

单词发音释义
pizza 名词/ˈpi.tsə/比薩 /比萨, 披薩 /披萨
input 名词/ˈɪnpʊt/輸入 /输入
predict 动词/pɹɪˈdɪkt/預言 /预言
activation 名词/ˌæktəˈveɪʃən/激活
output 名词/ˈaʊtpʊt/輸出 /输出
quest 名词/kwɛst/探索, 尋求 /寻求
cluster 名词/ˈklʌstɚ/串, 叢 /丛
connect 动词/kəˈnɛkt/連接 /连接
oven 名词/ˈʌ.vn̩/烤爐 /烤炉, 爐 /炉
assign 动词/əˈsaɪn/分配, 分派
associate 名词/əˈsoʊʃi.ət/同行, 同事
similarity 名词/ˌsɪm.ɪˈlæɹ.ɪ.ti/相似, 類似 /类似
phrase 名词/ˈfɹeɪ̯z/短語 /短语, 片語 /片语
graph 名词/ɡɹæf/圖表 /图表
stat 副词/stæt/即刻

视频中出现的短语动词

单词发音释义
check out 动词退房
come along 动词陪伴, 陪同
end up 动词到达
make up 动词/ˌmeɪk ˈʌp/組成 /组成
point out 动词指, 指出
turn out 动词原來 /原来

视频中的语法

说话人最常用的结构,并附上视频中的原话:

结构视频中的用法
被动语态 be + 过去分词 — 强调发生了什么,而不是谁做的be clearly explained · is brought · were connected
现在完成时 have/has + 过去分词 — 过去发生但与现在仍有关联的事has used · I've heard · we've seen

需要注意的发音

说话人用了 16 次缩略和弱读形式,例如 we'll, don't, I've。请按听到的简短形式来说。

  • “sh” 和 “zh” 音: activation /ˌæktəˈveɪʃən/, associate /əˈsoʊʃi.ət/, contrast /kənˈt(ʃ)ɹæst/, translation /tɹænzˈleɪʃən/, classification /ˌklæsɪfɪˈkeɪʃən/
  • 长单词——注意重音位置: activation /ˌæktəˈveɪʃən/, associate /əˈsoʊʃi.ət/, similarity /ˌsɪm.ɪˈlæɹ.ɪ.ti/, classification /ˌklæsɪfɪˈkeɪʃən/, parameter /pəˈɹæm.ə.tɚ/

中文母语者容易读错的音:

  • /v/ — 不要读成 /w/,上齿轻触下唇: activation /ˌæktəˈveɪʃən/, oven /ˈʌ.vn̩/, convert /kənˈvɝt/, dive /daɪv/, variable [ˈvæɹ.i.ə.bl̩]
  • 词尾辅音 — 要读清楚,后面不要加元音: input /ˈɪnpʊt/, predict /pɹɪˈdɪkt/, output /ˈaʊtpʊt/, quest /kwɛst/, connect /kəˈnɛkt/
  • /r/ 和 /l/ 的区别: neural /ˈnʊɹəl/, correctly /kəˈɹɛk(t).li/, similarity /ˌsɪm.ɪˈlæɹ.ɪ.ti/, translation /tɹænzˈleɪʃən/, randomly /ˈɹændm̩li/

如何用这段视频练习

  1. 先完整听一遍视频,不要开口,记下不认识的单词。
  2. 用正常速度逐句跟读,每句重复到你的节奏与说话人一致为止。
  3. 录下自己的声音并与原声对比,特别注意 pizza, input, predict 这类单词。

什么是跟读法?

跟读法 (Shadowing) 是一种有科学依据的语言学习技巧,最初开发用于专业口译员的培训,并由多语言者Alexander Arguelles博士普及。这个方法简单而强大:您在听英语母语原声的同时立即大声重复——就像是一个延迟1-2秒紧跟说话者的影子。与被动听力或语法练习不同,跟读法强迫您的大脑和口腔肌肉同时处理并模仿真实的讲话模式。研究表明它能显着提高发音准确性,语调,节奏,连读,听力理解和口语流利度——使其成为雅思口语备考和真实英语交流最有效的方法之一。

影子跟读法: 阅读完整分步指南 →