Sequential-NIAH: A Needle-In-A-Haystack Benchmark for Extracting Sequential Needles from Long Contexts

Yifei Yu, Qian-Wen Zhang, Lingfeng Qiao, Di Yin, Fang Li, Jie Wang, Chen Zeng Xi, Suncong Zheng, Xiaolong Liang, Xing Sun

TL;DR

Large language models (LLMs) are getting better at handling long texts, but evaluating their ability to extract specific, ordered information remains a challenge. This paper introduces Sequential-NIAH, a new benchmark designed to test LLMs' capacity to find and correctly order sequential "needles" (pieces of information) within lengthy documents, revealing significant limitations in current models.

What Problem Does This Paper Address?

As LLMs like Gemini-1.5 and GPT-4 gain the ability to process millions of tokens, evaluating their comprehension of long contexts becomes crucial. While existing benchmarks exist for long-context understanding and retrieving specific facts (Needle-in-a-Haystack or NIAH tasks), they often overlook the sequential nature of information. Many real-world scenarios require not just finding information, but also understanding its temporal or logical order. For instance, listing events in chronological order from a legal document or outlining steps in a guideline. This paper addresses the gap in evaluating LLMs' ability to handle these sequential information extraction tasks within long contexts.

Methods

The core contribution is the Sequential-NIAH benchmark. This benchmark consists of:

  • Three Needle Generation Pipelines:
    • Synthetic-temporal order: Generates fake entities, timestamps, and events to create temporal sequences.
  • Real-temporal order: Uses Temporal Knowledge Graphs (TKGs) to build sequential temporal items based on real-world relationships.
  • Real-logical order: Leverages a private open-domain QA resource to create sequences based on logical dependencies.
  • Long Contexts: The benchmark uses texts ranging from 8K to 128K tokens, sourced from the LongData-Corpus, covering diverse domains.
  • Evaluation Model: To overcome the cost and potential bias of using LLMs like GPT-4 for evaluation, the authors trained their own evaluation model. This model was trained on synthetic data encompassing various types of incorrect answers (missing, redundant, disordered, etc.) and achieved a high accuracy of 99.49% on their synthetic test set, outperforming GPT-40 and Claude.

Datasets

The paper introduces the Sequential-NIAH benchmark, comprising 14,000 samples (2,000 for testing). This dataset is constructed using three distinct needle generation pipelines (synthetic-temporal, real-temporal, and real-logical) and long contexts of varying lengths (8K to 128K tokens). The dataset is split into training, development, and test sets.

Key Insights and Ideas

  • Sequentiality is a Major Hurdle: Current state-of-the-art LLMs struggle significantly with extracting and ordering sequential information, even when the context length is manageable.
  • Real-world data is harder: Retrieving information in temporal order from real-world texts (real-temporal needles) is more challenging than logical order or synthetic temporal sequences.
  • Model size doesn't always guarantee performance: For some model families (like Qwen), performance can degrade as model size decreases, but this doesn't hold universally, and even the largest models show limitations.
  • A reliable evaluation tool is crucial: The authors demonstrate that a custom-trained evaluation model can be more accurate and efficient than powerful LLMs for benchmark evaluation.

Key Results

  • The best-performing LLM on the Sequential-NIAH benchmark achieved only 63.50% accuracy.
  • Accuracy generally decreases as context length increases.
  • Performance also deteriorates as the number of needles increases.
  • LLMs perform better on real-logical order needles compared to temporal order needles, suggesting that retrieving and listing information in temporal order is a greater challenge.
  • Language (English vs. Chinese) was found to be not a significant factor affecting performance.
  • Noise analysis showed that LLMs are somewhat robust to minor positional shifts but can be significantly impacted by more substantial changes or semantic noise.

Limitations and Future Work

  • Dataset Domain Bias: Model evaluations might be biased by the specific domains covered in the dataset.
  • API Parameter Optimization: Unoptimized API parameters for closed-source models could affect performance and fairness.
  • Academic Use Only: The dataset is intended for research purposes, and commercial or misuse is prohibited.

The authors suggest that their benchmark provides a valuable reference for advancing research on long-text information extraction capabilities of LLMs, implying future work should focus on improving these capabilities.

Summary updated

BibTeX
@inproceedings{yu2025sequential,
  author = {Yifei Yu and Qian-Wen Zhang and Lingfeng Qiao and Di Yin and Fang Li and Jie Wang and Chen Zeng Xi and Suncong Zheng and Xiaolong Liang and Xing Sun},
  title = {{Sequential-NIAH: A Needle-In-A-Haystack Benchmark for Extracting Sequential Needles from Long Contexts}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure