CoolFace
Datasetpublic

AmazonScience/document-haystack

Document Haystack Dataset This repository contains the dataset for the paper β€œDocument Haystack: A Long Context Multimodal Image/Document Understanding Vision LLM Benchmark”. πŸ“‘ Abstract Paper The proliferation of multimodal Large Language Models has significantly advanced the ability to analyze and understand complex data inputs from different modalities. However, the processing of long documents remains under-explored, largely due to a lack of suitable… See the full description on the dataset page: https://huggingface.co/datasets/AmazonScience/document-haystack.

sourceHugging Faceupdated 1y agoView on Hugging Face
20likes89kdownloads
Dataset Card

Document Haystack Dataset

This repository contains the dataset for the paper β€œDocument Haystack: A Long Context Multimodal Image/Document Understanding Vision LLM Benchmark”.


πŸ“‘ Abstract Paper

The proliferation of multimodal Large Language Models has significantly advanced the ability to analyze and understand complex data inputs from different modalities. However, the processing of long documents remains under-explored, largely due to a lack of suitable benchmarks. To address this, we introduce Document Haystack, a comprehensive benchmark designed to evaluate the performance of Vision Language Models (VLMs) on long, visually complex documents. Document Haystack features documents ranging from 5 to 200 pages and strategically inserts pure text or multimodal text+image "needles" at various depths within the documents to challenge VLMs' retrieval capabilities. Comprising 400 document variants and a total of 8,250 questions, it is supported by an objective, automated evaluation framework. We detail the construction and characteristics of the Document Haystack dataset, present results from prominent VLMs and discuss potential research avenues in this area.


πŸ—‚οΈ Overview

Document Haystack is a comprehensive benchmark dataset designed to evaluate the long-context retrieval and multimodal document understanding capabilities of Vision Language Models (VLMs).

It expands on the Needle in a Haystack concept by embedding needles β€” short key-value statements in pure text or as multimodal text+image snippets β€” within real-world long documents (5–200 pages). These needles test whether models can locate specific information hidden deep inside long, complex documents with textual, visual or mixed content.


🎯 Benchmark Design

  • β€”Key-value pairs: Each needle follows the pattern β€œThe secret KEY is VALUE.” where VALUE appears as either text or an image. For example: β€œThe secret sport is basketball.”. The keys span diverse categories including sports, animals, currencies, fruits, musical instruments, and more (see Table 3 in the paper for the complete category list).
  • β€”Tasks: Each needle has an associated retrieval question: β€œWhat is the secret KEY in the document?”
  • β€”Objective scoring: The VLM’s answer is checked for the correct VALUE (or acceptable aliases for text+image needles).

βœ… Key Features

  • β€”Document Lengths: 5, 10, 25, 50, 75, 100, 150, 200 pages
  • β€”Total Documents: 400 document variants
  • β€”Total Questions: 8,250 unique retrieval queries
  • β€”Needle Types:
  • β€”Text Needles: Pure text (e.g., β€œThe secret sport is basketball.”)
  • β€”Text+Image Needles: The value is shown as an image (e.g., β€œThe secret sport is \<image of basketball\>.”)
  • β€”Formats Provided:
  • β€”Original PDF
  • β€”Page-wise images (200 DPI)
  • β€”Parsed plain text (for text needles only)

πŸ”¬ Use Cases

  • β€”Stress-test multimodal VLMs for long-context understanding
  • β€”Compare retrieval from parsed pdf text vs images vs original pdfs
  • β€”Explore text vs image vs mixed retrieval challenges
  • β€”Measure performance drop with increasing context length

πŸ“¦ Document Haystack Format Variants

Benchmark SetFormatDescriptionUse Case
(1) Text needlesPDFOriginal document formatVLMs supporting PDF input
Image200 DPI page-wise imagesVLMs requiring image input
TextExtracted plain textText-only LLMs
(2) Text+Image needlesPDFOriginal document formatVLMs supporting PDF input
Image200 DPI page-wise imagesVLMs requiring image input

πŸ“Š Document Haystack Characteristics

# Pages510255075100150200Total
Text Needles # Documents2525252525252525200
Text Needles # Questions1252506256256256256256254125
Text+Image Needles # Documents2525252525252525200
Text+Image Needles # Questions1252506256256256256256254125
Total Documents5050505050505050400
Total Questions2505001250125012501250125012508250

πŸ—„οΈ Dataset Structure

Below is an example of the dataset’s folder layout:

