Commit
·
8da3d60
verified
·
0
Parent(s):
Duplicate from mteb/amazon_reviews_multi
Browse filesCo-authored-by: Nouamane Tazi <nouamanetazi@users.noreply.huggingface.co>
- .gitattributes +43 -0
- README.md +9 -0
- amazon_reviews_multi.py +106 -0
- de/test.jsonl +0 -0
- de/train.jsonl +3 -0
- de/validation.jsonl +0 -0
- en/test.jsonl +0 -0
- en/train.jsonl +3 -0
- en/validation.jsonl +0 -0
- es/test.jsonl +0 -0
- es/train.jsonl +3 -0
- es/validation.jsonl +0 -0
- fr/test.jsonl +0 -0
- fr/train.jsonl +3 -0
- fr/validation.jsonl +0 -0
- ja/test.jsonl +0 -0
- ja/train.jsonl +3 -0
- ja/validation.jsonl +0 -0
- zh/test.jsonl +0 -0
- zh/train.jsonl +3 -0
- zh/validation.jsonl +0 -0
.gitattributes
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.wasm 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
|
| 28 |
+
# Audio files - uncompressed
|
| 29 |
+
*.pcm filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.sam filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.raw filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
# Audio files - compressed
|
| 33 |
+
*.aac filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.flac filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
de/train.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
en/train.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
es/train.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
fr/train.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
ja/train.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
zh/train.jsonl filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- de
|
| 4 |
+
- en
|
| 5 |
+
- es
|
| 6 |
+
- fr
|
| 7 |
+
- ja
|
| 8 |
+
- zh
|
| 9 |
+
---
|
amazon_reviews_multi.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import datasets
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
_CITATION = """\
|
| 6 |
+
@inproceedings{marc_reviews,
|
| 7 |
+
title={The Multilingual Amazon Reviews Corpus},
|
| 8 |
+
author={Keung, Phillip and Lu, Yichao and Szarvas, György and Smith, Noah A.},
|
| 9 |
+
booktitle={Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing},
|
| 10 |
+
year={2020}
|
| 11 |
+
}
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
_LICENSE = """\
|
| 15 |
+
By accessing the Multilingual Amazon Reviews Corpus ("Reviews Corpus"), you agree that the Reviews Corpus is an Amazon Service subject to the Amazon.com Conditions of Use (https://www.amazon.com/gp/help/customer/display.html/ref=footer_cou?ie=UTF8&nodeId=508088) and you agree to be bound by them, with the following additional conditions:
|
| 16 |
+
In addition to the license rights granted under the Conditions of Use, Amazon or its content providers grant you a limited, non-exclusive, non-transferable, non-sublicensable, revocable license to access and use the Reviews Corpus for purposes of academic research. You may not resell, republish, or make any commercial use of the Reviews Corpus or its contents, including use of the Reviews Corpus for commercial research, such as research related to a funding or consultancy contract, internship, or other relationship in which the results are provided for a fee or delivered to a for-profit organization. You may not (a) link or associate content in the Reviews Corpus with any personal information (including Amazon customer accounts), or (b) attempt to determine the identity of the author of any content in the Reviews Corpus. If you violate any of the foregoing conditions, your license to access and use the Reviews Corpus will automatically terminate without prejudice to any of the other rights or remedies Amazon may have.
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
_DESCRIPTION = """\
|
| 20 |
+
We provide an Amazon product reviews dataset for multilingual text classification. The dataset contains reviews in English, Japanese, German, French, Chinese and Spanish, collected between November 1, 2015 and November 1, 2019. Each record in the dataset contains the review text, the review title, the star rating, an anonymized reviewer ID, an anonymized product ID and the coarse-grained product category (e.g. ‘books’, ‘appliances’, etc.) The corpus is balanced across stars, so each star rating constitutes 20% of the reviews in each language.
|
| 21 |
+
For each language, there are 200,000, 5,000 and 5,000 reviews in the training, development and test sets respectively. The maximum number of reviews per reviewer is 20 and the maximum number of reviews per product is 20. All reviews are truncated after 2,000 characters, and all reviews are at least 20 characters long.
|
| 22 |
+
Note that the language of a review does not necessarily match the language of its marketplace (e.g. reviews from amazon.de are primarily written in German, but could also be written in English, etc.). For this reason, we applied a language detection algorithm based on the work in Bojanowski et al. (2017) to determine the language of the review text and we removed reviews that were not written in the expected language.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
_LANGUAGES = {
|
| 26 |
+
"de": "German",
|
| 27 |
+
"en": "English",
|
| 28 |
+
"es": "Spanish",
|
| 29 |
+
"fr": "French",
|
| 30 |
+
"ja": "Japanese",
|
| 31 |
+
"zh": "Chinese",
|
| 32 |
+
}
|
| 33 |
+
_ALL_LANGUAGES = "all_languages"
|
| 34 |
+
_HOMEPAGE_URL = "https://registry.opendata.aws/amazon-reviews-ml/"
|
| 35 |
+
_DOWNLOAD_URL = "{lang}/{split}.jsonl"
|
| 36 |
+
_VERSION = "1.0.0"
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class AmazonReviewsMultiConfig(datasets.BuilderConfig):
|
| 40 |
+
"""BuilderConfig for AmazonReviewsMultiConfig."""
|
| 41 |
+
|
| 42 |
+
def __init__(self, languages=None, **kwargs):
|
| 43 |
+
super(AmazonReviewsMultiConfig, self).__init__(version=datasets.Version(_VERSION, ""), **kwargs),
|
| 44 |
+
self.languages = languages
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
class AmazonReviewsMulti(datasets.GeneratorBasedBuilder):
|
| 48 |
+
|
| 49 |
+
"""The Multilingual Amazon Reviews Corpus"""
|
| 50 |
+
|
| 51 |
+
BUILDER_CONFIGS = [
|
| 52 |
+
AmazonReviewsMultiConfig(
|
| 53 |
+
name=_ALL_LANGUAGES,
|
| 54 |
+
languages=_LANGUAGES,
|
| 55 |
+
description="A collection of Amazon reviews specifically designed to aid research in multilingual text classification.",
|
| 56 |
+
)
|
| 57 |
+
] + [
|
| 58 |
+
AmazonReviewsMultiConfig(
|
| 59 |
+
name=lang,
|
| 60 |
+
languages=[lang],
|
| 61 |
+
description=f"{_LANGUAGES[lang]} examples from a collection of Amazon reviews specifically designed to aid research in multilingual text classification",
|
| 62 |
+
)
|
| 63 |
+
for lang in _LANGUAGES
|
| 64 |
+
]
|
| 65 |
+
BUILDER_CONFIG_CLASS = AmazonReviewsMultiConfig
|
| 66 |
+
DEFAULT_CONFIG_NAME = _ALL_LANGUAGES
|
| 67 |
+
|
| 68 |
+
def _info(self):
|
| 69 |
+
return datasets.DatasetInfo(
|
| 70 |
+
description=_DESCRIPTION,
|
| 71 |
+
features=datasets.Features(
|
| 72 |
+
{
|
| 73 |
+
"id": datasets.Value("string"),
|
| 74 |
+
"text": datasets.Value("string"),
|
| 75 |
+
"label": datasets.Value("int32"),
|
| 76 |
+
"label_text": datasets.Value("string"),
|
| 77 |
+
}
|
| 78 |
+
),
|
| 79 |
+
supervised_keys=None,
|
| 80 |
+
license=_LICENSE,
|
| 81 |
+
homepage=_HOMEPAGE_URL,
|
| 82 |
+
citation=_CITATION,
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
def _split_generators(self, dl_manager):
|
| 86 |
+
train_urls = [_DOWNLOAD_URL.format(split="train", lang=lang) for lang in self.config.languages]
|
| 87 |
+
dev_urls = [_DOWNLOAD_URL.format(split="validation", lang=lang) for lang in self.config.languages]
|
| 88 |
+
test_urls = [_DOWNLOAD_URL.format(split="test", lang=lang) for lang in self.config.languages]
|
| 89 |
+
|
| 90 |
+
train_paths = dl_manager.download_and_extract(train_urls)
|
| 91 |
+
dev_paths = dl_manager.download_and_extract(dev_urls)
|
| 92 |
+
test_paths = dl_manager.download_and_extract(test_urls)
|
| 93 |
+
|
| 94 |
+
return [
|
| 95 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"file_paths": train_paths}),
|
| 96 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"file_paths": dev_paths}),
|
| 97 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"file_paths": test_paths}),
|
| 98 |
+
]
|
| 99 |
+
|
| 100 |
+
def _generate_examples(self, file_paths):
|
| 101 |
+
row_count = 0
|
| 102 |
+
for file_path in file_paths:
|
| 103 |
+
with open(file_path, "r", encoding="utf-8") as f:
|
| 104 |
+
for line in f:
|
| 105 |
+
yield row_count, json.loads(line)
|
| 106 |
+
row_count += 1
|
de/test.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
de/train.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c2fc225b5b2e196e9fa2558a252b6a665b7bc0c50a4ea90d56e5de7cf2b82a46
|
| 3 |
+
size 61424547
|
de/validation.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
en/test.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
en/train.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bd8f72b878e6529e2fff3f4d5dc3998dc32c7915a9d112f1381d579a81a774c8
|
| 3 |
+
size 53122910
|
en/validation.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
es/test.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
es/train.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:031b005bb5aa09f762f582874722e4cae2647b35ac13363d8717333a9f1a40a4
|
| 3 |
+
size 48675746
|
es/validation.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
fr/test.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
fr/train.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fc6ac53a4995e6f3e49ad1224eadd7d6fe51a50273c44f210c40db6b0adc262c
|
| 3 |
+
size 53037450
|
fr/validation.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
ja/test.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
ja/train.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7bad645ad1ae2e4334d74e2cf6a256eb012404e03fe6027151a815c540dc0154
|
| 3 |
+
size 140664080
|
ja/validation.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
zh/test.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
zh/train.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aafd6c66f5a9c039c5e8cf34d33bfba5df9ceb8cc8721aa7b4172ac8b76a9470
|
| 3 |
+
size 80251611
|
zh/validation.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|