Transformer

A neural network design from Google researchers in 2017 that uses attention to process a whole sequence at once, now the basis of most language models.

A transformer is a design for neural networks that handles sequences, such as sentences, by looking at every part of the sequence at once and working out which parts matter to each other. It is the "T" in GPT, which stands for generative pre-trained transformer, and it sits underneath almost every large language model.

The key mechanism is called attention. For every word, or token, the model scores how relevant every other token is and blends in information from the most relevant ones. In a model that generates text, such as GPT, each token looks only at the tokens before it. In "she paid the bank before walking along the river bank", attention lets the model connect each "bank" to the words that settle its meaning. A good analogy is a meeting where everyone can hear everyone at once, rather than a message passed down a line one person at a time.

That line-of-people approach is how earlier language systems, called recurrent networks, worked: they read one token after another in order. That made them slow to train and prone to losing track of earlier parts of long passages. Because a transformer processes all tokens together, its training can be spread across many chips in parallel, which is what made very large models affordable to train.

The design was published in June 2017 in a paper by Google researchers titled "Attention Is All You Need". They tested it on machine translation, English to German and English to French, and reported better quality than earlier systems at a fraction of the training cost. The same design has since been applied to images, audio and robotics as well as text.

There is a trade-off. In the standard design, the work of attention grows with the square of the input length: double the length and the work roughly quadruples. That is a big reason long context windows cost more to run.

Common questions

What is a transformer in AI?

A transformer is a type of neural network design that processes a whole sequence, such as a paragraph of text, at once. It uses a mechanism called attention to work out which words relate to which. Introduced by Google researchers in 2017, it is the architecture behind most large language models, including the GPT family, and it is also used for images and audio.

What does GPT stand for?

GPT stands for generative pre-trained transformer. Generative means it produces new text. Pre-trained means it first learned from a very large body of text before being adapted for specific uses. Transformer is the neural network design it is built on. The name is used for OpenAI's model family, and the same approach underpins many other language models.

What is attention in a transformer?

Attention is the step where the model decides, for each word, how much every other word in the input should influence it. It gives each pair of words a relevance score and mixes information accordingly. This lets the model connect a pronoun to the right noun, or work out which meaning of an ambiguous word is intended, even when the related words are far apart.

Finding more

Search for "Attention Is All You Need", "transformer architecture explained" and "self-attention visualised". The original paper is free on arXiv and its opening sections are readable without heavy maths. University courses on natural language processing and Google's machine learning glossary explain attention step by step. Treat with care any article that confuses AI transformers with electrical transformers, which turn up in stories about data centre power, or with the toy and film franchise of the same name.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.