|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""This loads the fewshot-pretraining dataset.""" |
|
|
|
import json |
|
import os |
|
import pandas as pd |
|
|
|
import datasets |
|
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
@InProceedings{huggingface:dataset, |
|
title = {A great new dataset}, |
|
author={huggingface, Inc. |
|
}, |
|
year={2020} |
|
} |
|
""" |
|
|
|
|
|
_DESCRIPTION = """\ |
|
The Fewshot Table dataset consists of tables that naturally occur on the web, that are formatted as few-shot tasks for fine-tuning language models to improve their few-shot performance. The dataset consists of approximately 413K tables that are extracted from the WDC Web Table Corpora 2015, which is released under the Apache-2.0 license. The WDC Web Table Corpora "contains vast amounts of HTML tables. [...] The Web Data Commons project extracts relational Web tables from the Common Crawl, the largest and most up-to-date Web corpus that is currently available to the public." |
|
""" |
|
|
|
|
|
_HOMEPAGE = "" |
|
|
|
_LICENSE = "Apache 2.0" |
|
|
|
|
|
|
|
|
|
_URLS = { |
|
"data_0": ["https://huggingface.co/datasets/JeremyAlain/123_test/raw/main/data/0/file_{}.jsonl".format(i) for i in range(20)], |
|
"data_1": ["https://huggingface.co/datasets/JeremyAlain/123_test/raw/main/data/1/file_{}.jsonl".format(i) for i in range(20)], |
|
"data_2": ["https://huggingface.co/datasets/JeremyAlain/123_test/raw/main/data/2/file_{}.jsonl".format(i) for i in range(20)], |
|
|
|
} |
|
logger = datasets.logging.get_logger(__name__) |
|
|
|
|
|
class FewshotPretraining(datasets.GeneratorBasedBuilder): |
|
"""The Fewshot Table dataset consists of tables that naturally occur on the web, that are formatted as few-shot tasks for fine-tuning language models to improve their few-shot performance. The dataset consists of approximately 413K tables that are extracted from the WDC Web Table Corpora 2015, which is released under the Apache-2.0 license. The WDC Web Table Corpora "contains vast amounts of HTML tables. [...] The Web Data Commons project extracts relational Web tables from the Common Crawl, the largest and most up-to-date Web corpus that is currently available to the public." |
|
""" |
|
|
|
VERSION = datasets.Version("1.1.0") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="data_0", version=VERSION, description="This part of my dataset covers data_0"), |
|
datasets.BuilderConfig(name="data_1", version=VERSION, description="This part of my dataset covers data_1"), |
|
datasets.BuilderConfig(name="data_2", version=VERSION, description="This part of my dataset covers data_2"), |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = "data_0" |
|
|
|
def _info(self): |
|
features = datasets.Features( |
|
{ |
|
|
|
"task": datasets.Value("string"), |
|
"input": datasets.Value("string"), |
|
"output": datasets.Value("string"), |
|
"options": datasets.Sequence([datasets.Value("string")]), |
|
"pageTitle": datasets.Value("string"), |
|
"outputColName": datasets.Value("string"), |
|
"url": datasets.Value("string"), |
|
"wdcFile": datasets.Value("string") |
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=features, |
|
|
|
|
|
|
|
|
|
|
|
|
|
license=_LICENSE, |
|
|
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
|
|
|
|
|
|
|
|
|
|
urls = _URLS[self.config.name] |
|
|
|
extracted_paths = dl_manager.download_and_extract(urls) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"file_paths": extracted_paths, |
|
}, |
|
) |
|
] |
|
|
|
|
|
|
|
def _generate_examples(self, file_paths): |
|
|
|
for file_idx, file_path in enumerate(file_paths): |
|
data = pd.read_json(file_path, orient="records", lines=True) |
|
for i in range(data.shape[0]): |
|
row = data.iloc[i] |
|
|
|
key = str(row["task"]) + "{}_{}".format(file_idx, i) |
|
yield key, { |
|
"task": data["task"], |
|
"input": data["input"], |
|
"output": data["output"], |
|
"options": data["options"], |
|
"pageTitle": data["pageTitle"], |
|
"outputColName": data["outputColName"], |
|
"url": data["url"], |
|
"wdcFile": data["wdcFile"], |
|
} |
|
|