system HF staff commited on
Commit
f8c8d34
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

Files changed (4) hide show
  1. .gitattributes +27 -0
  2. dataset_infos.json +1 -0
  3. docred.py +123 -0
  4. dummy/0.0.0/dummy_data.zip +3 -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
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
1
+ {"default": {"description": "Multiple entities in a document generally exhibit complex inter-sentence relations, and cannot be well handled by existing relation extraction (RE) methods that typically focus on extracting intra-sentence relations for single entity pairs. In order to accelerate the research on document-level RE, we introduce DocRED, a new dataset constructed from Wikipedia and Wikidata with three features:\n - DocRED annotates both named entities and relations, and is the largest human-annotated dataset for document-level RE from plain text.\n - DocRED requires reading multiple sentences in a document to extract entities and infer their relations by synthesizing all information of the document.\n - Along with the human-annotated data, we also offer large-scale distantly supervised data, which enables DocRED to be adopted for both supervised and weakly supervised scenarios.\n", "citation": "@inproceedings{yao2019DocRED,\n title={{DocRED}: A Large-Scale Document-Level Relation Extraction Dataset},\n author={Yao, Yuan and Ye, Deming and Li, Peng and Han, Xu and Lin, Yankai and Liu, Zhenghao and Liu, Zhiyuan and Huang, Lixin and Zhou, Jie and Sun, Maosong},\n booktitle={Proceedings of ACL 2019},\n year={2019}\n}\n", "homepage": "https://github.com/thunlp/DocRED", "license": "", "features": {"title": {"dtype": "string", "id": null, "_type": "Value"}, "sents": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "vertexSet": [[{"name": {"dtype": "string", "id": null, "_type": "Value"}, "sent_id": {"dtype": "int32", "id": null, "_type": "Value"}, "pos": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "type": {"dtype": "string", "id": null, "_type": "Value"}}]], "labels": {"feature": {"head": {"dtype": "int32", "id": null, "_type": "Value"}, "tail": {"dtype": "int32", "id": null, "_type": "Value"}, "relation_id": {"dtype": "string", "id": null, "_type": "Value"}, "relation_text": {"dtype": "string", "id": null, "_type": "Value"}, "evidence": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}}, "supervised_keys": null, "builder_name": "doc_red", "config_name": "default", "version": {"version_str": "0.0.0", "description": null, "datasets_version_to_prepare": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"validation": {"name": "validation", "num_bytes": 3435087, "num_examples": 1000, "dataset_name": "doc_red"}, "test": {"name": "test", "num_bytes": 2843877, "num_examples": 1000, "dataset_name": "doc_red"}, "train_annotated": {"name": "train_annotated", "num_bytes": 10413156, "num_examples": 3053, "dataset_name": "doc_red"}, "train_distant": {"name": "train_distant", "num_bytes": 3435087, "num_examples": 1000, "dataset_name": "doc_red"}}, "download_checksums": {"https://drive.google.com/uc?export=download&id=1fDmfUUo5G7gfaoqWWvK81u08m71TK2g7": {"num_bytes": 4299810, "checksum": "85691c5ca1df0048bffab1c1cf53d7d35b5de40f3de0a2c563c03da28746d5cb"}, "https://drive.google.com/uc?export=download&id=1NN33RzyETbanw4Dg2sRrhckhWpzuBQS9": {"num_bytes": 13029595, "checksum": "7e706348a02cf91f38bd8c379f934ab61aedadc901fca10d962c1d82ab78e95b"}, "https://drive.google.com/uc?export=download&id=1lAVDcD94Sigx7gR3jTfStI66o86cflum": {"num_bytes": 3674242, "checksum": "09386b5cb58249d8e087863c379ebd64557169c52ee502193d2f4f215e704ae8"}, "https://drive.google.com/uc?id=1y9A0zKrvETc1ddUFuFhBg3Xfr7FEL4dW&export=download": {"num_bytes": 2452, "checksum": "5ecf4e5e55c179fc83a3a3d19baa01efffecb26ba5edc0b4ac5a54ddf61fe3de"}}, "download_size": 21006099, "dataset_size": 20127207, "size_in_bytes": 41133306}}
docred.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """DocRED: A Large-Scale Document-Level Relation Extraction Dataset"""
2
+
3
+ from __future__ import absolute_import, division, print_function
4
+
5
+ import json
6
+ import os
7
+
8
+ import datasets
9
+
10
+
11
+ _CITATION = """\
12
+ @inproceedings{yao2019DocRED,
13
+ title={{DocRED}: A Large-Scale Document-Level Relation Extraction Dataset},
14
+ author={Yao, Yuan and Ye, Deming and Li, Peng and Han, Xu and Lin, Yankai and Liu, Zhenghao and Liu, \
15
+ Zhiyuan and Huang, Lixin and Zhou, Jie and Sun, Maosong},
16
+ booktitle={Proceedings of ACL 2019},
17
+ year={2019}
18
+ }
19
+ """
20
+
21
+ _DESCRIPTION = """\
22
+ Multiple entities in a document generally exhibit complex inter-sentence relations, and cannot be well handled by \
23
+ existing relation extraction (RE) methods that typically focus on extracting intra-sentence relations for single \
24
+ entity pairs. In order to accelerate the research on document-level RE, we introduce DocRED, a new dataset constructed \
25
+ from Wikipedia and Wikidata with three features:
26
+ - DocRED annotates both named entities and relations, and is the largest human-annotated dataset for document-level RE from plain text.
27
+ - DocRED requires reading multiple sentences in a document to extract entities and infer their relations by synthesizing all information of the document.
28
+ - Along with the human-annotated data, we also offer large-scale distantly supervised data, which enables DocRED to be adopted for both supervised and weakly supervised scenarios.
29
+ """
30
+
31
+ _URLS = {
32
+ "dev": "https://drive.google.com/uc?export=download&id=1fDmfUUo5G7gfaoqWWvK81u08m71TK2g7",
33
+ "train_distant": "https://drive.google.com/uc?export=download&id=1fDmfUUo5G7gfaoqWWvK81u08m71TK2g7",
34
+ "train_annotated": "https://drive.google.com/uc?export=download&id=1NN33RzyETbanw4Dg2sRrhckhWpzuBQS9",
35
+ "test": "https://drive.google.com/uc?export=download&id=1lAVDcD94Sigx7gR3jTfStI66o86cflum",
36
+ "rel_info": "https://drive.google.com/uc?id=1y9A0zKrvETc1ddUFuFhBg3Xfr7FEL4dW&export=download",
37
+ }
38
+
39
+
40
+ class DocRed(datasets.GeneratorBasedBuilder):
41
+ """DocRED: A Large-Scale Document-Level Relation Extraction Dataset"""
42
+
43
+ def _info(self):
44
+ return datasets.DatasetInfo(
45
+ description=_DESCRIPTION,
46
+ features=datasets.Features(
47
+ {
48
+ "title": datasets.Value("string"),
49
+ "sents": datasets.features.Sequence(datasets.features.Sequence(datasets.Value("string"))),
50
+ "vertexSet": [
51
+ [
52
+ {
53
+ "name": datasets.Value("string"),
54
+ "sent_id": datasets.Value("int32"),
55
+ "pos": datasets.features.Sequence(datasets.Value("int32")),
56
+ "type": datasets.Value("string"),
57
+ }
58
+ ]
59
+ ],
60
+ "labels": datasets.features.Sequence(
61
+ {
62
+ "head": datasets.Value("int32"),
63
+ "tail": datasets.Value("int32"),
64
+ "relation_id": datasets.Value("string"),
65
+ "relation_text": datasets.Value("string"),
66
+ "evidence": datasets.features.Sequence(datasets.Value("int32")),
67
+ }
68
+ ),
69
+ }
70
+ ),
71
+ supervised_keys=None,
72
+ homepage="https://github.com/thunlp/DocRED",
73
+ citation=_CITATION,
74
+ )
75
+
76
+ def _split_generators(self, dl_manager):
77
+ downloads = {}
78
+ for key in _URLS.keys():
79
+ downloads[key] = dl_manager.download_and_extract(_URLS[key])
80
+ # Fix for dummy data
81
+ if os.path.isdir(downloads[key]):
82
+ downloads[key] = os.path.join(downloads[key], key + ".json")
83
+
84
+ return [
85
+ datasets.SplitGenerator(
86
+ name=datasets.Split.VALIDATION,
87
+ gen_kwargs={"filepath": downloads["dev"], "rel_info": downloads["rel_info"]},
88
+ ),
89
+ datasets.SplitGenerator(
90
+ name=datasets.Split.TEST, gen_kwargs={"filepath": downloads["test"], "rel_info": downloads["rel_info"]}
91
+ ),
92
+ datasets.SplitGenerator(
93
+ name="train_annotated",
94
+ gen_kwargs={"filepath": downloads["train_annotated"], "rel_info": downloads["rel_info"]},
95
+ ),
96
+ datasets.SplitGenerator(
97
+ name="train_distant",
98
+ gen_kwargs={"filepath": downloads["train_distant"], "rel_info": downloads["rel_info"]},
99
+ ),
100
+ ]
101
+
102
+ def _generate_examples(self, filepath, rel_info):
103
+ """Generate DocRED examples."""
104
+ relation_name_map = json.load(open(rel_info))
105
+ data = json.load(open(filepath))
106
+
107
+ for idx, example in enumerate(data):
108
+
109
+ # Test set has no labels - Results need to be uploaded to Codalab
110
+ if "labels" not in example.keys():
111
+ example["labels"] = []
112
+
113
+ for label in example["labels"]:
114
+ # Rename and include full relation names
115
+ label["relation_text"] = relation_name_map[label["r"]]
116
+ label["relation_id"] = label["r"]
117
+ label["head"] = label["h"]
118
+ label["tail"] = label["t"]
119
+ del label["r"]
120
+ del label["h"]
121
+ del label["t"]
122
+
123
+ yield idx, example
dummy/0.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad5f87bbf1d936f40558f6ec5949e2e3a58c5c902c585082cb17519cc0005006
3
+ size 1888