Scaled Dot-Product Attention 的主要目的:别让 softmax 一开始就饱和
除以 √d_k 不是为了把点积变成余弦相似度,也不是单纯防溢出;它控制 logits 的方差,让 softmax 在训练初期仍有可用的梯度。
5 posts
除以 √d_k 不是为了把点积变成余弦相似度,也不是单纯防溢出;它控制 logits 的方差,让 softmax 在训练初期仍有可用的梯度。
BERT is neither encoder-decoder nor decoder-only. It stacks Transformer encoders with bidirectional self-attention. This article compares BERT, GPT and T5, and explains why BERT cannot generate freely like GPT.
Attention mixes information between tokens; the FFN transforms each token independently. This article explains where the FFN sits in a Transformer block, position-wise computation, the 4x expansion, GELU/SwiGLU, parameter counts, and why the FFN often holds most of a layer's parameters.
Last post: attention is one 'soft lookup'. So why multi-head at all? And why is it order-blind, needing positional encoding to rescue it? Two things, explained with minimal code.
Don't be scared by Transformer or 'Attention Is All You Need' — start with the smallest piece: attention. Explained with the hash table you already know, plus 20 lines of numpy so you can compute it yourself.
Subscribe via RSS to get new posts automatically.
Technical questions, feedback and leads: use the guestbook.