THUDM/LongBench

Dataset

Introduction

191

9 commits

3 linked in READMEs

updated Dec 18, 2024

See the code

README

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. 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

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

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 to load the data.

Data Format

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

{
    "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.

Task statistics

TaskTask TypeEval metricAvg lenLanguage#Sample
HotpotQAMulti-doc QAF19,151EN200
2WikiMultihopQAMulti-doc QAF14,887EN200
MuSiQueMulti-doc QAF111,214EN200
DuReaderMulti-doc QARouge-L15,768ZH200
MultiFieldQA-enSingle-doc QAF14,559EN150
MultiFieldQA-zhSingle-doc QAF16,701ZH200
NarrativeQASingle-doc QAF118,409EN200
QasperSingle-doc QAF13,619EN200
GovReportSummarizationRouge-L8,734EN200
QMSumSummarizationRouge-L10,614EN200
MultiNewsSummarizationRouge-L2,113EN200
VCSUMSummarizationRouge-L15,380ZH200
TriviaQAFew shotF18,209EN200
SAMSumFew shotRouge-L6,258EN200
TRECFew shotAccuracy5,177EN200
LSHTFew shotAccuracy22,337ZH200
PassageRetrieval-enSyntheticAccuracy9,289EN200
PassageCountSyntheticAccuracy11,141EN200
PassageRetrieval-zhSyntheticAccuracy6,745ZH200
LCCCodeEdit Sim1,235Python/C#/Java500
RepoBench-PCodeEdit Sim4,206Python/Java500

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

TaskTask Description
HotpotQAAnswer related questions based on multiple given documents
2WikiMultihopQAAnswer related questions based on multiple given documents
MuSiQueAnswer related questions based on multiple given documents
DuReaderAnswer related Chinese questions based on multiple retrieved documents
MultiFieldQA-enAnswer English questions based on a long article, which comes from a relatively diverse field
MultiFieldQA-zhAnswer Chinese questions based on a long article, which comes from a relatively diverse field
NarrativeQAAnswer questions based on stories or scripts, including understanding of important elements such as characters, plots, themes, etc.
QasperAnswer questions based on a NLP research paper, questions proposed and answered by NLP practitioners
GovReportA summarization task that requires summarizing government work reports
MultiNewsA multi-doc summarization that requires summarizing over multiple news
QMSumA summarization task that requires summarizing meeting records based on user queries
VCSUMA summarization task that requires summarizing Chinese meeting records
SAMSumA dialogue summarization task, providing several few-shot examples
TriviaQASingle document question answering task, providing several few-shot examples
NQSingle document question answering task, providing several few-shot examples
TRECA classification task that requires categorizing questions, includes 50 categories in total
LSHTA Chinese classification task that requires categorizing news, includes 24 categories in total
PassageRetrieval-enGiven 30 English Wikipedia paragraphs, determine which paragraph the given summary corresponds to
PassageCountDetermine the total number of different paragraphs in a given repetitive article
PassageRetrieval-zhGiven several Chinese paragraphs from the C4 data set, determine which paragraph the given abstract corresponds to
LCCGiven a long piece of code, predict the next line of code
RepoBench-PGiven 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, 2WikiMultihopQA, MuSiQue, and 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, Qasper, GovReport, QMSum and MultiNews directly use the data provided by the original papers. In the specific construction, we use the template provided by ZeroSCROLLS to convert the corresponding data into pure text input.
  • The VCSUM 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 task is constructed in the manner of CoLT5, 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, TREC and LSHT 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. 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 task, we sample from the original code completion dataset. In the RepoBench-P 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

TaskTask Type#data in 0-4k#data in 4-8k#data in 8k+
HotpotQAMulti-doc QA100100100
2WikiMultihopQAMulti-doc QA100100100
MultiFieldQA-enSingle-doc QA677013
QasperSingle-doc QA10010024
GovReportSummarization100100100
MultiNewsSummarization10010094
TriviaQAFew shot100100100
SAMSumFew shot100100100
TRECFew shot100100100
PassageRetrieval-enSynthetic100100100
PassageCountSynthetic100100100
LCCCode100100100
RepoBench-PCode100100100

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}
}
Long Context

Contributors

davidlvxin

8 commits

bys0318

1 commits

