Datasets:

Modalities:
Text
ArXiv:
Libraries:
Datasets
File size: 20,247 Bytes
175e6ae
f61f6c2
 
 
 
 
175e6ae
 
 
 
 
 
 
 
f61f6c2
29ee647
f61f6c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29ee647
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47ac8bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72ce14e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cc4e964
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad68a11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92b6c5f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b8e164b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f61f6c2
 
 
 
 
29ee647
 
 
 
47ac8bb
 
 
 
72ce14e
 
 
 
cc4e964
 
 
 
ad68a11
 
 
 
92b6c5f
 
 
 
b8e164b
 
 
 
175e6ae
 
 
 
7956e94
175e6ae
10e175d
175e6ae
7956e94
175e6ae
c2a61c1
7956e94
c2a61c1
175e6ae
 
 
 
 
 
 
7956e94
 
 
175e6ae
 
 
 
7956e94
 
 
 
 
 
 
 
 
 
 
175e6ae
 
 
7956e94
175e6ae
 
 
7956e94
 
 
 
175e6ae
 
 
 
 
 
 
 
 
 
 
 
 
 
c2a61c1
7956e94
 
 
c2a61c1
 
7956e94
 
c2a61c1
7956e94
 
 
 
 
 
 
 
 
c2a61c1
 
 
7956e94
175e6ae
 
 
 
 
c2a61c1
175e6ae
 
7956e94
175e6ae
c2a61c1
 
7956e94
 
175e6ae
7956e94
175e6ae
 
7956e94
c2a61c1
 
175e6ae
 
c2a61c1
 
 
 
 
175e6ae
 
 
 
7956e94
c2a61c1
7956e94
c2a61c1
7956e94
 
c2a61c1
 
 
7956e94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
---
language:
- en
- zh
size_categories:
- 1K<n<10K
task_categories:
- question-answering
- text-generation
- summarization
- conversational
- text-classification
tags:
- Long Context
dataset_info:
- config_name: 2wikimqa
  features:
  - name: input
    dtype: string
  - name: context
    dtype: string
  - name: answers
    list: string
  - name: length
    dtype: int32
  - name: dataset
    dtype: string
  - name: language
    dtype: string
  - name: all_classes
    list: string
  - name: _id
    dtype: string
  splits:
  - name: test
    num_bytes: 5982997
    num_examples: 200
  download_size: 3595131
  dataset_size: 5982997
- config_name: 2wikimqa_e
  features:
  - name: input
    dtype: string
  - name: context
    dtype: string
  - name: answers
    list: string
  - name: length
    dtype: int32
  - name: dataset
    dtype: string
  - name: language
    dtype: string
  - name: all_classes
    list: string
  - name: _id
    dtype: string
  splits:
  - name: test
    num_bytes: 11331920
    num_examples: 300
  download_size: 6782587
  dataset_size: 11331920
- config_name: dureader
  features:
  - name: input
    dtype: string
  - name: context
    dtype: string
  - name: answers
    list: string
  - name: length
    dtype: int32
  - name: dataset
    dtype: string
  - name: language
    dtype: string
  - name: all_classes
    list: string
  - name: _id
    dtype: string
  splits:
  - name: test
    num_bytes: 8212951
    num_examples: 200
  download_size: 5167177
  dataset_size: 8212951
- config_name: gov_report
  features:
  - name: input
    dtype: string
  - name: context
    dtype: string
  - name: answers
    list: string
  - name: length
    dtype: int32
  - name: dataset
    dtype: string
  - name: language
    dtype: string
  - name: all_classes
    list: string
  - name: _id
    dtype: string
  splits:
  - name: test
    num_bytes: 11593569
    num_examples: 200
  download_size: 5504355
  dataset_size: 11593569
- config_name: gov_report_e
  features:
  - name: input
    dtype: string
  - name: context
    dtype: string
  - name: answers
    list: string
  - name: length
    dtype: int32
  - name: dataset
    dtype: string
  - name: language
    dtype: string
  - name: all_classes
    list: string
  - name: _id
    dtype: string
  splits:
  - name: test
    num_bytes: 14263436
    num_examples: 300
  download_size: 6669354
  dataset_size: 14263436
- config_name: hotpotqa
  features:
  - name: input
    dtype: string
  - name: context
    dtype: string
  - name: answers
    list: string
  - name: length
    dtype: int32
  - name: dataset
    dtype: string
  - name: language
    dtype: string
  - name: all_classes
    list: string
  - name: _id
    dtype: string
  splits:
  - name: test
    num_bytes: 11379153
    num_examples: 200
  download_size: 6626936
  dataset_size: 11379153
