Transformer Model
Updated 2026-08-11
Summary
A neural network architecture built on self-attention that models dependencies between any two positions in a sequence, forming the basis of models such as BERT and GPT.
Definition
The transformer was introduced by Vaswani and colleagues in the paper Attention Is All You Need. Its core proposition is that self-attention alone, without recurrence, can capture relationships between any two positions in a sequence, which allows computation to be parallelized and long-range dependencies to be modeled directly. The key qualification is cost: attention scales quadratically with sequence length, so the architecture requires substantial data and compute, and larger models do not automatically suit every task.
Introduction
How to use
- Use task framing: cast the problem as sequence-to-sequence or representation learning. - Use pretrained features: start from a model such as BERT or GPT rather than training from scratch. - Use attention reading: inspect attention weights for clues, while treating them as correlation not cause.
Mechanism
Recurrent networks pass information step by step, so the signal from a distant word must survive many intermediate steps and computation cannot be parallelized. Self-attention computes a weighted relationship between every pair of positions directly, which shortens the path between distant elements and lets the whole sequence be processed at once. Stacking multiple attention heads with a feed-forward network and positional encoding lets each token combine information from several representation subspaces. The result is that training scales with the hardware, which is why the architecture enabled the large pretrained models.
Practice
In progress 0/1Practice this model in one real situation:
Cases
- The GPT series generating text, and BERT handling question answering and classification.
- Vision transformers that apply the same attention mechanism to image recognition tasks.
Common pitfalls
- Reading attention weights as a causal explanation of the model's output, which they do not provide.
- Ignoring the compute and data requirements, then concluding that the architecture failed.
- Assuming a larger model is always better, regardless of fit to the task and available data.
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- en.wikipedia.orghttps://en.wikipedia.org/wiki/Transformer_(deep_learningverified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS