Transformers and LLMs

Self-Attention, explained

Self-attention is attention applied within one sequence so each token can use information from other tokens in the same input.
Back to Glossary

Part of the Semantic Notion technical glossary.

Short Definition

Self-attention is attention applied within one sequence so each token can use information from other tokens in the same input.

Intuition

Every token gets a chance to look at the surrounding context and update its representation based on what matters.

Technical Definition

Self-attention forms queries, keys, and values from the same sequence and computes context-aware token representations through weighted value aggregation.

Example

In "the animal did not cross the road because it was tired," self-attention can connect "it" to "animal."

Common Misunderstandings

Self-attention is not automatically bidirectional; causal masks can restrict future tokens.
Self-attention still needs positional information to reason about order.

Start here

Need the broader concept map?

Return to the glossary index to move from this definition into adjacent AI, ML, mathematics, and computer science terms.