Skip to content

Commit

Permalink
Add The Pile dataset and PubMed Central subset (#3287)
Browse files Browse the repository at this point in the history
* Add The Pile dataset and PubMed Central subset

* Fix style

* Fix style

* Add README

* Make streamable the all config

* Add dummy data

* Add more info to README

* Fix dummy data
  • Loading branch information
albertvillanova committed Dec 1, 2021
1 parent 5efcab5 commit d5724c7
Show file tree
Hide file tree
Showing 3 changed files with 337 additions and 0 deletions.
174 changes: 174 additions & 0 deletions datasets/the_pile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
---
annotations_creators:
- no-annotation
language_creators:
- found
languages:
- en
licenses:
- other-
multilinguality:
- monolingual
pretty_name: The Pile
size_categories:
- unknown
source_datasets:
- original
task_categories:
- sequence-modeling
task_ids:
- language-modeling
---

# Dataset Card for The Pile

## Table of Contents
- [Table of Contents](#table-of-contents)
- [Dataset Description](#dataset-description)
- [Dataset Summary](#dataset-summary)
- [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
- [Languages](#languages)
- [Dataset Structure](#dataset-structure)
- [Data Instances](#data-instances)
- [Data Fields](#data-fields)
- [Data Splits](#data-splits)
- [Dataset Creation](#dataset-creation)
- [Curation Rationale](#curation-rationale)
- [Source Data](#source-data)
- [Annotations](#annotations)
- [Personal and Sensitive Information](#personal-and-sensitive-information)
- [Considerations for Using the Data](#considerations-for-using-the-data)
- [Social Impact of Dataset](#social-impact-of-dataset)
- [Discussion of Biases](#discussion-of-biases)
- [Other Known Limitations](#other-known-limitations)
- [Additional Information](#additional-information)
- [Dataset Curators](#dataset-curators)
- [Licensing Information](#licensing-information)
- [Citation Information](#citation-information)
- [Contributions](#contributions)

## Dataset Description

- **Homepage:** https://pile.eleuther.ai/
- **Repository:** https://github.com/EleutherAI/the-pile
- **Paper:** [The Pile: An 800GB Dataset of Diverse Text for Language Modeling](https://arxiv.org/abs/2101.00027)
- **Leaderboard:**
- **Point of Contact:** [EleutherAI](mailto:contact@eleuther.ai)

### Dataset Summary

The Pile is a 825 GiB diverse, open source language modelling data set that consists of 22 smaller, high-quality
datasets combined together.


### Supported Tasks and Leaderboards

[More Information Needed]

### Languages

[More Information Needed]

## Dataset Structure

### Data Instances

#### all
```
{
'meta': {'pile_set_name': 'Pile-CC'},
'text': 'It is done, and submitted. You can play “Survival of the Tastiest” on Android, and on the web. Playing on...'
}
```

#### pubmed_central
```
{
'id': 'PMC5595690',
'text': 'Introduction {#acel12642-sec-0001}\n============\n\nAlzheimer\\\'s disease (AD), the most common cause of...'
}
```

### Data Fields

#### all

- `meta` (dict): Metadata of the data instance, with keys:
- pile_set_name: Name of the subset.
- `text` (str): Text.

### Data Splits

The "all" configuration is composed of 3 splits: train, validation and test.

## Dataset Creation

### Curation Rationale

[More Information Needed]

### Source Data

#### Initial Data Collection and Normalization

[More Information Needed]

#### Who are the source language producers?

[More Information Needed]

### Annotations

#### Annotation process

[More Information Needed]

#### Who are the annotators?

[More Information Needed]

### Personal and Sensitive Information

[More Information Needed]

## Considerations for Using the Data

### Social Impact of Dataset

[More Information Needed]

### Discussion of Biases

[More Information Needed]

### Other Known Limitations

[More Information Needed]

## Additional Information

### Dataset Curators

[More Information Needed]

### Licensing Information

Please refer to the specific license depending on the subset you use:
- PubMed Central: [MIT License](https://github.com/EleutherAI/pile-pubmedcentral/blob/master/LICENSE)

### Citation Information

```
@misc{gao2020pile,
title={The Pile: An 800GB Dataset of Diverse Text for Language Modeling},
author={Leo Gao and Stella Biderman and Sid Black and Laurence Golding and Travis Hoppe and Charles Foster and Jason Phang and Horace He and Anish Thite and Noa Nabeshima and Shawn Presser and Connor Leahy},
year={2020},
eprint={2101.00027},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
```

### Contributions

Thanks to [@github-username](https://github.com/<github-username>) for adding this dataset.
Binary file added datasets/the_pile/dummy/all/0.0.0/dummy_data.zip
Binary file not shown.
163 changes: 163 additions & 0 deletions datasets/the_pile/the_pile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# coding=utf-8
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The Pile dataset."""

import json

import datasets


_CITATION = """\
@misc{gao2020pile,
title={The Pile: An 800GB Dataset of Diverse Text for Language Modeling},
author={Leo Gao and Stella Biderman and Sid Black and Laurence Golding and Travis Hoppe and Charles Foster and Jason Phang and Horace He and Anish Thite and Noa Nabeshima and Shawn Presser and Connor Leahy},
year={2020},
eprint={2101.00027},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
"""

_DESCRIPTION = """\
The Pile is a 825 GiB diverse, open source language modelling data set that consists of 22 smaller, high-quality
datasets combined together.
"""

_HOMEPAGE = "https://pile.eleuther.ai/"

_LICENSES = {
"all": "MIT License",
"pubmed_central": "MIT License",
}

_DATA_URLS = {
"all": {
"train": [f"https://the-eye.eu/public/AI/pile/train/{i:0>2}.jsonl.zst" for i in range(30)],
"validation": ["https://the-eye.eu/public/AI/pile/val.jsonl.zst"],
"test": ["https://the-eye.eu/public/AI/pile/test.jsonl.zst"],
},
"pubmed_central": "https://the-eye.eu/public/AI/pile_preliminary_components/PMC_extracts.tar.gz",
}

_FEATURES = {
"all": datasets.Features(
{
"text": datasets.Value("string"),
"meta": {"pile_set_name": datasets.Value("string")},
}
),
"pubmed_central": datasets.Features(
{
"id": datasets.Value("string"),
"text": datasets.Value("string"),
}
),
}


class ThePileConfig(datasets.BuilderConfig):
"""BuilderConfig for The Pile."""

def __init__(self, *args, subsets, **kwargs):
"""BuilderConfig for The Pile.
Args:
subsets (:obj:`List[str]`): List of subsets to load.
**kwargs: keyword arguments forwarded to super.
"""
super().__init__(
*args,
name="+".join(subsets),
**kwargs,
)
self.subsets = subsets


class ThePile(datasets.GeneratorBasedBuilder):
"""The Pile dataset."""

VERSION = datasets.Version("1.1.0")

BUILDER_CONFIG_CLASS = ThePileConfig
BUILDER_CONFIGS = [ThePileConfig(subsets=[subset]) for subset in _DATA_URLS]
DEFAULT_CONFIG_NAME = "all"

def _info(self):
"""Give information and typings for the dataset."""
return datasets.DatasetInfo(
# This is the description that will appear on the datasets page.
description=_DESCRIPTION,
# This defines the different columns of the dataset and their types
features=_FEATURES[self.config.name],
# If there's a common (input, target) tuple from the features,
# specify them here. They'll be used if as_supervised=True in
# builder.as_dataset.
supervised_keys=None,
# Homepage of the dataset for documentation
homepage=_HOMEPAGE,
# License for the dataset if available
license=_LICENSES[self.config.name],
# Citation for the dataset
citation=_CITATION,
)

def _split_generators(self, dl_manager):
"""Return SplitGenerators."""
if self.config.name == "all":
data_dir = dl_manager.download(_DATA_URLS[self.config.name])
return [
datasets.SplitGenerator(
name=split,
gen_kwargs={
"files": data_dir[split],
},
)
for split in [datasets.Split.TRAIN, datasets.Split.VALIDATION, datasets.Split.TEST]
]
else:
data_urls = {subset: _DATA_URLS[subset] for subset in self.config.subsets}
archive = dl_manager.download(data_urls)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"files": {subset: dl_manager.iter_archive(archive[subset]) for subset in self.config.subsets},
},
),
]

def _generate_examples(self, files):
"""Yield examples as (key, example) tuples."""
key = 0
if isinstance(files, list):
import zstandard as zstd

for path in files:
with zstd.open(open(path, "rb"), "rt", encoding="utf-8") as f:
for row in f:
data = json.loads(row)
yield key, data
key += 1
else:
for subset in files:
if subset == "pubmed_central":
for path, file in files[subset]:
id_ = path.split("/")[-1].split(".")[0]
text = file.read().decode("utf-8")
yield key, {
"id": id_,
"text": text,
}
key += 1

1 comment on commit d5724c7

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show benchmarks

PyArrow==3.0.0

Show updated benchmarks!

Benchmark: benchmark_array_xd.json

metric read_batch_formatted_as_numpy after write_array2d read_batch_formatted_as_numpy after write_flattened_sequence read_batch_formatted_as_numpy after write_nested_sequence read_batch_unformated after write_array2d read_batch_unformated after write_flattened_sequence read_batch_unformated after write_nested_sequence read_col_formatted_as_numpy after write_array2d read_col_formatted_as_numpy after write_flattened_sequence read_col_formatted_as_numpy after write_nested_sequence read_col_unformated after write_array2d read_col_unformated after write_flattened_sequence read_col_unformated after write_nested_sequence read_formatted_as_numpy after write_array2d read_formatted_as_numpy after write_flattened_sequence read_formatted_as_numpy after write_nested_sequence read_unformated after write_array2d read_unformated after write_flattened_sequence read_unformated after write_nested_sequence write_array2d write_flattened_sequence write_nested_sequence
new / old (diff) 0.087712 / 0.011353 (0.076359) 0.004469 / 0.011008 (-0.006540) 0.036522 / 0.038508 (-0.001986) 0.042709 / 0.023109 (0.019600) 0.365515 / 0.275898 (0.089617) 0.429897 / 0.323480 (0.106417) 0.104966 / 0.007986 (0.096980) 0.004050 / 0.004328 (-0.000278) 0.010510 / 0.004250 (0.006260) 0.049700 / 0.037052 (0.012648) 0.364118 / 0.258489 (0.105629) 0.435275 / 0.293841 (0.141434) 0.110380 / 0.128546 (-0.018167) 0.010243 / 0.075646 (-0.065403) 0.301036 / 0.419271 (-0.118235) 0.057475 / 0.043533 (0.013942) 0.347468 / 0.255139 (0.092330) 0.419677 / 0.283200 (0.136478) 0.107992 / 0.141683 (-0.033690) 2.075749 / 1.452155 (0.623594) 2.186159 / 1.492716 (0.693443)

Benchmark: benchmark_getitem_100B.json

metric get_batch_of_1024_random_rows get_batch_of_1024_rows get_first_row get_last_row
new / old (diff) 0.271380 / 0.018006 (0.253374) 0.488657 / 0.000490 (0.488167) 0.005029 / 0.000200 (0.004829) 0.000092 / 0.000054 (0.000037)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.042722 / 0.037411 (0.005311) 0.026245 / 0.014526 (0.011719) 0.032485 / 0.176557 (-0.144072) 0.231805 / 0.737135 (-0.505330) 0.033589 / 0.296338 (-0.262750)

Benchmark: benchmark_iterating.json

metric read 5000 read 50000 read_batch 50000 10 read_batch 50000 100 read_batch 50000 1000 read_formatted numpy 5000 read_formatted pandas 5000 read_formatted tensorflow 5000 read_formatted torch 5000 read_formatted_batch numpy 5000 10 read_formatted_batch numpy 5000 1000 shuffled read 5000 shuffled read 50000 shuffled read_batch 50000 10 shuffled read_batch 50000 100 shuffled read_batch 50000 1000 shuffled read_formatted numpy 5000 shuffled read_formatted_batch numpy 5000 10 shuffled read_formatted_batch numpy 5000 1000
new / old (diff) 0.492239 / 0.215209 (0.277030) 4.898708 / 2.077655 (2.821053) 2.135369 / 1.504120 (0.631249) 1.890482 / 1.541195 (0.349287) 1.986909 / 1.468490 (0.518419) 0.491744 / 4.584777 (-4.093033) 6.056241 / 3.745712 (2.310529) 2.835395 / 5.269862 (-2.434467) 1.025768 / 4.565676 (-3.539908) 0.072631 / 0.424275 (-0.351645) 0.016908 / 0.007607 (0.009301) 0.697003 / 0.226044 (0.470959) 6.333007 / 2.268929 (4.064079) 2.659898 / 55.444624 (-52.784727) 2.245713 / 6.876477 (-4.630764) 2.367535 / 2.142072 (0.225463) 0.631460 / 4.805227 (-4.173767) 0.137121 / 6.500664 (-6.363543) 0.068091 / 0.075469 (-0.007378)

Benchmark: benchmark_map_filter.json

metric filter map fast-tokenizer batched map identity map identity batched map no-op batched map no-op batched numpy map no-op batched pandas map no-op batched pytorch map no-op batched tensorflow
new / old (diff) 2.077931 / 1.841788 (0.236143) 15.147737 / 8.074308 (7.073429) 32.159411 / 10.191392 (21.968019) 0.845688 / 0.680424 (0.165264) 0.628507 / 0.534201 (0.094306) 0.441553 / 0.579283 (-0.137730) 0.647656 / 0.434364 (0.213292) 0.345164 / 0.540337 (-0.195174) 0.390981 / 1.386936 (-0.995955)
PyArrow==latest
Show updated benchmarks!

Benchmark: benchmark_array_xd.json

metric read_batch_formatted_as_numpy after write_array2d read_batch_formatted_as_numpy after write_flattened_sequence read_batch_formatted_as_numpy after write_nested_sequence read_batch_unformated after write_array2d read_batch_unformated after write_flattened_sequence read_batch_unformated after write_nested_sequence read_col_formatted_as_numpy after write_array2d read_col_formatted_as_numpy after write_flattened_sequence read_col_formatted_as_numpy after write_nested_sequence read_col_unformated after write_array2d read_col_unformated after write_flattened_sequence read_col_unformated after write_nested_sequence read_formatted_as_numpy after write_array2d read_formatted_as_numpy after write_flattened_sequence read_formatted_as_numpy after write_nested_sequence read_unformated after write_array2d read_unformated after write_flattened_sequence read_unformated after write_nested_sequence write_array2d write_flattened_sequence write_nested_sequence
new / old (diff) 0.086333 / 0.011353 (0.074980) 0.004291 / 0.011008 (-0.006717) 0.035801 / 0.038508 (-0.002707) 0.041208 / 0.023109 (0.018099) 0.343649 / 0.275898 (0.067751) 0.409753 / 0.323480 (0.086273) 0.104721 / 0.007986 (0.096735) 0.005388 / 0.004328 (0.001060) 0.008537 / 0.004250 (0.004287) 0.042730 / 0.037052 (0.005678) 0.340974 / 0.258489 (0.082485) 0.403377 / 0.293841 (0.109536) 0.107811 / 0.128546 (-0.020735) 0.010283 / 0.075646 (-0.065364) 0.357163 / 0.419271 (-0.062109) 0.053759 / 0.043533 (0.010226) 0.342743 / 0.255139 (0.087604) 0.382071 / 0.283200 (0.098871) 0.093303 / 0.141683 (-0.048380) 2.014948 / 1.452155 (0.562793) 2.205804 / 1.492716 (0.713087)

Benchmark: benchmark_getitem_100B.json

metric get_batch_of_1024_random_rows get_batch_of_1024_rows get_first_row get_last_row
new / old (diff) 0.304654 / 0.018006 (0.286648) 0.489223 / 0.000490 (0.488733) 0.029596 / 0.000200 (0.029396) 0.000337 / 0.000054 (0.000283)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.039155 / 0.037411 (0.001743) 0.024229 / 0.014526 (0.009703) 0.029379 / 0.176557 (-0.147178) 0.228317 / 0.737135 (-0.508819) 0.030866 / 0.296338 (-0.265472)

Benchmark: benchmark_iterating.json

metric read 5000 read 50000 read_batch 50000 10 read_batch 50000 100 read_batch 50000 1000 read_formatted numpy 5000 read_formatted pandas 5000 read_formatted tensorflow 5000 read_formatted torch 5000 read_formatted_batch numpy 5000 10 read_formatted_batch numpy 5000 1000 shuffled read 5000 shuffled read 50000 shuffled read_batch 50000 10 shuffled read_batch 50000 100 shuffled read_batch 50000 1000 shuffled read_formatted numpy 5000 shuffled read_formatted_batch numpy 5000 10 shuffled read_formatted_batch numpy 5000 1000
new / old (diff) 0.493863 / 0.215209 (0.278654) 4.946715 / 2.077655 (2.869061) 2.113937 / 1.504120 (0.609817) 1.875551 / 1.541195 (0.334356) 1.969112 / 1.468490 (0.500622) 0.496494 / 4.584777 (-4.088283) 6.373163 / 3.745712 (2.627450) 2.380648 / 5.269862 (-2.889214) 1.019401 / 4.565676 (-3.546276) 0.060066 / 0.424275 (-0.364209) 0.013349 / 0.007607 (0.005742) 0.624472 / 0.226044 (0.398427) 6.271915 / 2.268929 (4.002987) 2.707502 / 55.444624 (-52.737123) 2.275242 / 6.876477 (-4.601235) 2.351023 / 2.142072 (0.208950) 0.623032 / 4.805227 (-4.182196) 0.136531 / 6.500664 (-6.364133) 0.066766 / 0.075469 (-0.008703)

Benchmark: benchmark_map_filter.json

metric filter map fast-tokenizer batched map identity map identity batched map no-op batched map no-op batched numpy map no-op batched pandas map no-op batched pytorch map no-op batched tensorflow
new / old (diff) 1.952464 / 1.841788 (0.110677) 14.598882 / 8.074308 (6.524574) 31.473210 / 10.191392 (21.281818) 0.920353 / 0.680424 (0.239929) 0.612935 / 0.534201 (0.078734) 0.444930 / 0.579283 (-0.134353) 0.623742 / 0.434364 (0.189378) 0.368848 / 0.540337 (-0.171490) 0.355596 / 1.386936 (-1.031340)

CML watermark

Please sign in to comment.