Datasets:
Support latest HF datasets loading changes
Browse files- README.md +18 -9
- tigrinya-squad.py +0 -112
- data/Tigrinya-SQuAD-v1-train.json → train.parquet +2 -2
README.md
CHANGED
|
@@ -28,7 +28,7 @@ configs:
|
|
| 28 |
- config_name: default
|
| 29 |
data_files:
|
| 30 |
- split: train
|
| 31 |
-
path: "
|
| 32 |
---
|
| 33 |
|
| 34 |
# Tigrinya-SQuAD: Machine-Translated Training Dataset
|
|
@@ -61,18 +61,26 @@ Tigrinya-SQuAD is designed as training data for extractive question answering in
|
|
| 61 |
|
| 62 |
## How to Load Tigrinya-SQuAD
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
```python
|
| 65 |
from datasets import load_dataset
|
| 66 |
|
| 67 |
# Load the dataset
|
| 68 |
-
tigrinya_squad = load_dataset("fgaim/tigrinya-squad"
|
| 69 |
print(tigrinya_squad)
|
| 70 |
```
|
| 71 |
|
|
|
|
|
|
|
| 72 |
```python
|
| 73 |
DatasetDict({
|
| 74 |
train: Dataset({
|
| 75 |
-
features: ['id', '
|
| 76 |
num_rows: 46737
|
| 77 |
})
|
| 78 |
})
|
|
@@ -80,13 +88,14 @@ DatasetDict({
|
|
| 80 |
|
| 81 |
### Data Fields
|
| 82 |
|
| 83 |
-
- **`id`**: Unique identifier for each question
|
| 84 |
-
- **`
|
| 85 |
- **`context`**: The paragraph containing the answer (in Tigrinya)
|
| 86 |
-
- **`
|
| 87 |
-
-
|
| 88 |
-
- `
|
| 89 |
-
|
|
|
|
| 90 |
|
| 91 |
## Evaluation and Benchmarking
|
| 92 |
|
|
|
|
| 28 |
- config_name: default
|
| 29 |
data_files:
|
| 30 |
- split: train
|
| 31 |
+
path: "train.parquet"
|
| 32 |
---
|
| 33 |
|
| 34 |
# Tigrinya-SQuAD: Machine-Translated Training Dataset
|
|
|
|
| 61 |
|
| 62 |
## How to Load Tigrinya-SQuAD
|
| 63 |
|
| 64 |
+
Install the `datasets` library installed by running `pip install -U datasets` in the terminal.
|
| 65 |
+
|
| 66 |
+
> Make sure the latest `datasets` library is installed as older versions may not properly load the data.
|
| 67 |
+
|
| 68 |
+
Then pull and load the dataset using Python, as follows:
|
| 69 |
+
|
| 70 |
```python
|
| 71 |
from datasets import load_dataset
|
| 72 |
|
| 73 |
# Load the dataset
|
| 74 |
+
tigrinya_squad = load_dataset("fgaim/tigrinya-squad")
|
| 75 |
print(tigrinya_squad)
|
| 76 |
```
|
| 77 |
|
| 78 |
+
That will print the dataset features:
|
| 79 |
+
|
| 80 |
```python
|
| 81 |
DatasetDict({
|
| 82 |
train: Dataset({
|
| 83 |
+
features: ['id', 'question', 'context', 'answers', 'article_title', 'context_id'],
|
| 84 |
num_rows: 46737
|
| 85 |
})
|
| 86 |
})
|
|
|
|
| 88 |
|
| 89 |
### Data Fields
|
| 90 |
|
| 91 |
+
- **`id`**: Unique identifier for each question
|
| 92 |
+
- **`question`**: The question to be answered (in Tigrinya)
|
| 93 |
- **`context`**: The paragraph containing the answer (in Tigrinya)
|
| 94 |
+
- **`answers`**: A list of dictionaries of candidate answers, each entry containing:
|
| 95 |
+
- `text`: An answer string (training data has one answer per question)
|
| 96 |
+
- `answer_start`: A starting position of answer string in the context
|
| 97 |
+
- **`article_title`**: Title of the source article
|
| 98 |
+
- **`context_id`**: Unique identifier of the context in the data split
|
| 99 |
|
| 100 |
## Evaluation and Benchmarking
|
| 101 |
|
tigrinya-squad.py
DELETED
|
@@ -1,112 +0,0 @@
|
|
| 1 |
-
"""Tigrinya-SQuAD: Machine-Translated Training Dataset for Tigrinya Question Answering."""
|
| 2 |
-
|
| 3 |
-
import json
|
| 4 |
-
|
| 5 |
-
import datasets
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
_HOMEPAGE = "https://github.com/fgaim/tiquad"
|
| 9 |
-
|
| 10 |
-
_DESCRIPTION = """\
|
| 11 |
-
Tigrinya-SQuAD is a machine-translated and filtered version of the English SQuAD 1.1 training dataset,
|
| 12 |
-
automatically converted to Tigrinya for training question-answering models in low-resource settings.
|
| 13 |
-
This silver-standard dataset serves as training data only. For evaluation, use the gold-standard TiQuAD dataset.
|
| 14 |
-
"""
|
| 15 |
-
|
| 16 |
-
_CITATION = """\
|
| 17 |
-
@inproceedings{gaim-etal-2023-tiquad,
|
| 18 |
-
title = "{Question-Answering in a Low-resourced Language: Benchmark Dataset and Models for Tigrinya}",
|
| 19 |
-
author = "Fitsum Gaim and Wonsuk Yang and Hancheol Park and Jong C. Park",
|
| 20 |
-
booktitle = "Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
|
| 21 |
-
month = jul,
|
| 22 |
-
year = "2023",
|
| 23 |
-
address = "Toronto, Canada",
|
| 24 |
-
publisher = "Association for Computational Linguistics",
|
| 25 |
-
url = "https://aclanthology.org/2023.acl-long.661",
|
| 26 |
-
pages = "11857--11870",
|
| 27 |
-
}
|
| 28 |
-
"""
|
| 29 |
-
|
| 30 |
-
_LICENSE = "Creative Commons Attribution-ShareAlike 4.0"
|
| 31 |
-
|
| 32 |
-
_DATA_PATHS = {
|
| 33 |
-
"train": "data/Tigrinya-SQuAD-v1-train.json",
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
class TigrinyaSQuADConfig(datasets.BuilderConfig):
|
| 38 |
-
"""BuilderConfig for Tigrinya-SQuAD"""
|
| 39 |
-
|
| 40 |
-
def __init__(self, **kwargs):
|
| 41 |
-
"""BuilderConfig for Tigrinya-SQuAD.
|
| 42 |
-
Args:
|
| 43 |
-
**kwargs: keyword arguments forwarded to super.
|
| 44 |
-
"""
|
| 45 |
-
super(TigrinyaSQuADConfig, self).__init__(**kwargs)
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
class TigrinyaSQuAD(datasets.GeneratorBasedBuilder):
|
| 49 |
-
"""Tigrinya-SQuAD dataset."""
|
| 50 |
-
|
| 51 |
-
VERSION = datasets.Version("1.0.0")
|
| 52 |
-
|
| 53 |
-
def _info(self):
|
| 54 |
-
return datasets.DatasetInfo(
|
| 55 |
-
description=_DESCRIPTION,
|
| 56 |
-
features=datasets.Features(
|
| 57 |
-
{
|
| 58 |
-
"id": datasets.Value("string"),
|
| 59 |
-
"title": datasets.Value("string"),
|
| 60 |
-
"context": datasets.Value("string"),
|
| 61 |
-
"question": datasets.Value("string"),
|
| 62 |
-
"answers": datasets.features.Sequence(
|
| 63 |
-
{
|
| 64 |
-
"text": datasets.Value("string"),
|
| 65 |
-
"answer_start": datasets.Value("int32"),
|
| 66 |
-
}
|
| 67 |
-
),
|
| 68 |
-
}
|
| 69 |
-
),
|
| 70 |
-
homepage=_HOMEPAGE,
|
| 71 |
-
citation=_CITATION,
|
| 72 |
-
license=_LICENSE,
|
| 73 |
-
)
|
| 74 |
-
|
| 75 |
-
def _split_generators(self, dl_manager):
|
| 76 |
-
"""Returns SplitGenerators."""
|
| 77 |
-
downloaded_files = dl_manager.download_and_extract(_DATA_PATHS)
|
| 78 |
-
|
| 79 |
-
return [
|
| 80 |
-
datasets.SplitGenerator(
|
| 81 |
-
name=datasets.Split.TRAIN,
|
| 82 |
-
gen_kwargs={"filepath": downloaded_files["train"]},
|
| 83 |
-
)
|
| 84 |
-
]
|
| 85 |
-
|
| 86 |
-
def _generate_examples(self, filepath):
|
| 87 |
-
"""Yields Tigrinya-SQuAD examples."""
|
| 88 |
-
with open(filepath, encoding="utf-8") as fin:
|
| 89 |
-
squad_data = json.load(fin)
|
| 90 |
-
for example in squad_data["data"]:
|
| 91 |
-
title = example.get("title", "")
|
| 92 |
-
for paragraph in example["paragraphs"]:
|
| 93 |
-
context = paragraph["context"]
|
| 94 |
-
for qa in paragraph["qas"]:
|
| 95 |
-
_id = qa["id"]
|
| 96 |
-
answers = [
|
| 97 |
-
{
|
| 98 |
-
"text": answer["text"],
|
| 99 |
-
"answer_start": answer["answer_start"],
|
| 100 |
-
}
|
| 101 |
-
for answer in qa["answers"]
|
| 102 |
-
]
|
| 103 |
-
yield (
|
| 104 |
-
_id,
|
| 105 |
-
{
|
| 106 |
-
"id": _id,
|
| 107 |
-
"title": title,
|
| 108 |
-
"context": context,
|
| 109 |
-
"question": qa["question"],
|
| 110 |
-
"answers": answers,
|
| 111 |
-
},
|
| 112 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/Tigrinya-SQuAD-v1-train.json → train.parquet
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fdcffffc2b444d1f58d6ead29c30c4877270c176465f7feb1b9a1c230b7a54bb
|
| 3 |
+
size 14803675
|