Commit
•
50ce175
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +196 -0
- dataset_infos.json +1 -0
- dummy/labeled_final/1.1.0/dummy_data.zip +3 -0
- dummy/labeled_swap/1.1.0/dummy_data.zip +3 -0
- dummy/unlabeled_final/1.1.0/dummy_data.zip +3 -0
- paws.py +209 -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,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
labeled_final:
|
4 |
+
- expert-generated
|
5 |
+
labeled_swap:
|
6 |
+
- expert-generated
|
7 |
+
unlabeled_final:
|
8 |
+
- machine-generated
|
9 |
+
language_creators:
|
10 |
+
- machine-generated
|
11 |
+
languages:
|
12 |
+
- en
|
13 |
+
licenses:
|
14 |
+
- other
|
15 |
+
multilinguality:
|
16 |
+
- monolingual
|
17 |
+
size_categories:
|
18 |
+
labeled_final:
|
19 |
+
- 10K<n<100K
|
20 |
+
labeled_swap:
|
21 |
+
- 10K<n<100K
|
22 |
+
unlabeled_final:
|
23 |
+
- 100K<n<1M
|
24 |
+
source_datasets:
|
25 |
+
- original
|
26 |
+
task_categories:
|
27 |
+
- text-classification
|
28 |
+
- text-scoring
|
29 |
+
task_ids:
|
30 |
+
- semantic-similarity-classification
|
31 |
+
- semantic-similarity-scoring
|
32 |
+
- text-scoring-other-paraphrase-identification
|
33 |
+
---
|
34 |
+
|
35 |
+
# Dataset Card Creation Guide
|
36 |
+
|
37 |
+
## Table of Contents
|
38 |
+
- [Dataset Description](#dataset-description)
|
39 |
+
- [Dataset Summary](#dataset-summary)
|
40 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
41 |
+
- [Languages](#languages)
|
42 |
+
- [Dataset Structure](#dataset-structure)
|
43 |
+
- [Data Instances](#data-instances)
|
44 |
+
- [Data Fields](#data-fields)
|
45 |
+
- [Data Splits](#data-splits)
|
46 |
+
- [Dataset Creation](#dataset-creation)
|
47 |
+
- [Curation Rationale](#curation-rationale)
|
48 |
+
- [Source Data](#source-data)
|
49 |
+
- [Annotations](#annotations)
|
50 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
51 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
52 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
53 |
+
- [Discussion of Biases](#discussion-of-biases)
|
54 |
+
- [Other Known Limitations](#other-known-limitations)
|
55 |
+
- [Additional Information](#additional-information)
|
56 |
+
- [Dataset Curators](#dataset-curators)
|
57 |
+
- [Licensing Information](#licensing-information)
|
58 |
+
- [Citation Information](#citation-information)
|
59 |
+
|
60 |
+
## Dataset Description
|
61 |
+
|
62 |
+
- **Homepage:** [PAWS](https://github.com/google-research-datasets/paws)
|
63 |
+
- **Repository:** [PAWS](https://github.com/google-research-datasets/paws)
|
64 |
+
- **Paper:** [PAWS: Paraphrase Adversaries from Word Scrambling](https://arxiv.org/abs/1904.01130)
|
65 |
+
- **Point of Contact:** [Yuan Zhang]([email protected])
|
66 |
+
|
67 |
+
### Dataset Summary
|
68 |
+
|
69 |
+
PAWS: Paraphrase Adversaries from Word Scrambling
|
70 |
+
|
71 |
+
This dataset contains 108,463 human-labeled and 656k noisily labeled pairs that feature the importance of modeling structure, context, and word order information for the problem of paraphrase identification. The dataset has two subsets, one based on Wikipedia and the other one based on the Quora Question Pairs (QQP) dataset.
|
72 |
+
|
73 |
+
For further details, see the accompanying paper: PAWS: Paraphrase Adversaries from Word Scrambling (https://arxiv.org/abs/1904.01130)
|
74 |
+
|
75 |
+
PAWS-QQP is not available due to license of QQP. It must be reconstructed by downloading the original data and then running our scripts to produce the data and attach the labels.
|
76 |
+
|
77 |
+
### Supported Tasks and Leaderboards
|
78 |
+
|
79 |
+
[More Information Needed]
|
80 |
+
|
81 |
+
### Languages
|
82 |
+
|
83 |
+
The text in the dataset is in English.
|
84 |
+
|
85 |
+
## Dataset Structure
|
86 |
+
|
87 |
+
### Data Instances
|
88 |
+
|
89 |
+
Below are two examples from the dataset:
|
90 |
+
|
91 |
+
| | Sentence 1 | Sentence 2 | Label |
|
92 |
+
| :-- | :---------------------------- | :---------------------------- | :---- |
|
93 |
+
| (1) | Although interchangeable, the body pieces on the 2 cars are not similar. | Although similar, the body parts are not interchangeable on the 2 cars. | 0 |
|
94 |
+
| (2) | Katz was born in Sweden in 1947 and moved to New York City at the age of 1. | Katz was born in 1947 in Sweden and moved to New York at the age of one. | 1 |
|
95 |
+
|
96 |
+
The first pair has different semantic meaning while the second pair is a paraphrase. State-of-the-art models trained on existing datasets have dismal performance on PAWS (<40% accuracy); however, including PAWS training data for these models improves their accuracy to 85% while maintaining performance on existing datasets such as the [Quora Question Pairs](https://data.quora.com/First-Quora-Dataset-Release-Question-Pairs).
|
97 |
+
|
98 |
+
|
99 |
+
### Data Fields
|
100 |
+
|
101 |
+
This corpus contains pairs generated from Wikipedia pages, and can be downloaded
|
102 |
+
here:
|
103 |
+
|
104 |
+
* **PAWS-Wiki Labeled (Final)**: containing pairs that are generated from both word swapping and back translation methods. All pairs have human judgements on both paraphrasing and fluency and they are split into Train/Dev/Test sections.
|
105 |
+
|
106 |
+
* **PAWS-Wiki Labeled (Swap-only)**: containing pairs that have no back translation counterparts and therefore they are not included in the first set. Nevertheless, they are high-quality pairs with human judgements on both paraphrasing and fluency, and they can be included as an auxiliary training set.
|
107 |
+
|
108 |
+
* **PAWS-Wiki Unlabeled (Final)**: Pairs in this set have noisy labels without human judgments and can also be used as an auxiliary training set. They are generated from both word swapping and back translation methods.
|
109 |
+
|
110 |
+
All files are in the tsv format with four columns:
|
111 |
+
|
112 |
+
Column Name | Data
|
113 |
+
:------------ | :--------------------------
|
114 |
+
id | A unique id for each pair
|
115 |
+
sentence1 | The first sentence
|
116 |
+
sentence2 | The second sentence
|
117 |
+
(noisy_)label | (Noisy) label for each pair
|
118 |
+
|
119 |
+
Each label has two possible values: `0` indicates the pair has different meaning, while `1` indicates the pair is a paraphrase.
|
120 |
+
|
121 |
+
|
122 |
+
### Data Splits
|
123 |
+
|
124 |
+
The number of examples and the proportion of paraphrase (Yes%) pairs are shown
|
125 |
+
below:
|
126 |
+
|
127 |
+
Data | Train | Dev | Test | Yes%
|
128 |
+
:------------------ | ------: | -----: | ----: | ----:
|
129 |
+
Labeled (Final) | 49,401 | 8,000 | 8,000 | 44.2%
|
130 |
+
Labeled (Swap-only) | 30,397 | -- | -- | 9.6%
|
131 |
+
Unlabeled (Final) | 645,652 | 10,000 | -- | 50.0%
|
132 |
+
|
133 |
+
## Dataset Creation
|
134 |
+
|
135 |
+
### Curation Rationale
|
136 |
+
|
137 |
+
Existing paraphrase identification datasets lack sentence pairs that have high lexical overlap without being paraphrases. Models trained on such data fail to distinguish pairs like *flights from New York to Florida* and *flights from Florida to New York*.
|
138 |
+
|
139 |
+
### Source Data
|
140 |
+
|
141 |
+
#### Initial Data Collection and Normalization
|
142 |
+
|
143 |
+
Their automatic generation method is based on two ideas. The first swaps words to generate a sentence pair with the same BOW, controlled by a language model. The second uses back translation to generate paraphrases with high BOW overlap but different word order. These two strategies generate high-quality, diverse PAWS pairs, balanced evenly between paraphrases and non-paraphrases.
|
144 |
+
|
145 |
+
#### Who are the source language producers?
|
146 |
+
|
147 |
+
Mentioned above.
|
148 |
+
|
149 |
+
### Annotations
|
150 |
+
|
151 |
+
#### Annotation process
|
152 |
+
|
153 |
+
Sentence pairs are presented to five annotators, each of which gives a binary judgment as to whether they are paraphrases or not. They chose binary judgments to make dataset have the same label schema as the QQP corpus. Overall, human agreement is high on both Quora (92.0%) and Wikipedia (94.7%) and each label only takes about 24 seconds. As such, answers are usually straight-forward to human raters.
|
154 |
+
|
155 |
+
#### Who are the annotators?
|
156 |
+
|
157 |
+
[More Information Needed]
|
158 |
+
|
159 |
+
### Personal and Sensitive Information
|
160 |
+
|
161 |
+
[More Information Needed]
|
162 |
+
|
163 |
+
## Considerations for Using the Data
|
164 |
+
|
165 |
+
### Social Impact of Dataset
|
166 |
+
|
167 |
+
[More Information Needed]
|
168 |
+
|
169 |
+
### Discussion of Biases
|
170 |
+
|
171 |
+
[More Information Needed]
|
172 |
+
|
173 |
+
### Other Known Limitations
|
174 |
+
|
175 |
+
[More Information Needed]
|
176 |
+
|
177 |
+
## Additional Information
|
178 |
+
|
179 |
+
### Dataset Curators
|
180 |
+
|
181 |
+
List the people involved in collecting the dataset and their affiliation(s). If funding information is known, include it here.
|
182 |
+
|
183 |
+
### Licensing Information
|
184 |
+
|
185 |
+
The dataset may be freely used for any purpose, although acknowledgement of Google LLC ("Google") as the data source would be appreciated. The dataset is provided "AS IS" without any warranty, express or implied. Google disclaims all liability for any damages, direct or indirect, resulting from the use of the dataset.
|
186 |
+
|
187 |
+
### Citation Information
|
188 |
+
|
189 |
+
```
|
190 |
+
@InProceedings{paws2019naacl,
|
191 |
+
title = {{PAWS: Paraphrase Adversaries from Word Scrambling}},
|
192 |
+
author = {Zhang, Yuan and Baldridge, Jason and He, Luheng},
|
193 |
+
booktitle = {Proc. of NAACL},
|
194 |
+
year = {2019}
|
195 |
+
}
|
196 |
+
```
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"labeled_final": {"description": "PAWS: Paraphrase Adversaries from Word Scrambling\n\nThis dataset contains 108,463 human-labeled and 656k noisily labeled pairs that feature\nthe importance of modeling structure, context, and word order information for the problem\nof paraphrase identification. The dataset has two subsets, one based on Wikipedia and the\nother one based on the Quora Question Pairs (QQP) dataset.\n\nFor further details, see the accompanying paper: PAWS: Paraphrase Adversaries from Word Scrambling\n(https://arxiv.org/abs/1904.01130)\n\nPAWS-QQP is not available due to license of QQP. It must be reconstructed by downloading the original\ndata and then running our scripts to produce the data and attach the labels.\n\nNOTE: There might be some missing or wrong labels in the dataset and we have replaced them with -1.\n", "citation": "@InProceedings{paws2019naacl,\n title = {{PAWS: Paraphrase Adversaries from Word Scrambling}},\n author = {Zhang, Yuan and Baldridge, Jason and He, Luheng},\n booktitle = {Proc. of NAACL},\n year = {2019}\n}\n", "homepage": "https://github.com/google-research-datasets/paws", "license": "The dataset may be freely used for any purpose, although acknowledgement of Google LLC (\"Google\") as the data source would be appreciated. The dataset is provided \"AS IS\" without any warranty, express or implied. Google disclaims all liability for any damages, direct or indirect, resulting from the use of the dataset.", "features": {"id": {"dtype": "int32", "id": null, "_type": "Value"}, "sentence1": {"dtype": "string", "id": null, "_type": "Value"}, "sentence2": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 2, "names": ["0", "1"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "builder_name": "paws", "config_name": "labeled_final", "version": {"version_str": "1.1.0", "description": "", "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 12239978, "num_examples": 49401, "dataset_name": "paws"}, "test": {"name": "test", "num_bytes": 1987802, "num_examples": 8000, "dataset_name": "paws"}, "validation": {"name": "validation", "num_bytes": 1975870, "num_examples": 8000, "dataset_name": "paws"}}, "download_checksums": {"https://storage.googleapis.com/paws/english/paws_wiki_labeled_final.tar.gz": {"num_bytes": 4687157, "checksum": "1aad6cbb8a90b15563a0c154752c2b2c8e3bc5bdaa125172214d598bc76bc9fd"}}, "download_size": 4687157, "post_processing_size": null, "dataset_size": 16203650, "size_in_bytes": 20890807}, "labeled_swap": {"description": "PAWS: Paraphrase Adversaries from Word Scrambling\n\nThis dataset contains 108,463 human-labeled and 656k noisily labeled pairs that feature\nthe importance of modeling structure, context, and word order information for the problem\nof paraphrase identification. The dataset has two subsets, one based on Wikipedia and the\nother one based on the Quora Question Pairs (QQP) dataset.\n\nFor further details, see the accompanying paper: PAWS: Paraphrase Adversaries from Word Scrambling\n(https://arxiv.org/abs/1904.01130)\n\nPAWS-QQP is not available due to license of QQP. It must be reconstructed by downloading the original\ndata and then running our scripts to produce the data and attach the labels.\n\nNOTE: There might be some missing or wrong labels in the dataset and we have replaced them with -1.\n", "citation": "@InProceedings{paws2019naacl,\n title = {{PAWS: Paraphrase Adversaries from Word Scrambling}},\n author = {Zhang, Yuan and Baldridge, Jason and He, Luheng},\n booktitle = {Proc. of NAACL},\n year = {2019}\n}\n", "homepage": "https://github.com/google-research-datasets/paws", "license": "The dataset may be freely used for any purpose, although acknowledgement of Google LLC (\"Google\") as the data source would be appreciated. The dataset is provided \"AS IS\" without any warranty, express or implied. Google disclaims all liability for any damages, direct or indirect, resulting from the use of the dataset.", "features": {"id": {"dtype": "int32", "id": null, "_type": "Value"}, "sentence1": {"dtype": "string", "id": null, "_type": "Value"}, "sentence2": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 2, "names": ["0", "1"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "builder_name": "paws", "config_name": "labeled_swap", "version": {"version_str": "1.1.0", "description": "", "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 7963651, "num_examples": 30397, "dataset_name": "paws"}}, "download_checksums": {"https://storage.googleapis.com/paws/english/paws_wiki_labeled_swap.tar.gz": {"num_bytes": 2257283, "checksum": "886ddb2f7f7499b2f64d260956ebbd6e14fc436eadac56cdbb966831b00d7861"}}, "download_size": 2257283, "post_processing_size": null, "dataset_size": 7963651, "size_in_bytes": 10220934}, "unlabeled_final": {"description": "PAWS: Paraphrase Adversaries from Word Scrambling\n\nThis dataset contains 108,463 human-labeled and 656k noisily labeled pairs that feature\nthe importance of modeling structure, context, and word order information for the problem\nof paraphrase identification. The dataset has two subsets, one based on Wikipedia and the\nother one based on the Quora Question Pairs (QQP) dataset.\n\nFor further details, see the accompanying paper: PAWS: Paraphrase Adversaries from Word Scrambling\n(https://arxiv.org/abs/1904.01130)\n\nPAWS-QQP is not available due to license of QQP. It must be reconstructed by downloading the original\ndata and then running our scripts to produce the data and attach the labels.\n\nNOTE: There might be some missing or wrong labels in the dataset and we have replaced them with -1.\n", "citation": "@InProceedings{paws2019naacl,\n title = {{PAWS: Paraphrase Adversaries from Word Scrambling}},\n author = {Zhang, Yuan and Baldridge, Jason and He, Luheng},\n booktitle = {Proc. of NAACL},\n year = {2019}\n}\n", "homepage": "https://github.com/google-research-datasets/paws", "license": "The dataset may be freely used for any purpose, although acknowledgement of Google LLC (\"Google\") as the data source would be appreciated. The dataset is provided \"AS IS\" without any warranty, express or implied. Google disclaims all liability for any damages, direct or indirect, resulting from the use of the dataset.", "features": {"id": {"dtype": "int32", "id": null, "_type": "Value"}, "sentence1": {"dtype": "string", "id": null, "_type": "Value"}, "sentence2": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 2, "names": ["0", "1"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "builder_name": "paws", "config_name": "unlabeled_final", "version": {"version_str": "1.1.0", "description": "", "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 157806996, "num_examples": 645652, "dataset_name": "paws"}, "validation": {"name": "validation", "num_bytes": 2442173, "num_examples": 10000, "dataset_name": "paws"}}, "download_checksums": {"https://storage.googleapis.com/paws/english/paws_wiki_unlabeled_final.tar.gz": {"num_bytes": 47393331, "checksum": "c70222d390ece5218e397b3ea4b3797212ffe945fe1eae088fa6cb317c2ca3c6"}}, "download_size": 47393331, "post_processing_size": null, "dataset_size": 160249169, "size_in_bytes": 207642500}}
|
dummy/labeled_final/1.1.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dd79a3019efdeaff75ffd8e48e0457b307b4f65ac0d6c896b9d6410f3ac5266c
|
3 |
+
size 2306
|
dummy/labeled_swap/1.1.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:08140f0e1728e33b840fa54bda8d7776e44496b2f5a2899aa2b91e1f753bc0a0
|
3 |
+
size 995
|
dummy/unlabeled_final/1.1.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2dc312b5b0350443ef4ca377748b76f05ee806752aad3550818fd8ede9f41161
|
3 |
+
size 1867
|
paws.py
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"""PAWS, a dataset for paraphrase identification"""
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import csv
|
20 |
+
import os
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
|
25 |
+
_CITATION = """\
|
26 |
+
@InProceedings{paws2019naacl,
|
27 |
+
title = {{PAWS: Paraphrase Adversaries from Word Scrambling}},
|
28 |
+
author = {Zhang, Yuan and Baldridge, Jason and He, Luheng},
|
29 |
+
booktitle = {Proc. of NAACL},
|
30 |
+
year = {2019}
|
31 |
+
}
|
32 |
+
"""
|
33 |
+
|
34 |
+
_DESCRIPTION = """\
|
35 |
+
PAWS: Paraphrase Adversaries from Word Scrambling
|
36 |
+
|
37 |
+
This dataset contains 108,463 human-labeled and 656k noisily labeled pairs that feature
|
38 |
+
the importance of modeling structure, context, and word order information for the problem
|
39 |
+
of paraphrase identification. The dataset has two subsets, one based on Wikipedia and the
|
40 |
+
other one based on the Quora Question Pairs (QQP) dataset.
|
41 |
+
|
42 |
+
For further details, see the accompanying paper: PAWS: Paraphrase Adversaries from Word Scrambling
|
43 |
+
(https://arxiv.org/abs/1904.01130)
|
44 |
+
|
45 |
+
PAWS-QQP is not available due to license of QQP. It must be reconstructed by downloading the original
|
46 |
+
data and then running our scripts to produce the data and attach the labels.
|
47 |
+
|
48 |
+
NOTE: There might be some missing or wrong labels in the dataset and we have replaced them with -1.
|
49 |
+
"""
|
50 |
+
|
51 |
+
_HOMEPAGE = "https://github.com/google-research-datasets/paws"
|
52 |
+
|
53 |
+
_LICENSE = 'The dataset may be freely used for any purpose, although acknowledgement of Google LLC ("Google") as the data source would be appreciated. The dataset is provided "AS IS" without any warranty, express or implied. Google disclaims all liability for any damages, direct or indirect, resulting from the use of the dataset.'
|
54 |
+
|
55 |
+
_DATA_OPTIONS = [
|
56 |
+
"labeled_final",
|
57 |
+
"labeled_swap",
|
58 |
+
"unlabeled_final",
|
59 |
+
]
|
60 |
+
|
61 |
+
|
62 |
+
class PAWSConfig(datasets.BuilderConfig):
|
63 |
+
"""BuilderConfig for PAWS."""
|
64 |
+
|
65 |
+
def __init__(self, **kwargs):
|
66 |
+
"""Constructs a PAWSConfig.
|
67 |
+
Args:
|
68 |
+
**kwargs: keyword arguments forwarded to super.
|
69 |
+
"""
|
70 |
+
super(PAWSConfig, self).__init__(version=datasets.Version("1.1.0", ""), **kwargs),
|
71 |
+
|
72 |
+
|
73 |
+
class PAWS(datasets.GeneratorBasedBuilder):
|
74 |
+
"""PAWS, a dataset for paraphrase identification"""
|
75 |
+
|
76 |
+
VERSION = datasets.Version("1.1.0")
|
77 |
+
|
78 |
+
BUILDER_CONFIGS = [
|
79 |
+
PAWSConfig(
|
80 |
+
name=config_name,
|
81 |
+
description=(f"This config contains samples of {config_name}."),
|
82 |
+
)
|
83 |
+
for config_name in _DATA_OPTIONS
|
84 |
+
]
|
85 |
+
|
86 |
+
def _info(self):
|
87 |
+
features = datasets.Features(
|
88 |
+
{
|
89 |
+
"id": datasets.Value("int32"),
|
90 |
+
"sentence1": datasets.Value("string"),
|
91 |
+
"sentence2": datasets.Value("string"),
|
92 |
+
"label": datasets.features.ClassLabel(names=["0", "1"]),
|
93 |
+
}
|
94 |
+
)
|
95 |
+
return datasets.DatasetInfo(
|
96 |
+
# This is the description that will appear on the datasets page.
|
97 |
+
description=_DESCRIPTION,
|
98 |
+
# This defines the different columns of the dataset and their types
|
99 |
+
features=features, # Here we define them above because they are different between the two configurations
|
100 |
+
# If there's a common (input, target) tuple from the features,
|
101 |
+
# specify them here. They'll be used if as_supervised=True in
|
102 |
+
# builder.as_dataset.
|
103 |
+
supervised_keys=None,
|
104 |
+
# Homepage of the dataset for documentation
|
105 |
+
homepage=_HOMEPAGE,
|
106 |
+
# License for the dataset if available
|
107 |
+
license=_LICENSE,
|
108 |
+
# Citation for the dataset
|
109 |
+
citation=_CITATION,
|
110 |
+
)
|
111 |
+
|
112 |
+
def _split_generators(self, dl_manager):
|
113 |
+
"""Returns SplitGenerators."""
|
114 |
+
|
115 |
+
_DATA_URL = f"https://storage.googleapis.com/paws/english/paws_wiki_{self.config.name}.tar.gz"
|
116 |
+
data_dir = dl_manager.download_and_extract(_DATA_URL)
|
117 |
+
|
118 |
+
if self.config.name == "labeled_final":
|
119 |
+
_TRAIN_FILE_NAME = os.path.join(data_dir, "final", "train.tsv")
|
120 |
+
_VAL_FILE_NAME = os.path.join(data_dir, "final", "dev.tsv")
|
121 |
+
_TEST_FILE_NAME = os.path.join(data_dir, "final", "test.tsv")
|
122 |
+
return [
|
123 |
+
datasets.SplitGenerator(
|
124 |
+
name=datasets.Split.TRAIN,
|
125 |
+
# These kwargs will be passed to _generate_examples
|
126 |
+
gen_kwargs={
|
127 |
+
"filepath": _TRAIN_FILE_NAME,
|
128 |
+
"split": datasets.Split.TRAIN,
|
129 |
+
},
|
130 |
+
),
|
131 |
+
datasets.SplitGenerator(
|
132 |
+
name=datasets.Split.TEST,
|
133 |
+
# These kwargs will be passed to _generate_examples
|
134 |
+
gen_kwargs={
|
135 |
+
"filepath": _TEST_FILE_NAME,
|
136 |
+
"split": datasets.Split.TEST,
|
137 |
+
},
|
138 |
+
),
|
139 |
+
datasets.SplitGenerator(
|
140 |
+
name=datasets.Split.VALIDATION,
|
141 |
+
# These kwargs will be passed to _generate_examples
|
142 |
+
gen_kwargs={
|
143 |
+
"filepath": _VAL_FILE_NAME,
|
144 |
+
"split": datasets.Split.VALIDATION,
|
145 |
+
},
|
146 |
+
),
|
147 |
+
]
|
148 |
+
|
149 |
+
elif self.config.name == "labeled_swap":
|
150 |
+
_TRAIN_FILE_NAME = os.path.join(data_dir, "swap", "train.tsv")
|
151 |
+
return [
|
152 |
+
datasets.SplitGenerator(
|
153 |
+
name=datasets.Split.TRAIN,
|
154 |
+
# These kwargs will be passed to _generate_examples
|
155 |
+
gen_kwargs={
|
156 |
+
"filepath": _TRAIN_FILE_NAME,
|
157 |
+
"split": datasets.Split.TRAIN,
|
158 |
+
},
|
159 |
+
),
|
160 |
+
]
|
161 |
+
|
162 |
+
elif self.config.name == "unlabeled_final":
|
163 |
+
_TRAIN_FILE_NAME = os.path.join(data_dir, "unlabeled", "final", "train.tsv")
|
164 |
+
_VAL_FILE_NAME = os.path.join(data_dir, "unlabeled", "final", "dev.tsv")
|
165 |
+
return [
|
166 |
+
datasets.SplitGenerator(
|
167 |
+
name=datasets.Split.TRAIN,
|
168 |
+
# These kwargs will be passed to _generate_examples
|
169 |
+
gen_kwargs={
|
170 |
+
"filepath": _TRAIN_FILE_NAME,
|
171 |
+
"split": datasets.Split.TRAIN,
|
172 |
+
},
|
173 |
+
),
|
174 |
+
datasets.SplitGenerator(
|
175 |
+
name=datasets.Split.VALIDATION,
|
176 |
+
# These kwargs will be passed to _generate_examples
|
177 |
+
gen_kwargs={
|
178 |
+
"filepath": _VAL_FILE_NAME,
|
179 |
+
"split": datasets.Split.VALIDATION,
|
180 |
+
},
|
181 |
+
),
|
182 |
+
]
|
183 |
+
else:
|
184 |
+
raise NotImplementedError("{} does not exist".format(self.config.name))
|
185 |
+
|
186 |
+
def _generate_examples(self, filepath, split):
|
187 |
+
""" Yields examples. """
|
188 |
+
|
189 |
+
with open(filepath, encoding="utf-8") as f:
|
190 |
+
data = csv.DictReader(f, delimiter="\t")
|
191 |
+
for id_, row in enumerate(data):
|
192 |
+
if self.config.name != "unlabeled_final":
|
193 |
+
if row["label"] not in ["0", "1"]:
|
194 |
+
row["label"] = -1
|
195 |
+
yield id_, {
|
196 |
+
"id": row["id"],
|
197 |
+
"sentence1": row["sentence1"],
|
198 |
+
"sentence2": row["sentence2"],
|
199 |
+
"label": row["label"],
|
200 |
+
}
|
201 |
+
else:
|
202 |
+
if row["noisy_label"] not in ["0", "1"]:
|
203 |
+
row["noisy_label"] = -1
|
204 |
+
yield id_, {
|
205 |
+
"id": row["id"],
|
206 |
+
"sentence1": row["sentence1"],
|
207 |
+
"sentence2": row["sentence2"],
|
208 |
+
"label": row["noisy_label"],
|
209 |
+
}
|