TL;DR
PaLM is a 540-billion-parameter language model. It predicts the next token in a sequence, like earlier GPT-style models, but it is much larger and was trained on 780 billion tokens of text and code. Google trained it on 6144 TPU v4 chips using Pathways, a system that runs one training job across many accelerator pods. It also made several small changes to the Transformer block to make large models train faster and more stably, and it set few-shot results on many benchmarks.
Builds on: Transformer, In-Context Learning, Multi-Query Attention, Model Parallelism · Leads to: Compute-Optimal Training, which asks how to split a fixed compute budget between model size and data, a question a 540B run makes concrete
Why it mattered
PaLM was one of the largest dense language models published up to 2022, and it showed that the few-shot approach of GPT-3 still improved with scale at 540 billion parameters, about three times the 175 billion of GPT-3. On the BIG-bench suite of more than 150 tasks, PaLM 540B scored above the average human rater on aggregate. On the grade-school math benchmark GSM8K, prompting it to write out its reasoning (Chain-of-Thought Prompting) lifted accuracy from 17 percent to 54 percent with eight examples in the prompt.
The paper is also a standard reference for how large runs are engineered. It introduces an efficiency metric, model FLOPs utilization (MFU), which it reports as 46.2 percent for the 540B run, and it describes the practical work of keeping a 540B run stable over 255,000 steps.
History
Before 2022, the strongest language models were either encoder-only models fine-tuned for each task, or GPT-3, which showed that a decoder-only model could do many tasks from a prompt alone (Language Models are Few-Shot Learners (GPT-3)). The open question after GPT-3 was whether the prompt approach would keep improving at larger sizes, and at what cost.
Google's work in 2022 answered that with a 540B dense model, trained with the Pathways system that spread one job across thousands of accelerators. Other labs released similarly large models around the same time, and the comparisons in the paper show PaLM ahead on many few-shot tasks.
The problem
By 2022 the field had a simple recipe: make the model bigger, feed it more text, and it gets better at tasks it was never trained on. Earlier large models such as GLaM, Gopher and Megatron-Turing NLG had each pushed the size and the few-shot scores up. Three questions remained open.
The first was how far the recipe would go. Small models had shown smooth gains, and the paper asks whether a 540B model would keep the same pattern or show new behaviour.
The second was how to train such a model at all. A model of this size does not fit on one chip, and a single training job has to be split across thousands of chips without wasting most of their time on waiting. Earlier large runs reached about a third of peak: the paper's Table 3 lists 32.5 percent MFU for Gopher and 30.2 percent for Megatron-Turing NLG.
The third was whether the architecture itself could be improved at no cost to quality. Every change had to be cheap in training time and neutral or better in accuracy, because one full run could not be repeated many times.
How it works
Follow one short piece of text through the system, stage by stage.
-
Turn the text into tokens. The input "Pay 123.5 dollars" is split by a SentencePiece vocabulary of 256,000 pieces. PaLM splits every number into single digits, so "123.5" becomes five tokens: 1, 2, 3, ., 5. Check: the number of tokens is the number of characters in the number, here 5.
-
Look up an embedding for each token. Each token id picks a row of a learned matrix, giving one vector per token. PaLM uses the same matrix again at the output, which saves parameters. Check: 256,000 rows times the model width of 18,432 is a large but single table.
-
Run the stack of decoder blocks. The 540B model has 118 blocks. Each block has one attention sub-layer and one feed-forward (MLP) sub-layer, and both read the same normalised input. The two outputs are added to the residual stream in one step. This is the parallel formulation, and it lets the two input matrix multiplications run as one fused operation, about 15 percent faster at scale.
flowchart LR X[input x] --> N[LayerNorm] N --> A[multi-query attention] N --> M[SwiGLU MLP] X --> S((sum)) A --> S M --> S S --> Y[output y]
-
Compute the attention with shared keys and values. The query has 48 heads, but all heads share one key and one value per token. That shrinks the memory needed to generate text one token at a time, and the paper reports no quality loss. Positions are encoded by rotary embeddings, which rotate the query and key vectors instead of adding a position vector.
-
Compute the output scores. The final vector is multiplied by the shared embedding matrix to get one score per vocabulary entry. A softmax turns the scores into probabilities for the next token, and the training loss is how much probability the correct token received.
-
Train on many chips at once. The model is split across chips inside a pod (model parallelism) and the batch is split across pods (data parallelism). The two pods are joined by the data-centre network, and the gradients are exchanged once per step between the matching hosts.
-
Repeat for 255,000 steps. Every step uses a batch of 512 sequences of 2048 tokens, about one million tokens, at the start. The batch is doubled twice during the run. Each step ends with an optimiser update to the weights.
Worked example: tokens and cache size
- Split the number "123.5" into digit tokens: 1, 2, 3, ., 5. That is 5 tokens.
- Take a model with heads and head size , as in the 540B model. For one cached token in one layer, standard attention stores numbers.
- Multi-query attention stores numbers for the same token.
- The ratio is , which equals .
Interpretation: the cache is 48 times smaller, and that is why generation is cheaper. The paper's point is about decoding speed; the quality is unchanged.
The math
The math below formalises the walkthrough. The symbols are the ones the paper uses.
Step 3 in symbols: the parallel block
Write for the block input and for layer normalisation. A standard serial block computes
while PaLM's parallel block computes
The parallel version reads twice, so the two projections that take it as input can be computed as one matrix multiplication.
Step 4 in symbols: multi-query attention
Let be the head size, the number of heads, and the number of cached tokens. With standard multi-head attention, the key and value cache for one layer holds numbers. With multi-query attention each token has one key and one value, so the cache holds numbers. The saving is a factor of on the cache, and the queries still have heads.
Step 5 in symbols: the training loss
The loss is the average negative log probability of the correct next token over the batch:
where is the number of tokens in the batch, is the token at position , and is the model with weights . The paper adds a small auxiliary term that keeps the softmax normaliser close to 1, which made training more stable.
Step 6 in symbols: model FLOPs utilisation
For a dense decoder-only model with parameters, one training token needs about floating-point operations: for the forward pass and for the backward pass. If the system processes tokens per second on hardware whose peak is operations per second per chip across chips, then
MFU leaves out recomputation that the compiler adds to save memory, so it measures the useful work only.
Step 7 in symbols: the batch schedule
The batch holds sequences of tokens. The paper uses until step 50,000, then until step 115,000, then until step 255,000.
Worked examples: MFU and the batch schedule
Suppose each chip has a peak of operations per second. This is a round number for the sake of the arithmetic, not the real chip spec.
- The model has parameters, so operations per token.
- The system has chips, so total peak is operations per second.
- At MFU , the achieved rate is operations per second.
- Divide by the operations per token: tokens per second.
Interpretation: at a 46.2 percent MFU, the system pushes about 87,600 tokens per second through the model. The same formula shows that a drop of 10 percentage points, from 46.2 to 36.2 percent, cuts tokens per second by about a fifth, which is why the paper spends effort on utilisation.
This is the realistic case: the numbers the paper gives for the 540B run.
- Phase one: 50,000 steps at tokens per step. That is billion tokens.
- Phase two: 65,000 steps (from 50,000 to 115,000) at tokens. That is billion tokens.
- Phase three: 140,000 steps (from 115,000 to 255,000) at tokens. That is about billion tokens.
- The three phases add to about billion tokens. The paper quotes 780 billion, so the schedule as written reproduces the data budget to within rounding.
Interpretation: most of the tokens are seen in the last, largest-batch phase, because the paper's schedule grows the batch late. The total is close to the 780 billion tokens of the dataset, so the run consumed roughly the whole dataset once.
Try it: how many tokens does phase three alone account for, as a share of the total of about 776 billion? Answer: , so about 76 percent of the tokens are seen in the final 140,000 steps.
Results
PaLM 540B reports these headline numbers, with the paper's own tables.
- BIG-bench: over 150 text tasks; PaLM 540B scores above the average human rater in aggregate, though the average human still wins on about 35 percent of individual tasks.
- GSM8K, 8-shot chain-of-thought: 54 percent; 58 percent with a calculator; 17 percent without chain-of-thought (Table 10).
- Scaling: the 62B model reached 33 percent on the same GSM8K setup with chain-of-thought.
- Training: about twenty loss spikes on the largest model, handled by restarting from an earlier checkpoint and skipping the surrounding batches.
Limits and common misreadings
It is tempting to think that MFU is the share of the chip's peak that the hardware actually used. In fact the paper uses MFU to count only the operations the model needs, and the hardware figure, HFU, is higher at 57.8 percent. The gap is recomputation the compiler adds to save memory. Both numbers are real; they answer different questions, and MFU is the one that compares systems.
It is tempting to think that a bigger model is better at every task. In fact PaLM 540B beats the average human on BIG-bench in aggregate, yet the average human still scores higher on about 35 percent of the individual tasks, because scale does not help all tasks equally. It is tempting to think that few-shot learning changes the weights. In fact the model is not updated; the examples sit in the prompt and the model's fixed weights do the work (In-Context Learning). Few-shot results therefore depend on the prompt wording, and small changes in exemplars can move the score.
It is tempting to read the discontinuous jumps on some tasks as a sudden new ability. In fact the paper's own example, logical_sequence, goes from 13 percent at 8B to 25 percent at 62B to 87 percent at 540B. The jump is large on a coarse accuracy scale, and it depends on how the metric is chosen.
When to use this recipe: when you can afford a very large run, have a training system that scales across pods, and need one model for many tasks. When not to: when compute is limited, because a smaller model trained on more data may do better for the same budget, the question Compute-Optimal Training studies. Alternatives include fine-tuning a smaller model on the target task, or using retrieval to supply facts the model does not hold.
Reading guide
Read the paper in this order.
- Section 1, Introduction. The scaling question and the list of contributions. Needs Language Models are Few-Shot Learners (GPT-3) and In-Context Learning.
- Section 2, Model Architecture. The parallel block, SwiGLU, multi-query attention, rotary positions and the 256k vocabulary. Needs Transformer, GLU Variants Improve Transformer, Multi-Query Attention, Rotary Position Embedding and Subword Tokenization.
- Section 3, Training Dataset. The 780-billion-token mixture. Needs Language Model and Perplexity for what the training loss means.
- Section 4, Training Infrastructure. Pathways, the two-pod layout and model FLOPs utilisation. Needs Model Parallelism and Data Parallelism.
- Section 5, Training Setup. The optimiser, the learning-rate schedule, clipping and the batch schedule. Needs Adam Optimizer, Learning Rate and Gradient Norm Clipping.
- Section 6, Evaluation. Start with 6.2 BIG-bench and 6.3 Reasoning. Needs Chain-of-Thought Prompting and In-Context Learning.
- Sections 7 to 10. Memorisation, contamination, bias, toxicity and limits. Read them for the claims they make; they need no new prerequisites beyond the above.
Takeaways
- PaLM is a dense decoder-only Transformer with 540 billion parameters, trained on 780 billion tokens with the Pathways system across 6144 TPU v4 chips.
- Its block uses a parallel attention and MLP formulation (about 15 percent faster training at scale), SwiGLU activations, multi-query attention (a smaller decoding cache), rotary positions, shared input and output embeddings, and no biases (more stable training).
- Training uses an Adafactor optimiser with a batch schedule that doubles the batch twice, and the team recovered from about twenty loss spikes by restarting from an earlier checkpoint and skipping the batches around each spike.
- Few-shot results improved with scale, and chain-of-thought prompting made the largest gains on multi-step reasoning.
Read next: Compute-Optimal Training for how size and data should be balanced, and Chain-of-Thought Prompting for the reasoning results.
Check yourself
QuestionRecall: what does multi-query attention share across heads, and what does that save?Show answer
Multi-query attention keeps one key and one value per token, shared by all query heads. The key and value cache is smaller by a factor equal to the number of heads, which speeds up generation one token at a time. The paper reports no quality loss from the change.
QuestionCompute: a model has 48 heads and head size 256. How many numbers does one cached token need per layer under multi-query attention?Show answer
Multi-query attention stores one key and one value of size 256 each, so numbers. Standard attention would store .
QuestionWhy: the parallel block computes the attention and the MLP from the same normalised input. Why does that make training faster?Show answer
Both sub-layers take as input, so their input matrix multiplications can be fused into one larger operation. Fewer separate operations means better hardware use. The paper measured roughly 15 percent faster training at scale, with a small quality cost at 8B that it did not see at 62B.
QuestionScenario: a team reports 60 percent MFU for a run and says the chips were 60 percent busy. What is the likely error?Show answer
MFU counts only the operations the model needs, and it leaves out recomputation. A system can show high hardware utilisation while the useful throughput is lower, because part of the work is recomputed. The team should report MFU and HFU separately, and note which one they mean.