An attention mechanism is a method that enables neural networks to dynamically weight different parts of an input.
In doing so, so-called "attention scores" are calculated, indicating how relevant a particular element is compared to others.
These scores are often normalized using a softmax function, so they can be interpreted as probabilities.
The mechanism is frequently used in sequence-to-sequence models, such as in machine translation, to flexibly focus on important words.
Modern architectures like the Transformer are entirely based on attention, enabling parallel processing and better context consideration.