- config_name: hotpotqa_e
  features:
  - name: input
    dtype: string
  - name: context
    dtype: string
  - name: answers
    list: string
  - name: length
    dtype: int32
  - name: dataset
    dtype: string
  - name: language
    dtype: string
  - name: all_classes
    list: string
  - name: _id
    dtype: string
  splits:
  - name: test
    num_bytes: 12324268
    num_examples: 300
  download_size: 7196922
  dataset_size: 12324268
- config_name: lcc
  features:
  - name: input
    dtype: string
  - name: context
    dtype: string
  - name: answers
    list: string
  - name: length
    dtype: int32
  - name: dataset
    dtype: string
  - name: language
    dtype: string
  - name: all_classes
    list: string
  - name: _id
    dtype: string
  splits:
  - name: test
    num_bytes: 6878988
    num_examples: 500
  download_size: 2348393
  dataset_size: 6878988
configs:
- config_name: 2wikimqa
  data_files:
  - split: test
    path: 2wikimqa/test-*
- config_name: 2wikimqa_e
  data_files:
  - split: test
    path: 2wikimqa_e/test-*
- config_name: dureader
  data_files:
  - split: test
    path: dureader/test-*
- config_name: gov_report
  data_files:
  - split: test
    path: gov_report/test-*
- config_name: gov_report_e
  data_files:
  - split: test
    path: gov_report_e/test-*
- config_name: hotpotqa
  data_files:
  - split: test
    path: hotpotqa/test-*
- config_name: hotpotqa_e
  data_files:
  - split: test
    path: hotpotqa_e/test-*
- config_name: lcc
  data_files:
  - split: test
    path: lcc/test-*
---

# Introduction

**LongBench** is the first benchmark for bilingual, multitask, and comprehensive assessment of **long context understanding** capabilities of large language models. LongBench includes different languages (Chinese and English) to provide a more comprehensive evaluation of the large models' multilingual capabilities on long contexts. In addition, LongBench is composed of six major categories and twenty one different tasks, covering key long-text application scenarios such as single-document QA, multi-document QA, summarization, few-shot learning, synthetic tasks and code completion.

We are fully aware of the potentially high costs involved in the model evaluation process, especially in the context of long context scenarios (such as manual annotation costs or API call costs). Therefore, we adopt a fully automated evaluation method, aimed at measuring and evaluating the model's ability to understand long contexts at the lowest cost.

LongBench includes 14 English tasks, 5 Chinese tasks, and 2 code tasks, with the average length of most tasks ranging from 5k to 15k, and a total of 4,750 test data. For detailed statistics and construction methods of LongBench tasks, please refer [here](task.md). In addition, we provide LongBench-E, a test set with a more uniform length distribution constructed by uniform sampling, with comparable amounts of data in the 0-4k, 4k-8k, and 8k+ length intervals to provide an analysis of the model's performance variations at different input lengths.

Github Repo for LongBench: https://github.com/THUDM/LongBench
Arxiv Paper for LongBench: https://arxiv.org/pdf/2308.14508.pdf

# How to use it?

#### Loading Data

