Shadowing Practice: Encoder-Only Transformers (like BERT) for RAG, Clearly Explained!!! - Learn English Speaking with Video

בחר מצב תרגול

כל מצב פותח חדר תרגול במסך מלא.

172 משפטים
אם המשפטים קצרים או ארוכים מדי, לחץ על ערוך כדי להתאים אותם.
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 מילים לתרגול Shadowing. הדיבור נמשך 18:50. הדובר שומר על קצב יציב של כ-132 מילים בדקה, קצב נוח לתרגול Shadowing. רק 80% מהמילים נמצאות בין 3,000 המילים הנפוצות ביותר באנגלית, כך שאוצר המילים מאתגר.

אוצר מילים מרכזי בסרטון הזה

15 מילים מהסרטון שכדאי ללמוד, עם ההגייה והמשמעות שלהן:

מילההגייהמשמעות
pizza שם עצם/ˈpi.tsə/פִּיצָה
input שם עצם/ˈɪnpʊt/תְּרוּמָה
output שם עצם/ˈaʊtpʊt/פֶּלֶט
connect פועל/kəˈnɛkt/חיבר
oven שם עצם/ˈʌ.vn̩/תַּנּוּר
convert פועל/kənˈvɝt/המיר
similarity שם עצם/ˌsɪm.ɪˈlæɹ.ɪ.ti/דִּמְיוֹן
phrase שם עצם/ˈfɹeɪ̯z/צֵרוּף לָשׁוֹן, מִשְׁפָּט
graph שם עצם/ɡɹæf/גְּרָף
calculate פועל/ˈkælkjʊleɪt/חישב \ חִשֵּׁב
token שם עצם/ˈtoʊkən/אֲסִימוֹן, זִ׳יטוֹן
contrast שם עצם/kənˈt(ʃ)ɹæst/ניגוד
curious שם תואר/ˈkjʊɹ.i.əs/סַקְרָן, סקרנית
layer שם עצם/ˈleɪ̯ɚ/רוֹבֶד, שִׁכְבָה
translation שם עצם/tɹænzˈleɪʃən/תִּרְגּוּם

Phrasal verbs שתשמעו

מילהמשמעות
check out פועלבדק

דקדוק בסרטון הזה

המבנים שהדובר משתמש בהם הכי הרבה, עם המילים המדויקות מהסרטון:

מבנהבסרטון
סביל (Passive voice) be + past participle — הדגש הוא על מה שקורה, לא על מי שעושה את הפעולהbe clearly explained · is brought · were connected
הווה מושלם (Present perfect) have/has + past participle — פעולה שקרתה בעבר ועדיין יש לה חשיבות או השפעה עכשיו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ɚ/

צלילים שדוברי עברית מתקשים בהם:

  • /w/ — שפתיים מעוגלות, לא /v/: quest /kwɛst/, likewise /ˈlaɪkˌwaɪz/, squash /skwɔʃ/
  • /æ/ — פתוח יותר מה-“אֶ” העברית, לא כמו “a” ב-“cup”: activation /ˌæktəˈveɪʃən/, similarity /ˌsɪm.ɪˈlæɹ.ɪ.ti/, graph /ɡɹæf/, stat /stæt/, calculate /ˈkælkjʊleɪt/
  • /r/ — הלשון לא נוגעת בשום מקום, לא ה-“ר” הגרונית: predict /pɹɪˈdɪkt/, neural /ˈnʊɹəl/, correctly /kəˈɹɛk(t).li/, similarity /ˌsɪm.ɪˈlæɹ.ɪ.ti/, phrase /ˈfɹeɪ̯z/

איך לתרגל עם הסרטון הזה

  1. הקשיבו לכל הסרטון פעם אחת בלי לדבר, ורשמו את המילים שאתם לא מכירים.
  2. תרגלו Shadowing משפט אחר משפט במהירות רגילה, וחזרו על כל משפט עד שהקצב שלכם תואם את הדובר.
  3. הקליטו את עצמכם והשוו למקור, תוך תשומת לב למילים כמו pizza, input, output.

מהי טכניקת השאדואינג?

שאדואינג היא טכניקת למידת שפה מבוססת מדע שפותחה במקור להכשרת מתורגמנים מקצועיים ופופולרית על ידי הפוליגלוט ד"ר אלכסנדר ארגואלס. השיטה פשוטה אך עוצמתית: אתה מקשיב לאודיו באנגלית ילידית וחוזר עליו בקול רם מיד — כמו צל העוקב אחרי הדובר עם עיכוב של 1–2 שניות בלבד. בניגוד להאזנה פסיבית או תרגילי דקדוק, שאדואינג מכריח את המוח והשרירים בפה לעבד ולשחזר דפוסי דיבור אמיתיים בו זמנית. מחקרים מראים שזה משפר משמעותית את דיוק ההגייה, האינטונציה, הקצב, הדיבור המחובר, הבנת השמיעה ושטף הדיבור — מה שהופך אותו לאחת השיטות היעילות ביותר להכנה לIELTS Speaking ולתקשורת באנגלית בעולם האמיתי.

טכניקת Shadowing: קרא את המדריך המלא שלב אחר שלב →