Transformers and large language models
Neural networks built on self-attention that model sequences and underlie modern language AI.
Edited by Alex C, EduAlx · Sources cited below
Explanation
Vaswani et al. (2017) replaced recurrence with attention: each token weighs every other token through queries, keys and values. Pretraining on large text corpora, then fine-tuning and reinforcement learning from human feedback, gives general-purpose assistants (GPT, Claude, Gemini, Llama). Scaling laws (Kaplan et al., 2020) relate loss to model size, data and compute.
Example
Code
import numpy as np
def attention(Q, K, V):
s = Q @ K.T / np.sqrt(K.shape[-1])
w = np.exp(s - s.max(-1, keepdims=True))
w /= w.sum(-1, keepdims=True)
return w @ V
How it works, step by step
- Split text into tokens and embed them
- Add positional information
- Self-attention mixes information across tokens
- Feed-forward layers transform each token
- Stack many layers; predict the next token
Open the interactive page with diagrams →
People behind it
- Ashish Vaswani, Artificial intelligence, India / USA: Lead author of 'Attention Is All You Need' (2017), introducing the transformer, while at Google Brain.
- Geoffrey Hinton (b. 1947), Artificial intelligence, UK / Canada: Pioneer of backpropagation, Boltzmann machines and deep learning. Turing Award 2018; Nobel Prize in Physics 2024.
- Ilya Sutskever
References
- A. Vaswani et al., NeurIPS 2017, 5998–6008 (Attention Is All You Need).
- J. Kaplan et al., arXiv:2001.08361, 2020.
Textbooks
- Deep Learning, Ian Goodfellow, Yoshua Bengio, Aaron Courville (MIT Press, 2016; free online). Foundational deep learning text.
- Artificial Intelligence: A Modern Approach, Stuart Russell, Peter Norvig (Pearson, 4th ed. 2020). The standard AI text.
Related topics
Artificial intelligence: search and the Turing testNeural networks and backpropagationComputer vision and convolutional neural networksMachine learningNatural language processingReinforcement learningSoftware engineering and version controlQuantum computingCompilersBlockchain and distributed ledgers