Transformer:一次注意力怎么算?Transformer: Calculate One Attention Step
区分 query、key、value,计算三个权重的和,并解释因果遮罩为什么不能偷看未来。Distinguish queries, keys and values, check that weights sum to one and explain why causal masking hides the future.
先在纸上猜结果,再按按钮检验。Predict on paper before checking with the buttons.
数值是人为设置的单头示例,没有学到词义。完整 Transformer 还包含学习到的投影、多头、位置表示、前馈层、残差等;这里不训练完整模型。These are hand-set numbers for one attention head without learned word meanings. A complete Transformer also has learned projections, multiple heads, position information, feed-forward layers and residuals.