|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""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_1": "https://huggingface.co/datasets/JeremyAlain/fewshot-ptretraining/data/1", |
|
"data_2": "https://huggingface.co/datasets/JeremyAlain/fewshot-ptretraining/data/2", |
|
"data_3": "https://huggingface.co/datasets/JeremyAlain/fewshot-ptretraining/data/3", |
|
|
|
} |
|
|
|
|
|
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_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"), |
|
datasets.BuilderConfig(name="data_3", version=VERSION, description="This part of my dataset covers data_3"), |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = "data_1" |
|
|
|
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] |
|
data_dir = dl_manager.download_and_extract(urls) |
|
return datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"folder_path": data_dir, |
|
"split": "train", |
|
}, |
|
) |
|
|
|
|
|
|
|
def _generate_examples(self, folder_path, split): |
|
|
|
for filepath in os.listdir(folder_path): |
|
with open(filepath, encoding="utf-8") as f: |
|
data = pd.read_json(filepath, orient="records", lines=True) |
|
for i in range(data.shape[0]): |
|
row = data.iloc[i] |
|
|
|
key = row["task"] + "_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"], |
|
} |
|
|