Self-Attention

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.

Need this inside a product?

The studio builds the systems these terms describe. Tell us what you are working on.