Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

~10 min readGoogle DeepMind 2024

Gemini 1.5,
explained.

Hide a single sentence — a random passkey — somewhere inside an entire novel, then ask the model to recite it. Most models fail: whatever fell outside their effective attention span is simply gone. Gemini 1.5 finds it, at almost any depth, in a context of up to a million tokens — and, in research runs, ten million. The trick isn't a bigger prompt box; it's an attention span that actually reaches the whole context. Here's why that's hard, why it's expensive, and how to test it yourself.

The delta

What changes against GPT-4: the axis being scaled is context

Rungs 1 and 2 scale parameters and compute. This rung scales the context window, by roughly 5 to 80 times over what was then normal — from 128 to 200 thousand tokens to one million, with ten million demonstrated — in a sparse mixture-of-experts model.

The claim that made it credible is a measurement rather than a capacity, and the distinction is the whole point. A long window is easy to advertise and easy to fake: a model can accept a million tokens and attend to almost none of them usefully. The test reported is needle-in-a-haystack — hide a specific fact at an arbitrary position in the full context and ask for it back — and the reported recall is near-perfect across the whole window, not merely near its ends.

Stated against the context ladder, that result is a direct refutation of a family of approaches. A model whose attention is restricted to a neighbourhood cannot pass this test at position half-a-million, because no attention operation ever connects the needle to the query — the information has to be relayed through depth, and it is not. Passing it everywhere is evidence of something close to genuine global access, which is why this rung is consistent with keeping attention exact and sharding it rather than approximating it — though the report does not disclose how Gemini achieves it.

01

A book in the prompt

Every earlier leap in language models was about the model. Gemini 1.5's leap is about the prompt: how much you can put in front of the model at once. Its context window reaches 1 million tokens in production and up to 10 million in research — enough to hold entire books, whole codebases, or hours of audio and video in a single request. That changes what a model can do: instead of retrieving snippets and hoping, you can hand it the whole document and ask.

Architecturally Gemini 1.5 is a sparse mixture-of-experts transformer — only a fraction of its parameters fire for any given token (which cuts per-token compute, though not the cost of attending over a long context). But a huge window is only useful if the model can actually use all of it. A prompt box that holds a million tokens but only pays attention to the last few thousand is a bigger box, not a longer memory. The proof that Gemini 1.5's memory is real is a deceptively simple test.

The one-sentence version

A context window is only as good as the attention span that reaches across it — Gemini 1.5's span covers the whole million-token window, so a fact hidden anywhere in it is still retrievable.

02

The needle test

The needle-in-a-haystack test makes "does it really use the whole context?" measurable. Take a huge block of filler text (the haystack), hide one small, specific fact inside it (the needle — say, a random passkey), then ask the model to retrieve just that fact. Sweep the needle across many depths (start, middle, end) and many context lengths, and you get a grid of recall scores: green where the model found it, red where it didn't.

For most long-context models that grid lights up red in the early depths of long contexts — the needle placed near the beginning of a very long document is lost. Gemini 1.5's grid was near-uniformly green, ~99%+ recall across the whole range up to a million tokens. Depth barely mattered; length barely mattered. That uniformity is the claim: not "a big window" but "a window it can search end to end."

03

Why a window fails

To see why this is hard, imagine a model whose effective attention reaches only the last W tokens — a sliding window. Anything older than W tokens has scrolled out of view. Put the needle near the end of the context and it's inside the window: found. Put it near the start of a long context and it's beyond W: gone, no matter how big the prompt box is.

Needle depth vs a limited attention span W
Needle at endWithin the last W tokens → always retrieved, even in a huge context.
Needle at startBeyond W in a long context → outside the span → missed.
Full-span modelSpan covers the whole length (W ≥ L) → found at every depth.
The leverLong context = pushing the usable span up to the full million tokens.

So the interesting number isn't the size of the prompt box — it's the usable span. A model advertising a million-token window but effectively attending to only the last 8K would ace needles at the end and fail everything earlier. Gemini 1.5's achievement is that its usable span really does stretch across the entire window, which is exactly the condition the next section makes precise.

04

The recall condition

Place a needle at depth-fraction f (0 = start, 1 = end) in a context of length L. Its index is about f·(L−1), so its distance from the end is:

A needle at the very end (f=1) is distance 0; at the very start (f=0) it is nearly the whole length away.

A window model attending to the last W tokens retrieves the needle exactly when that distance fits inside the window:

To guarantee recall at every depth, including the very start (f=0), the span must cover the whole context: W ≥ L. That single inequality is the whole long-context game — and it comes at a price, because both self-attention (naively quadratic in L) and the KV cache that stores past tokens (linear in L, ~tens of GB at a million tokens) grow with the length you're trying to span. Gemini 1.5's undisclosed architecture changes and serving optimizations are what make W ≥ L ≈ 10⁶ affordable; MoE alone does not. The runnable version below builds the recall grid and shows a small window collapsing while a full-span one stays perfect.

