ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
1
[Description] Seq2Seq with Attention allows decoder to focus on relevant encoder states, solving the bottleneck problem.
2
Seq2Seq + Attention (Bahdanau Attention)
3
4
Original Seq2Seq limitation: Compressing long sequence into one fixed vector → Information loss
5
Solution: Allow Decoder to 'reference' all Encoder states at each step
6
7
8
═══ Original Seq2Seq vs Seq2Seq + Attention ═══
9
10
Original Seq2Seq:
11
Encoder: I → love → you → [Context Vector] → Decoder
12
↑ Only one fixed vector is passed
13
14
Seq2Seq + Attention:
15
Encoder: I → love → you
16
h₁ h₂ h₃ ← Store all hidden states
17
↓ ↓ ↓
18
Decoder: Decide where to look with attention at each step
19
20
21
═══ Attention Mechanism (Bahdanau) ═══
22
23
1. Alignment Score:
e_{t,i} = v^T · tanh(W_a · s_{t-1} + U_a · h_i)
24
2. Attention Weights:α_{t,i} = softmax(e_{t,i})
25
3. Context Vector:c_t = Σ α_{t,i} · h_i
26
4. Decoder Input:
s_t = tanh(W·e_t + U·s_{t-1} + C·c_t + b)
27
28
29
═══ Architecture Diagram ═══
30
31
ENCODER
32
Iloveyou
33
↓↓↓
34
h₁→h₂→h₃
35
↘↓↙
36
Attention
37
↓
38
DECODER
39
c_t+s_{t-1}→s_t→output
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100