Skip to content

Commit 10f7f96

Browse files
committed
master: multi-head attention overview.
1 parent 8310245 commit 10f7f96

File tree

10 files changed

+20
-4
lines changed

10 files changed

+20
-4
lines changed

Chapter-wise code/Code - PyTorch/7. Attention Models/2. Neural Text Summarization/1. Transformer Models/Attention Maths.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ often called *attention weights*. The shape of this matrix is `[Lq, Lk]`.<br>
4646
<img src="../images/20. attention formula.png" width="50%"></img> <br><br>
4747

4848
## Next Up
49-
Next, we will learn about different types of attention: causal attention and multi-head attention.
49+
Next, we will learn about different types of attention: [causal attention](./Causal%20Attention.md) and multi-head attention.

Chapter-wise code/Code - PyTorch/7. Attention Models/2. Neural Text Summarization/1. Transformer Models/Causal Attention.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ All other values become minus infinity. After a softmax, all minus infinities wi
2424

2525
4. The last step is the same as dot-product attention!
2626

27-
<img src="../images/25. step - 4.png" width="50%"></img><br><br>
27+
<img src="../images/25. step - 4.png" width="50%"></img><br><br>
28+
29+
## Next Up
30+
Next, we will learn about multi-head attention. You can find the read-me file for the same [here].

Chapter-wise code/Code - PyTorch/7. Attention Models/2. Neural Text Summarization/1. Transformer Models/Dot Product Attention.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ First, the word *I* is embedded, to obtain a vector representation that holds co
3131

3232
## Next Up
3333

34-
Now that we know about attention, next we will learn about *attention maths*. You can find the readme file for the same here.
34+
Now that we know about attention, next we will learn about *attention maths*. You can find the readme file for the same [here](./Attention%20Maths.md).
3535

3636

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Multi-Head Attention
2+
3+
1. Input to multi-head attention is a set of 3 values: Queries, Keys and Values.<br><br>
4+
<img src="../images/26. step -1 .png"></img><br>
5+
2. To achieve the multiple lookups, you first use a fully-connected, dense linear layer on each query, key, and value. This layer will create the representations for parallel attention heads. <br><br>
6+
<img src="../images/27. step -2 .png"></img><br>
7+
3. Here, you split these vectors into number of heads and perform attention on them as each head was different.<br><br>
8+
4. Then the result of the attention will be concatenated back together.<br><br>
9+
<img src="../images/28. step -3 .png"></img><br>
10+
5. Finally, the concatenated attention will be put through a final fully connected layer.<br><br>
11+
<img src="../images/29. step -4 .png"></img><br>
12+
6. The scale dot-product is the one used in the dot-product attention model except by the scale factor, one over square root of DK. DK is the key inquiry dimension. It's normalization prevents the gradients from the function to be extremely small when large values of D sub K are used.<br><br>
13+
<img src="../images/30. step -5 .png"></img><br>

Chapter-wise code/Code - PyTorch/7. Attention Models/2. Neural Text Summarization/1. Transformer Models/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ Some of the applications of Transformers include:
5555
<img src="../images/6. T5 model.png" width="50%"></img><br>
5656

5757
## Next-up
58-
Next, we will learn about dot-product attention. You can find the readme file here.
58+
Next, we will learn about dot-product attention. You can find the readme file [here](./Dot%20Product%20Attention.md).
48.1 KB
Loading
86.5 KB
Loading
96.4 KB
Loading
107 KB
Loading
201 KB
Loading

0 commit comments

Comments
 (0)