Commit ·
4beb224
0
Parent(s):
Update files from the datasets library (from 1.4.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.4.0
- .gitattributes +27 -0
- README.md +224 -0
- dataset_infos.json +1 -0
- dummy/default/1.0.0/dummy_data.zip +3 -0
- few_rel.py +189 -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,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
annotations_creators:
|
| 3 |
+
- crowdsourced
|
| 4 |
+
- machine-generated
|
| 5 |
+
language_creators:
|
| 6 |
+
- found
|
| 7 |
+
languages:
|
| 8 |
+
- en
|
| 9 |
+
licenses:
|
| 10 |
+
- mit
|
| 11 |
+
multilinguality:
|
| 12 |
+
- monolingual
|
| 13 |
+
size_categories:
|
| 14 |
+
default:
|
| 15 |
+
- 10K<n<100K
|
| 16 |
+
pid2name:
|
| 17 |
+
- n<1K
|
| 18 |
+
source_datasets:
|
| 19 |
+
- original
|
| 20 |
+
task_categories:
|
| 21 |
+
- other
|
| 22 |
+
task_ids:
|
| 23 |
+
- other-other-relation-extraction
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
# Dataset Card for few_rel
|
| 27 |
+
|
| 28 |
+
## Table of Contents
|
| 29 |
+
- [Dataset Description](#dataset-description)
|
| 30 |
+
- [Dataset Summary](#dataset-summary)
|
| 31 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
| 32 |
+
- [Languages](#languages)
|
| 33 |
+
- [Dataset Structure](#dataset-structure)
|
| 34 |
+
- [Data Instances](#data-instances)
|
| 35 |
+
- [Data Fields](#data-instances)
|
| 36 |
+
- [Data Splits](#data-instances)
|
| 37 |
+
- [Dataset Creation](#dataset-creation)
|
| 38 |
+
- [Curation Rationale](#curation-rationale)
|
| 39 |
+
- [Source Data](#source-data)
|
| 40 |
+
- [Annotations](#annotations)
|
| 41 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
| 42 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
| 43 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
| 44 |
+
- [Discussion of Biases](#discussion-of-biases)
|
| 45 |
+
- [Other Known Limitations](#other-known-limitations)
|
| 46 |
+
- [Additional Information](#additional-information)
|
| 47 |
+
- [Dataset Curators](#dataset-curators)
|
| 48 |
+
- [Licensing Information](#licensing-information)
|
| 49 |
+
- [Citation Information](#citation-information)
|
| 50 |
+
|
| 51 |
+
## Dataset Description
|
| 52 |
+
|
| 53 |
+
- **Homepage:** [GitHub Page](https://thunlp.github.io/)
|
| 54 |
+
- **Repository:** [GitHub](https://github.com/thunlp/FewRel)
|
| 55 |
+
- **Paper:** [FewRel](https://www.aclweb.org/anthology/D18-1514.pdf), [FewRel 2.0](https://www.aclweb.org/anthology/D19-1649.pdf)
|
| 56 |
+
- **Leaderboard:** [GitHub Leaderboard](https://thunlp.github.io/fewrel.html)
|
| 57 |
+
- **Point of Contact:** [Needs More Information]
|
| 58 |
+
|
| 59 |
+
### Dataset Summary
|
| 60 |
+
|
| 61 |
+
FewRel is a large-scale few-shot relation extraction dataset, which contains more than one hundred relations and tens of thousands of annotated instances cross different domains.
|
| 62 |
+
|
| 63 |
+
### Supported Tasks and Leaderboards
|
| 64 |
+
|
| 65 |
+
[Needs More Information]
|
| 66 |
+
|
| 67 |
+
### Languages
|
| 68 |
+
|
| 69 |
+
The dataset contaings English text, as used by writers on Wikipedia, and crowdsourced English annotations.
|
| 70 |
+
|
| 71 |
+
## Dataset Structure
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
### Data Instances
|
| 75 |
+
|
| 76 |
+
An instance from `train_wiki` split:
|
| 77 |
+
|
| 78 |
+
```
|
| 79 |
+
{'head': {'indices': [[16]], 'text': 'tjq', 'type': 'Q1331049'}, 'names': ['place served by transport hub', 'territorial entity or entities served by this transport hub (airport, train station, etc.)'], 'relation': 'P931', 'tail': {'indices': [[13, 14]], 'text': 'tanjung pandan', 'type': 'Q3056359'}, 'tokens': ['Merpati', 'flight', '106', 'departed', 'Jakarta', '(', 'CGK', ')', 'on', 'a', 'domestic', 'flight', 'to', 'Tanjung', 'Pandan', '(', 'TJQ', ')', '.']}
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
### Data Fields
|
| 83 |
+
|
| 84 |
+
For `default`:
|
| 85 |
+
|
| 86 |
+
- `relation`: a `string` feature containing PID of the relation.
|
| 87 |
+
- `tokens`: a `list` of `string` features containing tokens for the text.
|
| 88 |
+
- `head`: a dictionary containing:
|
| 89 |
+
- `text`: a `string` feature representing the head entity.
|
| 90 |
+
- `type`: a `string` feature representing the type of the head entity.
|
| 91 |
+
- `indices`: a `list` containing `list` of token indices.
|
| 92 |
+
|
| 93 |
+
- `tail`: a dictionary containing:
|
| 94 |
+
- `text`: a `string` feature representing the tail entity.
|
| 95 |
+
- `type`: a `string` feature representing the type of the tail entity.
|
| 96 |
+
- `indices`: a `list` containing `list` of token indices.
|
| 97 |
+
- `names`: a `list` of `string` features containing relation names. For `pubmed_unsupervised` split, this is set to a `list` with an empty `string`. For `val_semeval` and `val_pubmed` split, this is set to a `list` with the `string` from the `relation` field.
|
| 98 |
+
|
| 99 |
+
### Data Splits
|
| 100 |
+
|
| 101 |
+
`train_wiki`: 44800
|
| 102 |
+
`val_nyt`: 2500
|
| 103 |
+
`val_pubmed`: 1000
|
| 104 |
+
`val_semeval`: 8851
|
| 105 |
+
`val_wiki`: 11200
|
| 106 |
+
`pubmed_unsupervised`: 2500
|
| 107 |
+
|
| 108 |
+
## Dataset Creation
|
| 109 |
+
|
| 110 |
+
### Curation Rationale
|
| 111 |
+
|
| 112 |
+
[Needs More Information]
|
| 113 |
+
|
| 114 |
+
### Source Data
|
| 115 |
+
|
| 116 |
+
#### Initial Data Collection and Normalization
|
| 117 |
+
|
| 118 |
+
[Needs More Information]
|
| 119 |
+
|
| 120 |
+
#### Who are the source language producers?
|
| 121 |
+
|
| 122 |
+
[Needs More Information]
|
| 123 |
+
|
| 124 |
+
### Annotations
|
| 125 |
+
|
| 126 |
+
#### Annotation process
|
| 127 |
+
|
| 128 |
+
[Needs More Information]
|
| 129 |
+
|
| 130 |
+
#### Who are the annotators?
|
| 131 |
+
|
| 132 |
+
[Needs More Information]
|
| 133 |
+
|
| 134 |
+
### Personal and Sensitive Information
|
| 135 |
+
|
| 136 |
+
[Needs More Information]
|
| 137 |
+
|
| 138 |
+
## Considerations for Using the Data
|
| 139 |
+
|
| 140 |
+
### Social Impact of Dataset
|
| 141 |
+
|
| 142 |
+
[Needs More Information]
|
| 143 |
+
|
| 144 |
+
### Discussion of Biases
|
| 145 |
+
|
| 146 |
+
[Needs More Information]
|
| 147 |
+
|
| 148 |
+
### Other Known Limitations
|
| 149 |
+
|
| 150 |
+
[Needs More Information]
|
| 151 |
+
|
| 152 |
+
## Additional Information
|
| 153 |
+
|
| 154 |
+
### Dataset Curators
|
| 155 |
+
|
| 156 |
+
For FewRel:
|
| 157 |
+
|
| 158 |
+
Han, Xu and Zhu, Hao and Yu, Pengfei and Wang, Ziyun and Yao, Yuan and Liu, Zhiyuan and Sun, Maosong
|
| 159 |
+
|
| 160 |
+
For FewRel 2.0:
|
| 161 |
+
|
| 162 |
+
Gao, Tianyu and Han, Xu and Zhu, Hao and Liu, Zhiyuan and Li, Peng and Sun, Maosong and Zhou, Jie
|
| 163 |
+
|
| 164 |
+
### Licensing Information
|
| 165 |
+
|
| 166 |
+
```
|
| 167 |
+
MIT License
|
| 168 |
+
|
| 169 |
+
Copyright (c) 2018 THUNLP
|
| 170 |
+
|
| 171 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 172 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 173 |
+
in the Software without restriction, including without limitation the rights
|
| 174 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 175 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 176 |
+
furnished to do so, subject to the following conditions:
|
| 177 |
+
|
| 178 |
+
The above copyright notice and this permission notice shall be included in all
|
| 179 |
+
copies or substantial portions of the Software.
|
| 180 |
+
|
| 181 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 182 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 183 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 184 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 185 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 186 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 187 |
+
SOFTWARE.
|
| 188 |
+
```
|
| 189 |
+
|
| 190 |
+
### Citation Information
|
| 191 |
+
|
| 192 |
+
```
|
| 193 |
+
@inproceedings{han-etal-2018-fewrel,
|
| 194 |
+
title = "{F}ew{R}el: A Large-Scale Supervised Few-Shot Relation Classification Dataset with State-of-the-Art Evaluation",
|
| 195 |
+
author = "Han, Xu and Zhu, Hao and Yu, Pengfei and Wang, Ziyun and Yao, Yuan and Liu, Zhiyuan and Sun, Maosong",
|
| 196 |
+
booktitle = "Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing",
|
| 197 |
+
month = oct # "-" # nov,
|
| 198 |
+
year = "2018",
|
| 199 |
+
address = "Brussels, Belgium",
|
| 200 |
+
publisher = "Association for Computational Linguistics",
|
| 201 |
+
url = "https://www.aclweb.org/anthology/D18-1514",
|
| 202 |
+
doi = "10.18653/v1/D18-1514",
|
| 203 |
+
pages = "4803--4809"
|
| 204 |
+
}
|
| 205 |
+
```
|
| 206 |
+
```
|
| 207 |
+
|
| 208 |
+
@inproceedings{gao-etal-2019-fewrel,
|
| 209 |
+
title = "{F}ew{R}el 2.0: Towards More Challenging Few-Shot Relation Classification",
|
| 210 |
+
author = "Gao, Tianyu and Han, Xu and Zhu, Hao and Liu, Zhiyuan and Li, Peng and Sun, Maosong and Zhou, Jie",
|
| 211 |
+
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP)",
|
| 212 |
+
month = nov,
|
| 213 |
+
year = "2019",
|
| 214 |
+
address = "Hong Kong, China",
|
| 215 |
+
publisher = "Association for Computational Linguistics",
|
| 216 |
+
url = "https://www.aclweb.org/anthology/D19-1649",
|
| 217 |
+
doi = "10.18653/v1/D19-1649",
|
| 218 |
+
pages = "6251--6256"
|
| 219 |
+
}
|
| 220 |
+
```
|
| 221 |
+
|
| 222 |
+
### Contributions
|
| 223 |
+
|
| 224 |
+
Thanks to [@gchhablani](https://github.com/gchhablani) for adding this dataset.
|
dataset_infos.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"default": {"description": "FewRel is a large-scale few-shot relation extraction dataset, which contains more than one hundred relations and tens of thousands of annotated instances cross different domains.\n", "citation": "@inproceedings{han-etal-2018-fewrel,\n title = \"{F}ew{R}el: A Large-Scale Supervised Few-Shot Relation Classification Dataset with State-of-the-Art Evaluation\",\n author = \"Han, Xu and Zhu, Hao and Yu, Pengfei and Wang, Ziyun and Yao, Yuan and Liu, Zhiyuan and Sun, Maosong\",\n booktitle = \"Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing\",\n month = oct # \"-\" # nov,\n year = \"2018\",\n address = \"Brussels, Belgium\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/D18-1514\",\n doi = \"10.18653/v1/D18-1514\",\n pages = \"4803--4809\"\n}\n\n@inproceedings{gao-etal-2019-fewrel,\n title = \"{F}ew{R}el 2.0: Towards More Challenging Few-Shot Relation Classification\",\n author = \"Gao, Tianyu and Han, Xu and Zhu, Hao and Liu, Zhiyuan and Li, Peng and Sun, Maosong and Zhou, Jie\",\n booktitle = \"Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP)\",\n month = nov,\n year = \"2019\",\n address = \"Hong Kong, China\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/D19-1649\",\n doi = \"10.18653/v1/D19-1649\",\n pages = \"6251--6256\"\n}\n", "homepage": "https://thunlp.github.io/", "license": "https://raw.githubusercontent.com/thunlp/FewRel/master/LICENSE", "features": {"relation": {"dtype": "string", "id": null, "_type": "Value"}, "tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "head": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "type": {"dtype": "string", "id": null, "_type": "Value"}, "indices": {"feature": {"feature": {"dtype": "int64", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}}, "tail": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "type": {"dtype": "string", "id": null, "_type": "Value"}, "indices": {"feature": {"feature": {"dtype": "int64", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}}, "names": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "few_rel", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train_wiki": {"name": "train_wiki", "num_bytes": 19923155, "num_examples": 44800, "dataset_name": "few_rel"}, "val_nyt": {"name": "val_nyt", "num_bytes": 1385642, "num_examples": 2500, "dataset_name": "few_rel"}, "val_pubmed": {"name": "val_pubmed", "num_bytes": 488502, "num_examples": 1000, "dataset_name": "few_rel"}, "val_semeval": {"name": "val_semeval", "num_bytes": 2646249, "num_examples": 8851, "dataset_name": "few_rel"}, "val_wiki": {"name": "val_wiki", "num_bytes": 5147348, "num_examples": 11200, "dataset_name": "few_rel"}, "pubmed_unsupervised": {"name": "pubmed_unsupervised", "num_bytes": 1117703, "num_examples": 2500, "dataset_name": "few_rel"}}, "download_checksums": {"https://raw.githubusercontent.com/thunlp/FewRel/master/data/train_wiki.json": {"num_bytes": 14298985, "checksum": "8e9e58a05d559be773cbe18a8d4a16ba17e6d397663f9f05a056f894a94b92c1"}, "https://raw.githubusercontent.com/thunlp/FewRel/master/data/val_nyt.json": {"num_bytes": 1032006, "checksum": "b519adc61a2bab0f05178e33a3cd8f284338b635629493e9e09616ba81bb428e"}, "https://raw.githubusercontent.com/thunlp/FewRel/master/data/val_pubmed.json": {"num_bytes": 432600, "checksum": "fc0f13b534f6664fe0d8aec231d7590313bc6510d00dbc1b6746147f6a2b46e6"}, "https://raw.githubusercontent.com/thunlp/FewRel/master/data/val_semeval.json": {"num_bytes": 2203006, "checksum": "fd79cf35481f6596c23b92cd3ded3265481f3027a4b78d99921104f8fe632eb5"}, "https://raw.githubusercontent.com/thunlp/FewRel/master/data/val_wiki.json": {"num_bytes": 3534147, "checksum": "76bb44c2485b6faed358a3ce040eadafcc8a8835245cd7e6afc1bef672d4a0bf"}, "https://raw.githubusercontent.com/thunlp/FewRel/master/data/pid2name.json": {"num_bytes": 80278, "checksum": "eeedd25512a8e4c2bc06b78009836d27de81807bcba6ed929debd5cd713c07ea"}, "https://raw.githubusercontent.com/thunlp/FewRel/master/data/pubmed_unsupervised.json": {"num_bytes": 1093301, "checksum": "fa3555941364024c2ac1b1857396515ecc65a515bc742e9da0502568fad5dd1f"}}, "download_size": 22674323, "post_processing_size": null, "dataset_size": 30708599, "size_in_bytes": 53382922}, "pid2name": {"description": "FewRel is a large-scale few-shot relation extraction dataset, which contains more than one hundred relations and tens of thousands of annotated instances cross different domains.\n", "citation": "@inproceedings{han-etal-2018-fewrel,\n title = \"{F}ew{R}el: A Large-Scale Supervised Few-Shot Relation Classification Dataset with State-of-the-Art Evaluation\",\n author = \"Han, Xu and Zhu, Hao and Yu, Pengfei and Wang, Ziyun and Yao, Yuan and Liu, Zhiyuan and Sun, Maosong\",\n booktitle = \"Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing\",\n month = oct # \"-\" # nov,\n year = \"2018\",\n address = \"Brussels, Belgium\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/D18-1514\",\n doi = \"10.18653/v1/D18-1514\",\n pages = \"4803--4809\"\n}\n\n@inproceedings{gao-etal-2019-fewrel,\n title = \"{F}ew{R}el 2.0: Towards More Challenging Few-Shot Relation Classification\",\n author = \"Gao, Tianyu and Han, Xu and Zhu, Hao and Liu, Zhiyuan and Li, Peng and Sun, Maosong and Zhou, Jie\",\n booktitle = \"Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP)\",\n month = nov,\n year = \"2019\",\n address = \"Hong Kong, China\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/D19-1649\",\n doi = \"10.18653/v1/D19-1649\",\n pages = \"6251--6256\"\n}\n", "homepage": "https://thunlp.github.io/", "license": "https://raw.githubusercontent.com/thunlp/FewRel/master/LICENSE", "features": {"relation": {"dtype": "string", "id": null, "_type": "Value"}, "names": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "few_rel", "config_name": "pid2name", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"pid2name": {"name": "pid2name", "num_bytes": 81607, "num_examples": 744, "dataset_name": "few_rel"}}, "download_checksums": {"https://raw.githubusercontent.com/thunlp/FewRel/master/data/train_wiki.json": {"num_bytes": 14298985, "checksum": "8e9e58a05d559be773cbe18a8d4a16ba17e6d397663f9f05a056f894a94b92c1"}, "https://raw.githubusercontent.com/thunlp/FewRel/master/data/val_nyt.json": {"num_bytes": 1032006, "checksum": "b519adc61a2bab0f05178e33a3cd8f284338b635629493e9e09616ba81bb428e"}, "https://raw.githubusercontent.com/thunlp/FewRel/master/data/val_pubmed.json": {"num_bytes": 432600, "checksum": "fc0f13b534f6664fe0d8aec231d7590313bc6510d00dbc1b6746147f6a2b46e6"}, "https://raw.githubusercontent.com/thunlp/FewRel/master/data/val_semeval.json": {"num_bytes": 2203006, "checksum": "fd79cf35481f6596c23b92cd3ded3265481f3027a4b78d99921104f8fe632eb5"}, "https://raw.githubusercontent.com/thunlp/FewRel/master/data/val_wiki.json": {"num_bytes": 3534147, "checksum": "76bb44c2485b6faed358a3ce040eadafcc8a8835245cd7e6afc1bef672d4a0bf"}, "https://raw.githubusercontent.com/thunlp/FewRel/master/data/pid2name.json": {"num_bytes": 80278, "checksum": "eeedd25512a8e4c2bc06b78009836d27de81807bcba6ed929debd5cd713c07ea"}, "https://raw.githubusercontent.com/thunlp/FewRel/master/data/pubmed_unsupervised.json": {"num_bytes": 1093301, "checksum": "fa3555941364024c2ac1b1857396515ecc65a515bc742e9da0502568fad5dd1f"}}, "download_size": 22674323, "post_processing_size": null, "dataset_size": 81607, "size_in_bytes": 22755930}}
|
dummy/default/1.0.0/dummy_data.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f73aa3427b81fbed9ec55e0bbd8d60b8b375dff12d18def5ffe97290227e86cf
|
| 3 |
+
size 6859
|
few_rel.py
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 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 |
+
"""FewRel Dataset."""
|
| 16 |
+
|
| 17 |
+
from __future__ import absolute_import, division, print_function
|
| 18 |
+
|
| 19 |
+
import json
|
| 20 |
+
|
| 21 |
+
import datasets
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
_CITATION = """@inproceedings{han-etal-2018-fewrel,
|
| 25 |
+
title = "{F}ew{R}el: A Large-Scale Supervised Few-Shot Relation Classification Dataset with State-of-the-Art Evaluation",
|
| 26 |
+
author = "Han, Xu and Zhu, Hao and Yu, Pengfei and Wang, Ziyun and Yao, Yuan and Liu, Zhiyuan and Sun, Maosong",
|
| 27 |
+
booktitle = "Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing",
|
| 28 |
+
month = oct # "-" # nov,
|
| 29 |
+
year = "2018",
|
| 30 |
+
address = "Brussels, Belgium",
|
| 31 |
+
publisher = "Association for Computational Linguistics",
|
| 32 |
+
url = "https://www.aclweb.org/anthology/D18-1514",
|
| 33 |
+
doi = "10.18653/v1/D18-1514",
|
| 34 |
+
pages = "4803--4809"
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
@inproceedings{gao-etal-2019-fewrel,
|
| 38 |
+
title = "{F}ew{R}el 2.0: Towards More Challenging Few-Shot Relation Classification",
|
| 39 |
+
author = "Gao, Tianyu and Han, Xu and Zhu, Hao and Liu, Zhiyuan and Li, Peng and Sun, Maosong and Zhou, Jie",
|
| 40 |
+
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP)",
|
| 41 |
+
month = nov,
|
| 42 |
+
year = "2019",
|
| 43 |
+
address = "Hong Kong, China",
|
| 44 |
+
publisher = "Association for Computational Linguistics",
|
| 45 |
+
url = "https://www.aclweb.org/anthology/D19-1649",
|
| 46 |
+
doi = "10.18653/v1/D19-1649",
|
| 47 |
+
pages = "6251--6256"
|
| 48 |
+
}
|
| 49 |
+
"""
|
| 50 |
+
|
| 51 |
+
_DESCRIPTION = """\
|
| 52 |
+
FewRel is a large-scale few-shot relation extraction dataset, which contains more than one hundred relations and tens of thousands of annotated instances cross different domains.
|
| 53 |
+
"""
|
| 54 |
+
|
| 55 |
+
_HOMEPAGE = "https://thunlp.github.io/"
|
| 56 |
+
|
| 57 |
+
_LICENSE = "https://raw.githubusercontent.com/thunlp/FewRel/master/LICENSE"
|
| 58 |
+
|
| 59 |
+
DATA_URL = "https://raw.githubusercontent.com/thunlp/FewRel/master/data/"
|
| 60 |
+
_URLs = {
|
| 61 |
+
"train_wiki": DATA_URL + "train_wiki.json",
|
| 62 |
+
"val_nyt": DATA_URL + "val_nyt.json",
|
| 63 |
+
"val_pubmed": DATA_URL + "val_pubmed.json",
|
| 64 |
+
"val_semeval": DATA_URL + "val_semeval.json",
|
| 65 |
+
"val_wiki": DATA_URL + "val_wiki.json",
|
| 66 |
+
"pid2name": DATA_URL + "pid2name.json",
|
| 67 |
+
"pubmed_unsupervised": DATA_URL + "pubmed_unsupervised.json",
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
class FewRel(datasets.GeneratorBasedBuilder):
|
| 72 |
+
"""The FewRelDataset."""
|
| 73 |
+
|
| 74 |
+
VERSION = datasets.Version("1.0.0")
|
| 75 |
+
|
| 76 |
+
BUILDER_CONFIGS = [
|
| 77 |
+
datasets.BuilderConfig(name="default", version=VERSION, description="This covers the entire FewRel dataset."),
|
| 78 |
+
]
|
| 79 |
+
|
| 80 |
+
def _info(self):
|
| 81 |
+
features = datasets.Features(
|
| 82 |
+
{
|
| 83 |
+
"relation": datasets.Value("string"),
|
| 84 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
| 85 |
+
"head": {
|
| 86 |
+
"text": datasets.Value("string"),
|
| 87 |
+
"type": datasets.Value("string"),
|
| 88 |
+
"indices": datasets.Sequence(datasets.Sequence(datasets.Value("int64"))),
|
| 89 |
+
},
|
| 90 |
+
"tail": {
|
| 91 |
+
"text": datasets.Value("string"),
|
| 92 |
+
"type": datasets.Value("string"),
|
| 93 |
+
"indices": datasets.Sequence(datasets.Sequence(datasets.Value("int64"))),
|
| 94 |
+
},
|
| 95 |
+
"names": datasets.Sequence(datasets.Value("string"))
|
| 96 |
+
# These are the features of your dataset like images, labels ...
|
| 97 |
+
}
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
return datasets.DatasetInfo(
|
| 101 |
+
# This is the description that will appear on the datasets page.
|
| 102 |
+
description=_DESCRIPTION,
|
| 103 |
+
# This defines the different columns of the dataset and their types
|
| 104 |
+
features=features, # Here we define them above because they are different between the two configurations
|
| 105 |
+
# If there's a common (input, target) tuple from the features,
|
| 106 |
+
# specify them here. They'll be used if as_supervised=True in
|
| 107 |
+
# builder.as_dataset.
|
| 108 |
+
supervised_keys=None,
|
| 109 |
+
# Homepage of the dataset for documentation
|
| 110 |
+
homepage=_HOMEPAGE,
|
| 111 |
+
# License for the dataset if available
|
| 112 |
+
license=_LICENSE,
|
| 113 |
+
# Citation for the dataset
|
| 114 |
+
citation=_CITATION,
|
| 115 |
+
)
|
| 116 |
+
|
| 117 |
+
def _split_generators(self, dl_manager):
|
| 118 |
+
"""Returns SplitGenerators."""
|
| 119 |
+
data_dir = dl_manager.download_and_extract(_URLs)
|
| 120 |
+
return [
|
| 121 |
+
datasets.SplitGenerator(
|
| 122 |
+
name=datasets.Split(key),
|
| 123 |
+
# These kwargs will be passed to _generate_examples
|
| 124 |
+
gen_kwargs={
|
| 125 |
+
"filepath": data_dir[key],
|
| 126 |
+
"pid2name": data_dir["pid2name"],
|
| 127 |
+
"return_names": key in ["train_wiki", "val_wiki", "val_nyt"],
|
| 128 |
+
},
|
| 129 |
+
)
|
| 130 |
+
for key in data_dir.keys()
|
| 131 |
+
if key != "pid2name"
|
| 132 |
+
]
|
| 133 |
+
|
| 134 |
+
def _generate_examples(self, filepath, pid2name, return_names):
|
| 135 |
+
""" Yields examples. """
|
| 136 |
+
pid2name_dict = {}
|
| 137 |
+
with open(pid2name, encoding="utf-8") as f:
|
| 138 |
+
data = json.load(f)
|
| 139 |
+
for key in list(data.keys()):
|
| 140 |
+
name_1 = data[key][0]
|
| 141 |
+
name_2 = data[key][1]
|
| 142 |
+
pid2name_dict[key] = [name_1, name_2]
|
| 143 |
+
|
| 144 |
+
with open(filepath, encoding="utf-8") as f:
|
| 145 |
+
data = json.load(f)
|
| 146 |
+
# print(data)
|
| 147 |
+
if isinstance(data, dict):
|
| 148 |
+
id = 0
|
| 149 |
+
for key in list(data.keys()):
|
| 150 |
+
for items in data[key]:
|
| 151 |
+
tokens = items["tokens"]
|
| 152 |
+
h_0 = items["h"][0]
|
| 153 |
+
h_1 = items["h"][1]
|
| 154 |
+
h_2 = items["h"][2]
|
| 155 |
+
t_0 = items["t"][0]
|
| 156 |
+
t_1 = items["t"][1]
|
| 157 |
+
t_2 = items["t"][2]
|
| 158 |
+
id += 1
|
| 159 |
+
yield id, {
|
| 160 |
+
"relation": key,
|
| 161 |
+
"tokens": tokens,
|
| 162 |
+
"head": {"text": h_0, "type": h_1, "indices": h_2},
|
| 163 |
+
"tail": {"text": t_0, "type": t_1, "indices": t_2},
|
| 164 |
+
"names": pid2name_dict[key]
|
| 165 |
+
if return_names
|
| 166 |
+
else [
|
| 167 |
+
key,
|
| 168 |
+
],
|
| 169 |
+
}
|
| 170 |
+
else: # For `pubmed_unsupervised.json`
|
| 171 |
+
id = 0
|
| 172 |
+
for items in data:
|
| 173 |
+
tokens = items["tokens"]
|
| 174 |
+
h_0 = items["h"][0]
|
| 175 |
+
h_1 = items["h"][1]
|
| 176 |
+
h_2 = items["h"][2]
|
| 177 |
+
t_0 = items["t"][0]
|
| 178 |
+
t_1 = items["t"][1]
|
| 179 |
+
t_2 = items["t"][2]
|
| 180 |
+
id += 1
|
| 181 |
+
yield id, {
|
| 182 |
+
"relation": "",
|
| 183 |
+
"tokens": tokens,
|
| 184 |
+
"head": {"text": h_0, "type": h_1, "indices": h_2},
|
| 185 |
+
"tail": {"text": t_0, "type": t_1, "indices": t_2},
|
| 186 |
+
"names": [
|
| 187 |
+
"",
|
| 188 |
+
],
|
| 189 |
+
}
|