File size: 3,305 Bytes
adc60c4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import datasets
from datasets import DatasetBuilder, DatasetInfo
import pandas as pd
class TMDataset(datasets.GeneratorBasedBuilder):
def __init__(self):
self.downloads = [
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_1.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_10.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_11.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_12.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_13.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_14.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_15.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_16.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_17.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_18.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_2.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_3.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_4.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_5.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_6.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_7.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_8.parquet",
"https://huggingface.co/datasets/Locutusque/InstructMix-V2/resolve/main/data/combined_datasets_batch_9.parquet"
]
VERSION = datasets.Version("1.0.0")
def _info(self):
features = datasets.Features({
"text": datasets.Value("string"),
})
return datasets.DatasetInfo(
description="Combination of text completion datasets",
features=features,
supervised_keys=None
)
def _split_generators(self, dl_manager):
data_dir = dl_manager.download_and_extract(self.downloads)
return [
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_dir})
]
def _generate_examples(self, filepath):
for file in filepath:
df = pd.read_parquet(file)
for idx, row in df.iterrows():
yield idx, {
"text": row["text"],
} |