シャドーイング練習: 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発音採点文ごとに採点
IPA練習すべての音をマスター
単語学習自分の単語帳を作る
単語ゲーム遊びながら覚える

同じチャンネル

FOR YOU

おすすめ動画

このレッスンの語彙とスピーキングのポイント

このスピーキングレッスンは、動画「Encoder-Only Transformers (like BERT) for RAG, Clearly Explained!!!」を教材にしています。 繰り返し出てくる語は次のとおりです:word, embedding, pizza, transformer, encoder。 この動画には、シャドーイング用の文が172文、単語が2494語あります。 音声の長さは18:50です。 話す速さは1分あたり約132語で安定しており、シャドーイングしやすいペースです。 英語の頻出3,000語に含まれる単語は80%だけなので、語彙は難しめです。

この動画の重要語彙

動画に出てくる覚えておきたい単語15語を、発音と意味つきで紹介します。

単語発音意味
pizza 名詞/ˈpi.tsə/ピザ, ピッツァ
predict 動詞/pɹɪˈdɪkt/予言する
output 名詞/ˈaʊtpʊt/出力
quest 名詞/kwɛ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/グラフ, 図表
calculate 動詞/ˈkælkjʊleɪt/計算する
token 名詞/ˈtoʊkən/トークン
curious 形容詞/ˈkjʊɹ.i.əs/好奇心の強い, 知りたがる
refer 動詞/ɹɪˈfɜː/問い合わせる

動画に出てくる句動詞

単語意味
check out 動詞試験する, 検査する
point out 動詞指す, 指し示す

この動画の文法

話し手がよく使っている文型を、動画の実際の表現とともに紹介します。

文型動画での表現
受動態 be + 過去分詞 — 誰がするかより、何が起きるかに焦点を当てるbe clearly explained · is brought · were connected
現在完了形 have/has + 過去分詞 — 過去の出来事が今も関係しているhas used · I've heard · we've seen

注意したい発音

話し手はwe'll, don't, I'veなど、短縮形や弱形を16回使っています。聞こえたとおりの短い形で発音しましょう。

  • 「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ɚ/

日本語話者が苦手な音:

  • /r/ と /l/ の区別 — /l/ は舌先を歯茎につけ、/r/ はどこにもつけない: neural /ˈnʊɹəl/, correctly /kəˈɹɛk(t).li/, similarity /ˌsɪm.ɪˈlæɹ.ɪ.ti/, translation /tɹænzˈleɪʃən/, randomly /ˈɹændm̩li/
  • /v/ — /b/ にならないように、上の歯を下唇に当てる: activation /ˌæktəˈveɪʃən/, oven /ˈʌ.vn̩/, convert /kənˈvɝt/, dive /daɪv/, variable [ˈvæɹ.i.ə.bl̩]
  • /f/ — 「フ」ではなく、上の歯と下唇で出す: phrase /ˈfɹeɪ̯z/, graph /ɡɹæf/, refer /ɹɪˈfɜː/, classification /ˌklæsɪfɪˈkeɪʃən/, fundamental /ˌfʌn.dəˈmɛn.təl/

この動画での練習方法

  1. まず声を出さずに動画を最後まで聞き、知らない単語をメモします。
  2. 通常の速度で一文ずつシャドーイングし、話し手のリズムに合うまで繰り返します。
  3. 自分の声を録音して元の音声と比べます。pizza, predict, outputなどの単語に特に注意しましょう。

シャドーイングとは?英語上達に効果的な理由

シャドーイング(Shadowing)は、もともとプロの通訳者養成プログラムで開発された言語学習法で、多言語習得者として知られるDr. Alexander Arguelles によって広く普及されました。方法はシンプルですが非常に効果的:ネイティブスピーカーの英語を聞きながら、1〜2秒の遅延で声に出してすぐに繰り返す——まるで「影(shadow)」のように話者を追いかけます。文法ドリルや受動的なリスニングと異なり、シャドーイングは脳と口の筋肉が同時にリアルタイムで英語を処理・再現することを強制します。研究により、発音精度、抑揚、リズム、連音、リスニング力、そして会話の流暢さが大幅に向上することが確認されています。IELTSスピーキング対策や自然な英語コミュニケーションを目指す方に特におすすめです。

シャドーイングのやり方: ステップ別の完全ガイドを読む →