How it works

How the Gemini 1.5 report tests a million-token context

The report describes the model only in outline and its long-context design not at all, so the substance is in how the context was tested, from synthetic probes to realistic tasks.

cumulative avg NLL (lower is better) 1K 32K 1M 10M token position, log scale Gemini 1.0 Pro: flat after 32K Gemini 1.5 Pro: still falling fit: L(x) = α·x^β + γ
Schematic of the report's perplexity probe. Gemini 1.0 Pro stops improving after about 32K tokens; Gemini 1.5 Pro keeps improving to 1M tokens on documents and 10M on code, following the fitted power law to about 1M (documents) and 2M (code) before code drops below it.
  1. Start from what is disclosed. Gemini 1.5 Pro is a sparse mixture-of-experts Transformer: a learned router sends each input to a subset of the parameters, so total size can grow while the number active per input stays fixed. The report credits the long context to significant architecture changes it does not describe. The models were trained on multiple 4,096-chip pods of TPUv4 across data centers, on multimodal and multilingual data, then instruction-tuned and tuned on human preferences. The updated report adds Gemini 1.5 Flash, distilled from Pro, which computes attention and feed-forward layers in parallel, as PaLM did.
  2. Measure prediction by position. On long documents of up to 1 million tokens, and on code repositories built by shuffling and concatenating files up to 10 million, the report plots the cumulative average negative log-likelihood up to each token position and fits a power law. If far-back tokens help, the curve keeps falling.
  3. Hide a needle in text. The haystack is Paul Graham essays, concatenated and repeated to the target length. The needle is a sentence giving a special magic number for a named city, inserted at evenly spaced depths from the start to the end, and the model is asked for that city's number. The grid sweeps lengths up to 10 million tokens.
  4. Hide needles in video and audio. For video, a line saying the secret word is needle is overlaid on one random frame of a 10.5-hour video made from seven copies of the AlphaGo documentary, sampled at one frame per second: 9.9 million tokens. For audio, a few seconds of a speaker saying the secret keyword is hidden in up to 107 hours of multi-speaker speech from VoxPopuli. The question is always asked in text.
  5. Ask for many needles at once. A harder variant hides 100 distinct needles and asks for all of them in one turn, which tests whether retrieval holds up when it is not a single lookup.
  6. Move to realistic tasks. Long-document and long-video question answering, long-context speech recognition, and learning a language from its documentation: for Machine Translation from One Book, the field linguistics material for Kalamang goes into the prompt: a grammar of roughly 500 pages, a word list of about 2,000 entries and around 400 parallel sentences, about 250,000 tokens in all.
  7. Control for prior knowledge. Kalamang has fewer than 200 speakers and almost no presence on the web, and every model is also run 0-shot with no materials. Because GPT-4 Turbo (128K) and Claude 3 (200K) cannot hold the full materials, all models are also compared on half the grammar, about 100,000 tokens. The reference is a person who learned Kalamang from the same materials, who also rates the translations from 0 to 6.
The math

Cumulative NLL against context length, and the fitted power law

NLLavg(x) = (1/x) Σt=1^x −log p(wt | w1, …, wt−1)
L(x) = α·x^β + γ, β < 0
  • x — token position; NLLavg(x) averages the loss over the first x tokens of a document or repository.
  • wt — the token at position t, predicted from everything before it.
  • α, β — the fitted scale and exponent; γ — the level the curve approaches.

The curve is a test of whether distant context is used. A model that gains nothing from history beyond W tokens stops improving at position W, so its cumulative average levels off; the report shows Gemini 1.0 Pro improving only up to 32K tokens. Gemini 1.5 Pro's average kept falling to 1 million tokens on documents and 10 million on code. The power law fit well to about 1 million tokens for documents and about 2 million for code; near 10 million the code curve fell below the fit, which the report ties to repeated code blocks giving the model an outsized benefit and flags as possibly specific to the dataset. Read at the extremes, β near 0 would mean extra context buys nothing, and a curve that beats its fit can mean copying rather than understanding.

The evidence

Gemini 1.5 Pro on single needles, many needles and Kalamang

TestGemini 1.5 ProComparison
Text needle, up to 530K tokens100% recallClaude 2.1: 98% at its 200K limit
Text needle, 1M tokens99.7%GPT-4 Turbo stops at 128K
Text needle, 10M tokens99.2%No other model tested accepts this length
Video needle, 10.5 hours (9.9M tokens)Near-perfectGPT-4V's API takes only about the first 3 minutes of video
Audio needle, 107 hours (9.7M tokens)Near-perfectWhisper plus GPT-4 Turbo, about 94.5% overall
100 needles in one turnAbout 70% to 128K, above 60% to 1MGPT-4 Turbo: about 50% at 128K

