Nodes/ComfyUI/Shuffle Pairs of Video-Text
ComfyUI Node Runs on cloud

Shuffle Pairs of Video-Text

Shuffle Your Video-Text Training Pairs Without Fumbling the Captions

By Comfy-Org·Created 4 years ago·Updated about 5 hours ago· 128,055
Shuffle Pairs of Video-Text
  • videos
  • videos
  • texts
texts
seed0

This node takes two lists - videos and their text captions - and shuffles the order of both, using the exact same permutation, so every video stays glued to its own caption. The display name is a better description than the class name: it's "Shuffle Pairs of Video-Text," not "shuffle a list." If you're feeding video clips into ComfyUI's built-in LoRA trainer, this is the little deck-shuffler that keeps the pairs intact while scrambling the deal.

Why shuffle at all?

It's a training-discipline thing, and it's not a ComfyUI quirk - it's how every trainer works. If your dataset flows through in the same fixed order every epoch, the model can start memorizing sequence instead of content. Shuffling each pass breaks that. It's the same reason your dataset curation beats every training knob you can turn (the KB hammers this home): a clean, shuffled deck is free regularization.

There's a reproducibility angle too. Same seed, same shuffle - so when a run goes sideways you can reproduce the exact order that caused it, instead of chasing a random ordering that re-rolls every attempt.

How it works

Boringly and correctly. The node takes videos and texts, seeds NumPy's RNG with your seed, builds a random permutation of the list indices, and reorders both lists by those same indices. One permutation, applied twice. There's no cleverness here, and there doesn't need to be - it's the seed-controlled equivalent of shuffling two parallel arrays together.

The inputs that matter

Only three, and you'll actually touch all of them:

  • videos (VIDEO, list) - the clips. Typically from LoadVideo-Text (from Folder).
  • texts (STRING, list) - the captions, same order as the videos. Feed in one caption per video, in lockstep.
  • seed (INT, default 0) - controls the shuffle order. Change it to re-roll; keep it fixed to reproduce.

The one rule that bites people: the two lists must be the same length. The node builds its permutation from len(videos), then indexes texts with it. A shorter texts list throws an index error; a longer one silently drops the tail. Keep them in lockstep.

Outputs

Two lists: videos and texts, shuffled in the same new order. Wire both straight into the trainer - TrainLoRA (the built-in model/training node) is the natural downstream - or into whatever else wants an ordered pair of parallel lists. Nothing else comes out, because nothing else is needed.

Gotchas

It's a raw reorder only. It won't dedupe, won't split out a validation set, won't repeat samples. If you want to hold out 10% for eval, that's a job for a different node or a folder split, not this one.

It's also flagged experimental in the source, and it landed late 2025 as part of the dataset-processing batch that shipped alongside ComfyUI's built-in trainer nodes. That means the API surface could shift; don't build a mission-critical pipeline on it without pinning your ComfyUI version. For ordinary training prep, though, it's exactly the boring, correct tool you want - and since it ships with core, there's nothing to install.

The image sibling ShuffleImageTextDataset behaves identically, so the muscle memory transfers.

Categorydataset/video

Inputs (3)

NameTypeDefaultDescription
videosVIDEOList of videos to shuffle.
textsSTRINGList of texts to shuffle.
seedINT00–18446744073709550000Random seed.

Outputs (2)

NameTypeDescription
videosVIDEOShuffled videos
textsSTRINGShuffled texts