File size: 962 Bytes
0dced5c |
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 |
from datasets import load_dataset
from datasets import Dataset
# 1. Load the en split of C4 with streaming
ds = load_dataset("allenai/c4", "en", split="train", streaming=True)
# 2. Take first 10k examples and convert to regular dataset
ds_small = list(ds.take(10000)) # take first 10k examples
ds_small = Dataset.from_list(ds_small) # convert to regular Dataset
assert len(ds_small) == 10000
print("Sample example:", ds_small[0])
# 4. Push to the Hub
repo_name = "boom-project/c4-en-10k-debug"
ds_small.push_to_hub(
repo_id=repo_name,
token=True, # uses the token from `huggingface-cli login`
private=False,
)
print(f"✅ Pushed 10,000-example C4 subset to https://huggingface.co/{repo_name}")
# After pushing to the Hub, verify the dataset size and inspect one example
# from datasets import load_dataset
# ds = load_dataset("boom-project/c4-en-10k-debug", split="train")
# assert len(ds) == 10000
# print("Sample example:", ds[0]) |