# Transformer

> Canonical: https://skillalmanac.com/glossary/transformer | Last verified: 2026-11-24 | Index status: index-eligible

A Transformer is an attention-based neural network architecture introduced in 2017. The original design uses no recurrent or convolutional layers; later variants can combine attention with those mechanisms. BERT uses a bidirectional Transformer encoder.

Also called: transformers, transformer AI, transformers AI, AI transformer, transformer model, transformer architecture.

## In plain language

In machine learning, a Transformer is a neural network design built around attention. The original 2017 architecture used attention rather than recurrence or convolutions to connect positions in a sequence. It still contains feed-forward layers. Later variants include segment recurrence (Transformer-XL) or convolutional layers (Conformer). BERT uses a Transformer encoder for language understanding.

## Technical definition

Vaswani and colleagues proposed the Transformer in 2017 (arXiv v1, 12 June 2017) as a network architecture based solely on attention mechanisms, dispensing with recurrence and convolutions. Section 3.1 of the paper describes encoder and decoder stacks of identical layers. The architecture uses multi-head attention, position-wise feed-forward networks, residual connections with layer normalization, and positional encodings. In the decoder, self-attention is modified to prevent positions from attending to subsequent positions; the paper calls this masking. BERT uses a multi-layer bidirectional Transformer encoder with a masked language model pre-training objective.

The original Transformer was proposed in the 2017 paper *Attention Is All You Need*. Its architecture uses attention to connect sequence positions, without recurrent or convolutional layers; that exclusion does not describe every later Transformer variant.

## How it shows up when you use agents

The linked guide contains a worked example of the original Transformer encoder and decoder, followed by a BERT masked-token example. It contrasts the attention connections that a causal mask blocks with the input token that a masked-language-model exercise hides. The example is illustrative, not an execution of either model.

## Common confusions

- **Every position versus allowed positions.** In the original paper, each position in the encoder can attend to all positions in the previous encoder layer, while the decoder is modified to prevent positions from attending to subsequent positions.
- **Transformer versus BERT's training objective.** BERT uses a bidirectional Transformer encoder and is pre-trained with a masked language model rather than a traditional left-to-right language model.
- **Transformer versus LLM.** The large-language-model entry lists BERT-style masked bidirectional pretraining and recurrent architectures such as RWKV among LLM designs.

## Worked examples in this catalogue

### [What Is an LLM? The Facts Agent Users Need](https://skillalmanac.com/learn/what-is-an-llm-for-agent-users)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The guide's worked Transformer example contrasts source-side attention, decoder causal masking and BERT's masked-token objective.

Why it exercises the concept: Use the worked example to distinguish an architecture from a training objective; its words stand in for tokens.

## Related terms

- [Large language model (LLM)](https://skillalmanac.com/glossary/large-language-model.md)
- [Language model](https://skillalmanac.com/glossary/language-model.md)
- [Neural network](https://skillalmanac.com/glossary/neural-network.md)
- [Token](https://skillalmanac.com/glossary/token.md)
- [Embedding](https://skillalmanac.com/glossary/embedding.md)

## Sources

- [Attention Is All You Need — Vaswani et al.; first submitted 2017, arXiv v7, 2023](https://arxiv.org/html/1706.03762v7), arXiv (accessed 2026-11-24)
- [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding — Devlin et al.; arXiv v2, 2019](https://arxiv.org/html/1810.04805v2), arXiv (accessed 2026-11-24)
- [Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context](https://arxiv.org/abs/1901.02860), Dai et al. (arXiv) (accessed 2026-11-24)
- [Conformer: Convolution-augmented Transformer for Speech Recognition](https://arxiv.org/abs/2005.08100), Gulati et al. (arXiv) (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-24. [Glossary index](https://skillalmanac.com/glossary.md).
