🏠 Trang chính
·
← T4-L03: RNN/LSTM
·
T4-L04: Transformer
·
T5-L01: Text vectorization →
T4-L04 — Transformer & Attention
Self-attention · Multi-head · Positional encoding · Transformer architecture
1. Self-Attention — Attention heatmap tương tác
Câu ví dụ
Click token để xem attention từ token đó:
Câu:
the cat sat on the mat
I saw the man with the telescope
the animal did not cross because it was tired
Temperature (softmax):
1.00
Attention matrix A[i,j]
Attention từ token đã chọn
2. Multi-Head Attention — 8 heads khác nhau
d_model:
512 (paper gốc)
256
128
Số heads:
8
4
2
1
3. Positional Encoding — Sinusoidal
d_model:
32
Max pos:
20
Bảng giá trị PE (d=4, pos=0..4)
4. Transformer Architecture
Chế độ:
Encoder + Decoder (full)
Encoder only (BERT)
Decoder only (GPT)
5. RNN vs Transformer — Complexity so sánh
Độ dài sequence n:
100