The figures are from the updated report, which also gives the newer Gemini 1.5 Flash near-perfect recall up to 2 million tokens in all three modalities.

Several results mark the limits. Recall of 100 needles at once is far below single-needle recall, so finding one fact is not the same as gathering many, and GPT-4 Turbo's recall on that task oscillated as context grew. On the Kalamang benchmark every model, Gemini included, was essentially random with no materials in context, which confirms the language is not in the training data. With the materials, Gemini 1.5 Pro translated English to Kalamang about as well as the human learner on average, while Kalamang to English still trailed the learner noticeably; with half the grammar, it beat GPT-4 Turbo and Claude 3 on the same setup by a wide margin. The report also states that Gemini 1.5 Pro matches or beats Gemini 1.0 Ultra on a broad set of benchmarks while using significantly less training compute. All of these are evaluations run by the vendor on haystacks it built.

Since then

What the measurement shows, what it does not, and what happened next

The limitation is in what the benchmark rewards, and the field took several years to internalise it. Needle-in-a-haystack tests exact retrieval of a verbatim span. That is the single easiest thing to do with a long context and the least representative of why anyone wants one. The valuable cases are aggregation — summarise this whole book, find every place these two claims conflict, reason over facts scattered across five chapters — and a model can score perfectly on retrieval while degrading badly on all of them. The top of the context ladder is an argument about exactly this gap.

The cost side is also easy to skip past: a million-token prompt is a million-token prompt in compute and in price, every time it is sent, and the practical question of when that beats retrieving the relevant ten thousand tokens is an economic one the capability does not answer. Figures here are vendor-reported.

How it held up: very long context became a standard frontier feature rather than a differentiator, and needle-in-a-haystack became a standard benchmark and then, fairly quickly, a saturated one — which is the normal life cycle of a test that a specific architectural choice makes easy. The durable contribution is that it made "does this window actually work" a question with an answer, and the durable caution is that its answer was narrower than the headline.

SOLVE IT YOURSELF

Hide a needle, sweep the window

The needle-in-a-haystack test is just placement plus search. Build a context of filler with one passkey needle at a fractional depth; a window model only "sees" the last W tokens, so it finds a needle near the end but misses one near the start of a long context. Sweep a grid of lengths × depths: a full-span window (W ≥ L) scores perfect recall, while a small window drops every early needle. That grid is exactly the plot Gemini 1.5 turned near-uniformly green up to a million tokens. Change the window or the grid and watch recall move.

YOUR TASK

Write the body of recall_grid. Everything else in the file is already written; this is the function the paper is about. Press ▶ Run to check it against the 5 assertions below — they start red.

WHAT IT HAS TO SATISFY — 5 ASSERTIONS
  1. The needle lands at the correct fractional-depth index
  2. A needle inside the attention window is retrieved
  3. A needle before the window is missed by a limited span
  4. A full-context window gives perfect needle-in-haystack recall
  5. A small window drops early needles so recall falls below 1.0
CPython · WebAssembly
06

Why it mattered

Gemini 1.5 reframed a running debate: do you retrieve relevant chunks and feed a short context (RAG), or do you just put everything in a long one? A million-token window doesn't end retrieval — retrieval is still cheaper and scales past any fixed window — but it dramatically raises the bar for when you need it. Many tasks that used to demand a retrieval pipeline become "paste the whole thing and ask." The engineering shifts from chunking and indexing to managing one very large, very expensive context.

It also made long-context evaluation serious. Needle-in-a-haystack is only the floor — it tests retrieval, not reasoning across a long context — and the field quickly moved to harder tests of multi-fact synthesis over long inputs. But the simple passkey grid remains the honest first question to ask any long-context model: not "how big is your window?" but "can you actually find something at the far end of it?" Gemini 1.5 was the model that made the answer, convincingly, yes.

Worth knowing

Passing needle-in-a-haystack proves retrieval across the context, not reasoning over it. A model can fetch a lone passkey from a million tokens yet still struggle to synthesize facts scattered across that same context — which is why long-context evals keep getting harder.

Questions

Questions people ask about Gemini 1.5

How does the Gemini 1.5 needle-in-a-haystack test work?

The text version follows the standard recipe. A haystack of Paul Graham essays, concatenated and repeated, is cut to the target length, and a needle, a sentence stating a special magic number for a named city, is inserted at evenly spaced depths from the very start to the very end. The model is then asked for that city's number. Sweeping both length and depth gives a grid of hits and misses. Gemini 1.5 Pro recalled the needle 100 percent of the time up to 530,000 tokens, 99.7 percent at 1 million and 99.2 percent at 10 million. The report also built video and audio versions, with the question always asked in text.

How did Gemini 1.5 Pro compare with GPT-4 Turbo and Claude 2.1 on long context?

