查询向量 · “我现在需要找什么”Query · “What Am I Looking For Right Now?”
current position → Query direction → candidate ranking
查询向量(Query,Q)是当前位置提出“我需要找什么”的向量表示。它像一束可转向的探照灯:方向改变,匹配到的 Key 与注意力候选排序也跟着改变。A Query (Q) is the vector representation of what the current position needs to find. Think of it as an aimable spotlight: change its direction and the matching Keys and attention ranking change with it.
01 · 手电筒先决定照哪里01 · The flashlight aims before it finds
黑暗房间里有三个标签,只转动灯头,最显眼的候选为什么会换位?Three labels sit in a dark room. Why does turning only the lamp reorder which candidate stands out?
Q⌁
02旋转 Query 探照灯Rotate the Query Spotlight
探照灯隐喻Spotlight metaphor
当前需要Current need
什么
由 Q 方向表达encoded by Q direction
候选第 1Top candidate
皮球
—
最大线宽Max line width
—
1.5 + weight × 10
复用 S3 线宽语法:lineWidth = 1.5 + weight × 10。灯光强弱与候选线宽都来自同一个权重。S3 line grammar reused: lineWidth = 1.5 + weight × 10. Spotlight intensity and candidate line width come from the same weight.
03Query 探照灯的 4 个零件Four Parts of the Query Spotlight
提出需要,不携带答案Encodes a need, not an answer
PART 01
当前位置Current position
“它”需要从上下文补足某类信息。“It” needs a kind of information from context.
PART 02
Query
Q 用方向表达“此刻要找什么”。Q uses direction to encode what is sought now.
PART 03
Key
候选 Key 声明自己适合怎样被匹配。Candidate Keys describe how they can be matched.
PART 04
匹配排序Match ranking
方向越对齐,分数与归一化权重越高。Closer alignment produces a higher score and normalized weight.
04最小机制:用 Q 与每个 K 做匹配Minimal Mechanism: Match Q Against Every K
scorei = Q · Ki
Q angle ↔ Ki angle → scorei → weighti
此页用二维方向和 cosine 做玩具匹配。旋转 Q 会改变所有分数,但 Key 本身保持不动。This toy uses 2D direction and cosine matching. Rotating Q changes every score while the Keys stay fixed.
旋转 QRotate Q改变所求方向Change the need direction
重算对齐Recompute alignment三项分数换位Three scores reorder
重画线宽Redraw line widths候选排名更新Ranking updates
05边界实验:把灯指向三个 Key 之外Boundary Test: Aim Away from Every Key
主动制造失败Create a failure
Query 不保证一定找到好匹配A Query does not guarantee a good match
把 Q 转到 180°,背对当前三个 Key。softmax 仍会分完权重,但“有第一名”不等于“第一名匹配良好”。Turn Q to 180°, away from the three Keys. Softmax still distributes all weight, but having a first place does not mean the match is good.
尚未执行。当前 Q 正对“皮球”Key。Not run yet. Q currently points at the ball Key.
✗ Query 就是用户输入的问句。A Query is the user's written question. → ✓ 它是当前位置内部生成的匹配向量。It is an internal matching vector for a position.
✗ Query 里已经装着答案。The Query already contains the answer. → ✓ Q 表达需要,内容要从 Value 汇总。Q expresses a need; content comes from Values.
✗ 排序第一就一定高度匹配。Rank one must be a strong match. → ✓ 它可能只是几个弱匹配里最高。It may only be the best among weak matches.
06 · 一句话带走06 · One line to keep
Query 是当前位置提出“我需要找什么”的向量;旋转探照灯,就能检验 Key 排名与注意力线宽怎样一起换位。A Query is the current position's vector for “what I need to find.” Rotate the spotlight to verify how Key ranking and attention line width move together.