What Is a Transformer? The Architecture Behind Every Modern AI Model

Abstract 3D illustration of a neural network as colourful translucent geometric blocks and connected shapes

Photo: Hippopx (public domain). Illustrative image.

What is a transformer?

A transformer is a type of neural network architecture, introduced in 2017, that sits underneath virtually every modern AI model: GPT, Claude, Gemini, and every large language model you have used are transformers. It is not a product and not a chatbot — it is the design that makes the chatbot possible. The paper that introduced it, “Attention Is All You Need” by Vaswani and colleagues at Google, has been cited more than 150,000 times, making it one of the most influential papers in the history of computing.

The idea that gives the transformer its name is attention — specifically self-attention. When a transformer reads a sentence, every word looks at every other word in the passage and assigns each one a weight: how much does this word matter for understanding that word? In “the animal didn’t cross the street because it was too tired”, attention is what lets the model work out that “it” refers to the animal, not the street. The model does this for every word, in every layer, dozens of times over — and the pattern of weights is what we mean, loosely, when we say the model “understands” the text.

Why did it replace what came before?

Before transformers, the standard design for language was the recurrent neural network — RNNs, and their longer-memory cousins, LSTMs. These read text one word at a time, in order, carrying a summary forward. That made them slow to train (you cannot parallelise a sequence) and forgetful over long passages (the summary gets diluted with every step). Transformers removed the sequence entirely: because every word attends to every other word at once, the whole passage can be processed in parallel, which is exactly what GPUs are good at. Training that once took months could be done in days, and models could scale from millions of parameters to hundreds of billions. The mixture-of-experts designs in today’s biggest models are still transformers underneath — the attention machinery is the same.

What does a transformer look like?

The original design has two halves. The encoder reads the input and builds a rich representation of it; the decoder generates the output one piece at a time, attending both to what it has already written and to the encoder’s representation. Modern language models mostly use the decoder half alone: they predict the next word, then feed it back in and predict the next, which is how a chatbot writes its reply. Around the attention layers sit feed-forward networks that process each position, and the whole stack repeats — 12 layers in the original paper, 96 or more in today’s frontier models. The cost of attention grows with the square of the passage length, which is one reason a context window has a limit at all: double the passage, quadruple the attention work.

Frequently asked questions

Is a transformer the same as an LLM? No. A transformer is an architecture; an LLM is a model built with that architecture and trained on vast amounts of text. Every LLM is a transformer, but not every transformer is an LLM — transformers also power image, audio and video models.

What is attention in simple terms? It is a weighting: for each word, the model decides how much attention to pay to every other word when working out what it means. “It” in the sentence above pays most attention to “animal”. Attention is learned from data, not programmed in.

Who invented the transformer? A team at Google led by Ashish Vaswani, in the 2017 paper “Attention Is All You Need”. The eight authors — Vaswani, Shazeer, Parmar, Uszkoreit, Jones, Gomez, Kaiser and Polosukhin — were all at Google Research or Google Brain at the time.

Why does the transformer matter for ChatGPT? Without it, there is no ChatGPT. The parallel training that transformers allow is what made it possible to train models on trillions of words, and scale is what turned a research curiosity into a useful assistant.

Sources

  • transformer
  • explainer
  • attention
  • LLM
  • neural networks

Related articles

Guides

AI Hallucinations: Why Chatbots Make Things Up — and How to Catch Them

Chatbots invent books, misquote laws and state wrong dates in a perfect, confident tone. That behaviour is called hallucination, and it follows directly from how language models work. Why it happens, the forms it takes, and a working routine for catching it.

· hallucinations, chatbots, explainer, fact-checking, AI basics

Guides

How to Evaluate a New AI Tool Before You Trust It

New AI tools launch every week, and every launch claims to change everything. A practical checklist for testing a tool on your own real tasks before you pay, switch, or rely on it.

· AI tools, buying guide, productivity, how-to

Guides

How Does AI API Pricing Work? Token Pricing Explained in Plain English

AI models charge by the token, not by the question — and output tokens cost far more than input tokens. Here's how per-million-token pricing works, what caching and batch discounts do, and how to estimate a bill.

· AI API pricing, token pricing, AI costs, explainer, per million tokens