# Self-Attention

- **Canonical URL:** https://getaimath.com/dictionary/self-attention/
- **Topics:** [Transformer Architecture](https://getaimath.com/dictionary/category/transformer-architecture/)
- **Last updated:** 2026-11-25

## What is Self-Attention?

**In one sentence:** Self-attention lets every word in a sentence look at every other word and decide which ones matter most for understanding it.

When the model reads "The dog chased the ball because it was bouncy," self-attention helps "it" pay strong attention to "ball." Each word gathers useful information from the others, so its meaning gets richer. This happens inside every layer of a Transformer.

![Transformers & Attention: The Smart Highlighter — Simple cartoon diagram showing how a Transformer reads a whole sentence at once and shines a bright highlighter beam from the word "IT" back to "trophy" so it knows what "IT" means.](https://getaimath.com/diagrams/transformer-architecture.png)
*Napkin Diagram (Transformer Architecture): Older AI read word-by-word and often lost track of earlier words; a Transformer highlights which words connect to which.*

## What is an example of Self-Attention?

In "bank of the river," self-attention links "bank" to "river," so the model knows it is not a money bank.

## Why does Self-Attention matter?

Self-attention is the key idea that made Transformers, and today's LLMs, so powerful.

## Related Concepts

- [Transformer](https://getaimath.com/dictionary/transformer/): A Transformer is a type of neural network design that reads all the words in a passage at once and works out how they relate, using attention.
- [Attention Mechanism](https://getaimath.com/dictionary/attention-mechanism/): An attention mechanism is a way for a model to focus on the most useful parts of its input when producing each piece of output.
- [Multi-Head Attention (MHA)](https://getaimath.com/dictionary/multi-head-attention-mha/): Multi-head attention runs several attention processes side by side, so the model can notice different kinds of relationships at once.
- [Query (Q)](https://getaimath.com/dictionary/query-q/): In attention, the query is a list of numbers that represents what a word is looking for in other words.
- [Key (K)](https://getaimath.com/dictionary/key-k/): In attention, a key is a list of numbers that describes what a word offers, so queries can find it.
- [Value (V)](https://getaimath.com/dictionary/value-v/): In attention, a value is the actual information a word passes along when another word pays attention to it.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/self-attention/)
