Stijn de Boer commited on
Commit
4369489
·
1 Parent(s): 88ee947

Convert datasets to parquet format

Browse files
.gitattributes CHANGED
@@ -1,54 +1 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.lz4 filter=lfs diff=lfs merge=lfs -text
12
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
13
- *.model filter=lfs diff=lfs merge=lfs -text
14
- *.msgpack filter=lfs diff=lfs merge=lfs -text
15
- *.npy filter=lfs diff=lfs merge=lfs -text
16
- *.npz filter=lfs diff=lfs merge=lfs -text
17
- *.onnx filter=lfs diff=lfs merge=lfs -text
18
- *.ot filter=lfs diff=lfs merge=lfs -text
19
  *.parquet filter=lfs diff=lfs merge=lfs -text
20
- *.pb filter=lfs diff=lfs merge=lfs -text
21
- *.pickle filter=lfs diff=lfs merge=lfs -text
22
- *.pkl filter=lfs diff=lfs merge=lfs -text
23
- *.pt filter=lfs diff=lfs merge=lfs -text
24
- *.pth filter=lfs diff=lfs merge=lfs -text
25
- *.rar filter=lfs diff=lfs merge=lfs -text
26
- *.safetensors filter=lfs diff=lfs merge=lfs -text
27
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
28
- *.tar.* filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
36
- # Audio files - uncompressed
37
- *.pcm filter=lfs diff=lfs merge=lfs -text
38
- *.sam filter=lfs diff=lfs merge=lfs -text
39
- *.raw filter=lfs diff=lfs merge=lfs -text
40
- # Audio files - compressed
41
- *.aac filter=lfs diff=lfs merge=lfs -text
42
- *.flac filter=lfs diff=lfs merge=lfs -text
43
- *.mp3 filter=lfs diff=lfs merge=lfs -text
44
- *.ogg filter=lfs diff=lfs merge=lfs -text
45
- *.wav filter=lfs diff=lfs merge=lfs -text
46
- # Image files - uncompressed
47
- *.bmp filter=lfs diff=lfs merge=lfs -text
48
- *.gif filter=lfs diff=lfs merge=lfs -text
49
- *.png filter=lfs diff=lfs merge=lfs -text
50
- *.tiff filter=lfs diff=lfs merge=lfs -text
51
- # Image files - compressed
52
- *.jpg filter=lfs diff=lfs merge=lfs -text
53
- *.jpeg filter=lfs diff=lfs merge=lfs -text
54
- *.webp filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  *.parquet filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -10,6 +10,496 @@ task_ids:
10
  tags:
11
  - query-based-summarization
12
  - long-texts
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  ---
14
 
15
  ## Dataset Description
 
10
  tags:
11
  - query-based-summarization
12
  - long-texts
13
+ configs:
14
+ - config_name: gov_report
15
+ data_files:
16
+ - split: test
17
+ path: gov_report/*
18
+ - config_name: gov_report
19
+ data_files:
20
+ - split: validation
21
+ path: gov_report/*
22
+ - config_name: musique
23
+ data_files:
24
+ - split: test
25
+ path: musique/*
26
+ - config_name: musique
27
+ data_files:
28
+ - split: validation
29
+ path: musique/*
30
+ - config_name: narrative_qa
31
+ data_files:
32
+ - split: test
33
+ path: narrative_qa/*
34
+ - config_name: narrative_qa
35
+ data_files:
36
+ - split: validation
37
+ path: narrative_qa/*
38
+ - config_name: qasper
39
+ data_files:
40
+ - split: test
41
+ path: qasper/*
42
+ - config_name: qasper
43
+ data_files:
44
+ - split: validation
45
+ path: qasper/*
46
+ - config_name: qmsum
47
+ data_files:
48
+ - split: test
49
+ path: qmsum/*
50
+ - config_name: qmsum
51
+ data_files:
52
+ - split: validation
53
+ path: qmsum/*
54
+ - config_name: quality
55
+ data_files:
56
+ - split: test
57
+ path: quality/*
58
+ - config_name: quality
59
+ data_files:
60
+ - split: validation
61
+ path: quality/*
62
+ - config_name: space_digest
63
+ data_files:
64
+ - split: test
65
+ path: space_digest/*
66
+ - config_name: space_digest
67
+ data_files:
68
+ - split: validation
69
+ path: space_digest/*
70
+ - config_name: squality
71
+ data_files:
72
+ - split: test
73
+ path: squality/*
74
+ - config_name: squality
75
+ data_files:
76
+ - split: validation
77
+ path: squality/*
78
+ dataset_info:
79
+ - config_name: gov_report
80
+ features:
81
+ - name: id
82
+ dtype: string
83
+ - name: pid
84
+ dtype: string
85
+ - name: input
86
+ dtype: string
87
+ - name: output
88
+ dtype: string
89
+ - name: document_start_index
90
+ dtype: int64
91
+ - name: document_end_index
92
+ dtype: int64
93
+ - name: query_start_index
94
+ dtype: int64
95
+ - name: query_end_index
96
+ dtype: int64
97
+ - name: truncation_seperator
98
+ dtype: string
99
+ splits:
100
+ - name: test
101
+ num_bytes: 621455
102
+ num_examples: 20
103
+ download_size: 621455
104
+ dataset_size: 621455
105
+ - config_name: gov_report
106
+ features:
107
+ - name: id
108
+ dtype: string
109
+ - name: pid
110
+ dtype: string
111
+ - name: input
112
+ dtype: string
113
+ - name: output
114
+ dtype: string
115
+ - name: document_start_index
116
+ dtype: int64
117
+ - name: document_end_index
118
+ dtype: int64
119
+ - name: query_start_index
120
+ dtype: int64
121
+ - name: query_end_index
122
+ dtype: int64
123
+ - name: truncation_seperator
124
+ dtype: string
125
+ splits:
126
+ - name: validation
127
+ num_bytes: 621455
128
+ num_examples: 20
129
+ download_size: 621455
130
+ dataset_size: 621455
131
+ - config_name: musique
132
+ features:
133
+ - name: id
134
+ dtype: string
135
+ - name: pid
136
+ dtype: string
137
+ - name: input
138
+ dtype: string
139
+ - name: output
140
+ dtype: string
141
+ - name: document_start_index
142
+ dtype: int64
143
+ - name: document_end_index
144
+ dtype: int64
145
+ - name: query_start_index
146
+ dtype: int64
147
+ - name: query_end_index
148
+ dtype: int64
149
+ - name: truncation_seperator
150
+ dtype: string
151
+ - name: inner_docs_start_indices
152
+ dtype: string
153
+ splits:
154
+ - name: test
155
+ num_bytes: 128458
156
+ num_examples: 20
157
+ download_size: 128458
158
+ dataset_size: 128458
159
+ - config_name: musique
160
+ features:
161
+ - name: id
162
+ dtype: string
163
+ - name: pid
164
+ dtype: string
165
+ - name: input
166
+ dtype: string
167
+ - name: output
168
+ dtype: string
169
+ - name: document_start_index
170
+ dtype: int64
171
+ - name: document_end_index
172
+ dtype: int64
173
+ - name: query_start_index
174
+ dtype: int64
175
+ - name: query_end_index
176
+ dtype: int64
177
+ - name: truncation_seperator
178
+ dtype: string
179
+ - name: inner_docs_start_indices
180
+ dtype: string
181
+ splits:
182
+ - name: validation
183
+ num_bytes: 128458
184
+ num_examples: 20
185
+ download_size: 128458
186
+ dataset_size: 128458
187
+ - config_name: narrative_qa
188
+ features:
189
+ - name: id
190
+ dtype: string
191
+ - name: pid
192
+ dtype: string
193
+ - name: input
194
+ dtype: string
195
+ - name: output
196
+ dtype: string
197
+ - name: document_start_index
198
+ dtype: int64
199
+ - name: document_end_index
200
+ dtype: int64
201
+ - name: query_start_index
202
+ dtype: int64
203
+ - name: query_end_index
204
+ dtype: int64
205
+ - name: truncation_seperator
206
+ dtype: string
207
+ splits:
208
+ - name: test
209
+ num_bytes: 915220
210
+ num_examples: 20
211
+ download_size: 915220
212
+ dataset_size: 915220
213
+ - config_name: narrative_qa
214
+ features:
215
+ - name: id
216
+ dtype: string
217
+ - name: pid
218
+ dtype: string
219
+ - name: input
220
+ dtype: string
221
+ - name: output
222
+ dtype: string
223
+ - name: document_start_index
224
+ dtype: int64
225
+ - name: document_end_index
226
+ dtype: int64
227
+ - name: query_start_index
228
+ dtype: int64
229
+ - name: query_end_index
230
+ dtype: int64
231
+ - name: truncation_seperator
232
+ dtype: string
233
+ splits:
234
+ - name: validation
235
+ num_bytes: 915220
236
+ num_examples: 20
237
+ download_size: 915220
238
+ dataset_size: 915220
239
+ - config_name: qasper
240
+ features:
241
+ - name: id
242
+ dtype: string
243
+ - name: pid
244
+ dtype: string
245
+ - name: input
246
+ dtype: string
247
+ - name: output
248
+ dtype: string
249
+ - name: document_start_index
250
+ dtype: int64
251
+ - name: document_end_index
252
+ dtype: int64
253
+ - name: query_start_index
254
+ dtype: int64
255
+ - name: query_end_index
256
+ dtype: int64
257
+ - name: truncation_seperator
258
+ dtype: string
259
+ splits:
260
+ - name: test
261
+ num_bytes: 252094
262
+ num_examples: 28
263
+ download_size: 252094
264
+ dataset_size: 252094
265
+ - config_name: qasper
266
+ features:
267
+ - name: id
268
+ dtype: string
269
+ - name: pid
270
+ dtype: string
271
+ - name: input
272
+ dtype: string
273
+ - name: output
274
+ dtype: string
275
+ - name: document_start_index
276
+ dtype: int64
277
+ - name: document_end_index
278
+ dtype: int64
279
+ - name: query_start_index
280
+ dtype: int64
281
+ - name: query_end_index
282
+ dtype: int64
283
+ - name: truncation_seperator
284
+ dtype: string
285
+ splits:
286
+ - name: validation
287
+ num_bytes: 252094
288
+ num_examples: 28
289
+ download_size: 252094
290
+ dataset_size: 252094
291
+ - config_name: qmsum
292
+ features:
293
+ - name: id
294
+ dtype: string
295
+ - name: pid
296
+ dtype: string
297
+ - name: input
298
+ dtype: string
299
+ - name: output
300
+ dtype: string
301
+ - name: document_start_index
302
+ dtype: int64
303
+ - name: document_end_index
304
+ dtype: int64
305
+ - name: query_start_index
306
+ dtype: int64
307
+ - name: query_end_index
308
+ dtype: int64
309
+ - name: truncation_seperator
310
+ dtype: string
311
+ splits:
312
+ - name: test
313
+ num_bytes: 499957
314
+ num_examples: 20
315
+ download_size: 499957
316
+ dataset_size: 499957
317
+ - config_name: qmsum
318
+ features:
319
+ - name: id
320
+ dtype: string
321
+ - name: pid
322
+ dtype: string
323
+ - name: input
324
+ dtype: string
325
+ - name: output
326
+ dtype: string
327
+ - name: document_start_index
328
+ dtype: int64
329
+ - name: document_end_index
330
+ dtype: int64
331
+ - name: query_start_index
332
+ dtype: int64
333
+ - name: query_end_index
334
+ dtype: int64
335
+ - name: truncation_seperator
336
+ dtype: string
337
+ splits:
338
+ - name: validation
339
+ num_bytes: 499957
340
+ num_examples: 20
341
+ download_size: 499957
342
+ dataset_size: 499957
343
+ - config_name: quality
344
+ features:
345
+ - name: id
346
+ dtype: string
347
+ - name: pid
348
+ dtype: string
349
+ - name: input
350
+ dtype: string
351
+ - name: output
352
+ dtype: string
353
+ - name: document_start_index
354
+ dtype: int64
355
+ - name: document_end_index
356
+ dtype: int64
357
+ - name: query_start_index
358
+ dtype: int64
359
+ - name: query_end_index
360
+ dtype: int64
361
+ - name: truncation_seperator
362
+ dtype: string
363
+ splits:
364
+ - name: test
365
+ num_bytes: 363954
366
+ num_examples: 21
367
+ download_size: 363954
368
+ dataset_size: 363954
369
+ - config_name: quality
370
+ features:
371
+ - name: id
372
+ dtype: string
373
+ - name: pid
374
+ dtype: string
375
+ - name: input
376
+ dtype: string
377
+ - name: output
378
+ dtype: string
379
+ - name: document_start_index
380
+ dtype: int64
381
+ - name: document_end_index
382
+ dtype: int64
383
+ - name: query_start_index
384
+ dtype: int64
385
+ - name: query_end_index
386
+ dtype: int64
387
+ - name: truncation_seperator
388
+ dtype: string
389
+ splits:
390
+ - name: validation
391
+ num_bytes: 363954
392
+ num_examples: 21
393
+ download_size: 363954
394
+ dataset_size: 363954
395
+ - config_name: space_digest
396
+ features:
397
+ - name: id
398
+ dtype: string
399
+ - name: pid
400
+ dtype: string
401
+ - name: input
402
+ dtype: string
403
+ - name: output
404
+ dtype: string
405
+ - name: document_start_index
406
+ dtype: int64
407
+ - name: document_end_index
408
+ dtype: int64
409
+ - name: query_start_index
410
+ dtype: int64
411
+ - name: query_end_index
412
+ dtype: int64
413
+ - name: truncation_seperator
414
+ dtype: string
415
+ - name: inner_docs_start_indices
416
+ dtype: string
417
+ splits:
418
+ - name: test
419
+ num_bytes: 349818
420
+ num_examples: 20
421
+ download_size: 349818
422
+ dataset_size: 349818
423
+ - config_name: space_digest
424
+ features:
425
+ - name: id
426
+ dtype: string
427
+ - name: pid
428
+ dtype: string
429
+ - name: input
430
+ dtype: string
431
+ - name: output
432
+ dtype: string
433
+ - name: document_start_index
434
+ dtype: int64
435
+ - name: document_end_index
436
+ dtype: int64
437
+ - name: query_start_index
438
+ dtype: int64
439
+ - name: query_end_index
440
+ dtype: int64
441
+ - name: truncation_seperator
442
+ dtype: string
443
+ - name: inner_docs_start_indices
444
+ dtype: string
445
+ splits:
446
+ - name: validation
447
+ num_bytes: 349818
448
+ num_examples: 20
449
+ download_size: 349818
450
+ dataset_size: 349818
451
+ - config_name: squality
452
+ features:
453
+ - name: id
454
+ dtype: string
455
+ - name: pid
456
+ dtype: string
457
+ - name: input
458
+ dtype: string
459
+ - name: output
460
+ dtype: string
461
+ - name: document_start_index
462
+ dtype: int64
463
+ - name: document_end_index
464
+ dtype: int64
465
+ - name: query_start_index
466
+ dtype: int64
467
+ - name: query_end_index
468
+ dtype: int64
469
+ - name: truncation_seperator
470
+ dtype: string
471
+ splits:
472
+ - name: test
473
+ num_bytes: 421574
474
+ num_examples: 80
475
+ download_size: 421574
476
+ dataset_size: 421574
477
+ - config_name: squality
478
+ features:
479
+ - name: id
480
+ dtype: string
481
+ - name: pid
482
+ dtype: string
483
+ - name: input
484
+ dtype: string
485
+ - name: output
486
+ dtype: string
487
+ - name: document_start_index
488
+ dtype: int64
489
+ - name: document_end_index
490
+ dtype: int64
491
+ - name: query_start_index
492
+ dtype: int64
493
+ - name: query_end_index
494
+ dtype: int64
495
+ - name: truncation_seperator
496
+ dtype: string
497
+ splits:
498
+ - name: validation
499
+ num_bytes: 421574
500
+ num_examples: 80
501
+ download_size: 421574
502
+ dataset_size: 421574
503
  ---
504
 
505
  ## Dataset Description
qasper.zip → gov_report/0000.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:361bf8876595dea5f00f81283f94b1310990b858a061878a26794395675b89a0
3
- size 312956
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c64d01ac109dcce6101313875476b318a63f78825e8bf0aecb305f4ccad42ec
3
+ size 621455
metrics/accuracy.py DELETED
@@ -1,32 +0,0 @@
1
- import re
2
-
3
- PATTERN = re.compile(r'\b[A-D]\b')
4
-
5
-
6
- def find_answer(s):
7
- match = PATTERN.search(s)
8
- if match is None:
9
- return None
10
- return match.group()
11
-
12
-
13
- def accuracy_score(prediction, ground_truth):
14
- letter_ground_truth = find_answer(ground_truth)
15
- assert letter_ground_truth in ["A", "B", "C", "D"], f"Invalid ground truth: {ground_truth}"
16
- letter_prediction = find_answer(str(prediction))
17
- return letter_prediction == letter_ground_truth
18
-
19
-
20
- def metric_max_over_ground_truths(metric_fn, prediction, ground_truths):
21
- scores_for_ground_truths = []
22
- for ground_truth in ground_truths:
23
- score = metric_fn(prediction, ground_truth)
24
- scores_for_ground_truths.append(score)
25
- return max(scores_for_ground_truths)
26
-
27
-
28
- def compute_accuracy(predictions, references):
29
- accuracy = 0
30
- for prediction, ground_truths in zip(predictions, references):
31
- accuracy += metric_max_over_ground_truths(accuracy_score, prediction, ground_truths)
32
- return 100.0 * accuracy / len(predictions)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
metrics/concordance_index.py DELETED
@@ -1,57 +0,0 @@
1
- import re
2
- import string
3
- from lifelines.utils import concordance_index
4
-
5
-
6
- def keep_integers_commas_spaces(input_string):
7
- cleaned_string = re.sub(r'[^0-9\s,]', '', str(input_string))
8
- return cleaned_string
9
-
10
-
11
- def normalize_answer(s):
12
- """Lower text and remove punctuation, articles and extra whitespace."""
13
-
14
- def remove_punc(text):
15
- exclude = set(string.punctuation)
16
- return "".join(ch for ch in text if ch not in exclude)
17
-
18
- normalized_list = keep_integers_commas_spaces(s).replace(",", " ").strip(string.punctuation).split()
19
- try:
20
- normalized_list = [int(remove_punc(x).strip()) for x in normalized_list]
21
- except ValueError:
22
- return []
23
- return normalized_list
24
-
25
-
26
- def concordant_index_score(prediction, ground_truth):
27
- normalized_prediction = normalize_answer(prediction)
28
- normalized_ground_truth = normalize_answer(ground_truth)
29
- if sorted(normalized_ground_truth) != sorted(normalized_prediction):
30
- return 0.0
31
-
32
- pred_order = summ_id_per_location_to_pos_of_id(normalized_prediction)
33
- gold_order = summ_id_per_location_to_pos_of_id(normalized_ground_truth)
34
-
35
- return concordance_index(gold_order, pred_order)
36
-
37
-
38
- def summ_id_per_location_to_pos_of_id(id_per_location):
39
- order = [-1] * len(id_per_location)
40
- for i, id_ in enumerate(id_per_location, 1):
41
- order[id_ - 1] = i
42
- return order
43
-
44
-
45
- def metric_max_over_ground_truths(metric_fn, prediction, ground_truths):
46
- scores_for_ground_truths = []
47
- for ground_truth in ground_truths:
48
- score = metric_fn(prediction, ground_truth)
49
- scores_for_ground_truths.append(score)
50
- return max(scores_for_ground_truths)
51
-
52
-
53
- def compute_concordance_index(predictions, references):
54
- concordant_index = 0
55
- for prediction, ground_truths in zip(predictions, references):
56
- concordant_index += metric_max_over_ground_truths(concordant_index_score, prediction, ground_truths)
57
- return 100.0 * concordant_index / len(predictions)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
metrics/exp_similarity.py DELETED
@@ -1,47 +0,0 @@
1
- import re
2
-
3
- PATTERN = re.compile(r'\d+\.?\d*%')
4
-
5
-
6
- def find_percentage(s):
7
- match = PATTERN.search(s)
8
- if match is None:
9
- return None
10
- return match.group(0)
11
-
12
-
13
- def to_int(s):
14
- percentage_string = find_percentage(s)
15
- if percentage_string is None:
16
- return None
17
- percentage_string = percentage_string.replace("%", "")
18
- percentage = float(percentage_string)
19
- return percentage
20
-
21
-
22
- def exp_similarity_score(prediction, ground_truth):
23
- ground_truth_percentage = to_int(ground_truth)
24
- pred_percentage = to_int(str(prediction))
25
-
26
- if ground_truth_percentage is None:
27
- raise ValueError(f"ground_truth_percentage is None: {ground_truth_percentage}")
28
-
29
- if pred_percentage is None:
30
- return 0.0
31
-
32
- return 0.5 ** (abs(ground_truth_percentage - pred_percentage) / 10)
33
-
34
-
35
- def metric_max_over_ground_truths(metric_fn, prediction, ground_truths):
36
- scores_for_ground_truths = []
37
- for ground_truth in ground_truths:
38
- score = metric_fn(prediction, ground_truth)
39
- scores_for_ground_truths.append(score)
40
- return max(scores_for_ground_truths)
41
-
42
-
43
- def compute_exp_similarity(predictions, references):
44
- exp_similarity = 0
45
- for prediction, ground_truths in zip(predictions, references):
46
- exp_similarity += metric_max_over_ground_truths(exp_similarity_score, prediction, ground_truths)
47
- return 100 * exp_similarity / len(predictions)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
metrics/f1.py DELETED
@@ -1,53 +0,0 @@
1
- # Copied from https://github.com/huggingface/datasets/blob/d3c7b9481d427ce41256edaf6773c47570f06f3b/metrics/squad/evaluate.py
2
-
3
- import re
4
- import string
5
- from collections import Counter
6
- from unidecode import unidecode
7
-
8
-
9
- def normalize_answer(s):
10
- """Lower text and remove punctuation, articles and extra whitespace."""
11
-
12
- def remove_articles(text):
13
- return re.sub(r"\b(a|an|the)\b", " ", text)
14
-
15
- def white_space_fix(text):
16
- return " ".join(text.split())
17
-
18
- def remove_punc(text):
19
- exclude = set(string.punctuation)
20
- return "".join(ch for ch in text if ch not in exclude)
21
-
22
- def lower(text):
23
- return text.lower()
24
-
25
- return unidecode(white_space_fix(remove_articles(remove_punc(lower(s)))))
26
-
27
-
28
- def f1_score(prediction, ground_truth):
29
- prediction_tokens = normalize_answer(prediction).split()
30
- ground_truth_tokens = normalize_answer(ground_truth).split()
31
- common = Counter(prediction_tokens) & Counter(ground_truth_tokens)
32
- num_same = sum(common.values())
33
- if num_same == 0:
34
- return 0
35
- precision = 1.0 * num_same / len(prediction_tokens)
36
- recall = 1.0 * num_same / len(ground_truth_tokens)
37
- f1 = (2 * precision * recall) / (precision + recall)
38
- return f1
39
-
40
-
41
- def metric_max_over_ground_truths(metric_fn, prediction, ground_truths):
42
- scores_for_ground_truths = []
43
- for ground_truth in ground_truths:
44
- score = metric_fn(prediction, ground_truth)
45
- scores_for_ground_truths.append(score)
46
- return max(scores_for_ground_truths)
47
-
48
-
49
- def compute_f1(predictions, references):
50
- f1 = 0
51
- for prediction, ground_truths in zip(predictions, references):
52
- f1 += metric_max_over_ground_truths(f1_score, prediction, ground_truths)
53
- return 100.0 * f1 / len(predictions)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
metrics/rouge.py DELETED
@@ -1,28 +0,0 @@
1
- # Copied from https://github.com/huggingface/datasets/blob/d3c7b9481d427ce41256edaf6773c47570f06f3b/metrics/rouge/rouge.py
2
- # Added multiprocessing
3
-
4
- import multiprocessing
5
- import nltk
6
- from rouge_score import rouge_scorer
7
- from multiprocessing import Pool
8
-
9
-
10
- def compute_rouge(predictions, references, rouge_types=None, use_stemmer=False):
11
- if rouge_types is None:
12
- rouge_types = ["rouge1", "rouge2", "rougeL", "rougeLsum"]
13
-
14
- scorer = rouge_scorer.RougeScorer(rouge_types=rouge_types, use_stemmer=use_stemmer)
15
- with Pool() as p:
16
- scores = p.starmap(scorer.score, zip(references, predictions))
17
-
18
- result = {}
19
- for key in scores[0]:
20
- result[key] = list(score[key] for score in scores)
21
-
22
- return result
23
-
24
-
25
- # Copied from https://github.com/huggingface/transformers/blob/3977b58437b8ce1ea1da6e31747d888efec2419b/examples/pytorch/summarization/run_summarization.py#L520
26
- def postprocess_text(text):
27
- # rougeLSum expects newline after each sentence
28
- return "\n".join(nltk.sent_tokenize(text))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
metrics/zero_scrolls.py DELETED
@@ -1,353 +0,0 @@
1
- """ Zero-zero_scrolls benchmark metric. """
2
-
3
- from collections import defaultdict
4
- from copy import deepcopy
5
- import datasets
6
-
7
- # fmt: off
8
- from .rouge import compute_rouge, postprocess_text as rouge_postprocess_text # From: https://huggingface.co/datasets/tau/zero_scrolls/raw/main/metrics/rouge.py
9
- from .accuracy import compute_accuracy # From: https://huggingface.co/datasets/tau/zero_scrolls/raw/main/metrics/accuracy.py
10
- from .f1 import compute_f1 # From: https://huggingface.co/datasets/tau/zero_scrolls/raw/main/metrics/f1.py
11
- from .exp_similarity import compute_exp_similarity # From: https://huggingface.co/datasets/tau/zero_scrolls/raw/main/metrics/exp_similarity.py
12
- from .concordance_index import compute_concordance_index # From: https://huggingface.co/datasets/tau/zero_scrolls/raw/main/metrics/concordance_index.py
13
-
14
- # fmt: on
15
-
16
- _CITATION = """
17
- """
18
-
19
- _DESCRIPTION = """
20
- ZeroSCROLLS: Zero-Shot CompaRison Over Long Language Sequences.
21
- A zero shot benchmark for long text reasoning.
22
- https://zero.scrolls-benchmark.com/
23
- """
24
-
25
- _KWARGS_DESCRIPTION = """
26
- Compute zero_scrolls evaluation metric associated to each zero_scrolls dataset.
27
- Args:
28
- predictions: list of predictions to score.
29
- Each prediction should be a string.
30
- references: list of lists of references for each example.
31
- Each reference should be a string.
32
- Returns: depending on the zero_scrolls subset, one or several of:
33
- "accuracy": Accuracy score
34
- "f1": F1 score
35
- "rouge": ROUGE score
36
- "exp_similarity": Exponential Similarity score
37
- "concordance_index": Concordance Index score
38
-
39
- Use the following code to download the metric:
40
- ```
41
- import os, shutil
42
- from huggingface_hub import hf_hub_download
43
- def download_metric():
44
- zero_scrolls_metric_path = hf_hub_download(repo_id="tau/zero_scrolls", repo_type="dataset", filename="metrics/zero_scrolls.py")
45
- updated_zero_scrolls_metric_path = (
46
- os.path.dirname(zero_scrolls_metric_path) + os.path.basename(zero_scrolls_metric_path).replace(".", "_") + ".py"
47
- )
48
- shutil.copy(zero_scrolls_metric_path, updated_zero_scrolls_metric_path)
49
- return updated_zero_scrolls_metric_path
50
-
51
- zero_scrolls_metric_path = download_metric()
52
- ```
53
-
54
- Examples:
55
-
56
- >>> predictions = ["hello there", "general kenobi"] # List[str]
57
- >>> references = [["hello", "hi there"], ["commander kenobi"]] # List[List[str]]
58
- >>> zero_scrolls_metric = datasets.load_metric(zero_scrolls_metric_path, 'gov_report') # "gov_report" or "summ_screen_fd" or "qmsum" or "squality]
59
- >>> results = zero_scrolls_metric.compute(predictions=predictions, references=references)
60
- >>> print(results)
61
- {'rouge/rouge1': 72.2222, 'rouge/rouge2': 33.3333, 'rouge/rougeL': 72.2222, 'rouge/rougeLsum': 72.2222, 'rouge/geometric_mean': 55.8136,
62
- 'num_predicted': 3, 'mean_prediction_length_characters': 14.6667, 'zero_scrolls_score': 55.8136,
63
- 'display_keys': ['rouge/rouge1', 'rouge/rouge2', 'rouge/rougeL'], 'display': [72.2222, 33.3333, 72.2222]}
64
-
65
- >>> zero_scrolls_metric = datasets.load_metric(zero_scrolls_metric_path, 'narrative_qa') # "qasper" or "narrative_qa" or "musique"
66
- >>> results = zero_scrolls_metric.compute(predictions=predictions, references=references)
67
- >>> print(results)
68
- {'f1': 72.2222, 'num_predicted': 3, 'mean_prediction_length_characters': 14.6667, 'zero_scrolls_score': 72.2222,
69
- 'display_keys': ['f1'], 'display': [72.2222]}
70
-
71
- >>> predictions = ["The answer is (B)", "D", "A"] # List[str]
72
- >>> references = [["B"], ["C"], ["C"]] # List[List[str]]
73
- >>> zero_scrolls_metric = datasets.load_metric(zero_scrolls_metric_path, 'quality')
74
- >>> results = zero_scrolls_metric.compute(predictions=predictions, references=references)
75
- >>> print(results)
76
- {'accuracy': 33.3333, 'num_predicted': 3, 'mean_prediction_length_characters': 6.3333, 'zero_scrolls_score': 33.3333, 'display_keys': ['accuracy'], 'display': [33.3333]}
77
- 'display_keys': ['accuracy'], 'display': [33.3333]}
78
-
79
- >>> predictions = ["Answer: 4,1,2,3", "2,4,5,4,1"] # List[str]
80
- >>> references = [["1,2,3,4"], ["5,3,2,1,4"]] # List[List[str]]
81
- >>> zero_scrolls_metric = datasets.load_metric(zero_scrolls_metric_path, 'book_sum_sort')
82
- >>> results = zero_scrolls_metric.compute(predictions=predictions, references=references)
83
- >>> print(results)
84
- {'concordance_index': 25.0, 'num_predicted': 2, 'mean_prediction_length_characters': 12.0, 'zero_scrolls_score': 25.0, 'display_keys': ['concordance_index'], 'display': [25.0]}
85
-
86
- >>> predictions = ["There are 30% positive reviews", "25%"] # List[str]
87
- >>> references = [["40%"], ["82%"]] # List[List[str]]
88
- >>> zero_scrolls_metric = datasets.load_metric(zero_scrolls_metric_path, 'space_digest')
89
- >>> results = zero_scrolls_metric.compute(predictions=predictions, references=references)
90
- >>> print(results)
91
- {'exp_similarity': 25.9618, 'num_predicted': 2, 'mean_prediction_length_characters': 16.5, 'zero_scrolls_score': 25.9618, 'display_keys': ['exp_similarity'], 'display': [25.9618]}
92
- """
93
-
94
- DATASET_TO_METRICS = {
95
- "gov_report": {
96
- "metrics_to_compute": ["rouge"],
97
- "zero_scrolls_score_key": "rouge/geometric_mean",
98
- "display_keys": ["rouge/rouge1", "rouge/rouge2", "rouge/rougeL"],
99
- },
100
- "narrative_qa": {
101
- "metrics_to_compute": ["f1"],
102
- "zero_scrolls_score_key": "f1",
103
- "display_keys": ["f1"],
104
- },
105
- "qasper": {
106
- "metrics_to_compute": ["f1"],
107
- "zero_scrolls_score_key": "f1",
108
- "display_keys": ["f1"],
109
- },
110
- "qmsum": {
111
- "metrics_to_compute": ["rouge"],
112
- "zero_scrolls_score_key": "rouge/geometric_mean",
113
- "display_keys": ["rouge/rouge1", "rouge/rouge2", "rouge/rougeL"],
114
- },
115
- "summ_screen_fd": {
116
- "metrics_to_compute": ["rouge"],
117
- "zero_scrolls_score_key": "rouge/geometric_mean",
118
- "display_keys": ["rouge/rouge1", "rouge/rouge2", "rouge/rougeL"],
119
- },
120
- "quality": {
121
- "metrics_to_compute": ["accuracy"],
122
- "zero_scrolls_score_key": "accuracy",
123
- "display_keys": ["accuracy"],
124
- },
125
- "quality_hard": {
126
- "metrics_to_compute": ["accuracy"],
127
- "zero_scrolls_score_key": None,
128
- "display_keys": ["accuracy"],
129
- },
130
- "squality": {
131
- "metrics_to_compute": ["rouge"],
132
- "zero_scrolls_score_key": "rouge/geometric_mean",
133
- "display_keys": ["rouge/rouge1", "rouge/rouge2", "rouge/rougeL"],
134
- },
135
- "musique": {
136
- "metrics_to_compute": ["f1"],
137
- "zero_scrolls_score_key": "f1",
138
- "display_keys": ["f1"],
139
- },
140
- "space_digest": {
141
- "metrics_to_compute": ["exp_similarity"],
142
- "zero_scrolls_score_key": "exp_similarity",
143
- "display_keys": ["exp_similarity"],
144
- },
145
- "book_sum_sort": {
146
- "metrics_to_compute": ["concordance_index"],
147
- "zero_scrolls_score_key": "concordance_index",
148
- "display_keys": ["concordance_index"],
149
- },
150
- }
151
-
152
-
153
- @datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
154
- class ZeroScrolls(datasets.Metric):
155
- def __init__(self, *args, **kwargs):
156
- super().__init__(*args, **kwargs)
157
-
158
- self._compute_helper_kwargs_fn = {
159
- "rouge": lambda: {
160
- "metric_fn": compute_rouge,
161
- "agg_fn": max,
162
- "metric_fn_kwargs": {"use_stemmer": False},
163
- "metric_returns_per_example": True,
164
- "transform_single_input_fn": lambda text: rouge_postprocess_text(text),
165
- "transform_result_fn": lambda output: {
166
- key: (value[0] if isinstance(value, list) else value).fmeasure * 100
167
- for key, value in output.items()
168
- },
169
- "transform_aggregated_result_fn": lambda output: output.update(
170
- {"geometric_mean": (output["rouge1"] * output["rouge2"] * output["rougeL"]) ** (1.0 / 3.0)}
171
- )
172
- or output,
173
- },
174
- "accuracy": lambda: {
175
- "metric_fn": compute_accuracy,
176
- "agg_fn": None, # compute_accuracy already takes max
177
- "transform_result_fn": lambda output: {None: output},
178
- },
179
- "f1": lambda: {
180
- "metric_fn": compute_f1,
181
- "agg_fn": None, # compute_f1 already takes max
182
- "transform_result_fn": lambda output: {None: output},
183
- },
184
- "exp_similarity": lambda: {
185
- "metric_fn": compute_exp_similarity,
186
- "agg_fn": None, # compute_exp_similarity already takes max
187
- "transform_result_fn": lambda output: {None: output},
188
- },
189
- "concordance_index": lambda: {
190
- "metric_fn": compute_concordance_index,
191
- "agg_fn": None, # compute_concordance_index already takes max
192
- "transform_result_fn": lambda output: {None: output},
193
- },
194
- }
195
-
196
- custom_metrics = (
197
- [metric for metric in self.config_name.split(",") if len(metric) > 0]
198
- if self.config_name.startswith(",")
199
- else None
200
- )
201
- if custom_metrics is not None:
202
- for metric in custom_metrics:
203
- if metric not in self._compute_helper_kwargs_fn:
204
- raise KeyError(
205
- f"You should supply a metric name selected in {list(self._compute_helper_kwargs_fn.keys())}"
206
- )
207
- self._metrics_to_compute = custom_metrics
208
- else:
209
- if self.config_name not in DATASET_TO_METRICS:
210
- raise KeyError(f"You should supply a configuration name selected in {list(DATASET_TO_METRICS.keys())}")
211
- self._metrics_to_compute = DATASET_TO_METRICS[self.config_name]["metrics_to_compute"]
212
-
213
- def _info(self):
214
- return datasets.MetricInfo(
215
- description=_DESCRIPTION,
216
- citation=_CITATION,
217
- inputs_description=_KWARGS_DESCRIPTION,
218
- features=datasets.Features(
219
- {
220
- "predictions": datasets.Value("string"),
221
- "references": datasets.Sequence(datasets.Value("string")),
222
- }
223
- ),
224
- codebase_urls=[],
225
- reference_urls=[],
226
- )
227
-
228
- def convert_from_map_format(self, id_to_pred, id_to_labels):
229
- index_to_id = list(id_to_pred.keys())
230
- predictions = [id_to_pred[id_] for id_ in index_to_id]
231
- references = [id_to_labels[id_] for id_ in index_to_id]
232
- return {"predictions": predictions, "references": references}
233
-
234
- def _compute(self, predictions, references):
235
- metrics = {}
236
- for metric in self._metrics_to_compute:
237
- result = _compute_helper(
238
- deepcopy(predictions),
239
- deepcopy(references),
240
- **self._compute_helper_kwargs_fn[metric](),
241
- )
242
- metrics.update(
243
- {(f"{metric}/{key}" if key is not None else metric): value for key, value in result.items()}
244
- )
245
- metrics["num_predicted"] = len(predictions)
246
- prediction_lengths = [len(prediction) for prediction in predictions]
247
- metrics["mean_prediction_length_characters"] = sum(prediction_lengths) / len(prediction_lengths)
248
-
249
- metrics = {key: round(value, 4) for key, value in metrics.items()}
250
-
251
- if self.config_name in DATASET_TO_METRICS:
252
- zero_scrolls_score_key = DATASET_TO_METRICS[self.config_name]["zero_scrolls_score_key"]
253
- if zero_scrolls_score_key is not None:
254
- metrics["zero_scrolls_score"] = metrics[zero_scrolls_score_key]
255
- else:
256
- metrics["zero_scrolls_score"] = None
257
-
258
- display_keys = DATASET_TO_METRICS[self.config_name]["display_keys"]
259
- metrics["display_keys"] = display_keys
260
- metrics["display"] = []
261
- for display_key in display_keys:
262
- metrics["display"].append(metrics[display_key])
263
-
264
- return metrics
265
-
266
-
267
- def _compute_helper(
268
- predictions,
269
- references,
270
- metric_fn,
271
- agg_fn,
272
- metric_fn_kwargs=None,
273
- transform_single_input_fn=None,
274
- transform_result_fn=None,
275
- transform_aggregated_result_fn=None,
276
- metric_returns_per_example=False,
277
- ):
278
- if metric_fn_kwargs is None:
279
- metric_fn_kwargs = {}
280
-
281
- if agg_fn is None:
282
- assert metric_returns_per_example is False
283
-
284
- if transform_single_input_fn is not None:
285
- predictions = [transform_single_input_fn(prediction) for prediction in predictions]
286
- references = [
287
- [transform_single_input_fn(reference) for reference in reference_list] for reference_list in references
288
- ]
289
-
290
- if transform_result_fn is None:
291
- transform_result_fn = lambda x: x
292
- do_transform_result = False
293
- else:
294
- do_transform_result = True
295
-
296
- if transform_aggregated_result_fn is None:
297
- transform_aggregated_result_fn = lambda x: x
298
-
299
- if agg_fn is not None:
300
- # Required when the metric doesn't do the aggregation we need
301
- scores = defaultdict(list)
302
- if metric_returns_per_example is False:
303
- # If when given a list of prediction and references the metric returns an aggregated score,
304
- # we need to compute the metric for each prediction and reference and then aggregate the results.
305
- # This is only an issue when we want to get the best aggregated score (e.g. max) for prediction
306
- # with multiple references.
307
- for prediction, reference_list in zip(predictions, references):
308
- prediction_scores = defaultdict(list)
309
- for reference in reference_list:
310
- result = transform_result_fn(metric_fn([prediction], [reference], **metric_fn_kwargs))
311
- for key in result:
312
- prediction_scores[key].append(result[key])
313
- for key in prediction_scores:
314
- scores[key].append(agg_fn(prediction_scores[key]))
315
- else:
316
- # Flatten the references and then aggregate per prediction with agg_fn
317
- mapping = [[] for _ in range(len(predictions))]
318
- flattened_predictions = []
319
- flattened_references = []
320
- for i, prediction in enumerate(predictions):
321
- for reference in references[i]:
322
- flattened_predictions.append(prediction)
323
- flattened_references.append(reference)
324
- mapping[i].append(len(flattened_references) - 1)
325
-
326
- results = metric_fn(flattened_predictions, flattened_references, **metric_fn_kwargs)
327
- if isinstance(results, dict):
328
- # Convert a dictionary with lists per key to a list with dictionary with the same keys per element
329
- results_list = [{k: None for k in results} for _ in range(len(flattened_predictions))]
330
- for k, v in results.items():
331
- for i in range(len(v)):
332
- results_list[i][k] = v[i]
333
- else:
334
- results_list = results
335
-
336
- if do_transform_result:
337
- for i in range(len(results_list)):
338
- results_list[i] = transform_result_fn(results_list[i])
339
-
340
- for reference_indexes in mapping:
341
- prediction_scores = defaultdict(list)
342
- for reference_index in reference_indexes:
343
- result = results_list[reference_index]
344
- for key in result:
345
- prediction_scores[key].append(result[key])
346
- for key in prediction_scores:
347
- scores[key].append(agg_fn(prediction_scores[key]))
348
-
349
- return transform_aggregated_result_fn({key: sum(value) / len(value) for key, value in scores.items()})
350
- else:
351
- return transform_aggregated_result_fn(
352
- transform_result_fn(metric_fn(predictions, references, **metric_fn_kwargs))
353
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
book_sum_sort.zip → musique/0000.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4b8508e9a1264c891caf04eb52f13d1bdd1d3e80b1f138c6f9c60e314d08bda6
3
- size 5503241
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3e133498bd2166e9bb1df48913d91a69148d2edc2f5a9102086f881a9799566
3
+ size 128458
narrative_qa.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0c466684675f9c4ef4c2a6b44d9803e62743e4a5091c61e7e7b0bc585a8db433
3
- size 93871322
 
 
 
 
gov_report.zip → narrative_qa/0000.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e2515aa148ee946f521f138aee7a4d73207c560cb2543d1cfd66431976e7d195
3
- size 7938871
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:15abd45c77d33073918beee6263b2be71311447233bc44dc568360907b7fdf7a
3
+ size 915220
musique.zip → qasper/0000.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b6cc642ce30334f45d85b3dc1a160862e3197d5bd28ec3f55c59a7070ab08fa1
3
- size 2149313
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:756957ef331bb48810e12ba35acabd6d3707f8cf3ab981f99193281788c03cde
3
+ size 252094
qmsum.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:62697cc3b0e4254da64fd3d0c276727ccf86aba3665d028e0405f93b568d20cb
3
- size 4752607
 
 
 
 
qmsum/0000.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a519ed799eb8044abc4a8ab08ff560d7e31bb5d4a0b239f889c63d142dc33c4c
3
+ size 499957
quality.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0a1697fe2e348025e79af2c5e83260388e375cb2e66638b7d1e92f03e0d7307d
3
- size 3815130
 
 
 
 
quality/0000.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:643e63bc6ad42cbaade97450377bed97217a5ae81d31bb7ecdb4413669ee761c
3
+ size 363954
space_digest.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:bfaccdca27938166333301e03f831b414395bb32cef4dc74d5e7958e1d82ffaa
3
- size 5730459
 
 
 
 
space_digest/0000.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0aa42d3fd588105dab7572e9911945e9ee67c44cc1a135ac9782ca633ab402e
3
+ size 349818
squality.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c6f8730ce7020e53283606039bcc38f8715a997604282d69b4d7aa94b8a42c9c
3
- size 6686369
 
 
 
 
squality/0000.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b54d9ba35f4f2118a9ac6da5eb4dc40270ccd252a20076f8f28e60f99ee5d775
3
+ size 421574
summ_screen_fd.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:7ffb1e6350c60bf6464a8bce8662fb6f514c030742a17934672845a5d79b1a4f
3
- size 4279122
 
 
 
 
zero_scrolls.py DELETED
@@ -1,513 +0,0 @@
1
- # coding=utf-8
2
- # Lint as: python3
3
- """The ZeroSCROLLS benchmark."""
4
-
5
- import json
6
- import os
7
- import datasets
8
-
9
- _ZERO_SCROLLS_CITATION = """
10
- @inproceedings{shaham-etal-2023-zeroscrolls,
11
- title = "{Z}ero{SCROLLS}: A Zero-Shot Benchmark for Long Text Understanding",
12
- author = "Shaham, Uri and
13
- Ivgi, Maor and
14
- Efrat, Avia and
15
- Berant, Jonathan and
16
- Levy, Omer",
17
- editor = "Bouamor, Houda and
18
- Pino, Juan and
19
- Bali, Kalika",
20
- booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2023",
21
- month = dec,
22
- year = "2023",
23
- address = "Singapore",
24
- publisher = "Association for Computational Linguistics",
25
- url = "https://aclanthology.org/2023.findings-emnlp.536",
26
- doi = "10.18653/v1/2023.findings-emnlp.536",
27
- pages = "7977--7989"
28
- }
29
- Note that each ZeroSCROLLS task has its own citation. Please see the source to
30
- get the correct citation for each one.
31
- """
32
-
33
- _ZERO_SCROLLS_DESCRIPTION = """
34
- ZeroSCROLLS: Zero-Shot CompaRison Over Long Language Sequences.
35
- A zero shot benchmark for long text reasoning.
36
- https://zero.scrolls-benchmark.com/
37
- """
38
-
39
- _SCROLLS_CITATION = """
40
- @inproceedings{shaham-etal-2022-scrolls,
41
- title = "{SCROLLS}: Standardized {C}ompa{R}ison Over Long Language Sequences",
42
- author = "Shaham, Uri and
43
- Segal, Elad and
44
- Ivgi, Maor and
45
- Efrat, Avia and
46
- Yoran, Ori and
47
- Haviv, Adi and
48
- Gupta, Ankit and
49
- Xiong, Wenhan and
50
- Geva, Mor and
51
- Berant, Jonathan and
52
- Levy, Omer",
53
- booktitle = "Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing",
54
- month = dec,
55
- year = "2022",
56
- address = "Abu Dhabi, United Arab Emirates",
57
- publisher = "Association for Computational Linguistics",
58
- url = "https://aclanthology.org/2022.emnlp-main.823",
59
- pages = "12007--12021",
60
- }
61
- """
62
-
63
- _SCROLLS_DESCRIPTION = """
64
- SCROLLS: Standardized CompaRison Over Long Language Sequences.
65
- A suite of natural language datasets that require reasoning over long texts.
66
- https://scrolls-benchmark.com/
67
- """
68
-
69
- _SUMM_SCREEN_DESCRIPTION = """
70
- SummScreenFD (Chen et al., 2022) is a summarization dataset in the domain of TV shows (e.g. Friends, Game of Thrones).
71
- Given a transcript of a specific episode, the goal is to produce the episode's recap.
72
- The original dataset is divided into two complementary subsets, based on the source of its community contributed transcripts.
73
- For SCROLLS, we use the ForeverDreaming (FD) subset, as it incorporates 88 different shows,
74
- making it a more diverse alternative to the TV MegaSite (TMS) subset, which has only 10 shows.
75
- Community-authored recaps for the ForeverDreaming transcripts were collected from English Wikipedia and TVMaze."""
76
-
77
- _QASPER_DESCRIPTION = """
78
- Qasper (Dasigi et al., 2021) is a question answering dataset over NLP papers filtered from the Semantic Scholar Open Research Corpus (S2ORC).
79
- Questions were written by NLP practitioners after reading only the title and abstract of the papers,
80
- while another set of NLP practitioners annotated the answers given the entire document.
81
- Qasper contains abstractive, extractive, and yes/no questions, as well as unanswerable ones."""
82
-
83
- _QMSUM_DESCRIPTION = """
84
- QMSum (Zhong et al., 2021) is a query-based summarization dataset, consisting of 232 meetings transcripts from multiple domains.
85
- The corpus covers academic group meetings at the International Computer Science Institute and their summaries, industrial product meetings for designing a remote control,
86
- and committee meetings of the Welsh and Canadian Parliaments, dealing with a variety of public policy issues.
87
- Annotators were tasked with writing queries about the broad contents of the meetings, as well as specific questions about certain topics or decisions,
88
- while ensuring that the relevant text for answering each query spans at least 200 words or 10 turns."""
89
-
90
- _NARRATIVE_QA_DESCRIPTION = """
91
- NarrativeQA (Kočiský et al., 2018) is an established question answering dataset over entire books from Project Gutenberg and movie scripts from different websites.
92
- Annotators were given summaries of the books and scripts obtained from Wikipedia, and asked to generate question-answer pairs,
93
- resulting in about 30 questions and answers for each of the 1,567 books and scripts.
94
- They were encouraged to use their own words rather then copying, and avoid asking yes/no questions or ones about the cast.
95
- Each question was then answered by an additional annotator, providing each question with two reference answers (unless both answers are identical).."""
96
-
97
- _GOV_REPORT_DESCRIPTION = """
98
- GovReport (Huang et al., 2021) is a summarization dataset of reports addressing various national policy issues published by the
99
- Congressional Research Service and the U.S. Government Accountability Office, where each document is paired with a hand-written executive summary.
100
- The reports and their summaries are longer than their equivalents in other popular long-document summarization datasets;
101
- for example, GovReport's documents are approximately 1.5 and 2.5 times longer than the documents in Arxiv and PubMed, respectively."""
102
-
103
- _QUALITY_DESCRIPTION = """
104
- QuALITY (Pang et al., 2022) is a multiple-choice question answering dataset over articles and stories sourced from Project Gutenberg,
105
- the Open American National Corpus, and more.
106
- Experienced writers wrote questions and distractors, and were incentivized to write answerable, unambiguous questions such that in order to correctly answer them,
107
- human annotators must read large portions of the given document.
108
- Reference answers were then calculated using the majority vote between of the annotators and writer's answers.
109
- To measure the difficulty of their questions, Pang et al. conducted a speed validation process,
110
- where another set of annotators were asked to answer questions given only a short period of time to skim through the document.
111
- 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."""
112
-
113
- _SQUALITY_DESCRIPTION = """
114
- SQuALITY (Wang et al., 2022) is a question-focused summarization dataset, where given a story from Project Gutenberg,
115
- the task is to produce a summary of the story or aspects of it based on a guiding question.
116
- The questions and summaries are original and crowdsourced; experienced writers were guided to design questions that require reading significant parts of the story to answer correctly.
117
- """
118
-
119
- _MUSIQUE_DESCRIPTION = """
120
- MuSiQue (Trivedi et al,. 2022) is a multi-hop question answering dataset, where the inputs are 20 Wikipedia paragraphs and a question that requires multiple hops between different paragraphs.
121
- In the original dataset, each question also has an unanswerable twin question, where the correct answer is not present in the paragraphs.
122
- """
123
-
124
- _SPACE_DIGEST_DESCRIPTION = """
125
- SpaceDigest is a new sentiment aggregation task.
126
- Given 50 hotel reviews (without their ratings) from the Space dataset (Angelidis et al., 2021), the task is to determine the percentage of positive reviews.
127
- """
128
-
129
- _BOOK_SUM_DESCRIPTION = """
130
- BookSumSort is a new task based on the BookSum dataset (Kry ́sci ́nski et al., 2022), which contains summaries of chapters (or parts) of novels, plays, and long poems from various sources.
131
- Given a shuffled list of chapter summaries, the task is to reorder them according to the original order of summaries in BookSum.
132
- """
133
-
134
- _SUMM_SCREEN_CITATION = r"""
135
- @inproceedings{chen-etal-2022-summscreen,
136
- title = "{S}umm{S}creen: A Dataset for Abstractive Screenplay Summarization",
137
- author = "Chen, Mingda and
138
- Chu, Zewei and
139
- Wiseman, Sam and
140
- Gimpel, Kevin",
141
- booktitle = "Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
142
- month = may,
143
- year = "2022",
144
- address = "Dublin, Ireland",
145
- publisher = "Association for Computational Linguistics",
146
- url = "https://aclanthology.org/2022.acl-long.589",
147
- doi = "10.18653/v1/2022.acl-long.589",
148
- pages = "8602--8615",
149
- abstract = "We introduce SummScreen, a summarization dataset comprised of pairs of TV series transcripts and human written recaps. The dataset provides a challenging testbed for abstractive summarization for several reasons. Plot details are often expressed indirectly in character dialogues and may be scattered across the entirety of the transcript. These details must be found and integrated to form the succinct plot descriptions in the recaps. Also, TV scripts contain content that does not directly pertain to the central plot but rather serves to develop characters or provide comic relief. This information is rarely contained in recaps. Since characters are fundamental to TV series, we also propose two entity-centric evaluation metrics. Empirically, we characterize the dataset by evaluating several methods, including neural models and those based on nearest neighbors. An oracle extractive approach outperforms all benchmarked models according to automatic metrics, showing that the neural models are unable to fully exploit the input transcripts. Human evaluation and qualitative analysis reveal that our non-oracle models are competitive with their oracle counterparts in terms of generating faithful plot events and can benefit from better content selectors. Both oracle and non-oracle models generate unfaithful facts, suggesting future research directions.",
150
- }"""
151
-
152
- _QASPER_CITATION = r"""
153
- @inproceedings{dasigi-etal-2021-dataset,
154
- title = "A Dataset of Information-Seeking Questions and Answers Anchored in Research Papers",
155
- author = "Dasigi, Pradeep and
156
- Lo, Kyle and
157
- Beltagy, Iz and
158
- Cohan, Arman and
159
- Smith, Noah A. and
160
- Gardner, Matt",
161
- booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
162
- month = jun,
163
- year = "2021",
164
- address = "Online",
165
- publisher = "Association for Computational Linguistics",
166
- url = "https://aclanthology.org/2021.naacl-main.365",
167
- doi = "10.18653/v1/2021.naacl-main.365",
168
- pages = "4599--4610"
169
- }"""
170
-
171
- _QMSUM_CITATION = r"""@inproceedings{zhong-etal-2021-qmsum,
172
- title = "{QMS}um: A New Benchmark for Query-based Multi-domain Meeting Summarization",
173
- author = "Zhong, Ming and
174
- Yin, Da and
175
- Yu, Tao and
176
- Zaidi, Ahmad and
177
- Mutuma, Mutethia and
178
- Jha, Rahul and
179
- Awadallah, Ahmed Hassan and
180
- Celikyilmaz, Asli and
181
- Liu, Yang and
182
- Qiu, Xipeng and
183
- Radev, Dragomir",
184
- booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
185
- month = jun,
186
- year = "2021",
187
- address = "Online",
188
- publisher = "Association for Computational Linguistics",
189
- url = "https://aclanthology.org/2021.naacl-main.472",
190
- doi = "10.18653/v1/2021.naacl-main.472",
191
- pages = "5905--5921"
192
- }"""
193
-
194
- _NARRATIVE_QA_CITATION = r"""
195
- @article{kocisky-etal-2018-narrativeqa,
196
- title = "The {N}arrative{QA} Reading Comprehension Challenge",
197
- author = "Ko{\v{c}}isk{\'y}, Tom{\'a}{\v{s}} and
198
- Schwarz, Jonathan and
199
- Blunsom, Phil and
200
- Dyer, Chris and
201
- Hermann, Karl Moritz and
202
- Melis, G{\'a}bor and
203
- Grefenstette, Edward",
204
- journal = "Transactions of the Association for Computational Linguistics",
205
- volume = "6",
206
- year = "2018",
207
- address = "Cambridge, MA",
208
- publisher = "MIT Press",
209
- url = "https://aclanthology.org/Q18-1023",
210
- doi = "10.1162/tacl_a_00023",
211
- pages = "317--328"
212
- }"""
213
-
214
- _GOV_REPORT_CITATION = r"""
215
- @inproceedings{huang-etal-2021-efficient,
216
- title = "Efficient Attentions for Long Document Summarization",
217
- author = "Huang, Luyang and
218
- Cao, Shuyang and
219
- Parulian, Nikolaus and
220
- Ji, Heng and
221
- Wang, Lu",
222
- booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
223
- month = jun,
224
- year = "2021",
225
- address = "Online",
226
- publisher = "Association for Computational Linguistics",
227
- url = "https://aclanthology.org/2021.naacl-main.112",
228
- doi = "10.18653/v1/2021.naacl-main.112",
229
- pages = "1419--1436"
230
- }"""
231
-
232
- _QUALITY_CITATION = """\
233
- @inproceedings{pang-etal-2022-quality,
234
- title = "{Q}u{ALITY}: Question Answering with Long Input Texts, Yes!",
235
- author = "Pang, Richard Yuanzhe and
236
- Parrish, Alicia and
237
- Joshi, Nitish and
238
- Nangia, Nikita and
239
- Phang, Jason and
240
- Chen, Angelica and
241
- Padmakumar, Vishakh and
242
- Ma, Johnny and
243
- Thompson, Jana and
244
- He, He and
245
- Bowman, Samuel",
246
- booktitle = "Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
247
- month = jul,
248
- year = "2022",
249
- address = "Seattle, United States",
250
- publisher = "Association for Computational Linguistics",
251
- url = "https://aclanthology.org/2022.naacl-main.391",
252
- doi = "10.18653/v1/2022.naacl-main.391",
253
- pages = "5336--5358"
254
- }
255
- """
256
- _SQUALITY_CITATION = """\
257
- @inproceedings{wang-etal-2022-squality,
258
- title = "{SQ}u{ALITY}: Building a Long-Document Summarization Dataset the Hard Way",
259
- author = "Wang, Alex and
260
- Pang, Richard Yuanzhe and
261
- Chen, Angelica and
262
- Phang, Jason and
263
- Bowman, Samuel R.",
264
- booktitle = "Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing",
265
- month = dec,
266
- year = "2022",
267
- address = "Abu Dhabi, United Arab Emirates",
268
- publisher = "Association for Computational Linguistics",
269
- url = "https://aclanthology.org/2022.emnlp-main.75",
270
- pages = "1139--1156"
271
- }
272
- """
273
- _MUSIQUE_CITATION = """\
274
- @article{trivedi-etal-2022-musique,
275
- title = "♫ {M}u{S}i{Q}ue: Multihop Questions via Single-hop Question Composition",
276
- author = "Trivedi, Harsh and
277
- Balasubramanian, Niranjan and
278
- Khot, Tushar and
279
- Sabharwal, Ashish",
280
- journal = "Transactions of the Association for Computational Linguistics",
281
- volume = "10",
282
- year = "2022",
283
- address = "Cambridge, MA",
284
- publisher = "MIT Press",
285
- url = "https://aclanthology.org/2022.tacl-1.31",
286
- doi = "10.1162/tacl_a_00475",
287
- pages = "539--554"
288
- }
289
- """
290
-
291
- _SPACE_CITATION = """\
292
- @article{angelidis-etal-2021-extractive,
293
- title = "Extractive Opinion Summarization in Quantized Transformer Spaces",
294
- author = "Angelidis, Stefanos and
295
- Amplayo, Reinald Kim and
296
- Suhara, Yoshihiko and
297
- Wang, Xiaolan and
298
- Lapata, Mirella",
299
- journal = "Transactions of the Association for Computational Linguistics",
300
- volume = "9",
301
- year = "2021",
302
- address = "Cambridge, MA",
303
- publisher = "MIT Press",
304
- url = "https://aclanthology.org/2021.tacl-1.17",
305
- doi = "10.1162/tacl_a_00366",
306
- pages = "277--293"
307
- }
308
- """
309
- _BOOK_SUM_CITATION = """\
310
- @inproceedings{kryscinski-etal-2022-booksum,
311
- title = "{BOOKSUM}: A Collection of Datasets for Long-form Narrative Summarization",
312
- author = "Kryscinski, Wojciech and
313
- Rajani, Nazneen and
314
- Agarwal, Divyansh and
315
- Xiong, Caiming and
316
- Radev, Dragomir",
317
- booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2022",
318
- month = dec,
319
- year = "2022",
320
- address = "Abu Dhabi, United Arab Emirates",
321
- publisher = "Association for Computational Linguistics",
322
- url = "https://aclanthology.org/2022.findings-emnlp.488",
323
- pages = "6536--6558"
324
- }
325
- """
326
-
327
- FEATURE_TO_TYPE = {
328
- "id": "string",
329
- "pid": "string",
330
- "input": "string",
331
- "output": "string",
332
- "document_start_index": "int32",
333
- "document_end_index": "int32",
334
- "query_start_index": "int32",
335
- "query_end_index": "int32",
336
- "truncation_seperator": "string"
337
- }
338
-
339
-
340
- class ZeroScrollsConfig(datasets.BuilderConfig):
341
- """BuilderConfig for SCROLLS."""
342
-
343
- def __init__(self, features, data_url, citation, url, **kwargs):
344
- """BuilderConfig for SCROLLS.
345
- Args:
346
- features: `list[string]`, list of the features that will appear in the
347
- feature dict. Should not include "label".
348
- data_url: `string`, url to download the zip file from.
349
- citation: `string`, citation for the data set.
350
- url: `string`, url for information about the data set.
351
- label_classes: `list[string]`, the list of classes for the label if the
352
- label is present as a string. Non-string labels will be cast to either
353
- 'False' or 'True'.
354
- **kwargs: keyword arguments forwarded to super.
355
- """
356
- super(ZeroScrollsConfig, self).__init__(version=datasets.Version("1.0.0"), **kwargs)
357
- self.features = features
358
- self.data_url = data_url
359
- self.citation = citation
360
- self.url = url
361
-
362
-
363
- class QualityConfig(ZeroScrollsConfig):
364
- def __init__(self, **kwargs):
365
- super().__init__(**kwargs)
366
- self.hard_only = False
367
-
368
-
369
- class ZeroScrolls(datasets.GeneratorBasedBuilder):
370
- """The ZerpSCROLLS benchmark."""
371
-
372
- features = list(FEATURE_TO_TYPE.keys())
373
- features_with_multiple_inder_docs = features + ["inner_docs_start_indices"]
374
- DEFAULT_WRITER_BATCH_SIZE = 1000 # because Narrative QA is a rather large dataset
375
- BUILDER_CONFIGS = [
376
- ZeroScrollsConfig(
377
- name="summ_screen_fd",
378
- description=_SUMM_SCREEN_DESCRIPTION,
379
- features=features,
380
- data_url="https://huggingface.co/datasets/tau/zero_scrolls/resolve/main/summ_screen_fd.zip",
381
- citation=_SUMM_SCREEN_CITATION,
382
- url="https://github.com/mingdachen/SummScreen",
383
- ),
384
- ZeroScrollsConfig(
385
- name="qasper",
386
- description=_QASPER_DESCRIPTION,
387
- features=features,
388
- data_url="https://huggingface.co/datasets/tau/zero_scrolls/resolve/main/qasper.zip",
389
- citation=_QASPER_CITATION,
390
- url="https://allenai.org/project/qasper",
391
- ),
392
- ZeroScrollsConfig(
393
- name="qmsum",
394
- description=_QMSUM_DESCRIPTION,
395
- features=features,
396
- data_url="https://huggingface.co/datasets/tau/zero_scrolls/resolve/main/qmsum.zip",
397
- citation=_QMSUM_CITATION,
398
- url="https://github.com/Yale-LILY/QMSum",
399
- ),
400
- ZeroScrollsConfig(
401
- name="narrative_qa",
402
- description=_NARRATIVE_QA_DESCRIPTION,
403
- features=features,
404
- data_url="https://huggingface.co/datasets/tau/zero_scrolls/resolve/main/narrative_qa.zip",
405
- citation=_NARRATIVE_QA_CITATION,
406
- url="https://deepmind.com/research/publications/narrativeqa-reading-comprehension-challenge",
407
- ),
408
- ZeroScrollsConfig(
409
- name="gov_report",
410
- description=_GOV_REPORT_DESCRIPTION,
411
- features=features,
412
- data_url="https://huggingface.co/datasets/tau/zero_scrolls/resolve/main/gov_report.zip",
413
- citation=_GOV_REPORT_CITATION,
414
- url="https://gov-report-data.github.io/",
415
- ),
416
- QualityConfig(
417
- name="quality",
418
- description=_QUALITY_DESCRIPTION,
419
- features=features,
420
- data_url="https://huggingface.co/datasets/tau/zero_scrolls/resolve/main/quality.zip",
421
- citation=_QUALITY_CITATION,
422
- url="https://github.com/nyu-mll/quality",
423
- ),
424
- ZeroScrollsConfig(
425
- name="squality",
426
- description=_SQUALITY_DESCRIPTION,
427
- features=features,
428
- data_url="https://huggingface.co/datasets/tau/zero_scrolls/resolve/main/squality.zip",
429
- citation=_SQUALITY_CITATION,
430
- url="https://github.com/nyu-mll/SQuALITY",
431
- ),
432
- ZeroScrollsConfig(
433
- name="musique",
434
- description=_MUSIQUE_DESCRIPTION,
435
- features=features_with_multiple_inder_docs,
436
- data_url="https://huggingface.co/datasets/tau/zero_scrolls/resolve/main/musique.zip",
437
- citation=_MUSIQUE_CITATION,
438
- url="https://github.com/stonybrooknlp/musique",
439
- ),
440
- ZeroScrollsConfig(
441
- name="space_digest",
442
- description=_SPACE_DIGEST_DESCRIPTION,
443
- features=features_with_multiple_inder_docs,
444
- data_url="https://huggingface.co/datasets/tau/zero_scrolls/resolve/main/space_digest.zip",
445
- citation=_SPACE_CITATION,
446
- url="https://github.com/stangelid/qt",
447
- ),
448
- ZeroScrollsConfig(
449
- name="book_sum_sort",
450
- description=_BOOK_SUM_DESCRIPTION,
451
- features=features_with_multiple_inder_docs,
452
- data_url="https://huggingface.co/datasets/tau/zero_scrolls/resolve/main/book_sum_sort.zip",
453
- citation=_BOOK_SUM_CITATION,
454
- url="https://github.com/salesforce/booksum",
455
- ),
456
- ]
457
-
458
- def _info(self):
459
-
460
- features = {feature: datasets.Value(FEATURE_TO_TYPE[feature]) for feature in self.config.features if
461
- feature != "inner_docs_start_indices"}
462
- if "inner_docs_start_indices" in self.config.features:
463
- features["inner_docs_start_indices"] = datasets.Sequence(datasets.Value("int32"))
464
-
465
- return datasets.DatasetInfo(
466
- description=_ZERO_SCROLLS_DESCRIPTION + self.config.description,
467
- features=datasets.Features(features),
468
- homepage=self.config.url,
469
- citation=self.config.citation + "\n" + _SCROLLS_CITATION + "\n" + _ZERO_SCROLLS_CITATION,
470
- )
471
-
472
- def _split_generators(self, dl_manager):
473
- dl_dir = dl_manager.download_and_extract(self.config.data_url)
474
- task_name = _get_task_name_from_data_url(self.config.data_url)
475
- dl_dir = os.path.join(dl_dir, task_name)
476
-
477
- data_files = {} if self.config.data_files is not None else None
478
- if data_files is not None:
479
- for split, paths in self.config.data_files.items():
480
- data_files[split] = paths[0]
481
-
482
- return [
483
- datasets.SplitGenerator(
484
- name=datasets.Split.VALIDATION,
485
- gen_kwargs={
486
- "data_file": os.path.join(dl_dir, "validation.jsonl"),
487
- "split": datasets.Split.VALIDATION,
488
- },
489
- ),
490
- datasets.SplitGenerator(
491
- name=datasets.Split.TEST,
492
- gen_kwargs={
493
- "data_file": os.path.join(dl_dir, "test.jsonl") if data_files is None else data_files["test"],
494
- "split": datasets.Split.TEST,
495
- },
496
- ),
497
- ]
498
-
499
- def _generate_examples(self, data_file, split):
500
- with open(data_file, encoding="utf-8") as f:
501
- for line in f:
502
- row = json.loads(line)
503
-
504
- if self.config.name == "quality":
505
- is_hard = row.pop("is_hard", False)
506
- if self.config.hard_only and not is_hard:
507
- continue
508
-
509
- yield row["pid"], row
510
-
511
-
512
- def _get_task_name_from_data_url(data_url):
513
- return data_url.split("/")[-1].split(".")[0]