File size: 8,761 Bytes
7fadaf8
 
58195b6
7fadaf8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58195b6
 
 
 
 
 
 
 
7fadaf8
 
 
 
 
 
 
b7f3db9
7fadaf8
 
 
 
 
 
 
58195b6
7fadaf8
58195b6
 
 
 
7fadaf8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58195b6
 
 
 
 
 
 
 
 
 
 
 
 
7fadaf8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# 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 Set | Format | Description | Use Case |
|----------------|--------|-------------------------------|-------------------------------|
| (1) Text needles | PDF | Original document format | VLMs supporting PDF input |
|  | Image | 200 DPI page-wise images | VLMs requiring image input |
|  | Text | Extracted plain text | Text-only LLMs |
| (2) Text+Image needles | PDF | Original document format | VLMs supporting PDF input |
|  | Image | 200 DPI page-wise images | VLMs requiring image input |

---

## 📊 Document Haystack Characteristics

| # Pages | 5 | 10 | 25 | 50 | 75 | 100 | 150 | 200 | Total |
|----------------|-----|-----|------|------|------|-------|-------|-------|-------|
| Text Needles # Documents | 25 | 25 | 25 | 25 | 25 | 25 | 25 | 25 | 200 |
| Text Needles # Questions | 125 | 250 | 625 | 625 | 625 | 625 | 625 | 625 | 4125 |
| Text+Image Needles # Documents | 25 | 25 | 25 | 25 | 25 | 25 | 25 | 25 | 200 |
| Text+Image Needles # Questions | 125 | 250 | 625 | 625 | 625 | 625 | 625 | 625 | 4125 |
| **Total Documents** | **50** | **50** | **50** | **50** | **50** | **50** | **50** | **50** | **400** |
| **Total Questions** | **250** | **500** | **1250** | **1250** | **1250** | **1250** | **1250** | **1250** | **8250** |

---

## 📁 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/Folder | Description |
|-------------------------------|--------------------------------------------------------------------------|
| **AIG_5Pages_ImageNeedles.pdf** | PDF version with hidden Text+Image needles |
| **AIG_5Pages_TextNeedles.pdf** | PDF 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.csv** | Lists the key-value pairs inserted in the document variant |
| **needles_info.csv** | Detailed placement metadata for each needle (page, coordinates, font, etc.) |
| **prompt_questions.txt** | Contains 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 currency is a "euro".,1,13,purple,white,0.546,0.163,times-roman,143
The secret office supply is a "pencil".,2,8,gray,white,0.339,0.931,times-bold,90
```

| Column | Description |
|---------------------|----------------------------------------------|
| **Needle** | Needle text statement (the hidden key-value pair) |
| **Page** | Page number where needle is inserted |
| **Font Size** | Font size |
| **Text Color** | Foreground color |
| **Background Color** | Background color |
| **X** | X coordinate (normalized 0–1) |
| **Y** | Y coordinate (normalized 0–1) |
| **Font** | Font type |
| **Scale** | Image 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](https://github.com/amazon-science/document-haystack) 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.

---

## 👥 Authors

Amazon AGI
- **Goeric Huybrechts**
- **Srikanth Ronanki**
- **Sai Muralidhar Jayanthi**
- **Jack Fitzgerald**
- **Srinivasan Veeravanallur**