Attention (Self-Attention)
A mechanism that lets a model weigh how relevant each part of the input is to every other part.
In self-attention, each token creates a query, a key and a value vector. The model compares each query with every key to get relevance scores, turns those into weights with a softmax, and uses them to mix the value vectors.
This lets the model focus on the words that matter for interpreting each word. Standard attention costs grow quadratically with sequence length, which is why long context windows are expensive.
💡 Example: In translation, attention helps the model line up each output word with the right input words.