Back to LLMs Mind Map
中文·English
LLMsID: needle-lost-middle

Long-Context Eval Needle/Lost-in-Middle

长上下文评测 Needle/Lost-in-Middle
🎯Core Definition
two evaluation methods for long-context ability. (1) Needle-in-a-Haystack: insert one memorable fact (the needle) at a random position inside a long irrelevant text (the haystack), ask for it, and measure precise recall Acc=needles retrievedtotal tests\text{Acc} = \tfrac{\text{needles retrieved}}{\text{total tests}}, plotted as a recall heatmap over needle position and context length; (2) Lost-in-the-Middle (Liu et al., 2023): position experiments show models use content from the beginning and end far better than the middle — a U-shaped dip in the middle region, measured with multi-document KV retrieval tasks.
💡Use Cases
verifying real long-context capability claims (128K/1M) before release; RAG systems checking whether evidence is found wherever it sits in a document; context-window design (key info at the head/tail, re-ranked retrieval); a classic interview topic on why middle content gets lost.
Key Problems Solved
advertised context length ≠ effective context use. Needle tests expose fake long-context ("can fit but can't read"), and Lost-in-the-Middle reveals positional bias in long-range attention — guiding mitigations on both the training side (positional interpolation, randomized document order) and inference side (key info first, section markers).
🎯5 High-Frequency Exam Points
1
How do you design a needle-in-a-haystack test? What are the heatmap axes and what does an ideal model look like?
2
What is the U-shaped Lost-in-the-Middle dip, and why is middle content most often ignored?
3
Training-side mitigations for Lost-in-the-Middle: positional encoding, document order, attention bias — list them.
4
Inference-side organization: how to order retrieved chunks, where to put key info, and what section markers do.
5
Does a perfect needle score mean long-context is fully usable? What are its blind spots?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Long-Context Eval Needle/Lost-in-Middle"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardHallucination MitigationNext CardAgent & Tool Calling

🔗 More LLMs Knowledge Cards

Alignment Tax & Preference DataScaled Dot-Product AttentionAttention Variants MHA/MQA/GQABenchmarks MMLU/GSM8K