Skip to content

Commit 3baa0c9

Browse files
committed
master: Why transformer is better than basic seq2seq architecture.
1 parent dd74698 commit 3baa0c9

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,26 @@ the translation and as we know, with large sequences, the information tends to g
77
LSTMs and GRUs can help to overcome the vanishing gradient problem, but even those will fail to process long sequences.<br><br>
88
<img src="../images/1. drawbacks of seq2seq.png" width="50%"></img><br>
99

10-
2.
10+
2. In a conventional Encoder-decoder architeture, the model would again take T timesteps to compute the translation.<br><br>
11+
<img src="../images/2. basic encoder-decoder.png" width="50%"></img><br>
12+
13+
## Transformers - Basics
14+
```buildoutcfg
15+
TLDR:
16+
1. In RNNs, parallel computing is difficult to implement.
17+
2. For long sequences in RNN, there is loss of information.
18+
3. RNNs face the problem of vanishing gradient.
19+
4. Transformer architecture is the solution.
20+
```
21+
22+
1. Transformers are based on attention and don't require any sequential computation per layer, only one single step is needed.
23+
2. Additionally, the gradient steps that need to be taken from the last output to the first input in a transformer is just one.
24+
3. Transformers don't suffer from vanishing gradients problems that are related to the length of the sequences.<br><br>
25+
<img src="../images/3. transformer model.png" width="50%"></img><br>
26+
4. Transformer differs from sequence to sequence by using multi-head attention layers instead of recurrent layers.<br><br>
27+
<img src="../images/4. multi-head attention.png" width="50%"></img><br>
28+
29+
5. Transformers also use positional encoding to capture sequential information. The positional encoding out puts values to be added to the embeddings. That's where every input word that is given to the model you have some of the information about it's order and the position.
30+
<img src="../images/5. positional encoding.png" width="50%"></img><br>
31+
32+
6. Unlike the recurrent layer, the multi-head attention layer computes the outputs of each inputs in the sequence independently then it allows us to parallelize the computation. But it fails to model the sequential information for a given sequence. That is why you need to incorporate the positional encoding stage into the transformer model.
311 KB
Loading
302 KB
Loading
233 KB
Loading
211 KB
Loading

0 commit comments

Comments
 (0)