ORBiS TREE · ENGLISH DOCUMENT
Concepts →Attention
A mechanism that lets a neural network weigh the relevance of different positions when computing a representation.
한국어
English
This English page is a curated translation layer linked to the Korean source article. Community changes are currently made on the Korean source, where the full revision history and anonymous edit trail are preserved.
Attention computes how strongly one element of a sequence should use information from other elements. In Transformers, self-attention lets each token build a representation from other tokens in the same context.
How it works
A standard attention operation constructs query, key, and value representations. Similarity between queries and keys determines weights, and the weighted values are combined into the output. Multi-head attention performs this process in parallel across multiple learned projections.
Why it matters
Attention is central to the Transformer architecture and explains both its ability to connect distant context and much of its computational cost as sequence length grows.
Related concepts
Worked example: turn scores into weights and an output
Scaled dot-product attention in the original Transformer paper ↗ divides Q–K dot products by the square root of the key dimension, applies softmax, then combines V using those weights.[2] Q represents what a position queries, K provides comparison representations and V supplies the representations being combined. Learned projections produce these vectors; they are not literal strings or database keys.
Consider one fictional row, not a measured model. After dimension scaling, two scores are ln(2) and zero. Their exponentials are two and one, giving weights 2/3 and 1/3. With V vectors (3, 0) and (0, 6), the output is (2/3)×(3, 0) + (1/3)×(0, 6) = (2, 2). These weights allocate representation mixing within that row. They are not probabilities that the two passages are true.
A mask changes the candidates and denominator
For three fictional scores ln(2), zero and ln(4), unmasked weights are 2/7, 1/7 and 4/7. If the third is a forbidden future position, a causal mask sets its score to negative infinity. Its weight becomes zero while the remaining weights renormalize to 2/3 and 1/3. Merely appending zero to the previous weights would be incorrect.
Check permitted previous context for autoregressive generation and the task's input scope for bidirectional representations. Padding and causal masks have different purposes; input shifting and label alignment matter too. Leaking the next answer during training can produce misleading scores. Inspect a small example before interpreting evaluation results.
Questions that distinguish self-attention from cross-attention
Self-attention derives Q, K and V from the same sequence. An encoder–decoder connection where output-side Q reads input-side K and V is a cross-attention example. These mechanisms occur in different parts of the original Transformer. Multiple heads learn different projections and combine their outputs; a head is not guaranteed to represent one predetermined grammar rule or topic.
Distinguish an input embedding from a contextual representation after attention. Making a word's representation depend on its sentence differs from storing document vectors for retrieval. To read an architecture, identify the origins of Q, K and V, their dimensions, permitted positions and head-combination rule.
High weights do not establish explanations or evidence
Attention is not Explanation ↗ investigates NLP tasks where attention weights disagree with other importance measures or different weights yield similar predictions.[3] Do not extend this into a rejection of every interpretation of every model. Equally, a bright heatmap alone does not prove that a highlighted token caused the answer.
Record output changes after controlled input changes, whether the change preserves the question's meaning, and the inspected layer, head and normalization. Weight visualization differs from checking answer evidence. A model card should state the scope of the interpretation and what remains unverified.
SOURCES
Sources
-
Neural Machine Translation by Jointly Learning to Align and TranslateBahdanau et al. / arXivOpen source ↗
-
Attention Is All You NeedGoogle / NeurIPS / arXivOpen source ↗
-
Attention is not ExplanationJain and Wallace / NAACLOpen source ↗
KNOWLEDGE LINKS
Continue from here
BACKLINKS