Skip to main contentSkip to navigationSkip to footer
DigiTransact AI Education Centre Start Learning

Level 3 · Module 16 · 10 minutes

Attention: how models track context

What you will learn
  • Explain in plain words what attention does.
  • Explain why attention helps with distant words in a passage.
  • Explain why attention weights are not the same as human attention or reasons.

Attention is the part of a modern language model that lets each token use information from other tokens. Without it, a token would be handled mostly on its own, and the model would struggle with a pronoun whose meaning depends on an earlier noun, or with a fact stated far above the current sentence.

Weighing what matters

For each token, the model compares it with the other tokens in the window and gives each one a weight. The weights show how relevant that other token seems for understanding the current one. The model then mixes information from the other tokens according to those weights. Tokens judged irrelevant get little influence, and relevant tokens get more.

The comparison is learned during training. Nobody writes a rule that the word it should look at the previous noun. Instead, examples teach the weights that make useful connections. Different parts of the model, often called heads, can learn different patterns: one may link a pronoun to its noun, another may link an adjective to the thing it describes.

Why it helps with long text

Older sequence designs passed information along step by step, so distant connections were weaker. Attention can connect two tokens directly, whatever their distance, as long as both are inside the context window. That makes it easier to follow a long set of instructions or a document with a fact far from its use.

Attention is not free. Each token compares with many others, so longer contexts take more computation. The model also has a fixed window, and information outside it is not available.

Attention is not human attention

Attention weights are numbers inside a calculation. They show where information was mixed, not what the model understood or why it chose an answer. A high weight does not prove a fair or correct reason. The term borrows a word from human attention, but the mechanism is arithmetic.

A teaching picture, not a commercial system

Lessons draw a few arrows from one word to a few others. Real commercial models run many attention patterns across many layers and very long sequences. The arrows are a simplified educational picture, not the actual computation.

Common misconception

Attention means the model consciously focuses on the most important words, like a person choosing what to look at. Attention is a learned weighting calculation. It mixes information by numerical relevance, with no conscious focus and no guarantee that the weights reflect a sensible reason.

Guided practice

Write a sentence with a pronoun and two possible nouns. Draw arrows from the pronoun to each noun and give each arrow a rough weight. Change one word and redraw the arrows to show how the weights could shift. Explain in one sentence why the arrows are only a teaching picture. This is a paper exercise; no model is trained.

Knowledge check

1. What does attention let a token do?

2. Why is attention useful for long documents?

3. What do attention weights show?

Independent practice

Write a short example from your own work or daily life and decide whether it is AI, ordinary software or a mixture. Then explain why. Save it in your notes; no account is required.

Last reviewed: · Report a problem

Last updated: