Neural networks
Attention is a mechanism that lets a neural network focus on the most relevant parts of its input, such as which earlier words matter for the next one.
When you read 'The trophy did not fit in the suitcase because it was too big,' you instantly know 'it' means the trophy. You paid attention to the right word. Attention in a neural network is a learned version of this. For every word, the model scores how relevant each other word is, then uses those scores to combine their information.
The scores are computed from the words themselves, so they change with context. In one sentence, 'bank' attends to 'river'; in another, to 'money.' A transformer runs many attention 'heads' in parallel, each learning to track a different kind of relationship, such as grammar, meaning, or position.
Attention is also why context windows have limits. Comparing every word with every other word grows quickly as text gets longer, which costs memory and time. Much research goes into making attention cheaper so models can read whole books at once.
Asked 'What did Maria give her brother?' after a long story, the model's attention lights up on the one sentence where Maria hands over the keys.