YouTube2Text

Transformer Architecture Encoder Explained from Scratch (Pen & Paper Deep Dive) - Part1 — Transcript

by yogesh murumkar · 6,056 words · 1,212 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Hello everyone.
  2. 0:01This is Yogesh Moramkar.
  3. 0:03In this video, we are going to discuss
  4. 0:05about transformer architecture in detail
  5. 0:08with very simple explanation using the
  6. 0:11concepts like self-attention,
  7. 0:14multi-head attention,
  8. 0:16positional encoding,
  9. 0:18and layer normalization.
  10. 0:21So, self-attention,
  11. 0:23multi-head attention,
  12. 0:27Okay?
  13. 0:29positional encoding,
  14. 0:34and
  15. 0:35layer normalization.
  16. 0:40Layer normalization.
  17. 0:44And by chance, if someone is not aware
  18. 0:46about any of
  19. 0:49these concepts, please don't worry.
  20. 0:51I'll try to give you basic understanding
  21. 0:53of these concepts whenever required. And
  22. 0:56if someone wants to understand all these
  23. 0:58concepts in detail, I'll create separate
  24. 1:01videos for it.
  25. 1:02Okay?
  26. 1:03So,
  27. 1:04also before starting the explanation,
  28. 1:06let me tell you that the link for notes
  29. 1:09and all the diagrams
  30. 1:12have been provided in the description of
  31. 1:14this video.
  32. 1:16Whenever I say notes and all the
  33. 1:17diagrams, means see everyone, I'll be
  34. 1:18using all these things.
  35. 1:21I'll be explaining you
  36. 1:22the concept of transformer architecture
  37. 1:26with a very simple explanation. Everyone
  38. 1:28will be able to understand.
  39. 1:30Okay? So, all these things are already
  40. 1:32shared.
  41. 1:34You can go, you can click on the link
  42. 1:36provided in the description, and you can
  43. 1:38download all this stuff.
  44. 1:40So, that if you want to go, if you want
  45. 1:41to revise these things,
  46. 1:43you can easily revise and try to
  47. 1:45understand the concept properly.
  48. 1:48Okay?
  49. 1:50So,
  50. 1:51I have broken down this particular
  51. 1:53transformer architecture into two parts.
  52. 1:57In this video, we will focus only on
  53. 2:00encoder part of the architecture.
  54. 2:04As it is mentioned here.
  55. 2:07In the next video, we will focus on the
  56. 2:10decoder architecture.
  57. 2:12Okay, so what is encoder? What is
  58. 2:13decoder? We will talk about it.
  59. 2:16The main goal of this video is to
  60. 2:17understand the encoder architecture
  61. 2:20well.
  62. 2:22And I'll be using this these handwritten
  63. 2:24diagrams for the entire explanation.
  64. 2:27Whatever I have shown you just now.
  65. 2:30So, let me explain the journey of
  66. 2:32understanding transformer encoder
  67. 2:34architecture from the very familiar
  68. 2:36diagram which you are able to see here.
  69. 2:40Okay, I hope so everyone is able to see
  70. 2:42this properly.
  71. 2:43Starting with the inputs, input
  72. 2:45embedding
  73. 2:46on this side. And here you can see
  74. 2:48output shifted right, output embedding
  75. 2:50and so on.
  76. 2:52Okay, this is the very familiar diagram.
  77. 2:54By chance, if someone has come across
  78. 2:56something like
  79. 2:57transformer architecture, definitely
  80. 2:59they must have come across this
  81. 3:00particular diagram.
  82. 3:03So, see everyone, this diagram
  83. 3:05represents the entire transformer
  84. 3:07architecture.
  85. 3:08Both encoder and decoder are inside
  86. 3:12this.
  87. 3:15But the problem is that this diagram is
  88. 3:17very complex.
  89. 3:18If someone sees this diagram for the
  90. 3:20first time, they will feel a little
  91. 3:22confused.
  92. 3:24And some things will not be understood
  93. 3:26by them.
  94. 3:27But if I try to simplify this diagram a
  95. 3:30little,
  96. 3:31then things become easy.
  97. 3:34Let me ask you, do you at least see or
  98. 3:36do you at least understand that there
  99. 3:38are two parts in this diagram?
  100. 3:42One part is here. You can see everyone,
  101. 3:45this one.
  102. 3:46This one.
  103. 3:48First part of the diagram.
  104. 3:51Okay? On the left side. and another part
  105. 3:54is here.
  106. 3:55This one.
  107. 3:57See, I'm highlighting it. Okay?
  108. 4:01Then we can say clearly this part is our
  109. 4:04encoder. On the left side you see this
  110. 4:06one everyone, this is our encoder part.
  111. 4:09And this part
  112. 4:11is our decode.
  113. 4:13Okay? So, I can show you
  114. 4:15this particular diagram
  115. 4:19in a very simplified way.
  116. 4:21Like this.
  117. 4:23You see everyone.
  118. 4:24So, whenever I say transformer
  119. 4:26architecture, transformer architecture
  120. 4:27basically will have two blocks.
  121. 4:30Encoder and decoder. So, in our diagram
  122. 4:33which I showed it to you here, you can
  123. 4:35see this is the encoder part and this is
  124. 4:37the
  125. 4:38decoder part.
  126. 4:40Okay?
  127. 4:41One more thing everyone you can notice.
  128. 4:44Next to encoder, here, you see this NX
  129. 4:48is written.
  130. 4:50Right?
  131. 4:51Next to the encoder block, as well as
  132. 4:53decoder block as well. You see NX here
  133. 4:56and NX here.
  134. 4:58Right? Or N written here.
  135. 5:00And here as well.
  136. 5:01This N means what? This N means that
  137. 5:03there is not just one encoder block, but
  138. 5:06there are multiple such blocks. Not only
  139. 5:09one encoder block, but there are
  140. 5:10multiple such blocks. Similarly, there
  141. 5:13is not just one decoder block, there are
  142. 5:15multiple such a decoder blocks.
  143. 5:20If you read the original transformer
  144. 5:23paper,
  145. 5:24you might be knowing
  146. 5:26the name of the original transformer
  147. 5:27paper is what? Attention is all you
  148. 5:31need.
  149. 5:34Okay? Maybe
  150. 5:36most of you might have come across
  151. 5:37definitely.
  152. 5:39This is a paper written by eight people
  153. 5:41from Google Brains.
  154. 5:42Okay?
  155. 5:43So, if you read the original transformer
  156. 5:45paper titled attention is All You Need",
  157. 5:47you will find that
  158. 5:50they basically used six blocks for the
  159. 5:53encoder. How many? Six blocks.
  160. 5:57And six blocks for the decoder.
  161. 6:01So, if I want to show the next thing,
  162. 6:04the architecture basically looks like
  163. 6:06this one.
  164. 6:08Six encoder blocks and six
  165. 6:11decoder blocks.
  166. 6:13See, six is not a magical number. They
  167. 6:17achieved it through experimentation.
  168. 6:19And the number six basically gave them
  169. 6:23best results.
  170. 6:24That's the only reason. Otherwise, there
  171. 6:26is no specific reason why six encoder
  172. 6:28blocks and why six decoder blocks.
  173. 6:31Okay?
  174. 6:32Obviously, the question might have arise
  175. 6:34that
  176. 6:36why six? So, I've told you, right? It
  177. 6:39It's
  178. 6:40It's all through the experimentation.
  179. 6:42Okay? Now, the next question
  180. 6:45might be like, are all these blocks
  181. 6:47identical?
  182. 6:49Whenever I say six encoder blocks, are
  183. 6:51all these blocks identical? The answer
  184. 6:54is yes. All these blocks are completely
  185. 6:57identical. Meaning, their internal
  186. 6:59architecture is exactly same.
  187. 7:01I can say copy-paste.
  188. 7:03This means if you understand one block,
  189. 7:06you automatically understand other five
  190. 7:08blocks as well.
  191. 7:10Okay?
  192. 7:11So, obviously, our focus is now to
  193. 7:13understand single encoder block.
  194. 7:16What goes
  195. 7:17inside one single encoder block, that is
  196. 7:20what we will try to understand.
  197. 7:22Okay?
  198. 7:23So, now moving forward, everyone.
  199. 7:27As I've told you, this is the
  200. 7:28Transformer architecture. Out of this,
  201. 7:30we will try to focus on the entire
  202. 7:32encoder part.
  203. 7:34In the next video, we will try to
  204. 7:35discuss about the decoder part.
  205. 7:37So,
  206. 7:38the architecture
  207. 7:40in a simplified way looks like this.
  208. 7:42Inside one encoder,
  209. 7:44there are six encoders. So, it looks
  210. 7:46like this. And now, we will go inside
  211. 7:49one encoder, everyone.
  212. 7:51Okay?
  213. 7:53We will go inside one encoder, and that
  214. 7:55one encoder basically looks like this.
  215. 8:01Okay?
  216. 8:02>> [clears throat]
  217. 8:03>> So, when we zoom into a single encoder
  218. 8:06block, we find it contains two smaller
  219. 8:10blocks.
  220. 8:11Okay? This basically contains two
  221. 8:13smaller blocks.
  222. 8:15First is
  223. 8:17a self-attention block.
  224. 8:19Second is a feed-forward neural network.
  225. 8:22As you can see clearly here in this
  226. 8:24particular diagram.
  227. 8:27Next, let me explain how
  228. 8:30data flows through complete encoder.
  229. 8:35Okay?
  230. 8:36Let's try to discuss
  231. 8:38about that with a very simple example.
  232. 8:43Your sentence enters the first encoder
  233. 8:46block.
  234. 8:49See, as I've told you, there are six
  235. 8:50encoders, six decoders. So, your
  236. 8:52sentence enters the first encoder
  237. 8:55encoder block. The first first encoder
  238. 8:57block
  239. 8:59looks something like this.
  240. 9:05See, as as I've showed you,
  241. 9:08okay? Something like this.
  242. 9:11And if I want to show you
  243. 9:16what exactly happens when I say
  244. 9:18feed-forward neural network and
  245. 9:20self-attention, so it looks like this.
  246. 9:23The first encoder block, everyone, looks
  247. 9:25like this.
  248. 9:27From where I got it? So, you see here,
  249. 9:29in this case,
  250. 9:31multi-head attention, add and norm,
  251. 9:33feed-forward, add and norm. Exactly same
  252. 9:36thing is shown here. Multi-retention add
  253. 9:39a norm, feed forward add a norm.
  254. 9:42That is what I'm trying to show you.
  255. 9:44And like this, how many are there? Six.
  256. 9:46Six encoder blocks are there.
  257. 9:49So, the diagram basically becomes
  258. 9:52something like this one here. See.
  259. 9:54As I've told you,
  260. 9:56your sentence enters the first encoder
  261. 9:58block. This is the first encoder block.
  262. 10:01And the first encoder blocks look like
  263. 10:03this.
  264. 10:04It looks like this.
  265. 10:06The output The output from the first
  266. 10:09encoder block goes to the second encoder
  267. 10:11block. Even though I did not draw it
  268. 10:13here,
  269. 10:14but you can imagine. It is exactly same.
  270. 10:16I've told you, right?
  271. 10:18So, the output from the first encoder
  272. 10:19block
  273. 10:22goes to second encoder block.
  274. 10:24The second encoder block is identically
  275. 10:26the same.
  276. 10:28Then, processing happens inside second
  277. 10:30encoder block as well. The output from
  278. 10:32this second encoder block goes to the
  279. 10:34third one. The output uh from the third
  280. 10:37goes to the fourth.
  281. 10:39And so on.
  282. 10:41Till the sixth encoder block.
  283. 10:43Finally, our sixth encoder block output
  284. 10:47goes towards decoder.
  285. 10:52Okay, as you can see here.
  286. 10:55So, what exactly is 3 cross 512? How it
  287. 10:58How it is achieved? We'll talk about it.
  288. 11:01Fine? But, I hope so you got an
  289. 11:03overview.
  290. 11:04Whenever I say some input is passed to
  291. 11:06the encoder, what exactly happens? So,
  292. 11:08this is like higher high-level overview,
  293. 11:11I can say.
  294. 11:13Fine?
  295. 11:14Finally, as I've told you, our sixth
  296. 11:16encoder block output goes to decoder.
  297. 11:20And
  298. 11:22one more thing, everyone. Before the
  299. 11:24input enters the first encoder, this
  300. 11:27input, before it enters
  301. 11:30first encoder or first encoder block.
  302. 11:35There are three important operations
  303. 11:37which are performed on the sentence.
  304. 11:41Let me take an example everyone and
  305. 11:44explain each and every step to you.
  306. 11:47Okay. So, see here.
  307. 11:50Let's say
  308. 11:53Before see, before input enters the
  309. 11:57encoder block,
  310. 11:58what exactly happens? Let's try to see
  311. 12:00this. Okay, and I've told you already
  312. 12:02that there are six encoder blocks.
  313. 12:04So, for example everyone, let's say I
  314. 12:06have a sentence. I have an example
  315. 12:10like this.
  316. 12:11I am Yogesh.
  317. 12:14Okay.
  318. 12:16The first operation
  319. 12:18which comes into picture
  320. 12:20is tokenization.
  321. 12:23You can see here, tokenizer.
  322. 12:26This means the tokenizer will break our
  323. 12:28sentence into words.
  324. 12:30Okay? Tokenization means you break down
  325. 12:32a given sentence into tokens. Tokens
  326. 12:35could be a single word, two words, three
  327. 12:37words. It depends on the tokenization
  328. 12:39approach. For now,
  329. 12:41we are doing word level tokenization.
  330. 12:43This means the tokenizer will break our
  331. 12:44sentence into words.
  332. 12:46Let's say
  333. 12:47first token is I. Another token is am.
  334. 12:51And next token is Yogesh.
  335. 12:54The second operation is very important.
  336. 12:57This one.
  337. 13:01This is also called as text
  338. 13:03vectorization.
  339. 13:05This means your encoder or transformer
  340. 13:08cannot process words. Obviously, no
  341. 13:10machine can process words, right? You
  342. 13:13must somehow convert them into numbers.
  343. 13:17The technique we use for text
  344. 13:18vectorization is called embedding.
  345. 13:23The technique we use for
  346. 13:25vectorization, for text vectorization is
  347. 13:28called embedding.
  348. 13:30What we do
  349. 13:32is that we take every word and put it in
  350. 13:36this embedding layer.
  351. 13:39And this embedding layer will generate a
  352. 13:40vector of every word.
  353. 13:45In our case, it will be 512 dimension
  354. 13:49vector. Okay, that's why I have written
  355. 13:50here 512 dimension vector.
  356. 13:54It's It's like this.
  357. 13:561 2 3 4 and so on. 512 dimension vector.
  358. 14:03Fine. This means for the word I, for the
  359. 14:07word I or the token I, we create a 5 112
  360. 14:11dimensional vector representation.
  361. 14:15Similarly, for words and and Yogesh, we
  362. 14:18get 512 dimensional vector
  363. 14:20representation.
  364. 14:22But the problem is
  365. 14:24after this, but the problem is
  366. 14:27we don't have any information about the
  367. 14:30order of words.
  368. 14:33Which word comes first, which word comes
  369. 14:36later.
  370. 14:37We don't know that.
  371. 14:39And guess what? This is very very
  372. 14:40important, obviously.
  373. 14:42You must always know which words in your
  374. 14:44sentence come first and which
  375. 14:47come later.
  376. 14:49So, to add this positional information,
  377. 14:55we use a technique called as positional
  378. 14:58encoding. Basically, this this icon you
  379. 15:01can see everyone, this is for positional
  380. 15:03encoding.
  381. 15:05Okay, if someone has come across
  382. 15:08the transformer architecture shown in
  383. 15:10the
  384. 15:11uh attention is all you need paper,
  385. 15:14you must have seen that. They also have
  386. 15:15used the same notation.
  387. 15:18So, everyone, to add positional
  388. 15:19information, we use a technique called
  389. 15:21as positional encoding. For each
  390. 15:23position,
  391. 15:24like position number one, it will
  392. 15:26generate a 512 dimensional vector.
  393. 15:30Similarly, for position number two, it
  394. 15:33will also generate 512 dimensional
  395. 15:34vector, and similarly for position
  396. 15:36number three.
  397. 15:38Now,
  398. 15:40those 512 dimensional vectors are P1,
  399. 15:42P2, P3. Okay? And E1, E2, E3 are nothing
  400. 15:45but what? These are the 512 dimensional
  401. 15:48embedding vectors for I and M and
  402. 15:51Yogesh, respectively.
  403. 15:54Now, we have to add
  404. 15:57our
  405. 15:58embedding vectors with their positional
  406. 16:00vectors. So, basically, we add these two
  407. 16:03vectors, E1 and P1. We add these two
  408. 16:06vectors, E2 and P2. And then E3 and P3.
  409. 16:10You can see this addition operation.
  410. 16:13So, after all these addition operations
  411. 16:15are even, we get three new vectors.
  412. 16:19As you can see, I mentioned here X1, X2,
  413. 16:22X3.
  414. 16:23X1 is what? It's embedding of
  415. 16:26I. It's embedding of I. Right? This is
  416. 16:29for I, this is for M, and this is for
  417. 16:33Yogesh. These are the embeddings.
  418. 16:35So, X1 is what?
  419. 16:38X1 equal to embedding of I plus
  420. 16:41positional encoding of position
  421. 16:44one.
  422. 16:46X2 is what? Embedding of M plus
  423. 16:48positional encoding of position two.
  424. 16:51And
  425. 16:51>> [clears throat]
  426. 16:52>> X3 is what?
  427. 16:53Embedding of Yogesh plus positional
  428. 16:56encoding of position three.
  429. 16:59This is how we got X1, X2, X3.
  430. 17:02Now, these three vectors, X1, X2, X3,
  431. 17:07enter the first encoder block.
  432. 17:10It means what, everyone?
  433. 17:12It means
  434. 17:14the previous diagram which I showed you,
  435. 17:17this [clears throat] one.
  436. 17:19This X1, X2, X3 will enter this block
  437. 17:22because now everything related to input
  438. 17:24operation is done. Now that X1, X2, X3
  439. 17:27will enter first encoder block.
  440. 17:31That is this one. I hope so you are able
  441. 17:33to see that.
  442. 17:34It means what? It means everyone in our
  443. 17:38architecture, where are we right now?
  444. 17:41If you want to understand that, I'll
  445. 17:43just point it out. So see everyone,
  446. 17:46we are here.
  447. 17:48Okay? We are here.
  448. 17:51Fine?
  449. 17:52>> [clears throat]
  450. 17:54>> So
  451. 17:55they encounter
  452. 17:57this X1, X2, X3, as I've told you, they
  453. 17:59enter the first encoder block.
  454. 18:02And
  455. 18:03first they encounter the multi-head
  456. 18:06attention block. You see?
  457. 18:08Multi-head attention.
  458. 18:10The first thing which they will
  459. 18:11encounter, X1, X2, X3 will encounter is
  460. 18:13multi-head attention.
  461. 18:16So whatever we got here,
  462. 18:18>> [clears throat]
  463. 18:19>> this X1, X2, X3, right? They will
  464. 18:22encounter multi-head attention.
  465. 18:25Or here also, in this diagram also I can
  466. 18:28show you. You see? Input will encounter
  467. 18:31multi-head attention. Please try to
  468. 18:32understand. I'm just trying to
  469. 18:35break this in small small parts so that
  470. 18:37it will be easy for you to understand.
  471. 18:40Fine?
  472. 18:44>> [clears throat]
  473. 18:44>> Now,
  474. 18:46self-attention,
  475. 18:49that is this multi-head attention
  476. 18:51everyone. Multi-head attention is like
  477. 18:53multiple self-attentions, okay? So
  478. 18:55that's why I'm saying self-attention is
  479. 18:57applied because your embedding vector
  480. 18:59has a problem.
  481. 19:02This multi-head attention is multiple
  482. 19:04self-attentions.
  483. 19:05Now why?
  484. 19:06Why this
  485. 19:08self-attention is applied everyone?
  486. 19:12Why it is applied?
  487. 19:14So, that's what I'm trying to tell you.
  488. 19:16Self-attention is applied because your
  489. 19:18embedding vector has a problem.
  490. 19:20This X1, X2, X3, it has a problem. The
  491. 19:23problem is that the same word has same
  492. 19:26embedding everywhere.
  493. 19:28Please try to understand.
  494. 19:30The same word has the same embedding
  495. 19:33everywhere. For example,
  496. 19:35for example, let's say
  497. 19:40a very common example given will which
  498. 19:42you will find out everywhere. Let's say
  499. 19:43I have a sentence like this.
  500. 19:45I
  501. 19:47went to
  502. 19:49bank. Okay, this is the first sentence.
  503. 19:54Another sentence is
  504. 19:56I sat
  505. 19:59on the
  506. 20:02river bank.
  507. 20:05This is another sentence.
  508. 20:07Now, here everyone,
  509. 20:10in this case,
  510. 20:11both these sentences, sentence one and
  511. 20:14sentence two,
  512. 20:16they use the word bank.
  513. 20:19But, with completely different meanings.
  514. 20:23Right? Yet, the embedding will be
  515. 20:26exactly same for both. Embedding is
  516. 20:28nothing but what? Embedding is nothing
  517. 20:29but representing these words in terms of
  518. 20:31vector numbers.
  519. 20:33So, embedding will be same for them.
  520. 20:35Because bank and bank word is same. So,
  521. 20:37self-attention solve this problem.
  522. 20:39Because, if you see here, in this case,
  523. 20:42I went to the bank, bank is basically
  524. 20:45used in the context of financial
  525. 20:47institution.
  526. 20:49And here in this case, I sat on the
  527. 20:51river bank,
  528. 20:52bank word is used in some different
  529. 20:54context, like river bank they are
  530. 20:55talking about.
  531. 20:58Right? So, obviously everyone, their
  532. 21:00embedding should not be same.
  533. 21:02So, self-attention solve this problem.
  534. 21:04As soon as you apply self-attention, you
  535. 21:06notice that the embedding of bank in the
  536. 21:08first sentence and the embedding of bank
  537. 21:12in the second sentence changes. It
  538. 21:15starts considering surrounding words
  539. 21:18contextually.
  540. 21:20It becomes contextually aware.
  541. 21:25Okay? And what is even better
  542. 21:28than self-attention?
  543. 21:30It is multi-head attention.
  544. 21:33Because in multi-head attention,
  545. 21:34everyone, in multi-head attention, you
  546. 21:37bring multiple self-attention modules
  547. 21:40and get opinions from all of them. It's
  548. 21:43like one opinion is good, two opinions
  549. 21:46are better.
  550. 21:48And more opinions means you have more
  551. 21:50diversity.
  552. 21:53So, without going into the details of
  553. 21:55what is happening inside this block, I
  554. 21:57will directly give you the output. All
  555. 21:59right, I'll directly show you the
  556. 22:01output.
  557. 22:03Right? This block I'm talking about.
  558. 22:06So,
  559. 22:07when you send the first vector through
  560. 22:10multi-head attention, that is this X1
  561. 22:13through multi-head attention, you get
  562. 22:15another vector Z1,
  563. 22:18which is again a 512 dimensions.
  564. 22:21Okay? This is again 512 dimensions.
  565. 22:28But this Z1 will consider surrounding
  566. 22:31words contextually, that is Z2, Z3.
  567. 22:34Similarly, when you send X2,
  568. 22:38this is basically vector for M,
  569. 22:41embedding vector for M,
  570. 22:43you get
  571. 22:45uh
  572. 22:46when you send X2, you get Z2.
  573. 22:49Right? And when you send X3, you get Z3.
  574. 22:52So, all of them, they are basically 512
  575. 22:55dimension vectors.
  576. 22:58Now, here is something very good that is
  577. 23:00happening.
  578. 23:01We use residual connections. Everyone,
  579. 23:04this is called as residual connection or
  580. 23:06skip connection.
  581. 23:10Okay, residual connection or
  582. 23:13skip connection.
  583. 23:15In the original diagram as well, you can
  584. 23:17see here. See, this is what I'm talking
  585. 23:18about. This this line this line is
  586. 23:21called as residual connection or
  587. 23:23skip connection.
  588. 23:24Okay, this one.
  589. 23:29>> [clears throat]
  590. 23:30>> Notice here where it says add and norm.
  591. 23:35You see, add.
  592. 23:37That is actually for this residual
  593. 23:39connection. Everyone, this add is
  594. 23:40actually for residual connection. What
  595. 23:42happens is when you send your X vectors,
  596. 23:45these X vectors
  597. 23:47X1, X2, X3.
  598. 23:50When you send these
  599. 23:51uh
  600. 23:52X vectors
  601. 23:56that is X1, X2, X3, one path goes into
  602. 23:59multi-head attention.
  603. 24:02You see?
  604. 24:03Okay, you see here?
  605. 24:05This goes into multi-head This goes into
  606. 24:07multi-head attention.
  607. 24:08X1, X2, X3 will come from here and it
  608. 24:10will go into multi-head attention.
  609. 24:13Right? That is nothing but
  610. 24:15this one.
  611. 24:16Okay, as we have three words, that's why
  612. 24:18it is like this.
  613. 24:20So, one path goes inside multi-head
  614. 24:22attention, but another path does what?
  615. 24:25It bypasses the multi-head attention and
  616. 24:27goes ahead. See, you see here? It
  617. 24:30bypasses this multi-head attention and
  618. 24:33and you can see
  619. 24:35it goes here.
  620. 24:38Right? It goes ahead or here you can
  621. 24:40see. Again, same thing as I've told you.
  622. 24:42This one. It bypasses this multi-head
  623. 24:44attention and it goes ahead.
  624. 24:49So, we have two sets of vectors at this
  625. 24:51point.
  626. 24:53You can see?
  627. 24:56Because of this residual connection
  628. 24:58it has bypassed the multi-headed
  629. 25:00attention and now we have two sets of
  630. 25:02vectors.
  631. 25:05Okay?
  632. 25:06One from multi-headed attention, that is
  633. 25:08Z1, Z2, Z3. How we got it? We already
  634. 25:10seen that.
  635. 25:12And one original input, that is X1, X2,
  636. 25:15X3, which we have got
  637. 25:17through
  638. 25:18this residual connection or skip
  639. 25:20connection.
  640. 25:22The good thing is all these are 512
  641. 25:25dimensions. These are already 512 and
  642. 25:27these also are These also are 512
  643. 25:29dimensions.
  644. 25:30Which means you can perform any
  645. 25:32mathematical operation.
  646. 25:34And what operation
  647. 25:36we perform here? We perform addition.
  648. 25:38You see?
  649. 25:40>> [snorts]
  650. 25:41>> That is nothing but this add.
  651. 25:44Okay? So, we add
  652. 25:47Z1
  653. 25:48+ X1, Z2 + X2, Z3 + X3.
  654. 25:53This gives us a new set of vectors
  655. 25:56and that is nothing but
  656. 25:57Z1', Z2', and Z3'. Now, let me show you
  657. 26:02that particular part.
  658. 26:05You see everyone.
  659. 26:07After this, you understand after this
  660. 26:09X1, X2, X3
  661. 26:11All right? After addition of X1, X2, X3
  662. 26:13and Z1, Z2, Z3
  663. 26:15All right? After addition of this, we
  664. 26:16got Z1', Z2', and Z3'. Now, I'm going to
  665. 26:20continue with this.
  666. 26:22Okay? I'm going to continue with this
  667. 26:24one. So, we got Z1', Z2', Z3'.
  668. 26:29Which are again 512 dimensions. All of
  669. 26:32them again. They are 512 dimensions. 512
  670. 26:36dimensional vector, 512 dimensional
  671. 26:37vector.
  672. 26:39Okay?
  673. 26:40And finally, everyone, we have to
  674. 26:42perform
  675. 26:44normalization.
  676. 26:45Something called as layer normalization
  677. 26:48is applied.
  678. 26:49You can You this.
  679. 26:51You can see this here in the original
  680. 26:53architecture.
  681. 26:54After doing addition,
  682. 26:57we are doing what? Normalization. So,
  683. 26:59this norm means layer normalization
  684. 27:01even.
  685. 27:02Okay? That is what is basically shown
  686. 27:04here.
  687. 27:08In layer normalization, you take each
  688. 27:10vector
  689. 27:12like Z1 dash, Z2 dash, and Z3 dash.
  690. 27:17Okay? So, Z1 dash, which has 512
  691. 27:21numbers,
  692. 27:24we calculate the mean of all these 512
  693. 27:26numbers, calculate the standard
  694. 27:28deviation, and normalize or standardize
  695. 27:31all 512 numbers within some given range.
  696. 27:34Okay? So, we calculate the mean, that is
  697. 27:36mu. We calculate the standard deviation,
  698. 27:38that is sigma.
  699. 27:41And normalize or standardize all 512
  700. 27:43numbers within given range. I hope if
  701. 27:45someone has
  702. 27:47basic idea about at least machine
  703. 27:48learning, they know how to normalize the
  704. 27:51data, how to standardize the data.
  705. 27:53Okay? So, that is basically done here
  706. 27:56in layer normalization.
  707. 28:02It means what, everyone? It means
  708. 28:03whenever I say normalize or standardize
  709. 28:05all 512 numbers, we try to bring them
  710. 28:07within some given range.
  711. 28:10You do the same work for
  712. 28:12Z2 dash and Z3 dash.
  713. 28:15After this operation, Z1 dash becomes Z1
  714. 28:19normalized, Z2 dash becomes Z2
  715. 28:21normalized, and Z3 dash becomes Z3
  716. 28:23normalized.
  717. 28:25You can see, Z1 norm, Z2 norm, Z3 norm.
  718. 28:30By the way, why are we normalizing? The
  719. 28:32answer is simple.
  720. 28:34Just to stabilize the training process.
  721. 28:38I've told you, right? You must have come
  722. 28:39across normalization concept and
  723. 28:42standardization concept in machine
  724. 28:44learning as well.
  725. 28:47Okay?
  726. 28:48Just to stabilize the training process,
  727. 28:51we are normalizing.
  728. 28:53When you compute
  729. 28:55Z1, Z2, Z3 through multi-head attention,
  730. 28:59right? As we have seen in the previous
  731. 29:01step, this Z1, Z2, Z3.
  732. 29:04Z1, Z2, Z3.
  733. 29:07When you compute
  734. 29:09all these through multi-head
  735. 29:11attention, this can be in any range.
  736. 29:14It means there is no upper or lower
  737. 29:17limit which is defined for this.
  738. 29:20And and because you're multiplying two
  739. 29:22numbers
  740. 29:24and then doing another multiplication,
  741. 29:26there is no defined range for the
  742. 29:28self-attention output.
  743. 29:31This is not a good thing.
  744. 29:33Right? Neural network training is
  745. 29:34generally stable when numbers are in
  746. 29:37small given range. So, we need some
  747. 29:40mechanism to normalize these numbers
  748. 29:43into a small given range.
  749. 29:45That is what layer normalization is
  750. 29:48doing.
  751. 29:50Okay? This layer normalization is doing
  752. 29:53the same thing.
  753. 29:55It's trying to bring those values in
  754. 29:56some given range.
  755. 29:58Fine?
  756. 29:59I hope till this point
  757. 30:01I hope so you are able to understand.
  758. 30:04Now,
  759. 30:06next is feedforward neural network. As
  760. 30:09you can see in the original architecture
  761. 30:11given,
  762. 30:13now we are here.
  763. 30:14Okay? We are here.
  764. 30:16We have seen
  765. 30:18multi-head attention,
  766. 30:20add norm, and this residual connection.
  767. 30:23Now we are here.
  768. 30:25Okay? At this point.
  769. 30:28So, next is what? You can see
  770. 30:30feedforward neural network.
  771. 30:33The feedforward neural network inside an
  772. 30:35encoder block is basically a two-layer
  773. 30:38neural network.
  774. 30:42I'll show you that anyway. It looks
  775. 30:43something like this.
  776. 30:46Okay? It's a two-layer neural network.
  777. 30:53>> [clears throat]
  778. 30:53>> You can input 512 dimensional input to
  779. 30:55this
  780. 30:57neural network, okay?
  781. 30:59512 dimension input you can input to
  782. 31:01this particular neural network.
  783. 31:04The first layer has
  784. 31:072048 neurons.
  785. 31:09This layer has 2048 neurons.
  786. 31:14Each neuron has a ReLU activation
  787. 31:16function.
  788. 31:18Rectified linear unit activation
  789. 31:20function.
  790. 31:21The second layer has 512 neurons. This
  791. 31:24one here.
  792. 31:26And
  793. 31:28it is having
  794. 31:30activation function which is linear.
  795. 31:35Now, let us imagine that Z1 norm, Z2
  796. 31:39norm, Z1 norm, Z2 norm, and Z3 norm
  797. 31:43let's say they form
  798. 31:45a matrix like this, okay? A matrix like
  799. 31:48this.
  800. 31:50Which is of 3 cross 512.
  801. 31:53It means what? It means three words.
  802. 31:55Each word
  803. 31:57of 512 dimensions.
  804. 31:59You can think of this as sending a batch
  805. 32:02of data where the batch has three rows.
  806. 32:05First row, you see here.
  807. 32:08This is first row. This is second row.
  808. 32:12And third row.
  809. 32:15But all three
  810. 32:16go simultaneously.
  811. 32:19This goes and multiplies with the
  812. 32:22weights. See here. All this goes
  813. 32:26All this go here and multiplies with
  814. 32:27these weights. How many weights are
  815. 32:29there? So, as I've told you,
  816. 32:30this is 512 2048. So, it will be like
  817. 32:33512 cross
  818. 32:352048
  819. 32:36weights.
  820. 32:38Right? That's why I've told you this
  821. 32:39goes and multiplies with the weights of
  822. 32:41the first layer, that is 512 to cross
  823. 32:442048.
  824. 32:45Since both dimensions match,
  825. 32:48this is 512 cross 2048.
  826. 32:51And here everyone you see,
  827. 32:55right? This is This is basically three
  828. 32:57cross
  829. 32:59This is basically three cross 512. This
  830. 33:01dimension and this dimension they match.
  831. 33:03You see?
  832. 33:05Right?
  833. 33:06So, since both the dimensions
  834. 33:09match,
  835. 33:10you can perform this multiplication.
  836. 33:13And what you get is a three cross 2048
  837. 33:16dimensional matrix.
  838. 33:18You will get three cross 2048
  839. 33:21dimensional matrix.
  840. 33:23That means three vectors, each of size
  841. 33:252048.
  842. 33:29Fine?
  843. 33:30Then, you add the bias. Obviously, 2048
  844. 33:34neurons, that means there will be 2048
  845. 33:36biases. Let's say I'll just represent
  846. 33:38them with
  847. 33:39uh only one value, let's say B1. So, B1
  848. 33:42will be added.
  849. 33:43Okay?
  850. 33:45One for each neuron, one bias for each
  851. 33:47neuron, obviously.
  852. 33:48After that, everyone, then you apply
  853. 33:50ReLU activation function.
  854. 33:53Why As I told you, right? ReLU here. So,
  855. 33:55why ReLU here? ReLU is for
  856. 33:57non-linearity.
  857. 33:59Okay? And once that is done, after this
  858. 34:01layer, the dimensionality increase from
  859. 34:04512 to 2048.
  860. 34:09Now, in the second layer here,
  861. 34:12you take this three three cross 2048
  862. 34:15matrix and multiply it with weights,
  863. 34:18that is these weights.
  864. 34:21These weights will be how many everyone?
  865. 34:23As you can see, they are 2048 and 512.
  866. 34:26So, everyone,
  867. 34:28these weights in the second layer as as
  868. 34:31as you can see as you can see here in
  869. 34:33the second layer
  870. 34:34uh you take this 3 cross 2048 and
  871. 34:37multiplied with weights. How many
  872. 34:40weights? 2048 cross this 512.
  873. 34:44So, 2048 cross 512.
  874. 34:49Since these dimensions also match,
  875. 34:52you can do the multiplication. See, they
  876. 34:54match. So, once you do the
  877. 34:55multiplication everyone, what you get
  878. 34:57back is you get back 3 cross
  879. 35:00512
  880. 35:02matrix. That is three vectors, each of
  881. 35:04size 512.
  882. 35:07That is what you got here.
  883. 35:09Okay? And then you add bias. Let's say I
  884. 35:12I'll call that bias. Obviously, there'll
  885. 35:14be biases. 512 neurons are there, so 512
  886. 35:17bias values biases will be there. So, I
  887. 35:19will represent them as B2. So, we
  888. 35:21we add bias B2, let's say.
  889. 35:25Fine?
  890. 35:26So, finally we got 3 cross 512 now.
  891. 35:28Obviously, the question in your mind is
  892. 35:30what is the benefit here? First, we
  893. 35:32increase dimensionality to 2 2048.
  894. 35:35Then we reduce it back to 512. So, what
  895. 35:38is the benefit of all these things?
  896. 35:40We end up with 3 cross 512 matrix again.
  897. 35:45So, what was gained? The benefit is that
  898. 35:48we were able to introduce non-linearity.
  899. 35:54This is the
  900. 35:56motive everyone. We were able to reduce
  901. 35:57non-linearity through rectified linear
  902. 36:00unit ReLU activation function. The
  903. 36:02entire
  904. 36:03self-attention process is linear.
  905. 36:06Remember this. All operations are
  906. 36:08linear, but sometimes if you have data
  907. 36:10where there is some form of non-linear
  908. 36:13complexity, then you need a feed-forward
  909. 36:16neural network with non-linear
  910. 36:18activation to capture those
  911. 36:20non-linearities.
  912. 36:22And this feed-forward network is what
  913. 36:26introduces non-linearity into the model.
  914. 36:30I hope till this point
  915. 36:32you got the idea. Okay?
  916. 36:35After this, now again, interesting thing
  917. 36:39is
  918. 36:40we do the same thing again.
  919. 36:42We use
  920. 36:43residual connection. You see again, this
  921. 36:45residual connection?
  922. 36:46Right?
  923. 36:47In the original architecture, if I want
  924. 36:49to show it to you,
  925. 36:52so I'm talking about this residual
  926. 36:53connection. You see? It is bypassing
  927. 36:55feed forward. You see?
  928. 36:57This residual connection.
  929. 36:59So we use a residual connection
  930. 37:01bypassing the feed forward neural
  931. 37:02network and add output of feed forward
  932. 37:06neural network, whatever the output. So
  933. 37:08actually we are here now.
  934. 37:10Okay?
  935. 37:11Here. So
  936. 37:14what happens? As I said, we do the same
  937. 37:17thing again. We use residual connection
  938. 37:19bypassing the
  939. 37:20feed forward neural network.
  940. 37:23Okay? Like this.
  941. 37:25And add the output of feed forward
  942. 37:28neural network with our input. And what
  943. 37:30was What was our input again? What was
  944. 37:34our input?
  945. 37:35As you [clears throat] can see,
  946. 37:38our input was
  947. 37:41Z1 norm,
  948. 37:42Z2 norm, Z3 norm. That's why you see
  949. 37:44this this residual connection or cell
  950. 37:48skip connection. You see? Y1, Y2, Y3 is
  951. 37:50what we have got as output of feed
  952. 37:52forward neural network and we are adding
  953. 37:54it to the original input. The input
  954. 37:57which we got basically from layer
  955. 37:59normalization.
  956. 38:00Through this residual connection. Z1
  957. 38:01norm, Z2 norm, Z3 norm.
  958. 38:04Okay?
  959. 38:06So our input was Z1 norm, Z2 norm, Z3
  960. 38:08norm. We bypass this and bring it where
  961. 38:11the feed forward output is sitting. And
  962. 38:14feed forward output is sitting here, Y1,
  963. 38:15Y2, Y3.
  964. 38:18Okay? The feed forward output is Y1, Y2,
  965. 38:21Y3. These are also 512 dimensions each.
  966. 38:25This one also, this one also.
  967. 38:30We add them. That is Y1 plus Z1 now, Y2
  968. 38:33plus Z2 now, Y3 plus
  969. 38:36Z3 now.
  970. 38:38And this gives us, let's say Y1 dash, Y2
  971. 38:41dash, Y3 dash.
  972. 38:44Again, all are of 512
  973. 38:48dimensions.
  974. 38:51And now everyone, we apply layer
  975. 38:53normalization again. You see here?
  976. 38:56Layer normalization. That means in our
  977. 38:58original diagram,
  978. 39:01we are here, normalization. I'm talking
  979. 39:03about this one everyone. After adding,
  980. 39:05I'm talking about normalization. And
  981. 39:07this normalization is nothing but what?
  982. 39:08Layer normalization.
  983. 39:11Okay, I hope you understand that.
  984. 39:15So, we apply layer normalization,
  985. 39:18getting Y1 normalized, Y2 normalized,
  986. 39:21and Y3 normalized.
  987. 39:25Okay? This is interesting. Y1
  988. 39:27normalized, Y2 normalized, Y3 normalized
  989. 39:31will go to the next encoder block. You
  990. 39:33can see I written here.
  991. 39:35To the next encoder block. At the start
  992. 39:37only I have told you, right?
  993. 39:39How many encoder blocks are there? There
  994. 39:41are six encoder blocks. So, the output,
  995. 39:44this output which we got here from the
  996. 39:46first encoder block, now will go to the
  997. 39:49next encoder block. That means everyone,
  998. 39:52as I have told you,
  999. 39:54>> [clears throat]
  1000. 39:55>> we are done with this add and norm in
  1001. 39:58the first encoder block. And whatever
  1002. 39:59the output which we got here, it will
  1003. 40:01now go to the second encoder block. That
  1004. 40:03means in our original architecture, in
  1005. 40:06our original architecture, we are here.
  1006. 40:10But,
  1007. 40:11as I have told you, N N value is six, so
  1008. 40:13like this six encoder blocks are there,
  1009. 40:15right? So, [snorts]
  1010. 40:16that means the output of first encoder
  1011. 40:19block we got here. As I told you we are
  1012. 40:20here. This output will go to the
  1013. 40:23go as a input to the second encoder
  1014. 40:25block.
  1015. 40:26That is to the next encoder block.
  1016. 40:28Just like X1, X2, X3.
  1017. 40:31Right? Whatever X1, X2, X3 was there
  1018. 40:35initially.
  1019. 40:36X1, X2, X3.
  1020. 40:38Right? Just like X1, X2, X3 were the
  1021. 40:40input to the first encoder block.
  1022. 40:42Similarly, this Y1 norm, Y2 norm
  1023. 40:46and Y3 norm.
  1024. 40:48Okay? Y1 norm, Y2 norm, Y3 norm.
  1025. 40:53>> [clears throat]
  1026. 40:53>> Uh this will
  1027. 40:56uh become the input to the next encoder
  1028. 40:59block. Okay? And then
  1029. 41:02the same things repeat. Whatever we have
  1030. 41:05seen till now, the same things repeat.
  1031. 41:08There is also a multi-head attention
  1032. 41:10block
  1033. 41:12in the second encoder, everyone.
  1034. 41:14Obviously, as I have told you they are
  1035. 41:15same.
  1036. 41:16Right? So, there is also a multi-head
  1037. 41:19attention block in the second encoder.
  1038. 41:21Even though I have not drawn it, but I
  1039. 41:23think you understand, right? It is
  1040. 41:24exactly same.
  1041. 41:26Right? It is exactly same.
  1042. 41:28I I don't have enough space. That's why
  1043. 41:31I I did not draw every one of them, but
  1044. 41:33you you can imagine, right? Second
  1045. 41:35encoder, whenever I say, it will be
  1046. 41:36exactly same.
  1047. 41:38So, as I have told you, there is also a
  1048. 41:40multi-head attention for second encoder
  1049. 41:42block.
  1050. 41:43Right?
  1051. 41:45We will do
  1052. 41:47add
  1053. 41:49and norm after multi-head attention in
  1054. 41:51the second encoder block as well, like
  1055. 41:52this. Then there is also a feed forward
  1056. 41:54neural network
  1057. 41:56in the second encoder block. And we will
  1058. 41:58do add and norm in the second encoder
  1059. 42:00block again after feed forward neural
  1060. 42:02network.
  1061. 42:03And we go like this to the
  1062. 42:05next, that is third encoder block.
  1063. 42:08And then to the next, fourth encoder
  1064. 42:10block, fifth encoder block, and then
  1065. 42:13finally everyone to the sixth encoder
  1066. 42:16block.
  1067. 42:19Okay? One important thing you must
  1068. 42:22remember
  1069. 42:23and don't get confused about this, okay?
  1070. 42:25Although each encoder block has the same
  1071. 42:28architecture,
  1072. 42:29as I've told you, copy-pasting terms of
  1073. 42:31structure, the parameters are different
  1074. 42:33for each block. This block, this block,
  1075. 42:35this block, parameters are different.
  1076. 42:38Whatever the weights and biases you have
  1077. 42:40in multi-head attention
  1078. 42:43of this block,
  1079. 42:46that is first block, the weights and
  1080. 42:47biases in the multi-head attention of
  1081. 42:49another block, that is second block or
  1082. 42:50third block, they are different. That is
  1083. 42:53the meaning.
  1084. 42:54So, whatever the weights and biases
  1085. 42:56which are in the feed forward neural
  1086. 42:59network of one block, the weights and
  1087. 43:01biases in the feed forward neural
  1088. 43:03network of another block are different.
  1089. 43:06Each encoder block has its own parameter
  1090. 43:09values which keep changing during back
  1091. 43:11propagation. Please remember this.
  1092. 43:14Okay?
  1093. 43:15Fine?
  1094. 43:16So,
  1095. 43:20whatever the output everyone which we
  1096. 43:22got in the sixth encoder, this will go
  1097. 43:25to the decoder.
  1098. 43:27Okay? And that output obviously will be
  1099. 43:29of 3 cross 512 dimension.
  1100. 43:33Just to summarize all these things all
  1101. 43:34of you,
  1102. 43:35just to summarize,
  1103. 43:37let me show you.
  1104. 43:40We start from our input example, right?
  1105. 43:43We started from our input example. What
  1106. 43:45was our input? As I've given you example
  1107. 43:47here everyone, the input was this, I am
  1108. 43:50Yogesh.
  1109. 43:51In the input block we do
  1110. 43:53three operations,
  1111. 43:55tokenization,
  1112. 43:56embedding, and positional encoding.
  1113. 44:02And from there we get vectors. Which
  1114. 44:04one? X1, X2, X3.
  1115. 44:08First encoder block
  1116. 44:10in that what we did, we applied
  1117. 44:12multi-head attention
  1118. 44:14in the first encoder block, right?
  1119. 44:17As I've told you, six encoders are
  1120. 44:18there. So, in the first encoder block
  1121. 44:19you can see after the input
  1122. 44:22will come across the multi-head
  1123. 44:25attention as soon as it enters the first
  1124. 44:27encoder block.
  1125. 44:28That means what is given here.
  1126. 44:31Right? X1, X2, X3 will go through
  1127. 44:33multi-head attention. That is multiple
  1128. 44:35self-attentions.
  1129. 44:38Then
  1130. 44:40you know, we have done add
  1131. 44:43residual
  1132. 44:45right? Add residual and then layer
  1133. 44:48normalization.
  1134. 44:51These operations we have done.
  1135. 44:53Adding through residual and layer
  1136. 44:55normalization. That is nothing but this
  1137. 44:57one.
  1138. 44:58Add and norm. And you see residual
  1139. 45:00connection, skip connection. What are
  1140. 45:02the meaning of this? This also we have
  1141. 45:03discussed.
  1142. 45:05Then
  1143. 45:07what we did, we applied feed forward
  1144. 45:09neural network.
  1145. 45:11You see?
  1146. 45:13We were here. Now, feed forward neural
  1147. 45:15network.
  1148. 45:17And then add residual, add residual.
  1149. 45:22And layer normalization again.
  1150. 45:26That is nothing but
  1151. 45:29you see it here.
  1152. 45:31Okay?
  1153. 45:33Feed forward neural network.
  1154. 45:36Right? And then
  1155. 45:38what we have done is we have done
  1156. 45:39addition and layer normalization, layer
  1157. 45:42normalization again.
  1158. 45:45Output becomes
  1159. 45:46the output of the first encoder block
  1160. 45:48becomes the input to the second encoder
  1161. 45:50block. And this repeats how many times?
  1162. 45:53Six times for all six encoder blocks.
  1163. 45:58Because we already
  1164. 46:01discussed that there are six encoder
  1165. 46:02blocks like this.
  1166. 46:04And finally, everyone, the output from
  1167. 46:06the last encoder last encoder block goes
  1168. 46:10to the decoder.
  1169. 46:13That means in the original architecture,
  1170. 46:16if I want to show you everyone,
  1171. 46:18after six encoder, the output will come
  1172. 46:20here, and this output will go here in
  1173. 46:24the decoder. You see? In the decoder.
  1174. 46:30Okay? A very important observation. See,
  1175. 46:32this is all summary whatever we are
  1176. 46:33discussing till now, okay? But a very
  1177. 46:35important observation, whenever you look
  1178. 46:37in this entire pipeline,
  1179. 46:40if you take a sample at any point after
  1180. 46:43input processing,
  1181. 46:45you'll always get
  1182. 46:46a 3 cross 512
  1183. 46:50vector. This never changes. Everywhere.
  1184. 46:53Right? From here from here input
  1185. 46:56processing, everyone, you'll always get
  1186. 46:573 cross 512.
  1187. 47:00When you leave this point, I've told
  1188. 47:02you, right? As a final output as well,
  1189. 47:04you got what? 3 cross 512 vector.
  1190. 47:07So, when
  1191. 47:09when you leave this particular point,
  1192. 47:10you get 3 cross 512. Like this, when you
  1193. 47:13pass through last encoder block here
  1194. 47:15like this, the output you get is 3 cross
  1195. 47:17512. And this is what you send to the
  1196. 47:19decoder, as I've told you.
  1197. 47:21So, this is how
  1198. 47:23this is how
  1199. 47:26the encoder part of transformer
  1200. 47:29architecture works.
  1201. 47:32We are focused on the encoder part of
  1202. 47:35the transformer architecture.
  1203. 47:38I hope so.
  1204. 47:40You are able to understand the working.
  1205. 47:42If not, please go and please revise.
  1206. 47:46Okay? In the next video, everyone, we
  1207. 47:48will discuss about the decoder part.
  1208. 47:50I'll provide the link for the next video
  1209. 47:53in the description itself. Okay? So,
  1210. 47:55that's it from my side.
  1211. 47:56Thank you everyone.
  1212. 47:58Thanks a lot.

About this transcript

This page contains the full transcript of Transformer Architecture Encoder Explained from Scratch (Pen & Paper Deep Dive) - Part1 by yogesh murumkar, generated from the public captions YouTube serves with the video. The transcript has 6,056 words across 1,212 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.