system HF staff commited on
Commit
667c6d3
0 Parent(s):

Update files from the datasets library (from 1.0.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.0.0

.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 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
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Loading the KILT knowledge source and task data
2
+
3
+ The original KILT [release](https://github.com/facebookresearch/KILT) only provides question IDs for the TriviaQA task. Using the full dataset requires mapping those back to the TriviaQA questions, which can be done as follows:
4
+
5
+ ```python
6
+ from datasets import load_dataset
7
+
8
+ # Get the pre-processed Wikipedia knowledge source for kild
9
+ kilt_wiki = load_dataset("kilt_wikipedia")
10
+
11
+ # Get the KILT task datasets
12
+ kilt_tasks = load_sataset("kilt_tasks")
13
+
14
+ # Most tasks in KILT already have all required data, but KILT-TriviaQA
15
+ # only provides the question IDs, not the questions themselves.
16
+ # Thankfully, we can get the original TriviaQA data with:
17
+ trivia_qa = load_dataset('trivia_qa', 'unfiltered.nocontext')
18
+
19
+ # The KILT IDs can then be mapped to the TriviaQA questions with:
20
+ triviaqa_map = {}
21
+ for k in ['train', 'validation', 'test']:
22
+ triviaqa_map = dict([(q_id, i) for i, q_id in enumerate(triviaqa[k]['question_id'])])
23
+ kilt_tasks[k + '_triviaqa'] = kilt_tasks[k + '_triviaqa'].filter(lambda x: x['id'] in triviaqa_map)
24
+ kilt_tasks[k + '_triviaqa'] = kilt_tasks[k + '_triviaqa'].map(lambda x: {'input': triviaqa[k][triviaqa_map[x['id']]]['question']})
25
+ ```
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"all_tasks": {"description": "KILT tasks training and evaluation data.\n- [FEVER](https://fever.ai) | Fact Checking | fever\n- [AIDA CoNLL-YAGO](https://www.mpi-inf.mpg.de/departments/databases-and-information-systems/research/ambiverse-nlu/aida/downloads) | Entity Linking | aidayago2\n- [WNED-WIKI](https://github.com/U-Alberta/wned) | Entity Linking | wned\n- [WNED-CWEB](https://github.com/U-Alberta/wned) | Entity Linking | cweb\n- [T-REx](https://hadyelsahar.github.io/t-rex) | Slot Filling | trex\n- [Zero-Shot RE](http://nlp.cs.washington.edu/zeroshot) | Slot Filling | structured_zeroshot\n- [Natural Questions](https://ai.google.com/research/NaturalQuestions) | Open Domain QA | nq\n- [HotpotQA](https://hotpotqa.github.io) | Open Domain QA | hotpotqa\n- [TriviaQA](http://nlp.cs.washington.edu/triviaqa) | Open Domain QA | triviaqa\n- [ELI5](https://facebookresearch.github.io/ELI5/explore.html) | Open Domain QA | eli5\n- [Wizard of Wikipedia](https://parl.ai/projects/wizard_of_wikipedia) | Dialogue | wow\n\nTo finish linking TriviaQA questions to the IDs provided, follow the instructions [here](http://github.com/huggingface/datasets/datasets/kilt_tasks/README.md).\n", "citation": "@inproceedings{fb_kilt,\n author = {Fabio Petroni and\n Aleksandra Piktus and\n Angela Fan and\n Patrick Lewis and\n Majid Yazdani and\n Nicola De Cao and\n James Thorne and\n Yacine Jernite and\n Vassilis Plachouras and\n Tim Rockt\"aschel and\n Sebastian Riedel},\n title = {{KILT:} a {B}enchmark for {K}nowledge {I}ntensive {L}anguage {T}asks},\n journal = {CoRR},\n archivePrefix = {arXiv},\n year = {2020},\n", "homepage": "https://github.com/facebookresearch/KILT", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "input": {"dtype": "string", "id": null, "_type": "Value"}, "meta": {"left_context": {"dtype": "string", "id": null, "_type": "Value"}, "mention": {"dtype": "string", "id": null, "_type": "Value"}, "right_context": {"dtype": "string", "id": null, "_type": "Value"}, "partial_evidence": {"feature": {"start_paragraph_id": {"dtype": "int32", "id": null, "_type": "Value"}, "end_paragraph_id": {"dtype": "int32", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "section": {"dtype": "string", "id": null, "_type": "Value"}, "wikipedia_id": {"dtype": "string", "id": null, "_type": "Value"}, "meta": {"feature": {"evidence_span": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}, "obj_surface": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}, "sub_surface": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}, "subj_aliases": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}, "template_questions": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "output": {"feature": {"answer": {"dtype": "string", "id": null, "_type": "Value"}, "meta": {"score": {"dtype": "int32", "id": null, "_type": "Value"}}, "provenance": {"feature": {"bleu_score": {"dtype": "float32", "id": null, "_type": "Value"}, "start_character": {"dtype": "int32", "id": null, "_type": "Value"}, "start_paragraph_id": {"dtype": "int32", "id": null, "_type": "Value"}, "end_character": {"dtype": "int32", "id": null, "_type": "Value"}, "end_paragraph_id": {"dtype": "int32", "id": null, "_type": "Value"}, "meta": {"fever_page_id": {"dtype": "string", "id": null, "_type": "Value"}, "fever_sentence_id": {"dtype": "int32", "id": null, "_type": "Value"}, "annotation_id": {"dtype": "string", "id": null, "_type": "Value"}, "yes_no_answer": {"dtype": "string", "id": null, "_type": "Value"}, "evidence_span": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "section": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "wikipedia_id": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": {"features": null, "resources_checksums": {"train_fever": {}, "validation_fever": {}, "test_fever": {}, "train_nq": {}, "validation_nq": {}, "test_nq": {}, "train_hotpotqa": {}, "validation_hotpotqa": {}, "test_hotpotqa": {}, "train_triviaqa": {}, "validation_triviaqa": {}, "test_triviaqa": {}, "train_eli5": {}, "validation_eli5": {}, "test_eli5": {}, "train_trex": {}, "validation_trex": {}, "test_trex": {}, "train_structured_zeroshot": {}, "validation_structured_zeroshot": {}, "test_structured_zeroshot": {}, "train_aidayago2": {}, "validation_aidayago2": {}, "test_aidayago2": {}, "validation_wned": {}, "test_wned": {}, "validation_cweb": {}, "test_cweb": {}, "train_wow": {}, "validation_wow": {}, "test_wow": {}}}, "supervised_keys": null, "builder_name": "kilt_tasks", "config_name": "all_tasks", "version": {"version_str": "1.0.0", "description": "KILT tasks training and evaluation data", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train_fever": {"name": "train_fever", "num_bytes": 27423152, "num_examples": 104966, "dataset_name": "kilt_tasks"}, "validation_fever": {"name": "validation_fever", "num_bytes": 3945700, "num_examples": 10444, "dataset_name": "kilt_tasks"}, "test_fever": {"name": "test_fever", "num_bytes": 1357227, "num_examples": 10100, "dataset_name": "kilt_tasks"}, "train_aidayago2": {"name": "train_aidayago2", "num_bytes": 69671936, "num_examples": 18395, "dataset_name": "kilt_tasks"}, "validation_aidayago2": {"name": "validation_aidayago2", "num_bytes": 20932848, "num_examples": 4784, "dataset_name": "kilt_tasks"}, "test_aidayago2": {"name": "test_aidayago2", "num_bytes": 14350869, "num_examples": 4463, "dataset_name": "kilt_tasks"}, "validation_wned": {"name": "validation_wned", "num_bytes": 12794390, "num_examples": 3396, "dataset_name": "kilt_tasks"}, "test_wned": {"name": "test_wned", "num_bytes": 13187270, "num_examples": 3376, "dataset_name": "kilt_tasks"}, "validation_cweb": {"name": "validation_cweb", "num_bytes": 90041126, "num_examples": 5599, "dataset_name": "kilt_tasks"}, "test_cweb": {"name": "test_cweb", "num_bytes": 99382290, "num_examples": 5543, "dataset_name": "kilt_tasks"}, "train_trex": {"name": "train_trex", "num_bytes": 1213971546, "num_examples": 2284168, "dataset_name": "kilt_tasks"}, "validation_trex": {"name": "validation_trex", "num_bytes": 2630523, "num_examples": 5000, "dataset_name": "kilt_tasks"}, "test_trex": {"name": "test_trex", "num_bytes": 915477, "num_examples": 5000, "dataset_name": "kilt_tasks"}, "train_structured_zeroshot": {"name": "train_structured_zeroshot", "num_bytes": 55988052, "num_examples": 147909, "dataset_name": "kilt_tasks"}, "validation_structured_zeroshot": {"name": "validation_structured_zeroshot", "num_bytes": 1848289, "num_examples": 3724, "dataset_name": "kilt_tasks"}, "test_structured_zeroshot": {"name": "test_structured_zeroshot", "num_bytes": 1297614, "num_examples": 4966, "dataset_name": "kilt_tasks"}, "train_nq": {"name": "train_nq", "num_bytes": 35533981, "num_examples": 87372, "dataset_name": "kilt_tasks"}, "validation_nq": {"name": "validation_nq", "num_bytes": 6587478, "num_examples": 2837, "dataset_name": "kilt_tasks"}, "test_nq": {"name": "test_nq", "num_bytes": 379518, "num_examples": 1444, "dataset_name": "kilt_tasks"}, "train_hotpotqa": {"name": "train_hotpotqa", "num_bytes": 34838943, "num_examples": 88869, "dataset_name": "kilt_tasks"}, "validation_hotpotqa": {"name": "validation_hotpotqa", "num_bytes": 2428954, "num_examples": 5600, "dataset_name": "kilt_tasks"}, "test_hotpotqa": {"name": "test_hotpotqa", "num_bytes": 1061929, "num_examples": 5569, "dataset_name": "kilt_tasks"}, "train_triviaqa": {"name": "train_triviaqa", "num_bytes": 62374231, "num_examples": 61844, "dataset_name": "kilt_tasks"}, "validation_triviaqa": {"name": "validation_triviaqa", "num_bytes": 5962201, "num_examples": 5359, "dataset_name": "kilt_tasks"}, "test_triviaqa": {"name": "test_triviaqa", "num_bytes": 547068, "num_examples": 6586, "dataset_name": "kilt_tasks"}, "train_eli5": {"name": "train_eli5", "num_bytes": 531158920, "num_examples": 272634, "dataset_name": "kilt_tasks"}, "validation_eli5": {"name": "validation_eli5", "num_bytes": 13833241, "num_examples": 1507, "dataset_name": "kilt_tasks"}, "test_eli5": {"name": "test_eli5", "num_bytes": 126907, "num_examples": 600, "dataset_name": "kilt_tasks"}, "train_wow": {"name": "train_wow", "num_bytes": 64964362, "num_examples": 94577, "dataset_name": "kilt_tasks"}, "validation_wow": {"name": "validation_wow", "num_bytes": 2142799, "num_examples": 3058, "dataset_name": "kilt_tasks"}, "test_wow": {"name": "test_wow", "num_bytes": 1432546, "num_examples": 2944, "dataset_name": "kilt_tasks"}}, "download_checksums": {"http://dl.fbaipublicfiles.com/KILT/fever-train-kilt.jsonl": {"num_bytes": 38941824, "checksum": "a42b948957680b3d316bbc9c24f3e499f0e93a3b0a8b94ca9d972d5da5758c6a"}, "http://dl.fbaipublicfiles.com/KILT/fever-dev-kilt.jsonl": {"num_bytes": 6174139, "checksum": "0132fb971e4206c8bd9da3916f0f46a30ee6610394aee1738ce6cf6644592739"}, "http://dl.fbaipublicfiles.com/KILT/fever-test_without_answers-kilt.jsonl": {"num_bytes": 838585, "checksum": "d95e0a7086c1d5687984460aa9d5b82b3afb58972132c8cc04a75dfd23cb1a86"}, "http://dl.fbaipublicfiles.com/KILT/aidayago2-train-kilt.jsonl": {"num_bytes": 70139831, "checksum": "398231ec4ee9fd5616456d049875e51b1e0709f00ac2d74398dd4480ae5647b2"}, "http://dl.fbaipublicfiles.com/KILT/aidayago2-dev-kilt.jsonl": {"num_bytes": 21061554, "checksum": "3f5e23e1af46c8671c9870e13ced13fd517029da4963ad9ff4b834c4b42deb52"}, "http://dl.fbaipublicfiles.com/KILT/aidayago2-test_without_answers-kilt.jsonl": {"num_bytes": 14436143, "checksum": "2ba0836d3f8c70126022a83fd78da0bf7c910fa7813996dd2afee5e38de63648"}, "http://dl.fbaipublicfiles.com/KILT/wned-dev-kilt.jsonl": {"num_bytes": 12868348, "checksum": "e8e91d120abcb3433c952541aebd8dbf0c6abe3c378bdd64cd6d2186738cfbaf"}, "http://dl.fbaipublicfiles.com/KILT/wned-test_without_answers-kilt.jsonl": {"num_bytes": 13295124, "checksum": "f7b220d404d474f617b00c4a030a87024835b72aff131016716b84feca4d95ee"}, "http://dl.fbaipublicfiles.com/KILT/cweb-dev-kilt.jsonl": {"num_bytes": 90228527, "checksum": "c98b2301818b53df2025b09801be095152244dbbe7242efbfffd018929bfb4bf"}, "http://dl.fbaipublicfiles.com/KILT/cweb-test_without_answers-kilt.jsonl": {"num_bytes": 100216209, "checksum": "18b078340bde25e42c7136c5bc80c2e3557803e40137b40230af5834e74b6c0d"}, "http://dl.fbaipublicfiles.com/KILT/trex-train-kilt.jsonl": {"num_bytes": 1752330104, "checksum": "724a8a0fd1f99fe9b15cf6309d7ce63dcb7cd31f33aea717ff26e6d6b6fbdd97"}, "http://dl.fbaipublicfiles.com/KILT/trex-dev-kilt.jsonl": {"num_bytes": 3803558, "checksum": "7ee1a2cd351d928d01ede1763ae8d6ae442a00b07deef80e347852f20a029e5f"}, "http://dl.fbaipublicfiles.com/KILT/trex-test_without_answers-kilt.jsonl": {"num_bytes": 895854, "checksum": "0a2c6a31ebea567e7a8b31c44bf2fb59dab601c8da6de7f3a53419c7710bdc43"}, "http://dl.fbaipublicfiles.com/KILT/structured_zeroshot-train-kilt.jsonl": {"num_bytes": 71444475, "checksum": "f666359fa2b23e75d700bd1f25efd12d3bf981b1be70d8ad2d268d67e9bb3a5d"}, "http://dl.fbaipublicfiles.com/KILT/structured_zeroshot-dev-kilt.jsonl": {"num_bytes": 2266707, "checksum": "dd120ba5b62c6499f4e79bf5bf5a908eb96b583ba9bf8c76a4535ac21c5dac8d"}, "http://dl.fbaipublicfiles.com/KILT/structured_zeroshot-test_without_answers-kilt.jsonl": {"num_bytes": 1216038, "checksum": "3353137527c6fe9e48910e2c4d94d3ac01352c52e90a618beaaa807968fd39da"}, "http://dl.fbaipublicfiles.com/KILT/nq-train-kilt.jsonl": {"num_bytes": 51895886, "checksum": "13629ef9f0c4bb7b7b237ce08fae2334acb32a2c1bf69db2350021cad46188a4"}, "http://dl.fbaipublicfiles.com/KILT/nq-dev-kilt.jsonl": {"num_bytes": 7936566, "checksum": "1bcdb150fb10504bd80b915730cde1b384c21647bcf14a4592e4e5df42cc6dfb"}, "http://dl.fbaipublicfiles.com/KILT/nq-test_without_answers-kilt.jsonl": {"num_bytes": 334047, "checksum": "1232f95e7d008669930c441444aa470d54678d886335175e2227455716309e15"}, "http://dl.fbaipublicfiles.com/KILT/hotpotqa-train-kilt.jsonl": {"num_bytes": 52767068, "checksum": "7ba73ede642336703d1235c63ecb4c20ae90c7eb19d36302bffa7eb1ec7f9153"}, "http://dl.fbaipublicfiles.com/KILT/hotpotqa-dev-kilt.jsonl": {"num_bytes": 3971321, "checksum": "7f2efbc22c462eb5710e5ecd99447702e7f48203eecd4489bf32a332389d70b6"}, "http://dl.fbaipublicfiles.com/KILT/hotpotqa-test_without_answers-kilt.jsonl": {"num_bytes": 778249, "checksum": "656d51f53796e3ea2a1f808a22160e7363a24a05f1ac7dd094d25659d963ef51"}, "http://dl.fbaipublicfiles.com/KILT/triviaqa-train_id-kilt.jsonl": {"num_bytes": 101613288, "checksum": "509e627a5e606d3b8018c04cd99415d7dca90d7b9a9f491ba0cf2db8c7e999ad"}, "http://dl.fbaipublicfiles.com/KILT/triviaqa-dev_id-kilt.jsonl": {"num_bytes": 9809706, "checksum": "bb505d8437100589de72256bf0d106a4a72da01df5a977fbc778688b8621d5a6"}, "http://dl.fbaipublicfiles.com/KILT/triviaqa-test_id_without_answers-kilt.jsonl": {"num_bytes": 123354, "checksum": "a6904eeb81a269cc675152c72b31c5b3361b40bf277a2973f2836670c7de4a19"}, "http://dl.fbaipublicfiles.com/KILT/eli5-train-kilt.jsonl": {"num_bytes": 548249898, "checksum": "66f19183bda5f5185fe98a5fe84925f6802d9b53a5bb12728ded760fd80ef0a0"}, "http://dl.fbaipublicfiles.com/KILT/eli5-dev-kilt.jsonl": {"num_bytes": 14149811, "checksum": "10387a08e3277d3e5722305cef8e739279c83de0218e7b3db76b301949822303"}, "http://dl.fbaipublicfiles.com/KILT/eli5-test_without_answers-kilt.jsonl": {"num_bytes": 98951, "checksum": "43f82439f15f3141d115c06fb0dc0697a2a6313705dbdec6668eaefe9925a2c3"}, "http://dl.fbaipublicfiles.com/KILT/wow-train-kilt.jsonl": {"num_bytes": 71861702, "checksum": "91e04200a31daadbc9178382b724dac9be88ea9e76cd7a668e7a9430fe67713a"}, "http://dl.fbaipublicfiles.com/KILT/wow-dev-kilt.jsonl": {"num_bytes": 2418241, "checksum": "3202148ecaf41e77d44a2dec2453452c1ff8b3d646727e2c55ae6d9024e8e6b6"}, "http://dl.fbaipublicfiles.com/KILT/wow-test_without_answers-kilt.jsonl": {"num_bytes": 1292018, "checksum": "f3303ec5d7def4cf178552a8ed17bd01cb23bfeccc3abde147bebfa4bade6d8b"}}, "download_size": 3067457126, "post_processing_size": 0, "dataset_size": 2393111387, "size_in_bytes": 5460568513}}
dummy/all_tasks/1.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b4bfcd2a9dd13fca2f9d53da29271ff8346de131e554080bb57d753bc963a02
3
+ size 8382
kilt_tasks.py ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Lint as: python3
17
+ """KILT tasks training and evaluation data"""
18
+
19
+ from __future__ import absolute_import, division, print_function
20
+
21
+ import json
22
+ import logging
23
+
24
+ import datasets
25
+
26
+
27
+ _CITATION = """\
28
+ @inproceedings{fb_kilt,
29
+ author = {Fabio Petroni and
30
+ Aleksandra Piktus and
31
+ Angela Fan and
32
+ Patrick Lewis and
33
+ Majid Yazdani and
34
+ Nicola De Cao and
35
+ James Thorne and
36
+ Yacine Jernite and
37
+ Vassilis Plachouras and
38
+ Tim Rockt\"aschel and
39
+ Sebastian Riedel},
40
+ title = {{KILT:} a {B}enchmark for {K}nowledge {I}ntensive {L}anguage {T}asks},
41
+ journal = {CoRR},
42
+ archivePrefix = {arXiv},
43
+ year = {2020},
44
+ """
45
+
46
+ _DESCRIPTION = """\
47
+ KILT tasks training and evaluation data.
48
+ - [FEVER](https://fever.ai) | Fact Checking | fever
49
+ - [AIDA CoNLL-YAGO](https://www.mpi-inf.mpg.de/departments/databases-and-information-systems/research/ambiverse-nlu/aida/downloads) | Entity Linking | aidayago2
50
+ - [WNED-WIKI](https://github.com/U-Alberta/wned) | Entity Linking | wned
51
+ - [WNED-CWEB](https://github.com/U-Alberta/wned) | Entity Linking | cweb
52
+ - [T-REx](https://hadyelsahar.github.io/t-rex) | Slot Filling | trex
53
+ - [Zero-Shot RE](http://nlp.cs.washington.edu/zeroshot) | Slot Filling | structured_zeroshot
54
+ - [Natural Questions](https://ai.google.com/research/NaturalQuestions) | Open Domain QA | nq
55
+ - [HotpotQA](https://hotpotqa.github.io) | Open Domain QA | hotpotqa
56
+ - [TriviaQA](http://nlp.cs.washington.edu/triviaqa) | Open Domain QA | triviaqa
57
+ - [ELI5](https://facebookresearch.github.io/ELI5/explore.html) | Open Domain QA | eli5
58
+ - [Wizard of Wikipedia](https://parl.ai/projects/wizard_of_wikipedia) | Dialogue | wow
59
+
60
+ To finish linking TriviaQA questions to the IDs provided, follow the instructions [here](http://github.com/huggingface/datasets/datasets/kilt_tasks/README.md).
61
+ """
62
+
63
+
64
+ _DATA_URLS = {
65
+ "fever": {
66
+ "train": "http://dl.fbaipublicfiles.com/KILT/fever-train-kilt.jsonl",
67
+ "validation": "http://dl.fbaipublicfiles.com/KILT/fever-dev-kilt.jsonl",
68
+ "test": "http://dl.fbaipublicfiles.com/KILT/fever-test_without_answers-kilt.jsonl",
69
+ },
70
+ "aidayago2": {
71
+ "train": "http://dl.fbaipublicfiles.com/KILT/aidayago2-train-kilt.jsonl",
72
+ "validation": "http://dl.fbaipublicfiles.com/KILT/aidayago2-dev-kilt.jsonl",
73
+ "test": "http://dl.fbaipublicfiles.com/KILT/aidayago2-test_without_answers-kilt.jsonl",
74
+ },
75
+ "wned": {
76
+ "validation": "http://dl.fbaipublicfiles.com/KILT/wned-dev-kilt.jsonl",
77
+ "test": "http://dl.fbaipublicfiles.com/KILT/wned-test_without_answers-kilt.jsonl",
78
+ },
79
+ "cweb": {
80
+ "validation": "http://dl.fbaipublicfiles.com/KILT/cweb-dev-kilt.jsonl",
81
+ "test": "http://dl.fbaipublicfiles.com/KILT/cweb-test_without_answers-kilt.jsonl",
82
+ },
83
+ "trex": {
84
+ "train": "http://dl.fbaipublicfiles.com/KILT/trex-train-kilt.jsonl",
85
+ "validation": "http://dl.fbaipublicfiles.com/KILT/trex-dev-kilt.jsonl",
86
+ "test": "http://dl.fbaipublicfiles.com/KILT/trex-test_without_answers-kilt.jsonl",
87
+ },
88
+ "structured_zeroshot": {
89
+ "train": "http://dl.fbaipublicfiles.com/KILT/structured_zeroshot-train-kilt.jsonl",
90
+ "validation": "http://dl.fbaipublicfiles.com/KILT/structured_zeroshot-dev-kilt.jsonl",
91
+ "test": "http://dl.fbaipublicfiles.com/KILT/structured_zeroshot-test_without_answers-kilt.jsonl",
92
+ },
93
+ "nq": {
94
+ "train": "http://dl.fbaipublicfiles.com/KILT/nq-train-kilt.jsonl",
95
+ "validation": "http://dl.fbaipublicfiles.com/KILT/nq-dev-kilt.jsonl",
96
+ "test": "http://dl.fbaipublicfiles.com/KILT/nq-test_without_answers-kilt.jsonl",
97
+ },
98
+ "hotpotqa": {
99
+ "train": "http://dl.fbaipublicfiles.com/KILT/hotpotqa-train-kilt.jsonl",
100
+ "validation": "http://dl.fbaipublicfiles.com/KILT/hotpotqa-dev-kilt.jsonl",
101
+ "test": "http://dl.fbaipublicfiles.com/KILT/hotpotqa-test_without_answers-kilt.jsonl",
102
+ },
103
+ "triviaqa": {
104
+ "train": "http://dl.fbaipublicfiles.com/KILT/triviaqa-train_id-kilt.jsonl",
105
+ "validation": "http://dl.fbaipublicfiles.com/KILT/triviaqa-dev_id-kilt.jsonl",
106
+ "test": "http://dl.fbaipublicfiles.com/KILT/triviaqa-test_id_without_answers-kilt.jsonl",
107
+ },
108
+ "eli5": {
109
+ "train": "http://dl.fbaipublicfiles.com/KILT/eli5-train-kilt.jsonl",
110
+ "validation": "http://dl.fbaipublicfiles.com/KILT/eli5-dev-kilt.jsonl",
111
+ "test": "http://dl.fbaipublicfiles.com/KILT/eli5-test_without_answers-kilt.jsonl",
112
+ },
113
+ "wow": {
114
+ "train": "http://dl.fbaipublicfiles.com/KILT/wow-train-kilt.jsonl",
115
+ "validation": "http://dl.fbaipublicfiles.com/KILT/wow-dev-kilt.jsonl",
116
+ "test": "http://dl.fbaipublicfiles.com/KILT/wow-test_without_answers-kilt.jsonl",
117
+ },
118
+ }
119
+
120
+
121
+ class KILTTasksConfig(datasets.BuilderConfig):
122
+ """BuilderConfig for KILTTasks."""
123
+
124
+ def __init__(self, **kwargs):
125
+ """BuilderConfig for KILTTasks.
126
+
127
+ Args:
128
+ .
129
+ **kwargs: keyword arguments forwarded to super.
130
+ """
131
+ super(KILTTasksConfig, self).__init__(
132
+ version=datasets.Version("1.0.0", "KILT tasks training and evaluation data"), **kwargs
133
+ )
134
+
135
+
136
+ class KILTTasks(datasets.GeneratorBasedBuilder):
137
+ """WikipediaKILT: Wikipedia pre-processed for KILT. Version 1.0."""
138
+
139
+ BUILDER_CONFIGS = [
140
+ KILTTasksConfig(
141
+ name="all_tasks",
142
+ description="All KILT tasks traiing and evaluation data",
143
+ ),
144
+ ]
145
+
146
+ def _info(self):
147
+ return datasets.DatasetInfo(
148
+ description=_DESCRIPTION,
149
+ features=datasets.Features(
150
+ {
151
+ "id": datasets.Value("string"),
152
+ "input": datasets.Value("string"),
153
+ "meta": datasets.Features(
154
+ {
155
+ "left_context": datasets.Value("string"),
156
+ "mention": datasets.Value("string"),
157
+ "right_context": datasets.Value("string"),
158
+ "partial_evidence": datasets.features.Sequence(
159
+ {
160
+ "start_paragraph_id": datasets.Value("int32"),
161
+ "end_paragraph_id": datasets.Value("int32"),
162
+ "title": datasets.Value("string"),
163
+ "section": datasets.Value("string"),
164
+ "wikipedia_id": datasets.Value("string"),
165
+ "meta": datasets.features.Sequence(
166
+ {
167
+ "evidence_span": datasets.Value("string"),
168
+ }
169
+ ),
170
+ }
171
+ ),
172
+ "obj_surface": datasets.features.Sequence({"text": datasets.Value("string")}),
173
+ "sub_surface": datasets.features.Sequence({"text": datasets.Value("string")}),
174
+ "subj_aliases": datasets.features.Sequence({"text": datasets.Value("string")}),
175
+ "template_questions": datasets.features.Sequence({"text": datasets.Value("string")}),
176
+ }
177
+ ),
178
+ "output": datasets.features.Sequence(
179
+ {
180
+ "answer": datasets.Value("string"),
181
+ "meta": datasets.Features({"score": datasets.Value("int32")}),
182
+ "provenance": datasets.features.Sequence(
183
+ {
184
+ "bleu_score": datasets.Value("float32"),
185
+ "start_character": datasets.Value("int32"),
186
+ "start_paragraph_id": datasets.Value("int32"),
187
+ "end_character": datasets.Value("int32"),
188
+ "end_paragraph_id": datasets.Value("int32"),
189
+ "meta": datasets.Features(
190
+ {
191
+ "fever_page_id": datasets.Value("string"),
192
+ "fever_sentence_id": datasets.Value("int32"),
193
+ "annotation_id": datasets.Value("string"), # int runs into overflow issues
194
+ "yes_no_answer": datasets.Value("string"),
195
+ "evidence_span": datasets.features.Sequence(
196
+ {"text": datasets.Value("string")}
197
+ ),
198
+ }
199
+ ),
200
+ "section": datasets.Value("string"),
201
+ "title": datasets.Value("string"),
202
+ "wikipedia_id": datasets.Value("string"),
203
+ }
204
+ ),
205
+ }
206
+ ),
207
+ }
208
+ ),
209
+ # No default supervised_keys (as we have to pass both premise
210
+ # and hypothesis as input).
211
+ supervised_keys=None,
212
+ homepage="https://github.com/facebookresearch/KILT",
213
+ citation=_CITATION,
214
+ )
215
+
216
+ def _split_generators(self, dl_manager):
217
+ file_paths = {}
218
+ for task_name, task_urls in _DATA_URLS.items():
219
+ file_paths[task_name] = dl_manager.download_and_extract(task_urls)
220
+
221
+ return [
222
+ datasets.SplitGenerator(name=split + "_" + task, gen_kwargs={"filepath": downloaded_path})
223
+ for task, split_paths in file_paths.items()
224
+ for split, downloaded_path in split_paths.items()
225
+ ]
226
+
227
+ def _generate_examples(self, filepath):
228
+ """Generate Wikipedia articles for KILT.
229
+
230
+ Args:
231
+ filepath: a string
232
+
233
+ Yields:
234
+ dictionaries representing article data and metadata
235
+ """
236
+ logging.info("generating examples from = %s", filepath)
237
+ with open(filepath, encoding="utf-8") as f:
238
+ for idx, line in enumerate(f):
239
+ article = json.loads(line.strip())
240
+ article["input"] = article.get("input", "")
241
+ # meta
242
+ article["meta"] = article.get("meta", {})
243
+ for k in ["left_context", "mention", "right_context"]:
244
+ article["meta"][k] = article["meta"].get(k, "")
245
+ for k in ["obj_surface", "sub_surface", "subj_aliases", "template_questions"]:
246
+ article["meta"][k] = {"text": article["meta"].get(k, [])}
247
+ article["meta"]["partial_evidence"] = article["meta"].get("partial_evidence", [])
248
+ if "partial_evidence" in article["meta"]:
249
+ dct_list = {}
250
+ for k in ["start_paragraph_id", "end_paragraph_id"]:
251
+ dct_list[k] = [dct.get(k, -1) for dct in article["meta"]["partial_evidence"]]
252
+ for k in ["title", "section", "wikipedia_id"]:
253
+ dct_list[k] = [dct.get(k, "") for dct in article["meta"]["partial_evidence"]]
254
+ if any(["meta" in dct for dct in article["meta"]["partial_evidence"]]):
255
+ dct_list["meta"] = [dct.get("meta", {}) for dct in article["meta"]["partial_evidence"]]
256
+ for meta in dct_list["meta"]:
257
+ meta["evidence_span"] = meta.get("evidence_span", [])
258
+ else:
259
+ dct_list["meta"] = []
260
+ article["meta"]["partial_evidence"] = dct_list
261
+ # output
262
+ article["output"] = article.get("output", [])
263
+ dct_list = {}
264
+ dct_list["answer"] = [dct.get("answer", "") for dct in article["output"]]
265
+ if any(["meta" in dct for dct in article["output"]]):
266
+ dct_list["meta"] = [dct.get("meta", {"score": 0}) for dct in article["output"]]
267
+ else:
268
+ dct_list["meta"] = []
269
+ dct_list["provenance"] = []
270
+ for dct in article["output"]:
271
+ if "provenance" in dct:
272
+ prov_list = dct["provenance"]
273
+ prov_dct_list = {}
274
+ prov_dct_list["bleu_score"] = [prov.get("bleu_score", 0.0) for prov in prov_list]
275
+ if any(["meta" in prov for prov in prov_list]):
276
+ prov_dct_list["meta"] = [prov.get("meta", {}) for prov in prov_list]
277
+ for meta_dct in prov_dct_list["meta"]:
278
+ meta_dct["fever_page_id"] = meta_dct.get("fever_page_id", "")
279
+ meta_dct["fever_sentence_id"] = meta_dct.get("fever_sentence_id", -1)
280
+ meta_dct["yes_no_answer"] = meta_dct.get("yes_no_answer", "")
281
+ meta_dct["annotation_id"] = str(meta_dct.get("annotation_id", -1))
282
+ meta_dct["evidence_span"] = {"text": meta_dct.get("evidence_span", [])}
283
+ else:
284
+ prov_dct_list["meta"] = []
285
+ for k in ["start_character", "start_paragraph_id", "end_character", "end_paragraph_id"]:
286
+ prov_dct_list[k] = [prov.get(k, -1) for prov in prov_list]
287
+ for k in ["section", "title", "wikipedia_id"]:
288
+ prov_dct_list[k] = [prov.get(k, "") for prov in prov_list]
289
+ dct_list["provenance"] += [prov_dct_list]
290
+ article["output"] = dct_list
291
+ yield idx, article