Language models

What is a transformer?

In short

A transformer is the type of neural network design behind today's language models; it reads a whole text at once and works out which words relate to which.

The transformer was introduced by Google researchers in the 2017 paper "Attention Is All You Need". Its key idea, attention, lets the model weigh every word against every other word in the text. That made models both better at language and faster to train, which led to GPT, Claude, Gemini and others.

Mini course

3 short lessons, about 2 minutes in total

  1. The design behind modern AI
  2. Attention, simply put
  3. Why it matters to you

Lesson 1

The design behind modern AI

The transformer is a neural network design introduced by Google researchers in the 2017 paper 'Attention Is All You Need'. It is the T in GPT and the basis of nearly every leading language model, and it is used more and more for images, audio, video and even biology.

A transformer turns tokens into numbers, lets every token look at every other through attention, and repeats this in many layers to predict the next token

Tap a box to open that concept

Its big advantage: it can be trained efficiently on huge amounts of data using many chips in parallel.

Lesson 2

Attention, simply put

In the sentence 'The bank was closed because the river flooded', the word 'bank' means riverbank because of 'river'. Attention lets the model weigh how much each word should influence the understanding of every other word, across the whole text at once. Stacking many layers of attention lets the model build up grammar, facts and reasoning.

Earlier designs read text step by step and struggled with long-range links.

Lesson 3

Why it matters to you

Transformers explain many everyday traits of AI tools: why they work on tokens, why there is a context window limit, why longer inputs cost more, and why models are so good at language. You do not need to understand the math to use them, but knowing the basic idea helps you judge claims about new models.

  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 createTransformerLarge 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 Transformer sits in a company's AI setup

Researchers are exploring other designs too, but transformers remain dominant.

An everyday example

In "The trophy did not fit in the suitcase because it was too big", attention helps the model work out that "it" means the trophy.

How companies use it

Companies rarely deal with transformers directly, but almost every modern AI text, translation and speech tool is built on one.

Frequently asked questions

What does the T in GPT stand for?

Transformer: GPT means Generative Pre-trained Transformer.

Is a transformer only for text?

A transformer is not only for text. The same design is used for images, sound, video and even protein structures.

Do we need to understand transformers to use AI?

Using AI does not require understanding transformers. It is useful background, not a requirement.

In depth: Transformer

The full picture, about 4 minutes of reading

What a transformer is

A transformer is a design for a neural network, the kind of computer model that learns patterns from examples. It is the design behind almost all of today's large language models, including those in ChatGPT, Claude and Gemini. The T in GPT stands for transformer.

What sets it apart is how it reads. Instead of going through a text one word at a time from left to right, a transformer looks at the whole text at once and works out which words relate to which. That ability to see connections across a whole passage is what lets it understand context, follow long instructions and write text that hangs together.

The design was introduced by researchers at Google in a 2017 paper called Attention Is All You Need.

The problem it solved

Before transformers, language models mostly used recurrent networks. These read text word by word and carried a kind of running memory forward. It worked, but it had two problems.

The first was forgetting. By the time the network reached the end of a long sentence or paragraph, the memory of the beginning had faded. Connecting a word to something said much earlier was hard.

The second was speed. Because each word had to wait for the one before it, the work could not be split up and done in parallel. Training was slow, which limited how much text a model could learn from.

The transformer solved both at once. It lets every word look directly at every other word, however far apart, and it processes all of them at the same time. That made models both better at language and much faster to train on huge amounts of text.

Attention, simply put

The key idea in a transformer is called attention. For each word, the model asks: which other words in this text help me understand this one, and how much?

Take the sentence the trophy did not fit in the suitcase because it was too big. To understand it, you need to know that it means the trophy, not the suitcase. Attention lets the model weigh it against every other word and give the most weight to trophy, because the pattern too big and did not fit points there. Change big to small, and the weight shifts to suitcase.

A transformer does this many times in parallel, with several attention heads that each learn to look for different kinds of relationships, such as grammar, meaning or who did what. It then repeats the whole process in many layers stacked on top of each other, so each layer builds a richer understanding on the one below.

How a language model uses it

Text is first split into tokens, small pieces that are often a word or part of a word. Each token is turned into a list of numbers that represents it, and information about its position in the text is added, because attention by itself does not know word order.

The tokens then pass through the stack of attention layers. By the end, each token's numbers carry information about its meaning in this particular context.

A language model uses this to predict the next token. It picks one, adds it to the text and runs the process again for the next. Answers are built one token at a time this way. Training on enormous amounts of text, where the model constantly practices predicting the next token, is what gives it its broad knowledge and writing ability.

Strengths and limits

Transformers turned out to scale remarkably well. Making them bigger and training them on more data kept making them better, which is a large part of why AI improved so quickly in recent years. The same design also works beyond text, for images, sound, video and code.

The main cost is that attention compares every token with every other token. Doubling the length of a text roughly quadruples that work. This is one reason long documents are expensive to process and why there is a limit, called the context window, on how much text a model can consider at once. Much research goes into making this more efficient.

Transformers also inherit the limits of how they are trained. They predict likely text, which is not the same as checking facts, so they can produce confident mistakes.

What it means for a small business

A small business does not need to know how to build a transformer, any more than it needs to know how to build an engine to drive a car. But knowing the basic idea helps explain everyday behavior of AI tools.

Because transformers read the whole text at once, context matters a great deal. Giving the model the relevant background, examples and documents in the prompt usually improves answers far more than clever wording. Because there is a limit to how much text they can consider, very long documents may need to be split or summarized. And because they predict likely text rather than look up facts, important details should be checked.

These three points, give good context, mind the length and check the facts, cover much of what makes AI tools work well in daily business use.

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

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

Book a call