THUDM/LongBench

Dataset

Introduction

191

9 commits

3 linked in READMEs

updated Dec 18, 2024

See the code

README

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. 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

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

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 to load the data.

Data Format

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

{
    "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.

Task statistics

TaskTask TypeEval metricAvg lenLanguage#Sample
HotpotQAMulti-doc QAF19,151EN200
2WikiMultihopQAMulti-doc QAF14,887EN200
MuSiQueMulti-doc QAF111,214EN200
DuReaderMulti-doc QARouge-L15,768ZH200
MultiFieldQA-enSingle-doc QAF14,559EN150
MultiFieldQA-zhSingle-doc QAF16,701ZH200
NarrativeQASingle-doc QAF118,409EN200
QasperSingle-doc QAF13,619EN200
GovReportSummarizationRouge-L8,734EN200
QMSumSummarizationRouge-L10,614EN200
MultiNewsSummarizationRouge-L2,113EN200
VCSUMSummarizationRouge-L15,380ZH200
TriviaQAFew shotF18,209EN200
SAMSumFew shotRouge-L6,258EN200
TRECFew shotAccuracy5,177EN200
LSHTFew shotAccuracy22,337ZH200
PassageRetrieval-enSyntheticAccuracy9,289EN200
PassageCountSyntheticAccuracy11,141EN200
PassageRetrieval-zhSyntheticAccuracy6,745ZH200
LCCCodeEdit Sim1,235Python/C#/Java500
RepoBench-PCodeEdit Sim4,206Python/Java500

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

TaskTask Description
HotpotQAAnswer related questions based on multiple given documents
2WikiMultihopQAAnswer related questions based on multiple given documents
MuSiQueAnswer related questions based on multiple given documents
DuReaderAnswer related Chinese questions based on multiple retrieved documents
MultiFieldQA-enAnswer English questions based on a long article, which comes from a relatively diverse field
MultiFieldQA-zhAnswer Chinese questions based on a long article, which comes from a relatively diverse field
NarrativeQAAnswer questions based on stories or scripts, including understanding of important elements such as characters, plots, themes, etc.
QasperAnswer questions based on a NLP research paper, questions proposed and answered by NLP practitioners
GovReportA summarization task that requires summarizing government work reports
MultiNewsA multi-doc summarization that requires summarizing over multiple news
QMSumA summarization task that requires summarizing meeting records based on user queries
VCSUMA summarization task that requires summarizing Chinese meeting records
SAMSumA dialogue summarization task, providing several few-shot examples
TriviaQASingle document question answering task, providing several few-shot examples
NQSingle document question answering task, providing several few-shot examples
TRECA classification task that requires categorizing questions, includes 50 categories in total
LSHTA Chinese classification task that requires categorizing news, includes 24 categories in total
PassageRetrieval-enGiven 30 English Wikipedia paragraphs, determine which paragraph the given summary corresponds to
PassageCountDetermine the total number of different paragraphs in a given repetitive article
PassageRetrieval-zhGiven several Chinese paragraphs from the C4 data set, determine which paragraph the given abstract corresponds to
LCCGiven a long piece of code, predict the next line of code
RepoBench-PGiven 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, 2WikiMultihopQA, MuSiQue, and 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, Qasper, GovReport, QMSum and MultiNews directly use the data provided by the original papers. In the specific construction, we use the template provided by ZeroSCROLLS to convert the corresponding data into pure text input.
  • The VCSUM 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 task is constructed in the manner of CoLT5, 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, TREC and LSHT 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. 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 task, we sample from the original code completion dataset. In the RepoBench-P 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

TaskTask Type#data in 0-4k#data in 4-8k#data in 8k+
HotpotQAMulti-doc QA100100100
2WikiMultihopQAMulti-doc QA100100100
MultiFieldQA-enSingle-doc QA677013
QasperSingle-doc QA10010024
GovReportSummarization100100100
MultiNewsSummarization10010094
TriviaQAFew shot100100100
SAMSumFew shot100100100
TRECFew shot100100100
PassageRetrieval-enSynthetic100100100
PassageCountSynthetic100100100
LCCCode100100100
RepoBench-PCode100100100

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}
}
Long Context

Contributors

davidlvxin

8 commits

bys0318

1 commits