File size: 4,804 Bytes
daa4d09 33c85d1 14578c1 ff58907 2524267 daa4d09 33c85d1 062a7df 33c85d1 4e56abb ae6ab35 33c85d1 0d1a85b eabc2c6 33c85d1 f544d0b c3e1eb7 78157fc c3e1eb7 78157fc c3e1eb7 33c85d1 fcffc0e 76fad4d cc21ada fcffc0e cc21ada fcffc0e cc21ada fcffc0e cc21ada fcffc0e cc21ada fcffc0e cc21ada fcffc0e cc21ada fcffc0e 76fad4d fcffc0e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
---
dataset_info:
features:
- name: question
dtype: string
- name: context
dtype: string
- name: score
dtype: float64
- name: id
dtype: string
- name: title
dtype: string
- name: answers
struct:
- name: answer_start
sequence: int64
- name: text
sequence: string
splits:
- name: train
num_bytes: 127996360
num_examples: 130319
- name: dev
num_bytes: 10772220
num_examples: 10174
- name: test
num_bytes: 1792665
num_examples: 1699
download_size: 18702176
dataset_size: 140561245
configs:
- config_name: default
data_files:
- split: train
path: data/train-*
- split: dev
path: data/dev-*
- split: test
path: data/test-*
license: cc-by-sa-4.0
language:
- nl
task_categories:
- sentence-similarity
- question-answering
tags:
- sentence-transformers
pretty_name: SQuAD-NL v2.0 for Sentence TGransformers
---
# SQuAD-NL v2.0 for Sentence Transformers
The [SQuAD-NL v2.0](https://github.com/wietsedv/NLP-NL/tree/squad-nl-v1.0?tab=readme-ov-file#-squad-nl-translated-squad--xquad-question-answering) dataset (on Hugging Face: [GroNLP/squad-nl-v2.0](https://huggingface.co/datasets/GroNLP/squad-nl-v2.0)), modified for use in [Sentence Transformers](https://sbert.net/docs/sentence_transformer/dataset_overview.html) as a dataset of type "Pair with Similarity Score".
## Score
We added an extra column `score` to the original dataset.
The value of `score` is `1.0` if the question has an answer in the context (no matter where), and `0.0` if there are no answers in the context.
The allows the evaluation of embedding models that aim to pair queries and document fragments.
Please note that is a very hard task for embedding models, because SQuAD v2.0 was specifically designed to contain unanswerable questions adversarially written to look similar to answerable ones.
Expect your models to perform poorly.
## Translations
SQuAD-NL is translated from the original [SQuAD](https://rajpurkar.github.io/SQuAD-explorer/) and [XQuAD](https://github.com/google-deepmind/xquad) English-language datasets.
From the [SQuAD-NL v2.0 Readme](https://github.com/wietsedv/NLP-NL/tree/squad-nl-v1.0?tab=readme-ov-file#v20):
| Split | Source | Procedure | English | Dutch |
| ----- | ---------------------- | ------------------------ | ------: | ------: |
| train | SQuAD-train-v2.0 | Google Translate | 130,319 | 130,319 |
| dev | SQuAD-dev-v2.0 \ XQuAD | Google Translate | 10,174 | 10,174 |
| test | SQuAD-dev-v2.0 & XQuAD | Google Translate + Human | 1,699 | 1,699 |
For testing Dutch sentence embedding models it is therefore recommended to only use the `test` split.
Also it would be advisable to not train your model on the other splits, because you would train answering this specific style of questions into the model.
## Example code using Sentence Transformers
```python
import pprint
from datasets import load_dataset
from sentence_transformers import SentenceTransformer
from sentence_transformers.evaluation import EmbeddingSimilarityEvaluator, SimilarityFunction
eval_dataset = load_dataset('NetherlandsForensicInstitute/squad-nl-v2.0', split='test')
evaluator = EmbeddingSimilarityEvaluator(
sentences1=eval_dataset['question'],
sentences2=eval_dataset['context'],
scores=eval_dataset['score'],
main_similarity=SimilarityFunction.COSINE,
name="squad_nl_v2.0_test",
)
model = SentenceTransformer('NetherlandsForensicInstitute/robbert-2022-dutch-sentence-transformers')
results = evaluator(model)
pprint.pprint(results)
```
## Original dataset
SQuAD-NL is a derivative of the [SQuAD](https://rajpurkar.github.io/SQuAD-explorer/) and [XQuAD](https://github.com/google-deepmind/xquad) datasets, and their original [CC BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/legalcode) licenses apply.
## Code used to generate this dataset
<details>
<summary>code</summary>
```python
import json
import requests
from datasets import Dataset, DatasetDict
def squad(url):
response = requests.get(url)
rows = json.loads(response.text)['data']
for row in rows:
yield {'question': row['question'],
'context': row['context'],
'score': 1.0 if row['answers']['text'] else 0.,
'id': row['id'],
'title': row['title'],
'answers': row['answers']}
if __name__ == '__main__':
url = 'https://github.com/wietsedv/NLP-NL/raw/refs/tags/squad-nl-v1.0/SQuAD-NL/nl/{split}-v2.0.json'
dataset = DatasetDict({
split: Dataset.from_generator(squad, gen_kwargs={'url': url.format(split=split)})
for split in ('train', 'dev', 'test')
})
dataset.push_to_hub('NetherlandsForensicInstitute/squad-nl-v2.0')
```
</details> |