DocumentHaystack/
β”œβ”€β”€ AIG/
β”‚   β”œβ”€β”€ AIG_5Pages/
β”‚   β”‚   β”œβ”€β”€ AIG_5Pages_ImageNeedles.pdf
β”‚   β”‚   β”œβ”€β”€ AIG_5Pages_TextNeedles.pdf
β”‚   β”‚   β”œβ”€β”€ Images_TextImageNeedles/
β”‚   β”‚   β”‚   β”œβ”€β”€ AIG_5Pages_ImageNeedles_page_1.jpg
β”‚   β”‚   β”‚   β”œβ”€β”€ AIG_5Pages_ImageNeedles_page_2.jpg
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ Images_TextNeedles/
β”‚   β”‚   β”‚   β”œβ”€β”€ AIG_5Pages_TextNeedles_page_1.jpg
β”‚   β”‚   β”‚   β”œβ”€β”€ AIG_5Pages_TextNeedles_page_2.jpg
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ Text_TextNeedles/
β”‚   β”‚   β”‚   β”œβ”€β”€ AIG_5Pages_TextNeedles_page_1.txt
β”‚   β”‚   β”‚   β”œβ”€β”€ AIG_5Pages_TextNeedles_page_2.txt
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ needles_info.csv
β”‚   β”‚   β”œβ”€β”€ needles.csv
β”‚   β”‚   β”œβ”€β”€ prompt_questions.txt
β”‚   β”œβ”€β”€ AIG_10Pages/
β”‚   β”œβ”€β”€ AIG_25Pages/
β”‚   β”œβ”€β”€ AIG_50Pages/
β”‚   β”œβ”€β”€ AIG_75Pages/
β”‚   β”œβ”€β”€ AIG_100Pages/
β”‚   β”œβ”€β”€ AIG_150Pages/
β”‚   β”œβ”€β”€ AIG_200Pages/
β”‚
β”‚   needles.csv
β”‚   prompt_questions.txt
β”‚
β”œβ”€β”€ AmericanAirlines/
β”œβ”€β”€ APA/
β”œβ”€β”€ BankOfMontreal/
...

πŸ“ File and Folder Descriptions

Below is an explanation of the files inside the AIG_5Pages subfolder:

File/FolderDescription
AIG_5Pages_ImageNeedles.pdfPDF version with hidden Text+Image needles
AIG_5Pages_TextNeedles.pdfPDF version with hidden Text-only needles
Images_TextImageNeedles/Folder with page-wise JPGs of the Text+Image needles PDF
Images_TextNeedles/Folder with page-wise JPGs of the Text-only needles PDF
Text_TextNeedles/Folder with plain .txt files per page for Text-Needles version
needles.csvLists the key-value pairs inserted in the document variant
needles_info.csvDetailed placement metadata for each needle (page, coordinates, font, etc.)
prompt_questions.txtContains the questions the model must answer for needle retrieval

Within the main AIG folder, you'll find two key files: needles.csv, which lists all 25 needles that are utilized across the different AIG variants, and prompt_questions.txt, which contains the complete set of 25 prompts used throughout the AIG variants.

There are 25 top-level subfolders in total, each referring to a different document (e.g., AIG/, AmericanAirlines/, APA/, BankOfMontreal/), each structured the same way.


πŸ“Œ needles_info.csv

Each document variant includes a needles_info.csv detailing every needle’s properties:

Example rows:

The secret office supply is a "pencil".,2,8,gray,white,0.339,0.931,times-bold,90
The secret sport is "basketball".,3,10,green,white,0.917,0.746,times-bolditalic,112
ColumnDescription
NeedleNeedle text statement (the hidden key-value pair)
PagePage number where needle is inserted
Font SizeFont size
Text ColorForeground color
Background ColorBackground color
XX coordinate (normalized 0–1)
YY coordinate (normalized 0–1)
FontFont type
ScaleImage scale (for text+image needles)

Placement:

  • β€”Needles are randomly placed across equal, non-overlapping page ranges to ensure coverage throughout the document.
  • β€”Same locations are reused for both text-only and text+image sets.

πŸ“ Reference Evaluation

Use with the Document Haystack Benchmark Code for:

  • β€”Fully automated inference & scoring pipelines
  • β€”Heatmap generation for depth-based performance

πŸ“ License

This project is licensed under the CC-BY-NC-4.0 License - see the GitHub LICENSE file for details.


πŸ“š Citation

If you use this work in any way, please cite:

bibtex
@article{huybrechts2025document,
  title={Document Haystack: A Long Context Multimodal Image/Document Understanding Vision LLM Benchmark},
  author={Huybrechts, Goeric and Ronanki, Srikanth and Jayanthi, Sai Muralidhar and Fitzgerald, Jack and Veeravanallur, Srinivasan},
  journal={arXiv preprint arXiv:2507.15882},
  year={2025}
}

πŸ‘₯ Authors

Amazon AGI

  • β€”Goeric Huybrechts
  • β€”Srikanth Ronanki
  • β€”Sai Muralidhar Jayanthi
  • β€”Jack Fitzgerald
  • β€”Srinivasan Veeravanallur
AmazonScience/document-haystack Β· CoolFace