In plain English
When reading the sentence 'The bank of the river,' attention helps the model know that 'bank' relates to 'river' rather than money. It acts like an adjustable spotlight, letting the AI focus on the most relevant words in a prompt regardless of their distance apart.
Real-world example
Allowing translation models to track grammatical agreement across long sentences with inverted word orders.
Technical definition
The attention mechanism computes a weighted sum of value vectors based on the compatibility scores between query and key vectors. Scaled dot-product attention normalizes these scores using softmax to yield probability distributions over sequence elements. Multi-head variants project queries, keys, and values into multiple subspaces to jointly attend to information from different representation positions.