maorivgi commited on
Commit
909639c
1 Parent(s): f4e2823

initial commit

Browse files
Files changed (2) hide show
  1. README.md +144 -0
  2. sled.py +658 -0
README.md CHANGED
@@ -1,3 +1,147 @@
1
  ---
2
  license: mit
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
  ---
4
+ ---
5
+ language:
6
+ - en
7
+ task_categories:
8
+ - long-texts
9
+ - text-generation
10
+ task_ids:
11
+ - summarization
12
+ - question-answering
13
+ - natural-language-inference
14
+ - multiple-choice-qa
15
+ - -multi-hop question answering
16
+ - query-based-summarization
17
+ configs:
18
+ - gov_report
19
+ - summ_screen_fd
20
+ - qmsum
21
+ - qasper
22
+ - narrative_qa
23
+ - quality
24
+ - contract_nli
25
+ - squad
26
+ - squad_shuffled_distractors
27
+ - squad_ordered_distractors
28
+ - hotpotqa
29
+ - hotpotqa_second_only
30
+ ---
31
+
32
+ ## Dataset Description
33
+ - **Repository:** [SLED Github repository](https://github.com/Mivg/SLED)
34
+ - **Paper:** [Efficient Long-Text Understanding with Short-Text Models
35
+ ](https://arxiv.org/pdf/2208.00748.pdf)
36
+
37
+ # Dataset Card for SCROLLS
38
+
39
+ ## Overview
40
+ This dataset is based on the [SCROLLS](https://huggingface.co/datasets/tau/scrolls) dataset ([paper](https://arxiv.org/pdf/2201.03533.pdf)), the [SQuAD 1.1](https://huggingface.co/datasets/squad) dataset and the [HotpotQA](https://huggingface.co/datasets/hotpot_qa) dataset.
41
+ It doesn't contain any unpblished data, but includes the configuration needed for the [Efficient Long-Text Understanding with Short-Text Models
42
+ ](https://arxiv.org/pdf/2208.00748.pdf) paper.
43
+
44
+ ## Tasks
45
+ The tasks included are:
46
+
47
+ #### GovReport ([Huang et al., 2021](https://arxiv.org/pdf/2104.02112.pdf))
48
+ GovReport is a summarization dataset of reports addressing various national policy issues published by the
49
+ Congressional Research Service and the U.S. Government Accountability Office, where each document is paired with a hand-written executive summary.
50
+ The reports and their summaries are longer than their equivalents in other popular long-document summarization datasets;
51
+ for example, GovReport's documents are approximately 1.5 and 2.5 times longer than the documents in Arxiv and PubMed, respectively.
52
+
53
+ #### SummScreenFD ([Chen et al., 2021](https://arxiv.org/pdf/2104.07091.pdf))
54
+ SummScreenFD is a summarization dataset in the domain of TV shows (e.g. Friends, Game of Thrones).
55
+ Given a transcript of a specific episode, the goal is to produce the episode's recap.
56
+ The original dataset is divided into two complementary subsets, based on the source of its community contributed transcripts.
57
+ For SCROLLS, we use the ForeverDreaming (FD) subset, as it incorporates 88 different shows,
58
+ making it a more diverse alternative to the TV MegaSite (TMS) subset, which has only 10 shows.
59
+ Community-authored recaps for the ForeverDreaming transcripts were collected from English Wikipedia and TVMaze.
60
+
61
+ #### QMSum ([Zhong et al., 2021](https://arxiv.org/pdf/2104.05938.pdf))
62
+ QMSum is a query-based summarization dataset, consisting of 232 meetings transcripts from multiple domains.
63
+ The corpus covers academic group meetings at the International Computer Science Institute and their summaries, industrial product meetings for designing a remote control,
64
+ and committee meetings of the Welsh and Canadian Parliaments, dealing with a variety of public policy issues.
65
+ Annotators were tasked with writing queries about the broad contents of the meetings, as well as specific questions about certain topics or decisions,
66
+ while ensuring that the relevant text for answering each query spans at least 200 words or 10 turns.
67
+
68
+ #### NarrativeQA ([Kočiský et al., 2021](https://arxiv.org/pdf/1712.07040.pdf))
69
+ NarrativeQA (Kočiský et al., 2021) is an established question answering dataset over entire books from Project Gutenberg and movie scripts from different websites.
70
+ Annotators were given summaries of the books and scripts obtained from Wikipedia, and asked to generate question-answer pairs,
71
+ resulting in about 30 questions and answers for each of the 1,567 books and scripts.
72
+ They were encouraged to use their own words rather then copying, and avoid asking yes/no questions or ones about the cast.
73
+ Each question was then answered by an additional annotator, providing each question with two reference answers (unless both answers are identical).
74
+
75
+ #### Qasper ([Dasigi et al., 2021](https://arxiv.org/pdf/2105.03011.pdf))
76
+ Qasper is a question answering dataset over NLP papers filtered from the Semantic Scholar Open Research Corpus (S2ORC).
77
+ Questions were written by NLP practitioners after reading only the title and abstract of the papers,
78
+ while another set of NLP practitioners annotated the answers given the entire document.
79
+ Qasper contains abstractive, extractive, and yes/no questions, as well as unanswerable ones.
80
+
81
+ #### QuALITY ([Pang et al., 2021](https://arxiv.org/pdf/2112.08608.pdf))
82
+ QuALITY is a multiple-choice question answering dataset over articles and stories sourced from Project Gutenberg,
83
+ the Open American National Corpus, and more.
84
+ Experienced writers wrote questions and distractors, and were incentivized to write answerable, unambiguous questions such that in order to correctly answer them,
85
+ human annotators must read large portions of the given document.
86
+ Reference answers were then calculated using the majority vote between of the annotators and writer's answers.
87
+ To measure the difficulty of their questions, Pang et al. conducted a speed validation process,
88
+ where another set of annotators were asked to answer questions given only a short period of time to skim through the document.
89
+ As a result, 50% of the questions in QuALITY are labeled as hard, i.e. the majority of the annotators in the speed validation setting chose the wrong answer.
90
+
91
+ #### ContractNLI ([Koreeda and Manning, 2021](https://arxiv.org/pdf/2110.01799.pdf))
92
+ Contract NLI is a natural language inference dataset in the legal domain.
93
+ Given a non-disclosure agreement (the premise), the task is to predict whether a particular legal statement (the hypothesis) is entailed, not entailed (neutral), or cannot be entailed (contradiction) from the contract.
94
+ The NDAs were manually picked after simple filtering from the Electronic Data Gathering, Analysis, and Retrieval system (EDGAR) and Google.
95
+ The dataset contains a total of 607 contracts and 17 unique hypotheses, which were combined to produce the dataset's 10,319 examples.
96
+
97
+ #### SQuAD 1.1 ([Rajpurkar et al., 2016](https://arxiv.org/pdf/1606.05250.pdf))
98
+ Stanford Question Answering Dataset (SQuAD) is a reading comprehension \
99
+ dataset, consisting of questions posed by crowdworkers on a set of Wikipedia \
100
+ articles, where the answer to every question is a segment of text, or span, \
101
+ from the corresponding reading passage, or the question might be unanswerable.
102
+
103
+ #### HotpotQA ([Yang et al., 2018](https://arxiv.org/pdf/1809.09600.pdf))
104
+ HotpotQA is a new dataset with 113k Wikipedia-based question-answer pairs with four key features:
105
+ (1) the questions require finding and reasoning over multiple supporting documents to answer;
106
+ (2) the questions are diverse and not constrained to any pre-existing knowledge bases or knowledge schemas;
107
+ (3) we provide sentence-level supporting facts required for reasoning, allowingQA systems to reason with strong supervisionand explain the predictions;
108
+ (4) we offer a new type of factoid comparison questions to testQA systems’ ability to extract relevant facts and perform necessary comparison.
109
+
110
+ ## Data Fields
111
+
112
+ All the datasets in the benchmark are in the same input-output format
113
+
114
+ - `input`: a `string` feature. The input document.
115
+ - `input_prefix`: an optional `string` feature, for the datasets containing prefix (e.g. question)
116
+ - `output`: a `string` feature. The target.
117
+ - `id`: a `string` feature. Unique per input.
118
+ - `pid`: a `string` feature. Unique per input-output pair (can differ from 'id' in NarrativeQA and Qasper, where there is more then one valid target).
119
+
120
+ The dataset that contain `input_prefix` are:
121
+ - SQuAD - the question
122
+ - HotpotQA - the question
123
+ - qmsum - the query
124
+ - qasper - the question
125
+ - narrative_qa - the question
126
+ - quality - the question + the four choices
127
+ - contract_nli - the hypothesis
128
+
129
+ ## Controlled experiments
130
+ To test multiple properties of SLED, we modify SQuAD 1.1 [Rajpurkar et al., 2016](https://arxiv.org/pdf/1606.05250.pdf)
131
+ and HotpotQA [Yang et al., 2018](https://arxiv.org/pdf/1809.09600.pdf) to create a few controlled experiments settings.
132
+ Those are accessible via the following configurations:
133
+ - squad - Contains the original version of SQuAD 1.1 (question + passage)
134
+ - squad_ordered_distractors - For each example, 9 random distrctor passages are concatenated (separated by '\n')
135
+ - squad_shuffled_distractors - For each example, 9 random distrctor passages are added (separated by '\n'), and jointly the 10 passages are randomly shuffled
136
+ - hotpotqa - A clean version of HotpotQA, where each input contains only the two gold passages (separated by '\n')
137
+ - hotpotqa_second_only - In each example, the input contains only the second gold passage
138
+
139
+ ## Citation
140
+ If you use this dataset, **please make sure to cite all the original dataset papers as well SCROLLS.** [[bibtex](TODO - bib file)]
141
+ ```
142
+ @inproceedings{Ivgi2022EfficientLU,
143
+ title={Efficient Long-Text Understanding with Short-Text Models},
144
+ author={Maor Ivgi and Uri Shaham and Jonathan Berant},
145
+ year={2022}
146
+ }
147
+ ```
sled.py ADDED
@@ -0,0 +1,658 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Lint as: python3
3
+ """Data for SLED, based on the SCROLLS benchmark."""
4
+ import itertools
5
+ import json
6
+ import os
7
+ import random
8
+ import re
9
+
10
+ import datasets
11
+
12
+ import numpy as np
13
+
14
+
15
+ _SLED_DESCRIPTION = """
16
+ Efficient Long-Text Understanding with Short-Text Models.
17
+ Our SLiding-Encoder and Decoder uses any pretrained encoder-decoder model, to independtly encode overlapping chunks of
18
+ the inputs, and perform fusion-in-decoder to achieve linear-memory requirment for long-range natural language understanding.
19
+
20
+ """
21
+
22
+ _SCROLLS_DESCRIPTION = """
23
+ SCROLLS: Standardized CompaRison Over Long Language Sequences.
24
+ A suite of natural language datasets that require reasoning over long texts.
25
+ https://scrolls-benchmark.com/
26
+
27
+ """
28
+
29
+ _SUMM_SCREEN_DESCRIPTION = """
30
+ SummScreenFD (Chen et al., 2021) is a summarization dataset in the domain of TV shows (e.g. Friends, Game of Thrones).
31
+ Given a transcript of a specific episode, the goal is to produce the episode's recap.
32
+ The original dataset is divided into two complementary subsets, based on the source of its community contributed transcripts.
33
+ For SCROLLS, we use the ForeverDreaming (FD) subset, as it incorporates 88 different shows,
34
+ making it a more diverse alternative to the TV MegaSite (TMS) subset, which has only 10 shows.
35
+ Community-authored recaps for the ForeverDreaming transcripts were collected from English Wikipedia and TVMaze."""
36
+
37
+ _QASPER_DESCRIPTION = """
38
+ Qasper (Dasigi et al., 2021) is a question answering dataset over NLP papers filtered from the Semantic Scholar Open Research Corpus (S2ORC).
39
+ Questions were written by NLP practitioners after reading only the title and abstract of the papers,
40
+ while another set of NLP practitioners annotated the answers given the entire document.
41
+ Qasper contains abstractive, extractive, and yes/no questions, as well as unanswerable ones."""
42
+
43
+ _QMSUM_DESCRIPTION = """
44
+ QMSum (Zhong et al., 2021) is a query-based summarization dataset, consisting of 232 meetings transcripts from multiple domains.
45
+ The corpus covers academic group meetings at the International Computer Science Institute and their summaries, industrial product meetings for designing a remote control,
46
+ and committee meetings of the Welsh and Canadian Parliaments, dealing with a variety of public policy issues.
47
+ Annotators were tasked with writing queries about the broad contents of the meetings, as well as specific questions about certain topics or decisions,
48
+ while ensuring that the relevant text for answering each query spans at least 200 words or 10 turns."""
49
+
50
+ _NARRATIVE_QA_DESCRIPTION = """
51
+ NarrativeQA (Kočiský et al., 2021) is an established question answering dataset over entire books from Project Gutenberg and movie scripts from different websites.
52
+ Annotators were given summaries of the books and scripts obtained from Wikipedia, and asked to generate question-answer pairs,
53
+ resulting in about 30 questions and answers for each of the 1,567 books and scripts.
54
+ They were encouraged to use their own words rather then copying, and avoid asking yes/no questions or ones about the cast.
55
+ Each question was then answered by an additional annotator, providing each question with two reference answers (unless both answers are identical).."""
56
+
57
+ _GOV_REPORT_DESCRIPTION = """
58
+ GovReport (Huang et al., 2021) is a summarization dataset of reports addressing various national policy issues published by the
59
+ Congressional Research Service and the U.S. Government Accountability Office, where each document is paired with a hand-written executive summary.
60
+ The reports and their summaries are longer than their equivalents in other popular long-document summarization datasets;
61
+ for example, GovReport's documents are approximately 1.5 and 2.5 times longer than the documents in Arxiv and PubMed, respectively."""
62
+
63
+ _CONTRACT_NLI_DESCRIPTION = """
64
+ Contract NLI (Koreeda and Manning, 2021) is a natural language inference dataset in the legal domain.
65
+ Given a non-disclosure agreement (the premise), the task is to predict whether a particular legal statement (the hypothesis) is entailed, not entailed (neutral), or cannot be entailed (contradiction) from the contract.
66
+ The NDAs were manually picked after simple filtering from the Electronic Data Gathering, Analysis, and Retrieval system (EDGAR) and Google.
67
+ The dataset contains a total of 607 contracts and 17 unique hypotheses, which were combined to produce the dataset's 10,319 examples."""
68
+
69
+ _QUALITY_DESCRIPTION = """
70
+ QuALITY (Pang et al., 2021) is a multiple-choice question answering dataset over articles and stories sourced from Project Gutenberg,
71
+ the Open American National Corpus, and more.
72
+ Experienced writers wrote questions and distractors, and were incentivized to write answerable, unambiguous questions such that in order to correctly answer them,
73
+ human annotators must read large portions of the given document.
74
+ Reference answers were then calculated using the majority vote between of the annotators and writer's answers.
75
+ To measure the difficulty of their questions, Pang et al. conducted a speed validation process,
76
+ where another set of annotators were asked to answer questions given only a short period of time to skim through the document.
77
+ As a result, 50% of the questions in QuALITY are labeled as hard, i.e. the majority of the annotators in the speed validation setting chose the wrong answer."""
78
+
79
+ _SQUAD_DESCRIPTION = """\
80
+ Stanford Question Answering Dataset (SQuAD) is a reading comprehension \
81
+ dataset, consisting of questions posed by crowdworkers on a set of Wikipedia \
82
+ articles, where the answer to every question is a segment of text, or span, \
83
+ from the corresponding reading passage, or the question might be unanswerable.
84
+ """
85
+
86
+ _HOTPOTQA_DESCRIPTION = """\
87
+ HotpotQA is a new dataset with 113k Wikipedia-based question-answer pairs with four key features:
88
+ (1) the questions require finding and reasoning over multiple supporting documents to answer;
89
+ (2) the questions are diverse and not constrained to any pre-existing knowledge bases or knowledge schemas;
90
+ (3) we provide sentence-level supporting facts required for reasoning, allowingQA systems to reason with strong supervisionand explain the predictions;
91
+ (4) we offer a new type of factoid comparison questions to testQA systems’ ability to extract relevant facts and perform necessary comparison.
92
+ """
93
+
94
+ _SLED_CITATION = """
95
+ @inproceedings{Ivgi2022EfficientLU,
96
+ title={Efficient Long-Text Understanding with Short-Text Models},
97
+ author={Maor Ivgi and Uri Shaham and Jonathan Berant},
98
+ year={2022}
99
+ }
100
+ Note that each SLED dataset has its own citation. Please see the source to
101
+ get the correct citation for each contained dataset (and also cite the SCROLLS dataset on which it is based).
102
+ """
103
+
104
+ _SCROLLS_CITATION = """
105
+ @misc{shaham2022scrolls,
106
+ title={SCROLLS: Standardized CompaRison Over Long Language Sequences},
107
+ author={Uri Shaham and Elad Segal and Maor Ivgi and Avia Efrat and Ori Yoran and Adi Haviv and Ankit Gupta and Wenhan Xiong and Mor Geva and Jonathan Berant and Omer Levy},
108
+ year={2022},
109
+ eprint={2201.03533},
110
+ archivePrefix={arXiv},
111
+ primaryClass={cs.CL}
112
+ }
113
+ Note that each SCROLLS dataset has its own citation. Please see the source to
114
+ get the correct citation for each contained dataset.
115
+ """
116
+
117
+ _SUMM_SCREEN_CITATION = r"""
118
+ @misc{chen2021summscreen,
119
+ title={SummScreen: A Dataset for Abstractive Screenplay Summarization},
120
+ author={Mingda Chen and Zewei Chu and Sam Wiseman and Kevin Gimpel},
121
+ year={2021},
122
+ eprint={2104.07091},
123
+ archivePrefix={arXiv},
124
+ primaryClass={cs.CL}
125
+ }"""
126
+
127
+ _QASPER_CITATION = r"""
128
+ @inproceedings{dasigi-etal-2021-dataset,
129
+ title = "A Dataset of Information-Seeking Questions and Answers Anchored in Research Papers",
130
+ author = "Dasigi, Pradeep and
131
+ Lo, Kyle and
132
+ Beltagy, Iz and
133
+ Cohan, Arman and
134
+ Smith, Noah A. and
135
+ Gardner, Matt",
136
+ booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
137
+ month = jun,
138
+ year = "2021",
139
+ address = "Online",
140
+ publisher = "Association for Computational Linguistics",
141
+ url = "https://aclanthology.org/2021.naacl-main.365",
142
+ doi = "10.18653/v1/2021.naacl-main.365",
143
+ pages = "4599--4610",
144
+ abstract = "Readers of academic research papers often read with the goal of answering specific questions. Question Answering systems that can answer those questions can make consumption of the content much more efficient. However, building such tools requires data that reflect the difficulty of the task arising from complex reasoning about claims made in multiple parts of a paper. In contrast, existing information-seeking question answering datasets usually contain questions about generic factoid-type information. We therefore present Qasper, a dataset of 5049 questions over 1585 Natural Language Processing papers. Each question is written by an NLP practitioner who read only the title and abstract of the corresponding paper, and the question seeks information present in the full text. The questions are then answered by a separate set of NLP practitioners who also provide supporting evidence to answers. We find that existing models that do well on other QA tasks do not perform well on answering these questions, underperforming humans by at least 27 F1 points when answering them from entire papers, motivating further research in document-grounded, information-seeking QA, which our dataset is designed to facilitate.",
145
+ }"""
146
+
147
+ _QMSUM_CITATION = r"""@inproceedings{zhong-etal-2021-qmsum,
148
+ title = "{QMS}um: A New Benchmark for Query-based Multi-domain Meeting Summarization",
149
+ author = "Zhong, Ming and
150
+ Yin, Da and
151
+ Yu, Tao and
152
+ Zaidi, Ahmad and
153
+ Mutuma, Mutethia and
154
+ Jha, Rahul and
155
+ Awadallah, Ahmed Hassan and
156
+ Celikyilmaz, Asli and
157
+ Liu, Yang and
158
+ Qiu, Xipeng and
159
+ Radev, Dragomir",
160
+ booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
161
+ month = jun,
162
+ year = "2021",
163
+ address = "Online",
164
+ publisher = "Association for Computational Linguistics",
165
+ url = "https://aclanthology.org/2021.naacl-main.472",
166
+ doi = "10.18653/v1/2021.naacl-main.472",
167
+ pages = "5905--5921",
168
+ abstract = "Meetings are a key component of human collaboration. As increasing numbers of meetings are recorded and transcribed, meeting summaries have become essential to remind those who may or may not have attended the meetings about the key decisions made and the tasks to be completed. However, it is hard to create a single short summary that covers all the content of a long meeting involving multiple people and topics. In order to satisfy the needs of different types of users, we define a new query-based multi-domain meeting summarization task, where models have to select and summarize relevant spans of meetings in response to a query, and we introduce QMSum, a new benchmark for this task. QMSum consists of 1,808 query-summary pairs over 232 meetings in multiple domains. Besides, we investigate a locate-then-summarize method and evaluate a set of strong summarization baselines on the task. Experimental results and manual analysis reveal that QMSum presents significant challenges in long meeting summarization for future research. Dataset is available at \url{https://github.com/Yale-LILY/QMSum}.",
169
+ }"""
170
+
171
+ _NARRATIVE_QA_CITATION = r"""
172
+ @article{kovcisky2018narrativeqa,
173
+ title={The narrativeqa reading comprehension challenge},
174
+ author={Ko{\v{c}}isk{\'y}, Tom{\'a}{\v{s}} and Schwarz, Jonathan and Blunsom, Phil and Dyer, Chris and Hermann, Karl Moritz and Melis, G{\'a}bor and Grefenstette, Edward},
175
+ journal={Transactions of the Association for Computational Linguistics},
176
+ volume={6},
177
+ pages={317--328},
178
+ year={2018},
179
+ publisher={MIT Press}
180
+ }"""
181
+
182
+ _GOV_REPORT_CITATION = r"""
183
+ @inproceedings{huang-etal-2021-efficient,
184
+ title = "Efficient Attentions for Long Document Summarization",
185
+ author = "Huang, Luyang and
186
+ Cao, Shuyang and
187
+ Parulian, Nikolaus and
188
+ Ji, Heng and
189
+ Wang, Lu",
190
+ booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
191
+ month = jun,
192
+ year = "2021",
193
+ address = "Online",
194
+ publisher = "Association for Computational Linguistics",
195
+ url = "https://aclanthology.org/2021.naacl-main.112",
196
+ doi = "10.18653/v1/2021.naacl-main.112",
197
+ pages = "1419--1436",
198
+ abstract = "The quadratic computational and memory complexities of large Transformers have limited their scalability for long document summarization. In this paper, we propose Hepos, a novel efficient encoder-decoder attention with head-wise positional strides to effectively pinpoint salient information from the source. We further conduct a systematic study of existing efficient self-attentions. Combined with Hepos, we are able to process ten times more tokens than existing models that use full attentions. For evaluation, we present a new dataset, GovReport, with significantly longer documents and summaries. Results show that our models produce significantly higher ROUGE scores than competitive comparisons, including new state-of-the-art results on PubMed. Human evaluation also shows that our models generate more informative summaries with fewer unfaithful errors.",
199
+ }"""
200
+
201
+ _CONTRACT_NLI_CITATION = """\
202
+ @inproceedings{koreeda-manning-2021-contractnli,
203
+ title = "ContractNLI: A Dataset for Document-level Natural Language Inference for Contracts",
204
+ author = "Koreeda, Yuta and
205
+ Manning, Christopher D.",
206
+ booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2021",
207
+ year = "2021",
208
+ publisher = "Association for Computational Linguistics"
209
+ }
210
+ """
211
+ _QUALITY_CITATION = """\
212
+ @article{pang2021quality,
213
+ title={{QuALITY}: Question Answering with Long Input Texts, Yes!},
214
+ author={Pang, Richard Yuanzhe and Parrish, Alicia and Joshi, Nitish and Nangia, Nikita and Phang, Jason and Chen, Angelica and Padmakumar, Vishakh and Ma, Johnny and Thompson, Jana and He, He and Bowman, Samuel R.},
215
+ journal={arXiv preprint arXiv:2112.08608},
216
+ year={2021}
217
+ }
218
+ """
219
+ _SQUAD_CITATION = """\
220
+ @article{2016arXiv160605250R,
221
+ author = {{Rajpurkar}, Pranav and {Zhang}, Jian and {Lopyrev},
222
+ Konstantin and {Liang}, Percy},
223
+ title = "{SQuAD: 100,000+ Questions for Machine Comprehension of Text}",
224
+ journal = {arXiv e-prints},
225
+ year = 2016,
226
+ eid = {arXiv:1606.05250},
227
+ pages = {arXiv:1606.05250},
228
+ archivePrefix = {arXiv},
229
+ eprint = {1606.05250},
230
+ }
231
+ """
232
+ _HOTPOTQA_CITATION = """
233
+ 27 @inproceedings{yang2018hotpotqa,
234
+ 28 title={{HotpotQA}: A Dataset for Diverse, Explainable Multi-hop Question Answering},
235
+ 29 author={Yang, Zhilin and Qi, Peng and Zhang, Saizheng and Bengio, Yoshua and Cohen, William W. and Salakhutdinov, Ruslan and Manning, Christopher D.},
236
+ 30 booktitle={Conference on Empirical Methods in Natural Language Processing ({EMNLP})},
237
+ 31 year={2018}
238
+ 32 }
239
+ """
240
+
241
+
242
+ class SLEDConfig(datasets.BuilderConfig):
243
+ """BuilderConfig for SLED."""
244
+
245
+ def __init__(self, features, data_url, citation, url, **kwargs):
246
+ """BuilderConfig for SLED.
247
+ Args:
248
+ features: `list[string]`, list of the features that will appear in the
249
+ feature dict. Should not include "label".
250
+ data_url: `string`, url to download the zip file from.
251
+ citation: `string`, citation for the data set.
252
+ url: `string`, url for information about the data set.
253
+ label_classes: `list[string]`, the list of classes for the label if the
254
+ label is present as a string. Non-string labels will be cast to either
255
+ 'False' or 'True'.
256
+ **kwargs: keyword arguments forwarded to super.
257
+ """
258
+ super(SLEDConfig, self).__init__(version=datasets.Version("1.0.0"), **kwargs)
259
+ self.features = features
260
+ self.data_url = data_url
261
+ self.citation = citation
262
+ self.url = url
263
+
264
+
265
+ class SquadConfig(SLEDConfig):
266
+ """BuilderConfig for SQUAD."""
267
+ _URL = "https://rajpurkar.github.io/SQuAD-explorer/dataset/"
268
+ _URLS = {
269
+ "train": _URL + "train-v1.1.json",
270
+ "dev": _URL + "dev-v1.1.json",
271
+ }
272
+
273
+ def __init__(self, n_distractors=0, random_order=True, **kwargs):
274
+ """BuilderConfig for SQUAD.
275
+ Args:
276
+ **kwargs: keyword arguments forwarded to super.
277
+ """
278
+ super(SquadConfig, self).__init__(**kwargs)
279
+ self.n_distractors = n_distractors
280
+ self.random_order = random_order
281
+
282
+
283
+ class HotpotQAConfig(SLEDConfig):
284
+ """BuilderConfig for HotpotQA distractors settings"""
285
+ _URL_BASE = "http://curtis.ml.cmu.edu/datasets/hotpot/"
286
+ _HOMEPAGE = '"https://hotpotqa.github.io/"'
287
+
288
+ def __init__(self, gold_passages, distractors=True, **kwargs):
289
+ """
290
+ gold_passages should be one of first, second and both
291
+ """
292
+ super(HotpotQAConfig, self).__init__(**kwargs)
293
+ self.gold_passages = gold_passages
294
+ self.distractors = distractors
295
+
296
+
297
+ class QualityConfig(SLEDConfig):
298
+ def __init__(self, prefix_only=False, **kwargs):
299
+ super().__init__(**kwargs)
300
+ self.hard_only = False
301
+ self.prefix_only = prefix_only
302
+
303
+
304
+ features_qa = ["id", "pid", "input", 'input_prefix', "output"]
305
+ features = ["id", "pid", "input", "output"]
306
+
307
+
308
+ class SLED(datasets.GeneratorBasedBuilder):
309
+ """The SCROLLS benchmark with modifications for SLED. + tasks based on SQuAD 1.1 and HotpotQA"""
310
+
311
+ DEFAULT_WRITER_BATCH_SIZE = 1000 # because Narrative QA is a rather large dataset
312
+ BUILDER_CONFIGS = [
313
+ SLEDConfig(
314
+ name="summ_screen_fd",
315
+ description=_SUMM_SCREEN_DESCRIPTION,
316
+ features=features,
317
+ data_url="https://scrolls-tau.s3.us-east-2.amazonaws.com/summ_screen_fd.zip",
318
+ citation=_SUMM_SCREEN_CITATION,
319
+ url="https://github.com/mingdachen/SummScreen",
320
+ ),
321
+ SLEDConfig(
322
+ name="qasper",
323
+ description=_QASPER_DESCRIPTION,
324
+ features=features_qa,
325
+ data_url="https://scrolls-tau.s3.us-east-2.amazonaws.com/qasper.zip",
326
+ citation=_QASPER_CITATION,
327
+ url="https://allenai.org/project/qasper",
328
+ ),
329
+ SLEDConfig(
330
+ name="qmsum",
331
+ description=_QMSUM_DESCRIPTION,
332
+ features=features_qa,
333
+ data_url="https://scrolls-tau.s3.us-east-2.amazonaws.com/qmsum.zip",
334
+ citation=_QMSUM_CITATION,
335
+ url="https://github.com/Yale-LILY/QMSum",
336
+ ),
337
+ SLEDConfig(
338
+ name="narrative_qa",
339
+ description=_NARRATIVE_QA_DESCRIPTION,
340
+ features=features_qa,
341
+ data_url="https://scrolls-tau.s3.us-east-2.amazonaws.com/narrative_qa.zip",
342
+ citation=_NARRATIVE_QA_CITATION,
343
+ url="https://deepmind.com/research/publications/narrativeqa-reading-comprehension-challenge",
344
+ ),
345
+ SLEDConfig(
346
+ name="gov_report",
347
+ description=_GOV_REPORT_CITATION,
348
+ features=features,
349
+ data_url="https://scrolls-tau.s3.us-east-2.amazonaws.com/gov_report.zip",
350
+ citation=_GOV_REPORT_DESCRIPTION,
351
+ url="https://gov-report-data.github.io/",
352
+ ),
353
+ SLEDConfig(
354
+ name="contract_nli",
355
+ description=_CONTRACT_NLI_DESCRIPTION,
356
+ features=features_qa,
357
+ data_url="https://scrolls-tau.s3.us-east-2.amazonaws.com/contract_nli.zip",
358
+ citation=_CONTRACT_NLI_CITATION,
359
+ url="https://stanfordnlp.github.io/contract-nli/",
360
+ ),
361
+ QualityConfig(
362
+ name="quality",
363
+ prefix_only=False,
364
+ description=_QUALITY_CITATION,
365
+ features=features_qa,
366
+ data_url="https://scrolls-tau.s3.us-east-2.amazonaws.com/quality.zip",
367
+ citation=_QUALITY_DESCRIPTION,
368
+ url="https://github.com/nyu-mll/quality",
369
+ ),
370
+ SquadConfig(
371
+ name="squad",
372
+ data_url=SquadConfig._URLS,
373
+ features=features_qa,
374
+ citation=_SQUAD_CITATION,
375
+ url=SquadConfig._URL,
376
+ description=_SQUAD_DESCRIPTION
377
+ ),
378
+ SquadConfig(
379
+ name="squad_shuffled_distractors",
380
+ data_url=SquadConfig._URLS,
381
+ n_distractors=9,
382
+ random_order=True,
383
+ features=features_qa,
384
+ citation=_SQUAD_CITATION,
385
+ url=SquadConfig._URL,
386
+ description=_SQUAD_DESCRIPTION
387
+ ),
388
+ SquadConfig(
389
+ name="squad_ordered_distractors",
390
+ data_url=SquadConfig._URLS,
391
+ n_distractors=9,
392
+ random_order=False,
393
+ features=features_qa,
394
+ citation=_SQUAD_CITATION,
395
+ url=SquadConfig._URL,
396
+ description=_SQUAD_DESCRIPTION
397
+ ),
398
+ HotpotQAConfig(
399
+ name=f"hotpotqa",
400
+ data_url=HotpotQAConfig._URL_BASE,
401
+ gold_passages='both',
402
+ distractors=False,
403
+ features=features_qa,
404
+ citation=_HOTPOTQA_CITATION,
405
+ url=HotpotQAConfig._HOMEPAGE,
406
+ description=_HOTPOTQA_DESCRIPTION
407
+ ),
408
+ HotpotQAConfig(
409
+ name=f"hotpotqa_second_only",
410
+ data_url=HotpotQAConfig._URL_BASE,
411
+ gold_passages='second',
412
+ distractors=False,
413
+ features=features_qa,
414
+ citation=_HOTPOTQA_CITATION,
415
+ url=HotpotQAConfig._HOMEPAGE,
416
+ description=_HOTPOTQA_DESCRIPTION
417
+ )]
418
+
419
+ def _info(self):
420
+ features = {feature: datasets.Value("string") for feature in self.config.features}
421
+
422
+ return datasets.DatasetInfo(
423
+ description=_SLED_DESCRIPTION + _SCROLLS_DESCRIPTION + self.config.description,
424
+ features=datasets.Features(features),
425
+ homepage=self.config.url,
426
+ citation=self.config.citation + "\n" + _SCROLLS_CITATION + "\n" + _SLED_CITATION
427
+ )
428
+
429
+ def _scrolls_split_generators(self, dl_manager):
430
+ dl_dir = dl_manager.download_and_extract(self.config.data_url)
431
+ task_name = _get_task_name_from_data_url(self.config.data_url)
432
+ dl_dir = os.path.join(dl_dir, task_name)
433
+
434
+ data_files = {} if self.config.data_files is not None else None
435
+ if data_files is not None:
436
+ for split, paths in self.config.data_files.items():
437
+ data_files[split] = paths[0]
438
+
439
+ return [
440
+ datasets.SplitGenerator(
441
+ name=datasets.Split.TRAIN,
442
+ gen_kwargs={
443
+ "data_file": os.path.join(dl_dir, "train.jsonl"),
444
+ "split": datasets.Split.TRAIN,
445
+ },
446
+ ),
447
+ datasets.SplitGenerator(
448
+ name=datasets.Split.VALIDATION,
449
+ gen_kwargs={
450
+ "data_file": os.path.join(dl_dir, "validation.jsonl"),
451
+ "split": datasets.Split.VALIDATION,
452
+ },
453
+ ),
454
+ datasets.SplitGenerator(
455
+ name=datasets.Split.TEST,
456
+ gen_kwargs={
457
+ "data_file": os.path.join(dl_dir, "test.jsonl") if data_files is None else data_files["test"],
458
+ "split": datasets.Split.TEST,
459
+ },
460
+ ),
461
+ ]
462
+
463
+ def _squad_split_generators(self, dl_manager):
464
+
465
+ downloaded_files = dl_manager.download_and_extract(self.config.data_url)
466
+
467
+ return [
468
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
469
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
470
+ ]
471
+
472
+ def _hotpotqa_split_generators(self, dl_manager):
473
+ """Returns SplitGenerators."""
474
+ paths = {
475
+ datasets.Split.TRAIN: HotpotQAConfig._URL_BASE + "hotpot_train_v1.1.json",
476
+ datasets.Split.VALIDATION: HotpotQAConfig._URL_BASE + "hotpot_dev_distractor_v1.json",
477
+ }
478
+
479
+ files = dl_manager.download(paths)
480
+
481
+ split_generators = []
482
+ for split in files:
483
+ split_generators.append(datasets.SplitGenerator(name=split, gen_kwargs={"data_file": files[split]}))
484
+
485
+ return split_generators
486
+
487
+ def _split_generators(self, dl_manager):
488
+ if 'squad' in self.config.name:
489
+ return self._squad_split_generators(dl_manager)
490
+ elif 'hotpotqa' in self.config.name:
491
+ return self._hotpotqa_split_generators(dl_manager)
492
+ else:
493
+ return self._scrolls_split_generators(dl_manager)
494
+
495
+ def _scrolls_gen(self, data_file, split):
496
+ def prefix_splitter(line):
497
+ row = json.loads(line)
498
+ i = row['input'].find('\n\n')
499
+ row['input'], row['input_prefix'] = row['input'][i + 2:], row['input'][:i]
500
+ return row
501
+
502
+ def get_quality_splitter(prefix_only):
503
+ def quality_prefix_splitter(line):
504
+ # quality has 4 answers, and they are also split by \n\n in scrolls, but not consistently
505
+ row = json.loads(line)
506
+ # using index rather then find to get an exception if we have a bad example
507
+ inp = row['input']
508
+ last_answer_idx = inp.index("(D)")
509
+ context_start_ind = inp[last_answer_idx:].index("\n\n") + 1 + last_answer_idx
510
+ row['input'], row['input_prefix'] = inp[context_start_ind+2:].strip(), row['input'][:context_start_ind].strip()
511
+ if prefix_only:
512
+ row['input'] = ''
513
+ return row
514
+ return quality_prefix_splitter
515
+
516
+ # if this is a dataset that should be treated as a qa dataset, choose the loader accordingly
517
+ loader = (lambda line: json.loads(line)) if 'input_prefix' not in self.config.features else prefix_splitter
518
+ if 'quality' in self.config.name:
519
+ loader = get_quality_splitter(self.config.prefix_only)
520
+
521
+ with open(data_file, encoding="utf-8") as f:
522
+ for line in f:
523
+ row = loader(line)
524
+
525
+ if "quality" in self.config.name:
526
+ is_hard = row.pop("is_hard", False)
527
+ if self.config.hard_only and not is_hard:
528
+ continue
529
+
530
+ yield row["pid"], row
531
+
532
+ def _squad_gen(self, filepath, split):
533
+ """This function returns the examples in the raw (text) form."""
534
+ key = 0
535
+ np.random.seed(42)
536
+ random.seed(42)
537
+ with open(filepath, encoding="utf-8") as f:
538
+ squad = json.load(f)
539
+ n_distractors = self.config.n_distractors
540
+ random_order = self.config.random_order
541
+ context_list = []
542
+ if n_distractors > 0:
543
+ context_list = [(paragraph["context"], article["title"]) for article in squad["data"] for paragraph in
544
+ article["paragraphs"]]
545
+ for article in squad["data"]:
546
+ title = article.get("title", "")
547
+ for paragraph in article["paragraphs"]:
548
+ orig_context = paragraph["context"] # do not strip leading blank spaces GH-2585
549
+ for qa in paragraph["qas"]:
550
+ # answer_starts = [answer["answer_start"] for answer in qa["answers"]]
551
+ # Due to usage of answer starts, we may have multiple positions with the same answer
552
+ # (exact value). To avoid redundant duplication of the answer, we take the unique set of answers
553
+ answers = list({answer["text"] for answer in qa["answers"]})
554
+ # train and validation gets the same treatment - splitting into multiple examples
555
+ for i, answer in enumerate(answers): # generate multiple example
556
+ context = self._prepare_squad_context(orig_context, context_list, n_distractors,
557
+ random_order, title, answers)
558
+ if n_distractors > 1:
559
+ assert len(context.split('\n\n')) == n_distractors+1
560
+ yield key, {
561
+ # In scrolls, id is based on the question+ context (i.e. input id), while pid is added a suffix
562
+ # enumerating the duplication, based on the answer. This duplication and enumeration happens both in
563
+ # train and validation
564
+ "pid": qa["id"] + f'_{i}',
565
+ "id": qa["id"],
566
+ "input": f"{context}".strip(),
567
+ 'input_prefix': qa['question'].strip(),
568
+ "output": answer, # does not give the answer start
569
+ }
570
+ key += 1
571
+
572
+ def _prepare_squad_context(self, context, context_list, n_distractors, random_order, title, answers):
573
+ if n_distractors > 0:
574
+ n_iter = 0
575
+ distractors = []
576
+ pattern = re.compile('|'.join(f'(?:\\b{re.escape(answer)}\\b)' for answer in answers))
577
+ for i in np.random.permutation(len(context_list)):
578
+ distractor, dist_title = context_list[i]
579
+ if dist_title == title:
580
+ continue
581
+ # assert any(answer in distractor for answer in answers) == (len(pattern.findall(distractor)) > 0)
582
+ # if any(answer in distractor for answer in answers):
583
+ if len(pattern.findall(distractor)) > 0:
584
+ continue
585
+ if distractor in distractors:
586
+ continue
587
+ distractors.append(distractor)
588
+
589
+ if len(distractors) == n_distractors:
590
+ break
591
+
592
+ n_iter += 1
593
+ if n_iter == 10:
594
+ raise RuntimeError('reached maximum attempts to create context distractors!')
595
+
596
+ context = [context] + distractors
597
+ if random_order:
598
+ random.shuffle(context)
599
+ context = '\n\n'.join(context)
600
+ return context
601
+
602
+ def _generate_examples(self, data_file=None, split=None, filepath=None):
603
+ if 'squad' in self.config.name:
604
+ gen = self._squad_gen(filepath, split)
605
+ elif 'hotpotqa' in self.config.name:
606
+ gen = self._hotpotqa_gen(data_file)
607
+ else:
608
+ gen = self._scrolls_gen(data_file, split)
609
+
610
+ for key, row in gen:
611
+ yield key, row
612
+
613
+ def _hotpotqa_gen(self, data_file):
614
+ """This function returns the examples."""
615
+ data = json.load(open(data_file))
616
+
617
+ for idx, example in enumerate(data):
618
+
619
+ # Test set has missing keys
620
+ for k in ["answer", "type", "level"]:
621
+ if k not in example.keys():
622
+ example[k] = None
623
+
624
+ gold_context_labels = list(
625
+ dict.fromkeys([sf[0] for sf in example['supporting_facts']])) # remove duplicates but keep order
626
+ assert len(gold_context_labels) == 2
627
+ context = {title: ' '.join(sentences) for title, sentences in example["context"]}
628
+ gold_context_first = context.pop(gold_context_labels[0])
629
+ gold_context_second = context.pop(gold_context_labels[1])
630
+ distractors = list(context.values())
631
+
632
+ if self.config.gold_passages == 'first':
633
+ context = [gold_context_first]
634
+ elif self.config.gold_passages == 'second':
635
+ context = [gold_context_second]
636
+ elif self.config.gold_passages == 'both':
637
+ context = [gold_context_first, gold_context_second]
638
+ else:
639
+ raise NotImplementedError(f'Unknown gold context config: {self.config.gold_passages}')
640
+
641
+ if self.config.distractors:
642
+ context = context + distractors
643
+ context = context[:9] # so that we will always have only 9 passages
644
+ random.shuffle(context)
645
+ context = '\n\n'.join(context)
646
+
647
+ # there is a single answer for each question
648
+ yield idx, {
649
+ "id": example["_id"],
650
+ "pid": example["_id"] + '_0',
651
+ "input": context,
652
+ "input_prefix": example["question"],
653
+ "output": example["answer"],
654
+ }
655
+
656
+
657
+ def _get_task_name_from_data_url(data_url):
658
+ return data_url.split("/")[-1].split(".")[0]