Evidence label: deterministic synthetic model. This page runs a small JavaScript model of the context-assembly step in RAG. For each of 300 synthetic questions it draws retriever scores for one answer chunk, four hard negatives and 36 weaker chunks, optionally adds near-duplicate copies, retrieves the top k, packs them into a token budget, orders them and computes the probability that a model would answer correctly from a positional curve. Nothing here calls a model or a vector database; every number is a calculated estimate from a synthetic model.
Play the lab
How to play
Choose an ordering, then adjust top-k, chunk size and the context budget. Every change re-runs the same 300 questions with the same random draws, so a difference you see comes from your change, not from luck. The strip at the top cycles through sample prompts; the green dot on the curve shows where the answer chunk landed and the probability the model uses it. Metric tiles show the change against your previous setup in green or red.
Missions unlock in order. Load mission setup starts you from a broken configuration. One star means you met the goal; more stars reward the cheaper or more robust fix. Toggle the duplicate flood, retriever drift or weaker-model events at any time to stress your setup.
What the model assumes
The answer chunk's retriever score is normally distributed with a mean that falls as chunks get larger (larger chunks dilute the embedding) and falls further under drift. Hard negatives score close to it; ordinary chunks score lower. Chunk lengths vary between 80% and 120% of the chosen size. An answer fact of about 40 tokens is split across a chunk boundary with probability 40 divided by chunk size, which cuts the chance of a correct answer to 60% of its value. The positional curve is an edge accuracy of 95% minus a dip that is zero at the ends and largest in the middle; the dip grows with the logarithm of prompt length and is deeper for the weaker model. Each hard negative in the prompt costs 1.2 points and each extra chunk 0.2 points. Cost uses an illustrative $3 per million input tokens and prefill assumes roughly 22,000 tokens per second.
What it cannot tell you
Real models do not follow one smooth curve: the dip depends on the model, the task, how similar the chunks look and how the prompt is formatted, and some recent models show little dip on simple lookups. The model also ignores multi-chunk answers, reranking, instructions that tell the model where to look, and answers that are partly right. Use it to build intuition about how ordering, top-k, chunk size and prompt length interact, then measure your own system with a position-swap evaluation.
Read the full explanation
- Lost in the Middle: Ordering and Packing Retrieved Context for Long Prompts (companion article)
- Cross-Encoder Reranking Depth: How Many Candidates Are Worth the Latency
- Chunking Strategies Compared: Fixed, Recursive, Semantic and Late Chunking
All AI in Production labs · Lab catalog
- Lost in the Middle: How Language Models Use Long Contexts (Liu et al., TACL 2024)
- RULER: What's the Real Context Size of Your Long-Context Language Models? (Hsieh et al., 2024)
- LangChain how-to: reorder retrieved results to mitigate the lost in the middle effect
- LlamaIndex example: LongContextReorder node postprocessor
- Anthropic documentation: long context prompting tips
Views are my own and do not represent any employer, past or present.