Benchmarks · Long context & retrieval
Needle in a Haystack
also: NIAH, Multi-needle in a haystack
Whether a model can retrieve a single fact ('the needle') planted at an arbitrary point inside a long document ('the haystack'), across varying document lengths and needle positions.
Greg KamradtReleased 8 November 2023Saturated
Needle in a Haystack began as one researcher’s informal pressure-test rather than an academic benchmark. Greg Kamradt built it in November 2023 to check whether OpenAI’s newly released 128,000-token GPT-4 Turbo could actually use all of the context window it claimed, by planting a single out-of-place sentence somewhere inside a long document and asking the model to find it. Sweeping the test across a grid of document lengths and insertion depths produced a heatmap that made a model’s blind spots visible at a glance — and the visual made the test spread fast, becoming close to a default first check in any long-context model announcement.
The test also produced one of the more widely circulated anecdotes in the field: when Anthropic tested an early version of Claude 3 Opus with it, the model not only found the inserted sentence but remarked that it appeared to have been placed there to test its attention — a moment Anthropic’s own researchers described as a curiosity rather than a claim about the model’s broader awareness. Within roughly a year, Google’s Gemini 1.5 Pro launch helped make million-token context windows a standard line in system cards, and needle-in-a-haystack sweeps became a routine part of how labs demonstrated them.
Basic single-needle retrieval is now close to solved for frontier models at most context lengths, so labs have moved to harder variants: multiple needles inserted at once, at the longest context lengths a model supports. Anthropic’s Claude Opus 4.6 release, for instance, reported 76% accuracy on an eight-needle test at 1 million tokens against 18.5% for its predecessor Sonnet 4.5 — evidence that, even as the original test saturates, its harder descendants still separate current models by a wide margin.
The set
A short, out-of-place factual sentence is inserted at a chosen depth into a long filler document (originally Paul Graham's essays), and the model is asked to retrieve it verbatim. Runs are swept across a grid of context lengths and insertion depths and plotted as a heatmap, so a model's retrieval accuracy can be read off by both how long the document is and where the fact sits within it. Harder variants insert multiple needles and ask about several or all of them at once.
Example
The original 2023 needle: 'The best thing to do in San Francisco is eat a sandwich and sit in Dolores Park on a sunny day.', inserted at a chosen depth into a filler document built from Paul Graham's essays, with the model then asked what the best thing to do in San Francisco was, using only the provided context.arize.com
Where it stands
Single-needle retrieval at moderate lengths is close to solved for frontier models; harder multi-needle variants at very long context lengths still separate them clearly.
In the timeline · 3 entries
Anthropic releases Claude Opus 4.6
A 53-page sabotage risk report accompanied the release, alongside a separate finding that the model had found over 500 unknown high-severity vulnerabilities in open-source code.
Models & capabilities · Safety & alignment
Anthropic's Claude 3 takes the frontier from GPT-4
The first time a lab other than OpenAI held the top spot on headline benchmarks, and the start of the small/medium/large release pattern.
Models & capabilities · Labs & people
Gemini 1.5 Pro ships a million-token context window
A mixture-of-experts model that matched Gemini 1.0 Ultra on many tasks at lower compute, offered in limited preview with up to a million tokens of context.
Models & capabilities