On single-needle text retrieval, Gemini 1.5 Pro reached 100 percent recall at 200,000 tokens, where Claude 2.1 at its 200,000-token limit reached 98 percent, and it kept near-perfect recall to 10 million tokens, far beyond GPT-4 Turbo's 128,000-token window. On the harder task of retrieving 100 needles in one turn, Gemini kept around 70 percent recall up to 128,000 tokens and above 60 percent to 1 million, while GPT-4 Turbo averaged around 50 percent at 128,000, with recall that oscillated as the context grew. These are the vendor's own evaluations, run on haystacks Google built.

What was the Kalamang translation experiment in the Gemini 1.5 report?

It used the Machine Translation from One Book benchmark. Kalamang is spoken by fewer than 200 people and has almost no presence on the web, so a model cannot have learned it in pretraining; a 0-shot run with no materials confirmed this, with every model near random. Gemini 1.5 Pro was then given the field linguistics materials in its prompt, about 250,000 tokens: a reference grammar of roughly 500 pages, a word list of about 2,000 entries and around 400 parallel sentences. A person who learned Kalamang from the same materials rated translations from 0 to 6. English to Kalamang came out close to that human learner on average; Kalamang to English still trailed.

What does the Gemini 1.5 report say about its architecture?

Very little. Gemini 1.5 Pro is described as a sparse mixture-of-experts Transformer building on Gemini 1.0, with a learned routing function that sends each input to a subset of the parameters, so total parameters can grow while the number active per input stays constant. The report attributes the long context to significant architecture changes that it does not describe, and says the models were trained on multiple 4,096-chip TPUv4 pods across data centers. The updated report adds Gemini 1.5 Flash, distilled from Pro and computing attention and feed-forward layers in parallel. Parameter counts, the attention design and the data mixture are not disclosed.

Does perfect needle recall mean a model can reason over its whole context?

No. A single needle tests whether a model can find one verbatim fact anywhere in its input, which is necessary but much easier than using many facts together. Gemini 1.5's own results show the gap: single-needle text recall stayed above 99 percent to 10 million tokens, but when asked to retrieve 100 needles in one turn it recalled around 70 percent up to 128,000 tokens and a little over 60 percent at 1 million. Tasks such as summarizing a whole book or reconciling facts spread across chapters are harder still, which is why the report pairs its needle grids with long-document and long-video question answering.

Check yourself

4 questions to test what you just read

Work each one out before you open it — a number, a prediction or a reason, not a definition. Producing the answer is what makes it stick. Your progress is kept on this device.

A needle sits at 30 percent depth in a 1 million-token haystack. About how far is it from the end, and why is that a problem for a model whose useful attention reaches only the last 128K tokens?

Show answer

Distance from the end is (1 − f)(L − 1) ≈ 0.7 × 1,000,000 = 700,000 tokens, more than five times a 128K reach, so such a model has no direct route from the question to the needle. Gemini 1.5 Pro's near-uniform recall across depths means its usable span covers that distance.

Gemini 1.5 Pro recalled one needle more than 99 percent of the time at 1M tokens but only a bit over 60 percent of 100 needles. Why is the second test so much harder?

Show answer

One needle is one lookup: any single match answers the question. A hundred needles must all be found and reproduced in one answer, so every miss counts and the targets compete for attention and output. It is closer to aggregation than to retrieval, which is the use most people actually want from long context.

Gemini 1.0 Pro's cumulative NLL stops improving after about 32K tokens, while 1.5 Pro keeps falling to 1M on documents and 10M on code. What does a flat curve tell you?

Show answer

That tokens further back than about 32K no longer help the model predict the next token, either because they are outside its window or because it cannot use them. A falling curve means distant tokens still carry usable information, which is direct evidence that the long window is being used.

In the Kalamang test, why did the report also run every model 0-shot and with only half the grammar book?

Show answer

The 0-shot run, near random for all models, shows Kalamang knowledge is not in the weights, so later gains come from in-context learning. The half-book run, about 100K tokens, fits inside GPT-4 Turbo's 128K and Claude 3's 200K windows, giving a like-for-like comparison the full 250K materials could not.

Where this sits

What the labs report

Four papers that are reports, not methods: they state capability and withhold recipe. Read for the evaluation design and the omissions, not the architecture.

  1. 1PaLM2022
  2. 2GPT-4 Technical Report2023
  3. 3Gemini 1.52024
  4. 4GPT-5.6 System Card2026

All 110 papers, in 19 ladders →

Gemini 1.5: Unlocking Multimodal Understanding Across Millions of Tokens of Context · Gemini Team · Google DeepMind · 2024 · read the original paper on arXiv → · Vibe Engines · 2026
Finished this one? 0 / 110 Paper Breakdowns done
NextGPT-5.6 System Card Next on the “What the labs report” ladder · rung 4 of 4

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Paper Breakdowns