Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Load, stream, process, and publish datasets with the HuggingFace datasets library. Covers Apache Arrow-backed streaming for large datasets, map/filter operations, train/val/test splitting, interleaving, concatenation, and pushing to the Hub.
.claude/skills/mkurman-hf-datasets/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✓→✗ | ▼ Worse | 34% | 0% |
| case-18 | ✓→✗ | ▼ Worse | 44% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 52% | 0% |
| case-02 | ✓→✓ | = Same ✓ | -1% | 0% |
| case-08 | ✓→✓ | = Same ✓ | -11% | 0% |
The datasets library by HuggingFace provides memory-efficient, Apache Arrow-backed access to tens of thousands of public datasets and your own local/remote data. It supports streaming for datasets that don't fit in RAM and integrates directly with transformers tokenizers and training loops.
Use this skill when:
.map() and .filter().Do not use for:
transformers or vllm skills.embedding-analysis skill.bashuv pip install datasets pyarrow huggingface_hub
pythonfrom datasets import load_dataset, load_from_disk # From the Hub dataset = load_dataset("imdb", split="train") # From local files dataset = load_dataset("parquet", data_files="data/*.parquet", split="train") # From disk (pre-saved) dataset = load_from_disk("./my_saved_dataset") # Streaming (never loads full dataset into memory) dataset = load_dataset("c4", "en", split="train", streaming=True)
pythonprint(dataset) # Dataset info print(dataset.shape) # (n_rows, n_columns) print(dataset.features) # Schema print(dataset[0]) # First row print(dataset[:5]) # First 5 rows as dict print(dataset.column_names) # Column list
python# Basic mapping def add_length(example): example["text_length"] = len(example["text"]) return example dataset = dataset.map(add_length) # Batched mapping (faster for large datasets) dataset = dataset.map(add_length, batched=True, batch_size=1000) # Tokenization with transformers from transformers import AutoTokenizer tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased") def tokenize(batch): return tokenizer(batch["text"], truncation=True, padding="max_length", max_length=512) dataset = dataset.map(tokenize, batched=True)
python# Quality filter: remove short or low-quality examples dataset = dataset.filter(lambda x: len(x["text"]) > 100) dataset = dataset.filter(lambda x: x["score"] > 0.5 if x["score"] is not None else False) # Language filter from langdetect import detect dataset = dataset.filter(lambda x: detect(x["text"]) == "en")
python# Random split train_test = dataset.train_test_split(test_size=0.2, seed=42) train = train_test["train"] test = train_test["test"] # Stratified split (requires class labels) from datasets import ClassLabel, DatasetDict split_dataset = dataset.class_encode_column("label").train_test_split( test_size=0.2, stratify_by_column="label", seed=42 )
python# Shuffle dataset = dataset.shuffle(seed=42) # Select specific indices dataset = dataset.select(range(1000)) # Sort dataset = dataset.sort("timestamp")
pythonfrom datasets import concatenate_datasets, interleave_datasets # Concatenate combined = concatenate_datasets([dataset_a, dataset_b]) # Interleave (round-robin mixing) mixed = interleave_datasets([dataset_a, dataset_b], probabilities=[0.7, 0.3], seed=42)
For datasets that don't fit in RAM, compose a streaming pipeline:
pythondataset = load_dataset("bigcode/the-stack", "python", split="train", streaming=True) # Filter first (cheap operation) dataset = dataset.filter(lambda x: len(x["content"]) > 500) # Then map (expensive operation only on filtered data) dataset = dataset.map(enrich_with_heuristics) # Take only what you need for i, example in enumerate(dataset): if i >= 10000: break process(example)
python# Save to disk (Arrow format, fastest reload) dataset.save_to_disk("./my_dataset") # Export to other formats dataset.to_parquet("./my_dataset.parquet") dataset.to_json("./my_dataset.jsonl") dataset.to_csv("./my_dataset.csv")
pythonfrom huggingface_hub import login login() dataset.push_to_hub("my-username/my-curated-dataset") # With a DatasetDict (train/val/test) dataset_dict = DatasetDict({ "train": train_dataset, "validation": val_dataset, "test": test_dataset, }) dataset_dict.push_to_hub("my-username/my-curated-dataset")
batched=True in .map() — 10-100x faster than row-level mapping.num_proc for CPU-bound map operations:pythondataset = dataset.map(heavy_function, batched=True, num_proc=4)
A dataset load pipeline is correct when:
.features matches the expected schema.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 9,986 | 5,375 | -46% | 1 | 1 | 0% | 1,620 | 2,462 | +52% | 0 | 0 | — |
case-02 | pass→pass | 13,651 | 5,043 | -63% | 1 | 1 | 0% | 2,479 | 2,457 | -1% | 0 | 0 | — |
case-03 | pass→fail | 13,824 | 9,435 | -32% | 1 | 1 | 0% | 2,409 | 3,220 | +34% | 0 | 0 | — |
case-08 | pass→pass | 11,892 | 2,887 | -76% | 1 | 1 | 0% | 2,296 | 2,051 | -11% | 0 | 0 | — |
case-04 | pass→pass | 10,305 | 4,252 | -59% | 1 | 1 | 0% | 1,801 | 2,235 | +24% | 0 | 0 | — |
case-05 | pass→pass | 7,454 | 5,038 | -32% | 1 | 1 | 0% | 1,255 | 2,394 | +91% | 0 | 0 | — |
case-06 | pass→pass | 6,820 | 5,620 | -18% | 1 | 1 | 0% | 1,193 | 2,567 | +115% | 0 | 0 | — |
case-07 | pass→pass | 5,639 | 4,440 | -21% | 1 | 1 | 0% | 1,072 | 2,397 | +124% | 0 | 0 | — |
case-09 | pass→pass | 5,552 | 2,178 | -61% | 1 | 1 | 0% | 1,110 | 1,891 | +70% | 0 | 0 | — |
case-10 | pass→pass | 3,469 | 4,062 | +17% | 1 | 1 | 0% | 660 | 2,316 | +251% | 0 | 0 | — |
case-11 | pass→pass | 6,586 | 4,969 | -25% | 1 | 1 | 0% | 1,191 | 2,427 | +104% | 0 | 0 | — |
case-12 | pass→pass | 3,839 | 3,279 | -15% | 1 | 1 | 0% | 723 | 2,092 | +189% | 0 | 0 | — |
case-22 | pass→pass | 11,256 | 5,164 | -54% | 1 | 1 | 0% | 2,145 | 2,411 | +12% | 0 | 0 | — |
case-13 | pass→pass | 5,822 | 1,895 | -67% | 1 | 1 | 0% | 933 | 1,791 | +92% | 0 | 0 | — |
case-14 | pass→pass | 8,412 | 2,606 | -69% | 1 | 1 | 0% | 1,648 | 2,006 | +22% | 0 | 0 | — |
case-15 | pass→pass | 6,731 | 1,982 | -71% | 1 | 1 | 0% | 1,431 | 1,871 | +31% | 0 | 0 | — |
case-16 | pass→pass | 2,819 | 3,085 | +9% | 1 | 1 | 0% | 512 | 2,074 | +305% | 0 | 0 | — |
case-17 | pass→pass | 5,904 | 2,357 | -60% | 1 | 1 | 0% | 1,199 | 1,966 | +64% | 0 | 0 | — |
case-18 | pass→fail | 13,005 | 9,286 | -29% | 1 | 1 | 0% | 2,088 | 3,012 | +44% | 0 | 0 | — |
case-19 | pass→pass | 2,676 | 1,244 | -54% | 1 | 1 | 0% | 478 | 1,665 | +248% | 0 | 0 | — |
case-20 | pass→pass | 8,027 | 2,235 | -72% | 1 | 1 | 0% | 1,013 | 1,822 | +80% | 0 | 0 | — |
case-21 | pass→pass | 8,443 | 4,577 | -46% | 1 | 1 | 0% | 1,593 | 2,323 | +46% | 0 | 0 | — |
case-23 | pass→pass | 2,441 | 2,840 | +16% | 1 | 1 | 0% | 408 | 1,970 | +383% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of -100 percentage points is the difference between those two pass rates over the 23 comparable cases. 2 cases got worse with the skill loaded, and they are included in that figure.
Other measured skills in the registry, with their headline benchmark lift.