In a nutshell
Attention lets a model decide, for each item, which other items matter right now. Every item produces a query, a key, and a value; the query is compared to all keys by dot product to get scores, a softmax turns those scores into attention weights that sum to 1, and the output is the weighted sum of the values. So instead of treating all inputs equally, the model dynamically pulls in exactly the context it needs — the core operation inside transformers.