Home Glossary Self-Attention

Self-Attention

Self-attention is a mechanism that builds a representation of each token or input element by comparing it with other elements in the same sequence. The model creates queries, keys, and values, calculates compatibility scores, normalizes them, and combines the value vectors according to those weights. This allows direct modeling of long-range relationships and supports highly parallel training, making self-attention central to transformers. Standard attention cost grows quickly with sequence length, so long-context systems may use sparse, local, compressed, or optimized implementations. Attention weights can offer clues about information flow, but they should not automatically be treated as complete explanations of why a model produced an output.

Related News