LAMBADA
Tests whether a model can guess the last word of a passage from a novel when that word can only be predicted from the whole passage.
At a glance
What it tests
LAMBADA is a language-modelling test with a filter. Each passage from a novel ends one word short, and the passage was kept only if people could predict the missing word after reading the whole thing but not from the final sentence by itself.
So the metric rewards exactly the ability that perplexity on random text does not isolate: carrying information across several sentences. A model that only attends to the last few tokens scores near zero.
GPT-2 raised the state of the art from 59% to 63% zero-shot (and perplexity from 99 to 8.6) and noted that most errors were valid continuations that were not the end of a sentence — adding a stop-word filter gave 4 more points. GPT-3 reached 86.4% few-shot by prompting with a fill-in-the-blank format that taught the model to output exactly one word.
Examples
Items from the dataset (or representative items where the originals are not freely redistributable).
Reported results
Scores reported on this benchmark, with the evaluation setting each one used.
| Setting | Reported | Context |
|---|---|---|
| Zero-shot (1.5B) | 63.24 acc8.63 ppl | Prior SOTA 59.23 acc / 99.8 ppl |
| Few-shot (15 examples), cloze-style prompt | 86.4 acc1.92 ppl | Zero-shot 76.2 acc / 3.00 ppl; prior SOTA 68.0 |
State of the art
Megatron-Turing NLG 530B 87.2. Rarely reported by frontier models after 2023. Source: arxiv.org ↗ · checked October 2026.
Quickstart
Load the benchmark and score a Hugging Face causal LM on it in a few lines.
pip install -U datasets transformers evaluate lm-eval sacrebleu rouge-score scikit-learn
text (full passage; the target is the final whitespace-separated word). `cimec/lambada` is the original, un-detokenised version.
from datasets import load_dataset ds = load_dataset("EleutherAI/lambada_openai", "default", split="test") print(ds) # columns: text (full passage; the target is the final whitespace-separated word) print(ds[0])
Two helpers cover every benchmark in this collection: loglik for anything multiple-choice (score each option, pick the highest) and generate for anything free-form. Swap MODEL for whatever you are evaluating.
import torch from transformers import AutoTokenizer, AutoModelForCausalLM MODEL = "gpt2" # or "Qwen/Qwen2.5-1.5B", "meta-llama/Llama-3.2-1B", … tok = AutoTokenizer.from_pretrained(MODEL); model = AutoModelForCausalLM.from_pretrained(MODEL, torch_dtype=torch.bfloat16).eval().to("cuda") @torch.no_grad() def loglik(context, continuation): """Sum of log-probs of `continuation` tokens given `context` — the standard multiple-choice scorer.""" ids = tok(context + continuation, return_tensors="pt").input_ids.to(model.device) n_ctx = len(tok(context).input_ids) logp = model(ids).logits.log_softmax(-1)[0, :-1] return logp.gather(1, ids[0, 1:, None])[n_ctx - 1:].sum().item() @torch.no_grad() def generate(prompt, max_new_tokens=32, stop=None): ids = tok(prompt, return_tensors="pt").input_ids.to(model.device) out = model.generate(ids, max_new_tokens=max_new_tokens, do_sample=False, pad_token_id=tok.eos_token_id) text = tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True) return text.split(stop)[0] if stop else text
# Predict the final word; count it correct only if the whole word is produced greedily correct = 0 for ex in ds: ctx, target = ex["text"].rsplit(" ", 1) out = generate(ctx, max_new_tokens=8).strip().split() correct += int(out and out[0].strip(".,!?\"'") == target.strip(".,!?\"'")) print("accuracy", correct / len(ds))
Task name(s): lambada_openai. The harness reproduces the GPT-3 prompt formats and reports the standard metric.
lm_eval --model hf --model_args pretrained=gpt2,dtype=bfloat16 \
--tasks lambada_openai --num_fewshot 0 --batch_size auto --output_path results/Pitfalls
- Use lambada_openai — the original release has tokenisation artefacts (spaces before punctuation) that depress accuracy.
- Greedy decoding of the next token is not enough: the target word may be several BPE tokens; score the whole word.
- Perplexity numbers across papers are not comparable unless the same version and tokeniser were used.
References
- Paper (arXiv 1606.06031)https://arxiv.org/abs/1606.06031
- Hugging Face (lambada_openai)https://huggingface.co/datasets/EleutherAI/lambada_openai
- Original datahttps://zenodo.org/record/2630551