- A mechanism that randomly selects important words in a sequence?
- A mechanism that weighs the importance of different parts of the input sequence?
- A filter that removes stop words from the input sequence?
- Attention, a technique that extends the context window of the model.

- Attention enables each output token to “look at” the entire input sequence and assign higher influence to relevant tokens for that particular prediction.
- This allows transformers to capture long-range dependencies and contextual relationships without relying on recurrence.
- Each token position has Query (Q), Key (K), and Value (V) vectors (produced by learned linear projections).
- For a given query, compute similarity scores with all keys (dot products).
- Scale the scores (typically by sqrt(d_k)), then apply softmax to obtain attention weights.
- Use the weights to compute a weighted sum of the values — that becomes the attention output for the query position.
Additional notes
- Multi-head attention: multiple attention “heads” use different projections so the model can capture several relationship types simultaneously (syntax, coreference, positional signals, etc.).
- Attention is learned during training — the model optimizes the projections that produce Q, K, V to maximize downstream performance.
- Attention is not a stop-word remover nor a random selector: it’s a differentiable, data-driven weighting mechanism.
Attention is a learned, dynamic weighting mechanism that lets transformers focus on the most relevant tokens for each prediction — effectively a configurable spotlight over the input sequence.
- Attention Is All You Need (original Transformer paper): https://arxiv.org/abs/1706.03762
- Illustrated Transformer (visual explanation): https://jalammar.github.io/illustrated-transformer/
- Transformer model family and docs: https://huggingface.co/docs/transformers/