Transformer
A type of neural network architecture that processes all parts of an input at once, making it highly effective for language tasks. It powers most modern AI chatbots.
A transformer is a neural network architecture introduced in 2017 that changed the course of AI research. Unlike older models that processed text one word at a time, a transformer reads an entire sequence at once, which lets it understand the relationships between words no matter how far apart they appear in a sentence. This parallel approach is both faster and more accurate, particularly for the kind of nuanced language tasks that large language models need to handle.
The transformer's success comes down to a single core idea: instead of treating every word equally, it learns to pay more attention to the words that matter most in a given context. This mechanism, called self-attention, is what allows the model to disambiguate meaning, follow long chains of reasoning, and translate between languages with impressive accuracy.
How it works#
A transformer is made of stacked layers, each containing two key components: an attention block and a feed-forward block.
The attention block scans all the tokens in the input and assigns each pair a relevance score. Tokens that are strongly related, such as a pronoun and the noun it refers to, receive high scores. The model then uses these scores to weight how much influence each token has on the others. This happens across multiple parallel "heads" simultaneously, allowing the model to track several types of relationship at once.
The feed-forward block processes the output of the attention step and adds further transformations, helping the model learn complex patterns. After many such layers, the final output is a rich numerical representation of each token that captures its meaning in context.
During training, millions of examples are fed through the network and the parameters are adjusted until the outputs become reliably accurate. At inference time, the process runs in reverse: the model uses its learned parameters to generate the most appropriate next token, one at a time.
Examples#
Resolving ambiguous meaning. Consider the sentence "The bank by the river was covered in wildflowers." A transformer uses attention to notice that "river" is nearby and highly relevant to "bank". It assigns a high relevance score to that pairing and correctly interprets "bank" as a riverbank rather than a financial institution. An older, word-by-word model would have no mechanism to look back at "river" while processing "bank".
Long-document summarisation. When asked to summarise a 10-page report, a transformer can hold the whole document in view at once, rather than reading it in chunks and losing earlier context. This is why modern AI tools can produce coherent, accurate summaries of lengthy material.
Why it matters#
The transformer architecture is the reason AI language tools improved so dramatically after 2017. Every major model you are likely to use, from ChatGPT to Claude to Google's Gemini, is built on this design. Understanding it helps explain why these tools are good at some things (holding context across a long conversation) and less reliable at others (precise arithmetic, which requires a different kind of reasoning).
For anyone building with AI or simply trying to use it well, knowing that transformers exist and why they work gives useful intuition about what to expect. If you want to go deeper, the tutorial How LLMs Work walks through the transformer without the jargon, and the broader AI vs ML vs Deep Learning tutorial puts it in context alongside other approaches.
Transformer: frequently asked questions
- What is a transformer in AI?
- A transformer is a type of neural network design that looks at all words in a piece of text at the same time rather than reading them one by one. This allows it to spot relationships between distant words far more effectively than earlier approaches. Almost all modern AI language tools are built on transformer architecture.
- What does 'attention' mean in a transformer model?
- Attention is the mechanism that lets a transformer decide which words in a sentence are most relevant to each other. When processing the word 'bank', for example, the attention mechanism scans the surrounding words to figure out whether it means a riverbank or a financial institution. This context-awareness is what makes transformers so good at language.
- Who invented the transformer?
- The transformer architecture was introduced by researchers at Google in a 2017 paper titled 'Attention Is All You Need'. The design proved so effective that it rapidly replaced older approaches and became the foundation for GPT, BERT, Claude, and virtually every other leading language model.
Go deeper with related tutorials
AI vs Machine Learning vs Deep Learning: What's the Difference?
Understand the difference between artificial intelligence, machine learning, and deep learning. Clear definitions with real-world examples.
Read tutorialHow Large Language Models Work (Simple Explanation)
A clear explanation of how large language models like the AI assistants people use every day actually work. No technical background needed.
Read tutorialUseful? Now picture your whole team knowing it.
Everything here is free, and the first course is too: eight short online lessons your team can start this afternoon. When you want the skills to stick, we come to you for a day on-site, built around the work your people actually do.