π€ Dataset Shuffle
Shuffle your dataset with a seed β reproducibility that actually reproduces
- dataset
- dataset
Every dataset arrives in the order someone else chose, and that order is usually useless to you - reviews sorted by length, images grouped by class, all the boring rows up front. π€ Dataset Shuffle fixes that with one input and one idea: if you randomize, do it behind a seed so the same graph run gives you the same rows in the same order every single time.
How it works
It's a thin wrapper over datasets.Dataset.shuffle (and IterableDataset.shuffle), which means you feed a HUGGINGFACE_DATASET in and get one back out, reordered. Only two inputs exist, and only one of them is interesting:
seed- defaults to0, and that default is doing more work than it looks. Leave it at 0 and the shuffle is deterministic: rerun the graph, same order. This is the right behavior for anyone whose downstream steps assume a stable row sequence - and it's why this node beats "random every run" workflows for anything you might want to debug later.dataset- whatever the loader or a previous π€ node handed you.
For a fully-loaded dataset, a seed of 0 gives you a repeatable shuffle but not a uniformly shuffled one in the sense that matters for sampling - if you actually want a different draw, change the seed. It works on both loaded and streaming datasets; the one hard rule is that streaming datasets require a seed, and the node enforces it rather than silently producing non-deterministic streams.
Where you'd actually use it
- Before a
Takeor materialization, to grab a random-ish slice of a big corpus instead of the boring first N rows. - Before a downstream split or batch, to kill whatever ordering bias the source shipped with.
- Whenever a workflow's output depends on row order and you want the same output on rerun - the seed makes it a deliberate input instead of ambient luck.
Output is the shuffled dataset, ready to chain into Filter, Take, To Data List, or anything else in the pack.
Installing it
Part of StableLlama/ComfyUI-huggingface_dataset. ComfyUI-Manager β search "Hugging Face dataset", or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-huggingface_dataset
pip install -r requirements.txt
Restart ComfyUI. The only runtime dependency is datasets, which Manager installs for you.
Gotchas
The phrase "random" makes people assume they need no seed - they don't, it's set for them, which is nice. The trap is the opposite one: you shuffle, take the first 100 rows as your "random sample," and then wonder why every run shows the same 100. That's the seed working as designed. Change it when you want variety, or keep it when you want to compare two pipeline versions on identical data. One more: shuffling a streaming dataset isn't a global shuffle - it reorders the lazily-iterated stream with a seeded buffer, so if you need a true shuffle of the whole thing, load it fully first.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| dataset | HUGGINGFACE_DATASET | Input dataset to shuffle (from the π€ Dataset Loader or another dataset node). | |
| seed | INT | 00β2147483647 | Random seed for a reproducible shuffle; required when the input is streaming. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| dataset | HUGGINGFACE_DATASET | The shuffled dataset. |