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])