Commit
·
2f687f5
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 +268 -0
- dataset_infos.json +1 -0
- dummy/all/1.1.0/dummy_data.zip +3 -0
- m_lama.py +241 -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,268 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
+
- crowdsourced
|
| 8 |
+
- expert-generated
|
| 9 |
+
- machine-generated
|
| 10 |
+
languages:
|
| 11 |
+
- af
|
| 12 |
+
- ar
|
| 13 |
+
- az
|
| 14 |
+
- be
|
| 15 |
+
- bg
|
| 16 |
+
- bn
|
| 17 |
+
- ca
|
| 18 |
+
- ceb
|
| 19 |
+
- cs
|
| 20 |
+
- cy
|
| 21 |
+
- da
|
| 22 |
+
- de
|
| 23 |
+
- el
|
| 24 |
+
- en
|
| 25 |
+
- es
|
| 26 |
+
- et
|
| 27 |
+
- eu
|
| 28 |
+
- fa
|
| 29 |
+
- fi
|
| 30 |
+
- fr
|
| 31 |
+
- ga
|
| 32 |
+
- gl
|
| 33 |
+
- he
|
| 34 |
+
- hi
|
| 35 |
+
- hr
|
| 36 |
+
- hu
|
| 37 |
+
- hy
|
| 38 |
+
- id
|
| 39 |
+
- it
|
| 40 |
+
- ja
|
| 41 |
+
- ka
|
| 42 |
+
- ko
|
| 43 |
+
- la
|
| 44 |
+
- lt
|
| 45 |
+
- lv
|
| 46 |
+
- ms
|
| 47 |
+
- nl
|
| 48 |
+
- pl
|
| 49 |
+
- pt
|
| 50 |
+
- ro
|
| 51 |
+
- ru
|
| 52 |
+
- sk
|
| 53 |
+
- sl
|
| 54 |
+
- sq
|
| 55 |
+
- sr
|
| 56 |
+
- sv
|
| 57 |
+
- ta
|
| 58 |
+
- th
|
| 59 |
+
- tr
|
| 60 |
+
- uk
|
| 61 |
+
- ur
|
| 62 |
+
- vi
|
| 63 |
+
- zh
|
| 64 |
+
licenses:
|
| 65 |
+
- cc-by-nc-sa-4-0
|
| 66 |
+
multilinguality:
|
| 67 |
+
- translation
|
| 68 |
+
size_categories:
|
| 69 |
+
- 1M>n>100K
|
| 70 |
+
source_datasets:
|
| 71 |
+
- extended|lama
|
| 72 |
+
task_categories:
|
| 73 |
+
- question-answering
|
| 74 |
+
- text-scoring
|
| 75 |
+
task_ids:
|
| 76 |
+
- open-domain-qa
|
| 77 |
+
- text-scoring-other-probing
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
+
# Dataset Card for [Dataset Name]
|
| 81 |
+
|
| 82 |
+
## Table of Contents
|
| 83 |
+
- [Dataset Card for [Dataset Name]](#dataset-card-for-dataset-name)
|
| 84 |
+
- [Table of Contents](#table-of-contents)
|
| 85 |
+
- [Dataset Description](#dataset-description)
|
| 86 |
+
- [Dataset Summary](#dataset-summary)
|
| 87 |
+
- [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
|
| 88 |
+
- [Languages](#languages)
|
| 89 |
+
- [Dataset Structure](#dataset-structure)
|
| 90 |
+
- [Data Instances](#data-instances)
|
| 91 |
+
- [Data Fields](#data-fields)
|
| 92 |
+
- [Data Splits](#data-splits)
|
| 93 |
+
- [Dataset Creation](#dataset-creation)
|
| 94 |
+
- [Curation Rationale](#curation-rationale)
|
| 95 |
+
- [Source Data](#source-data)
|
| 96 |
+
- [Initial Data Collection and Normalization](#initial-data-collection-and-normalization)
|
| 97 |
+
- [Who are the source language producers?](#who-are-the-source-language-producers)
|
| 98 |
+
- [Annotations](#annotations)
|
| 99 |
+
- [Annotation process](#annotation-process)
|
| 100 |
+
- [Who are the annotators?](#who-are-the-annotators)
|
| 101 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
| 102 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
| 103 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
| 104 |
+
- [Discussion of Biases](#discussion-of-biases)
|
| 105 |
+
- [Other Known Limitations](#other-known-limitations)
|
| 106 |
+
- [Additional Information](#additional-information)
|
| 107 |
+
- [Dataset Curators](#dataset-curators)
|
| 108 |
+
- [Licensing Information](#licensing-information)
|
| 109 |
+
- [Citation Information](#citation-information)
|
| 110 |
+
- [Contributions](#contributions)
|
| 111 |
+
|
| 112 |
+
## Dataset Description
|
| 113 |
+
|
| 114 |
+
- **Homepage:** [Multilingual LAMA](http://cistern.cis.lmu.de/mlama/)
|
| 115 |
+
- **Repository:** [Github](https://github.com/norakassner/mlama)
|
| 116 |
+
- **Paper:** [Arxiv](https://arxiv.org/abs/2102.00894)
|
| 117 |
+
- **Point of Contact:** [Contact section](http://cistern.cis.lmu.de/mlama/)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
### Dataset Summary
|
| 122 |
+
|
| 123 |
+
This dataset provides the data for mLAMA, a multilingual version of LAMA.
|
| 124 |
+
Regarding LAMA see https://github.com/facebookresearch/LAMA. For mLAMA
|
| 125 |
+
the TREx and GoogleRE part of LAMA was considered and machine translated using
|
| 126 |
+
Google Translate, and the Wikidata and Google Knowledge Graph API. The machine
|
| 127 |
+
translated templates were checked for validity, i.e., whether they contain
|
| 128 |
+
exactly one '[X]' and one '[Y]'.
|
| 129 |
+
|
| 130 |
+
This data can be used for creating fill-in-the-blank queries like
|
| 131 |
+
"Paris is the capital of [MASK]" across 53 languages. For more details see
|
| 132 |
+
the website http://cistern.cis.lmu.de/mlama/ or the github repo https://github.com/norakassner/mlama.
|
| 133 |
+
|
| 134 |
+
### Supported Tasks and Leaderboards
|
| 135 |
+
|
| 136 |
+
Language model knowledge probing.
|
| 137 |
+
|
| 138 |
+
### Languages
|
| 139 |
+
|
| 140 |
+
This dataset contains data in 53 languages:
|
| 141 |
+
af,ar,az,be,bg,bn,ca,ceb,cs,cy,da,de,el,en,es,et,eu,fa,fi,fr,ga,gl,he,hi,hr,hu,hy,id,it,ja,ka,ko,la,lt,lv,ms,nl,pl,pt,ro,ru,sk,sl,sq,sr,sv,ta,th,tr,uk,ur,vi,zh
|
| 142 |
+
|
| 143 |
+
## Dataset Structure
|
| 144 |
+
For each of the 53 languages and each of the 43 relations/predicates there is a set of triples.
|
| 145 |
+
|
| 146 |
+
### Data Instances
|
| 147 |
+
For each language and relation there are triples, that consists of an object, a predicate and a subject. For each predicate there is a template available. An example for `dataset["test"][0]` is given here:
|
| 148 |
+
```python
|
| 149 |
+
{
|
| 150 |
+
'language': 'af',
|
| 151 |
+
'lineid': 0,
|
| 152 |
+
'obj_label': 'Frankryk',
|
| 153 |
+
'obj_uri': 'Q142',
|
| 154 |
+
'predicate_id': 'P1001',
|
| 155 |
+
'sub_label': 'President van Frankryk',
|
| 156 |
+
'sub_uri': 'Q191954',
|
| 157 |
+
'template': "[X] is 'n wettige term in [Y].",
|
| 158 |
+
'uuid': '3fe3d4da-9df9-45ba-8109-784ce5fba38a'
|
| 159 |
+
}
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
### Data Fields
|
| 164 |
+
|
| 165 |
+
Each instance has the following fields
|
| 166 |
+
* "uuid": a unique identifier
|
| 167 |
+
* "lineid": a identifier unique to mlama
|
| 168 |
+
* "obj_id": knowledge graph id of the object
|
| 169 |
+
* "obj_label": surface form of the object
|
| 170 |
+
* "sub_id": knowledge graph id of the subject
|
| 171 |
+
* "sub_label": surface form of the subject
|
| 172 |
+
* "template": template
|
| 173 |
+
* "language": language code
|
| 174 |
+
* "predicate_id": relation id
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
### Data Splits
|
| 178 |
+
|
| 179 |
+
There is only one partition that is labelled as 'test data'.
|
| 180 |
+
|
| 181 |
+
## Dataset Creation
|
| 182 |
+
|
| 183 |
+
### Curation Rationale
|
| 184 |
+
|
| 185 |
+
The dataset was translated into 53 languages to investigate knowledge in pretrained language models
|
| 186 |
+
multilingually.
|
| 187 |
+
|
| 188 |
+
### Source Data
|
| 189 |
+
|
| 190 |
+
#### Initial Data Collection and Normalization
|
| 191 |
+
|
| 192 |
+
The data has several sources:
|
| 193 |
+
|
| 194 |
+
LAMA (https://github.com/facebookresearch/LAMA) licensed under Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
|
| 195 |
+
T-REx (https://hadyelsahar.github.io/t-rex/) licensed under Creative Commons Attribution-ShareAlike 4.0 International License
|
| 196 |
+
Google-RE (https://github.com/google-research-datasets/relation-extraction-corpus)
|
| 197 |
+
Wikidata (https://www.wikidata.org/) licensed under Creative Commons CC0 License and Creative Commons Attribution-ShareAlike License
|
| 198 |
+
|
| 199 |
+
#### Who are the source language producers?
|
| 200 |
+
|
| 201 |
+
See links above.
|
| 202 |
+
|
| 203 |
+
### Annotations
|
| 204 |
+
|
| 205 |
+
#### Annotation process
|
| 206 |
+
|
| 207 |
+
Crowdsourced (wikidata) and machine translated.
|
| 208 |
+
|
| 209 |
+
#### Who are the annotators?
|
| 210 |
+
|
| 211 |
+
Unknown.
|
| 212 |
+
|
| 213 |
+
### Personal and Sensitive Information
|
| 214 |
+
|
| 215 |
+
Names of (most likely) famous people who have entries in Google Knowledge Graph or Wikidata.
|
| 216 |
+
|
| 217 |
+
## Considerations for Using the Data
|
| 218 |
+
|
| 219 |
+
Data was created through machine translation and automatic processes.
|
| 220 |
+
|
| 221 |
+
### Social Impact of Dataset
|
| 222 |
+
|
| 223 |
+
[More Information Needed]
|
| 224 |
+
|
| 225 |
+
### Discussion of Biases
|
| 226 |
+
|
| 227 |
+
[More Information Needed]
|
| 228 |
+
|
| 229 |
+
### Other Known Limitations
|
| 230 |
+
|
| 231 |
+
Not all triples are available in all languages.
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
## Additional Information
|
| 235 |
+
|
| 236 |
+
### Dataset Curators
|
| 237 |
+
|
| 238 |
+
The authors of the mLAMA paper and the authors of the original datasets.
|
| 239 |
+
|
| 240 |
+
### Licensing Information
|
| 241 |
+
|
| 242 |
+
The Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0). https://creativecommons.org/licenses/by-nc-sa/4.0/
|
| 243 |
+
|
| 244 |
+
### Citation Information
|
| 245 |
+
|
| 246 |
+
```
|
| 247 |
+
@article{kassner2021multilingual,
|
| 248 |
+
author = {Nora Kassner and
|
| 249 |
+
Philipp Dufter and
|
| 250 |
+
Hinrich Sch{\"{u}}tze},
|
| 251 |
+
title = {Multilingual {LAMA:} Investigating Knowledge in Multilingual Pretrained
|
| 252 |
+
Language Models},
|
| 253 |
+
journal = {CoRR},
|
| 254 |
+
volume = {abs/2102.00894},
|
| 255 |
+
year = {2021},
|
| 256 |
+
url = {https://arxiv.org/abs/2102.00894},
|
| 257 |
+
archivePrefix = {arXiv},
|
| 258 |
+
eprint = {2102.00894},
|
| 259 |
+
timestamp = {Tue, 09 Feb 2021 13:35:56 +0100},
|
| 260 |
+
biburl = {https://dblp.org/rec/journals/corr/abs-2102-00894.bib},
|
| 261 |
+
bibsource = {dblp computer science bibliography, https://dblp.org},
|
| 262 |
+
note = {to appear in EACL2021}
|
| 263 |
+
}
|
| 264 |
+
```
|
| 265 |
+
|
| 266 |
+
### Contributions
|
| 267 |
+
|
| 268 |
+
Thanks to [@pdufter](https://github.com/pdufter) for adding this dataset.
|
dataset_infos.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"all": {"description": "mLAMA: a multilingual version of the LAMA benchmark (T-REx and GoogleRE) covering 53 languages.", "citation": "\n@article{kassner2021multilingual,\n author = {Nora Kassner and\n Philipp Dufter and\n Hinrich Sch{\"{u}}tze},\n title = {Multilingual {LAMA:} Investigating Knowledge in Multilingual Pretrained\n Language Models},\n journal = {CoRR},\n volume = {abs/2102.00894},\n year = {2021},\n url = {https://arxiv.org/abs/2102.00894},\n archivePrefix = {arXiv},\n eprint = {2102.00894},\n timestamp = {Tue, 09 Feb 2021 13:35:56 +0100},\n biburl = {https://dblp.org/rec/journals/corr/abs-2102-00894.bib},\n bibsource = {dblp computer science bibliography, https://dblp.org},\n note = {to appear in EACL2021}\n}\n", "homepage": "http://cistern.cis.lmu.de/mlama/", "license": "The Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0). https://creativecommons.org/licenses/by-nc-sa/4.0/", "features": {"uuid": {"dtype": "string", "id": null, "_type": "Value"}, "lineid": {"dtype": "uint32", "id": null, "_type": "Value"}, "obj_uri": {"dtype": "string", "id": null, "_type": "Value"}, "obj_label": {"dtype": "string", "id": null, "_type": "Value"}, "sub_uri": {"dtype": "string", "id": null, "_type": "Value"}, "sub_label": {"dtype": "string", "id": null, "_type": "Value"}, "template": {"dtype": "string", "id": null, "_type": "Value"}, "language": {"dtype": "string", "id": null, "_type": "Value"}, "predicate_id": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "m_lama", "config_name": "all", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 125919995, "num_examples": 843143, "dataset_name": "m_lama"}}, "download_checksums": {"http://cistern.cis.lmu.de/mlama/mlama1.1.zip": {"num_bytes": 40772287, "checksum": "043dc82b1b4b72de10ec98fb3a75341af13a1b439f6ee8e769398f42bd6d5883"}}, "download_size": 40772287, "post_processing_size": null, "dataset_size": 125919995, "size_in_bytes": 166692282}}
|
dummy/all/1.1.0/dummy_data.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:88f979f6051f015349ff51138ae78f590791c3f5a981129ed45b996b494aa4c0
|
| 3 |
+
size 699202
|
m_lama.py
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
"""The mLAMA Dataset"""
|
| 16 |
+
|
| 17 |
+
from __future__ import absolute_import, division, print_function
|
| 18 |
+
|
| 19 |
+
import json
|
| 20 |
+
import os
|
| 21 |
+
|
| 22 |
+
import datasets
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
_CITATION = """
|
| 26 |
+
@article{kassner2021multilingual,
|
| 27 |
+
author = {Nora Kassner and
|
| 28 |
+
Philipp Dufter and
|
| 29 |
+
Hinrich Sch{\"{u}}tze},
|
| 30 |
+
title = {Multilingual {LAMA:} Investigating Knowledge in Multilingual Pretrained
|
| 31 |
+
Language Models},
|
| 32 |
+
journal = {CoRR},
|
| 33 |
+
volume = {abs/2102.00894},
|
| 34 |
+
year = {2021},
|
| 35 |
+
url = {https://arxiv.org/abs/2102.00894},
|
| 36 |
+
archivePrefix = {arXiv},
|
| 37 |
+
eprint = {2102.00894},
|
| 38 |
+
timestamp = {Tue, 09 Feb 2021 13:35:56 +0100},
|
| 39 |
+
biburl = {https://dblp.org/rec/journals/corr/abs-2102-00894.bib},
|
| 40 |
+
bibsource = {dblp computer science bibliography, https://dblp.org},
|
| 41 |
+
note = {to appear in EACL2021}
|
| 42 |
+
}
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
_DESCRIPTION = """mLAMA: a multilingual version of the LAMA benchmark (T-REx and GoogleRE) covering 53 languages."""
|
| 47 |
+
|
| 48 |
+
_HOMEPAGE = "http://cistern.cis.lmu.de/mlama/"
|
| 49 |
+
|
| 50 |
+
_LICENSE = "The Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0). https://creativecommons.org/licenses/by-nc-sa/4.0/"
|
| 51 |
+
|
| 52 |
+
_URL = "http://cistern.cis.lmu.de/mlama/mlama1.1.zip"
|
| 53 |
+
|
| 54 |
+
_LANGUAGES = (
|
| 55 |
+
"af",
|
| 56 |
+
"ar",
|
| 57 |
+
"az",
|
| 58 |
+
"be",
|
| 59 |
+
"bg",
|
| 60 |
+
"bn",
|
| 61 |
+
"ca",
|
| 62 |
+
"ceb",
|
| 63 |
+
"cs",
|
| 64 |
+
"cy",
|
| 65 |
+
"da",
|
| 66 |
+
"de",
|
| 67 |
+
"el",
|
| 68 |
+
"en",
|
| 69 |
+
"es",
|
| 70 |
+
"et",
|
| 71 |
+
"eu",
|
| 72 |
+
"fa",
|
| 73 |
+
"fi",
|
| 74 |
+
"fr",
|
| 75 |
+
"ga",
|
| 76 |
+
"gl",
|
| 77 |
+
"he",
|
| 78 |
+
"hi",
|
| 79 |
+
"hr",
|
| 80 |
+
"hu",
|
| 81 |
+
"hy",
|
| 82 |
+
"id",
|
| 83 |
+
"it",
|
| 84 |
+
"ja",
|
| 85 |
+
"ka",
|
| 86 |
+
"ko",
|
| 87 |
+
"la",
|
| 88 |
+
"lt",
|
| 89 |
+
"lv",
|
| 90 |
+
"ms",
|
| 91 |
+
"nl",
|
| 92 |
+
"pl",
|
| 93 |
+
"pt",
|
| 94 |
+
"ro",
|
| 95 |
+
"ru",
|
| 96 |
+
"sk",
|
| 97 |
+
"sl",
|
| 98 |
+
"sq",
|
| 99 |
+
"sr",
|
| 100 |
+
"sv",
|
| 101 |
+
"ta",
|
| 102 |
+
"th",
|
| 103 |
+
"tr",
|
| 104 |
+
"uk",
|
| 105 |
+
"ur",
|
| 106 |
+
"vi",
|
| 107 |
+
"zh",
|
| 108 |
+
)
|
| 109 |
+
_RELATIONS = (
|
| 110 |
+
"place_of_birth",
|
| 111 |
+
"place_of_death",
|
| 112 |
+
"P1001",
|
| 113 |
+
"P101",
|
| 114 |
+
"P103",
|
| 115 |
+
"P106",
|
| 116 |
+
"P108",
|
| 117 |
+
"P127",
|
| 118 |
+
"P1303",
|
| 119 |
+
"P131",
|
| 120 |
+
"P136",
|
| 121 |
+
"P1376",
|
| 122 |
+
"P138",
|
| 123 |
+
"P140",
|
| 124 |
+
"P1412",
|
| 125 |
+
"P159",
|
| 126 |
+
"P17",
|
| 127 |
+
"P176",
|
| 128 |
+
"P178",
|
| 129 |
+
"P19",
|
| 130 |
+
"P190",
|
| 131 |
+
"P20",
|
| 132 |
+
"P264",
|
| 133 |
+
"P27",
|
| 134 |
+
"P276",
|
| 135 |
+
"P279",
|
| 136 |
+
"P30",
|
| 137 |
+
"P31",
|
| 138 |
+
"P36",
|
| 139 |
+
"P361",
|
| 140 |
+
"P364",
|
| 141 |
+
"P37",
|
| 142 |
+
"P39",
|
| 143 |
+
"P407",
|
| 144 |
+
"P413",
|
| 145 |
+
"P449",
|
| 146 |
+
"P463",
|
| 147 |
+
"P47",
|
| 148 |
+
"P495",
|
| 149 |
+
"P527",
|
| 150 |
+
"P530",
|
| 151 |
+
"P740",
|
| 152 |
+
"P937",
|
| 153 |
+
)
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
class MLamaConfig(datasets.BuilderConfig):
|
| 157 |
+
"""BuilderConfig for mLAMA."""
|
| 158 |
+
|
| 159 |
+
def __init__(self, languages=None, relations=None, **kwargs):
|
| 160 |
+
"""BuilderConfig for mLAMA.
|
| 161 |
+
Args:
|
| 162 |
+
languages: A subset of af,ar,az,be,bg,bn,ca,ceb,cs,cy,da,de,el,en,es,et,eu,fa,fi,fr,ga,gl,he,hi,hr,hu,hy,id,it,ja,ka,ko,la,lt,lv,ms,nl,pl,pt,ro,ru,sk,sl,sq,sr,sv,ta,th,tr,uk,ur,vi,zh
|
| 163 |
+
relations: A subset of place_of_birth,place_of_death,P1001,P101,P103,P106,P108,P127,P1303,P131,P136,P1376,P138,P140,P1412,P159,P17,P176,P178,P19,P190,P20,P264,P27,P276,P279,P30,P31,P36,P361,P364,P37,P39,P407,P413,P449,P463,P47,P495,P527,P530,P740,P937
|
| 164 |
+
**kwargs: keyword arguments forwarded to super.
|
| 165 |
+
"""
|
| 166 |
+
super(MLamaConfig, self).__init__(**kwargs)
|
| 167 |
+
self.languages = languages if languages is not None else _LANGUAGES
|
| 168 |
+
self.relations = relations if relations is not None else _RELATIONS
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
class MLama(datasets.GeneratorBasedBuilder):
|
| 172 |
+
"""multilingual LAMA Dataset (mLAMA)"""
|
| 173 |
+
|
| 174 |
+
VERSION = datasets.Version("1.1.0")
|
| 175 |
+
BUILDER_CONFIG_CLASS = MLamaConfig
|
| 176 |
+
BUILDER_CONFIGS = [
|
| 177 |
+
MLamaConfig(
|
| 178 |
+
name="all",
|
| 179 |
+
languages=None,
|
| 180 |
+
relations=None,
|
| 181 |
+
version=datasets.Version("1.1.0"),
|
| 182 |
+
description="Import of mLAMA for all languages and all relations.",
|
| 183 |
+
)
|
| 184 |
+
]
|
| 185 |
+
|
| 186 |
+
def _info(self):
|
| 187 |
+
features = datasets.Features(
|
| 188 |
+
{
|
| 189 |
+
"uuid": datasets.Value("string"),
|
| 190 |
+
"lineid": datasets.Value("uint32"),
|
| 191 |
+
"obj_uri": datasets.Value("string"),
|
| 192 |
+
"obj_label": datasets.Value("string"),
|
| 193 |
+
"sub_uri": datasets.Value("string"),
|
| 194 |
+
"sub_label": datasets.Value("string"),
|
| 195 |
+
"template": datasets.Value("string"),
|
| 196 |
+
"language": datasets.Value("string"),
|
| 197 |
+
"predicate_id": datasets.Value("string"),
|
| 198 |
+
}
|
| 199 |
+
)
|
| 200 |
+
return datasets.DatasetInfo(
|
| 201 |
+
description=_DESCRIPTION,
|
| 202 |
+
features=features,
|
| 203 |
+
supervised_keys=None,
|
| 204 |
+
homepage=_HOMEPAGE,
|
| 205 |
+
license=_LICENSE,
|
| 206 |
+
citation=_CITATION,
|
| 207 |
+
)
|
| 208 |
+
|
| 209 |
+
def _split_generators(self, dl_manager):
|
| 210 |
+
"""Returns SplitGenerators."""
|
| 211 |
+
data_dir = dl_manager.download_and_extract(_URL)
|
| 212 |
+
return [
|
| 213 |
+
datasets.SplitGenerator(
|
| 214 |
+
name=datasets.Split.TEST,
|
| 215 |
+
gen_kwargs={
|
| 216 |
+
"filepath": os.path.join(data_dir, "mlama1.1"),
|
| 217 |
+
"split": "test",
|
| 218 |
+
},
|
| 219 |
+
),
|
| 220 |
+
]
|
| 221 |
+
|
| 222 |
+
def _generate_examples(self, filepath, split):
|
| 223 |
+
""" Yields examples from the mLAMA dataset. """
|
| 224 |
+
id_ = -1
|
| 225 |
+
for language in self.config.languages:
|
| 226 |
+
# load templates
|
| 227 |
+
templates = {}
|
| 228 |
+
with open(os.path.join(filepath, language, "templates.jsonl"), encoding="utf-8") as fp:
|
| 229 |
+
for line in fp:
|
| 230 |
+
line = json.loads(line)
|
| 231 |
+
templates[line["relation"]] = line["template"]
|
| 232 |
+
for relation in self.config.relations:
|
| 233 |
+
# load triples
|
| 234 |
+
with open(os.path.join(filepath, language, f"{relation}.jsonl"), encoding="utf-8") as fp:
|
| 235 |
+
for line in fp:
|
| 236 |
+
triple = json.loads(line)
|
| 237 |
+
triple["language"] = language
|
| 238 |
+
triple["predicate_id"] = relation
|
| 239 |
+
triple["template"] = templates.get(relation, "")
|
| 240 |
+
id_ += 1
|
| 241 |
+
yield id_, triple
|