Language models

What is attention in AI?

In short

Attention is the technique that lets an AI model weigh which parts of a text matter most for understanding each word. It is the core idea behind the transformer, the design used by almost all modern language models.

In the sentence 'The bank was closed because of the flood', attention helps the model link 'bank' to 'flood' and read it as a river bank or a building depending on context. Every word looks at every other word and decides how much to focus on it.

Mini course

3 short lessons, about 2 minutes in total

  1. Reading in context
  2. The breakthrough
  3. What it means in practice

Lesson 1

Reading in context

Words change meaning with their neighbors. Older AI models read text one word at a time and forgot the start of long sentences. Attention lets the model look at all the words at once and, for each word, decide which others are relevant.

Inside the model
Attention
Transformer layers
Next word
For every word, attention weighs which other words in the text matter most, so meaning is read in context

Tap a box to open that concept

The model learns these weightings during training, from billions of examples of how words relate.

Lesson 2

The breakthrough

In 2017, researchers at Google published a design called the transformer, built almost entirely on attention. It could be trained on far more data, much faster, using many chips in parallel. Every major language model since, including GPT, Claude and Gemini, builds on that design.

In short, attention is a big part of why AI suddenly got so much better.

Lesson 3

What it means in practice

Because every word attends to many others, longer inputs mean much more computing. That is one reason context windows have limits and long prompts cost more. Models also tend to pay less attention to details in the middle of very long inputs.

  1. Customers find youHow customers and AI tools find the companySEOGEOGoogle AI Overviews
  2. AI in daily workTools staff and customers useChatbotAI copilotVoice AI
  3. Building blocksHow AI connects to data and systemsRAG (retrieval-augmented generation)AI agentMCP (Model Context Protocol)
  4. AI modelsThe models that understand and createAttentionLarge language model (LLM)Generative AIMachine learning
  5. DataCompany data, gathered and cleanedData warehouseETLData quality
  6. InfrastructureCloud, networks and systems underneathCloud computingDatabaseAPI key
Trust and rulesSecurity, law and control in every layerGDPR and AIEU AI ActAI guardrails
Where Attention sits in a company's AI setup

Practical tip: put the most important instructions and facts at the start or end of a long prompt, and send only what is needed.

An everyday example

When you ask a model to summarize a long contract, attention is what lets it connect a clause on page 12 to a definition on page 2.

How companies use it

Business users do not tune attention directly, but it explains two practical things: why models understand context so well, and why very long inputs cost more and can make models miss details.

Frequently asked questions

Where does the name come from?

From a 2017 research paper titled 'Attention Is All You Need', which introduced the transformer.

Why do long texts cost more?

Because each word is compared with many others, the work grows quickly as the text gets longer.

Does attention mean the model understands like a human?

Attention does not mean a model understands like a human. Attention is a mathematical weighting of connections that works remarkably well, but it is not human understanding.

In depth: Attention

The full picture, about 4 minutes of reading

The problem of reading in context

Words rarely mean much on their own. "It" can point to almost anything. "Bank" can be a building or the edge of a river. "Not bad" means good. People solve this without effort, by keeping the rest of the sentence, and often the rest of the page, in mind while reading each word.

Early language software read text one word at a time, from left to right, and carried a kind of running summary forward. That worked for short sentences, but the summary faded. By the end of a long paragraph, the software had largely forgotten the beginning. Attention was the idea that fixed this: instead of relying on a fading summary, let every word look directly at every other word and decide which ones matter for its meaning.

How attention works, in plain steps

First, the text is split into tokens, which are words or pieces of words, and each token is turned into a list of numbers that stands for its meaning.

Second, each token asks a question of all the others. In the model, this is done with three small sets of numbers per token, often called query, key and value. You can think of the query as "what am I looking for?", the key as "what do I contain?" and the value as "what do I pass on if you pick me?"

Third, the model compares each query with every key and gives each pair a score. High scores mean "this word is relevant to me". In "The bank was closed because of the flood", the token "bank" gives a high score to "flood".

Fourth, each token builds a new version of itself by mixing in the values of the tokens it scored highly. "Bank" now carries a hint of "river". This happens many times in parallel, in layers stacked on top of each other, so the model can pick up grammar in one place, topic in another and long-distance links in a third.

Why it changed AI

Attention became the center of a design called the transformer, described in a 2017 research paper from Google researchers. The transformer dropped the old one-word-at-a-time reading and relied on attention alone. That had two big effects.

The first was quality. Because any word can look at any other word directly, the model can connect a pronoun with a name several paragraphs earlier, or a clause on page 12 with a definition on page 2.

The second was speed of training. Reading one word at a time is hard to split across many processors. Attention compares all words at once, which suits graphics processors (GPUs), the chips that do many small calculations side by side. That made it practical to train much larger models on much more text, and it is a big reason why today's language models, including the ones behind ChatGPT, Claude and Gemini, exist at all.

The cost of looking at everything

Letting every token look at every other token has a price. If a text doubles in length, the number of comparisons roughly quadruples, because each new token must be compared with all the others. Long documents therefore need much more memory and computing power than short ones, which is a big part of why AI services charge per token and why very long inputs are slower.

Model makers use many tricks to soften this cost, and today's models can take in very long texts, such as whole reports or many documents at once. But a large context window, the amount of text a model can consider in one go, does not mean the model pays equal attention to all of it. Tests show that models can overlook details buried in the middle of a long input, especially when many similar passages compete for attention.

What attention is not

The name invites a human comparison, but attention in a model is arithmetic, not awareness. It is a way of weighting numbers so that relevant information flows to where it is needed. It does not mean the model understands the text the way a person does, and it does not mean the model focuses on what you think is important.

It also does not explain the model's choices in a simple way. Researchers can sometimes see which words a model weighted heavily, and that can hint at why it answered as it did, but attention patterns are spread over many layers and are hard to read with confidence. Treat claims such as "the model paid attention to this sentence, so it understood it" with care.

What it means for a small business

Nobody in a small business needs to tune attention. It is useful to know about because it explains several everyday experiences with AI tools.

It explains why models handle context so well: you can paste a messy email thread and get a sensible summary, because each part can be linked to the others. It explains why long inputs cost more and run slower, which matters if you pay per token or send large documents often. And it explains why stuffing everything into one prompt is not always wise. Giving the model the few relevant pages, clearly marked, usually beats handing over a hundred pages and hoping it finds the right line. Put the key instruction where it is easy to find, and ask the model to quote the passage it relied on, so you can check it.

Sources: Vaswani et al., Attention Is All You Need (arXiv, 2017)

Curious what this could mean for your company? Book a call.

Book a call