```python
from datasets import load_dataset

datasets = ["narrativeqa", "qasper", "multifieldqa_en", "multifieldqa_zh", "hotpotqa", "2wikimqa", "musique", \
            "dureader", "gov_report", "qmsum", "multi_news", "vcsum", "trec", "triviaqa", "samsum", "lsht", \
            "passage_count", "passage_retrieval_en", "passage_retrieval_zh", "lcc", "repobench-p"]

for dataset in datasets:
    data = load_dataset('THUDM/LongBench', dataset, split='test')
```
Similarly, you can load the **LongBench-E** data
```python
from datasets import load_dataset

datasets = ["qasper", "multifieldqa_en", "hotpotqa", "2wikimqa", "gov_report", "multi_news", "trec", \
            "triviaqa", "samsum", "passage_count", "passage_retrieval_en", "lcc", "repobench-p"]

for dataset in datasets:
    data = load_dataset('THUDM/LongBench', f"{dataset}_e", split='test')
```
Alternatively, you can download the folder from [this link](https://huggingface.co/datasets/THUDM/LongBench/resolve/main/data.zip) to load the data.

#### Data Format

All data in **LongBench** (LongBench-E) are standardized to the following format:

```json
{
    "input": "The input/command for the task, usually short, such as questions in QA, queries in Few-shot tasks, etc",
    "context": "The long context required for the task, such as documents, cross-file code, few-shot examples in Few-shot tasks",
    "answers": "A List of all true answers",
    "length": "Total length of the first three items (counted in characters for Chinese and words for English)",
    "dataset": "The name of the dataset to which this piece of data belongs",
    "language": "The language of this piece of data",
    "all_classes": "All categories in classification tasks, null for non-classification tasks",
    "_id": "Random id for each piece of data"
}
```

#### Evaluation

This repository provides data download for LongBench. If you wish to use this dataset for automated evaluation, please refer to our [github](https://github.com/THUDM/LongBench).

# Task statistics

| Task          | Task Type | Eval metric |     Avg len                            |Language | \#Sample |
| :-------- | :-----------:| :-----------: |:-------: | :-----------: |:--------: |
| HotpotQA   | Multi-doc QA | F1                        |9,151                           |EN                           |200                           |
| 2WikiMultihopQA| Multi-doc QA | F1                        |4,887                           |EN                           |200                           |
| MuSiQue| Multi-doc QA | F1                        |11,214                           |EN                           |200                           |
| DuReader| Multi-doc QA | Rouge-L                 |15,768                           |ZH                           |200                           |
| MultiFieldQA-en| Single-doc QA | F1                        |4,559                           |EN                           |150                           |
| MultiFieldQA-zh| Single-doc QA | F1                        |6,701                           |ZH                           |200                           |
| NarrativeQA| Single-doc QA | F1                        |18,409                           |EN                           |200                           |
| Qasper| Single-doc QA | F1                        |3,619                           |EN                           |200                           |
| GovReport| Summarization | Rouge-L                 |8,734                           |EN                           |200                           |
| QMSum| Summarization | Rouge-L                 |10,614                           |EN                           |200                           |
| MultiNews| Summarization  | Rouge-L                 |2,113                           |EN                          |200                           |
| VCSUM| Summarization | Rouge-L                 |15,380                           |ZH                           |200                           |
| TriviaQA| Few shot  | F1                        |8,209                           |EN                           |200                           |
| SAMSum| Few shot | Rouge-L                        |6,258                           |EN                           |200                           |
| TREC| Few shot | Accuracy                |5,177                           |EN                           |200                           |
| LSHT| Few shot | Accuracy                |22,337                           |ZH                           |200                           |
| PassageRetrieval-en| Synthetic | Accuracy                |9,289                           |EN                           |200                           |
| PassageCount| Synthetic | Accuracy                |11,141                           |EN                           |200  |
| PassageRetrieval-zh | Synthetic | Accuracy                |6,745                           |ZH                           |200                           |
| LCC| Code | Edit Sim              |1,235                           |Python/C#/Java                           |500                           |
| RepoBench-P| Code | Edit Sim                |4,206                           |Python/Java                           |500                           |

> Note: In order to avoid discrepancies caused by different tokenizers, we use the word count (using Python's split function) to calculate the average length of English datasets and code datasets, and use the character count to calculate the average length of Chinese datasets.

# Task description
| Task              | Task Description                                            |
| :---------------- | :----------------------------------------------------------- |
| HotpotQA          | Answer related questions based on multiple given documents   |
| 2WikiMultihopQA   | Answer related questions based on multiple given documents   |
| MuSiQue           | Answer related questions based on multiple given documents   |
| DuReader          | Answer related Chinese questions based on multiple retrieved documents |
| MultiFieldQA-en   | Answer English questions based on a long article, which comes from a relatively diverse field |
| MultiFieldQA-zh   | Answer Chinese questions based on a long article, which comes from a relatively diverse field |
| NarrativeQA       | Answer questions based on stories or scripts, including understanding of important elements such as characters, plots, themes, etc. |
| Qasper            | Answer questions based on a NLP research paper, questions proposed and answered by NLP practitioners |
| GovReport         | A summarization task that requires summarizing government work reports |
| MultiNews             | A multi-doc summarization that requires summarizing over multiple news   |
| QMSum             | A summarization task that requires summarizing meeting records based on user queries |
| VCSUM             | A summarization task that requires summarizing Chinese meeting records |
| SAMSum            | A dialogue summarization task, providing several few-shot examples                    |
| TriviaQA          | Single document question answering task, providing several few-shot examples |
| NQ                | Single document question answering task, providing several few-shot examples |
| TREC              | A classification task that requires categorizing questions, includes 50 categories in total |
| LSHT              | A Chinese classification task that requires categorizing news, includes 24 categories in total |
| PassageRetrieval-en | Given 30 English Wikipedia paragraphs, determine which paragraph the given summary corresponds to |
| PassageCount | Determine the total number of different paragraphs in a given repetitive article |
| PassageRetrieval-zh | Given several Chinese paragraphs from the C4 data set, determine which paragraph the given abstract corresponds to |
| LCC               | Given a long piece of code, predict the next line of code |
| RepoBench-P       | Given code in multiple files within a GitHub repository (including cross-file dependencies), predict the next line of code |

# Task construction
> Note: For all tasks constructed from existing datasets, we use data from the validation or test set of the existing dataset (except for VCSUM).

- The tasks of [HotpotQA](https://hotpotqa.github.io/), [2WikiMultihopQA](https://aclanthology.org/2020.coling-main.580/), [MuSiQue](https://arxiv.org/abs/2108.00573), and [DuReader](https://github.com/baidu/DuReader) are built based on the original datasets and processed to be suitable for long context evaluation. Specifically, for questions in the validation set, we select the evidence passage that contains the answer and several distracting articles. These articles together with the original question constitute the input of the tasks.
- The tasks of MultiFiedQA-zh and MultiFieldQA-en consist of long artical data from about 10 sources, including Latex papers, judicial documents, government work reports, and PDF documents indexed by Google. For each long artical, we invite several PhD and master students to annotate, i.e., to ask questions based on the long artical and give the correct answers. To better automate evaluation, we ask the annotators to propose questions with definitive answers as much as possible.
- The tasks of [NarrativeQA](https://arxiv.org/pdf/1712.07040.pdf), [Qasper](https://arxiv.org/pdf/2105.03011.pdf), [GovReport](https://arxiv.org/pdf/2104.02112.pdf), [QMSum](https://arxiv.org/pdf/2104.05938.pdf) and [MultiNews](https://aclanthology.org/P19-1102.pdf) directly use the data provided by the original papers. In the specific construction, we use the template provided by [ZeroSCROLLS](https://www.zero.scrolls-benchmark.com/) to convert the corresponding data into pure text input.
- The [VCSUM](https://arxiv.org/abs/2305.05280) task is built based on the original dataset, and we design a corresponding template to convert the corresponding data into pure text input.
- The [TriviaQA](https://nlp.cs.washington.edu/triviaqa/) task is constructed in the manner of [CoLT5](https://arxiv.org/abs/2303.09752), which provides several examples of question and answering based on documents, and requires the language model to answer related questions based on new documents.
- The tasks of [SAMSum](https://aclanthology.org/D19-5409.pdf), [TREC](https://aclanthology.org/C02-1150.pdf) and [LSHT](http://tcci.ccf.org.cn/conference/2014/dldoc/evatask6.pdf) are built based on the original datasets. For each question in the validation set, we sample several data from the training set to form few-shot examples. These examples together with the questions in the validation set constitute the input for this task.
- The PassageRetrieval-en task is constructed based on English Wikipedia. For each piece of data, we randomly sample 30 paragraphs from English Wikipedia and select one for summarization (using GPT-3.5-Turbo). This task requires the model to give the original paragraph name to which the summary corresponds.
- The PassageCount task is constructed based on the English wiki. For each piece of data, we randomly sample several passages from English Wikipedia, repeat each paragraph at random several times, and finally shuffle the paragraphs. This task requires the model to determine the total number of different paragraphs in the given context.
- The PasskeyRetrieval-zh task is constructed based on [C4](https://arxiv.org/abs/1910.10683). For each piece of data, we randomly sample several Chinese paragraphs from C4 and select one of them for summarization (using GPT-3.5-Turbo). This task requires the model to give the original paragraph name to which the summary corresponds.
- For the [LCC](https://arxiv.org/abs/2306.14893) task, we sample from the original code completion dataset. In the [RepoBench-P](https://arxiv.org/abs/2306.03091) task, we select the most challenging XF-F (Cross-File-First) setting from the original dataset and refer to the Oracle-Filled scenario in the paper. For each original piece of data, we randomly extract multiple cross-file code snippets, including the gold cross-file code snippet, and concatenate them as input, requiring the model to effectively use cross-file code for completion.

# LongBench-E statistics
| Task          | Task Type  |   \#data in 0-4k  |     \#data in 4-8k                    | \#data in 8k+|
| :--------- | :-----------:| :-----------: |:---------: | :-------------: |
| HotpotQA   | Multi-doc QA       | 100                        |100                           |100   |
| 2WikiMultihopQA| Multi-doc QA | 100                        |100                           |100     |
| MultiFieldQA-en| Single-doc QA | 67                        |70                           |13      |
| Qasper| Single-doc QA    | 100                        |100                           |24      |
| GovReport| Summarization | 100                 |100                           |100        |
| MultiNews| Summarization | 100                 |100                           |94            |
| TriviaQA| Few shot  | 100                        |100                           |100 |
| SAMSum| Few shot | 100                        |100                           |100   |
| TREC| Few shot | 100                |100                           |100     |
| PassageRetrieval-en| Synthetic | 100                |100                           |100     |
| PassageCount| Synthetic | 100                |100                           |100   |
| LCC| Code | 100              |100                           |100  |
| RepoBench-P| Code | 100               |100                          |100  |

# Citation
```
@misc{bai2023longbench,
      title={LongBench: A Bilingual, Multitask Benchmark for Long Context Understanding}, 
      author={Yushi Bai and Xin Lv and Jiajie Zhang and Hongchang Lyu and Jiankai Tang and Zhidian Huang and Zhengxiao Du and Xiao Liu and Aohan Zeng and Lei Hou and Yuxiao Dong and Jie Tang and Juanzi Li},
      year={2023},
      eprint={2308.14508},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
```