Glossary termNeural network architecture

Transformer

Also known as: Transformer architecture, Transformer model

Neural network architecture based on self-attention, introduced in 2017, that underlies most large language models and many vision and audio models.

The transformer is a neural network design that processes a sequence by letting every element attend to every other element through a mechanism called self-attention. Input text is split into tokens, each converted to a vector, and positional information is added so the model knows word order. The vectors then pass through a stack of identical blocks, each combining multi-head self-attention with a small feed-forward network, plus residual connections and normalization. Because the whole sequence is processed in parallel during training, transformers make efficient use of GPUs.

A team of eight researchers, most of them at Google, introduced the architecture in the 2017 paper "Attention Is All You Need", aimed at machine translation. The original design had an encoder that reads the input and a decoder that generates output. Later families used parts of it: encoder-only models such as BERT (2018) for understanding tasks, and decoder-only models such as OpenAI's GPT series, which predict the next token and became the template for large language models. Vision transformers applied the same design to image patches from 2020.

Transformers proved remarkably general, handling text, images, audio, protein sequences and combinations of these in multimodal models, and their performance improves predictably with more data and compute. Their main weakness is that standard self-attention costs grow with the square of sequence length, which limits the context window and has prompted many efficiency variants. Alternative architectures, including state space models, compete on efficiency, but as of 2025 transformers remained the dominant design for the most capable AI systems.

Key points

  • Transformers rely on self-attention, letting each token weigh information from every other token.
  • The architecture was introduced in the 2017 paper "Attention Is All You Need".
  • Parallel processing during training made transformers well suited to large-scale GPU computing.
  • Encoder-only, decoder-only and encoder-decoder variants serve different kinds of tasks.

Related entries

Glossary term

Neural network technique that lets a model weigh the relevance of different parts of its input when producing each part of its output.

Glossary term

Neural network trained on very large amounts of text to predict the next token, able to generate language and perform many tasks from prompts.

Glossary term

Neural network architecture that processes sequences step by step while carrying a hidden state, giving it a form of memory of earlier inputs.

Glossary term

The process of splitting text into smaller units called tokens, such as words, subwords or characters, that a language model can process as numbers.

Glossary term

The maximum amount of input, measured in tokens, that a language model can take into account at once, including the text it is generating.

Technology

Hugging Face Transformers

AIProgrammingFOSS

Open-source Python library from Hugging Face that provides a common interface for loading, running and fine-tuning thousands of pretrained models.

Glossary term

Large AI model trained on broad data at scale, usually with self-supervision, that can be adapted to a wide range of downstream tasks.

Glossary term

Empirical regularities showing that AI model performance improves predictably as model size, training data and computation increase.

Featured in guides

Referenced by

Other entries that discuss or point to Transformer.