I am working on a video dataset with a long-tail distribution across topics, languages, creators, and source platforms.
The current concern is that random sampling may overrepresent popular categories and creators while leaving rare but important groups underrepresented.
I am considering a sampling pipeline with:
Multi-label taxonomy fields
Per-category sample counts
Language-aware sampling
Creator or channel caps
Platform-level balancing
Weighted sampling during training
A separate coverage report before creating the splits
For PyTorch users working with video datasets:
Do you balance the dataset during preprocessing or inside the Sampler?
How do you avoid oversampling rare categories too aggressively?
Do you apply creator-level caps before train/validation splitting?
How do you handle samples with multiple topic labels?
Which coverage metrics do you track besides the class distribution?
I am particularly interested in practical Dataset and Sampler patterns that preserve long-tail coverage without causing excessive duplication.
I work on aicost.tools (cost tracking, not video ML), so take this as an outside view: I’d apply the creator/channel caps and split train/val by creator before any balancing, otherwise one prolific creator leaks into both splits and the rare groups look better than they are. The balancing itself I’d keep in the Sampler rather than on disk: WeightedRandomSampler with weights like 1/sqrt(count) instead of 1/count stops the rarest classes from being repeated dozens of times per epoch. For multi-label clips, using the weight of the rarest label the clip carries works reasonably well, and tracking “unique clips seen per group per epoch” next to the class histogram shows over-duplication right away.
One trap with weighting by the rarest label is that a clip which only touches a rare tag still gets drawn as if it were a pure example of that tag, so a few multi-label videos can fill the tail. I would assign each clip to a single stratum, using language, platform, and its rarest topic, for sampling only, and keep the loss on every label. Draw without replacement inside the stratum until it is used up, and cap repeats at two or three per epoch instead of a with-replacement weighted sampler, which will otherwise show the same rare file on many steps. Besides the class histogram, log unique clip ids per stratum divided by steps; if that ratio drops well under one, the tail is being memorized rather than covered.
That distinction makes sense. I like the idea of using one primary stratum for sampling while keeping the full multi-label target for the loss and evaluation.
The “draw without replacement” rule also seems safer than letting rare examples repeat throughout every epoch. Tracking unique clip IDs per stratum should reveal whether the sampler is improving coverage or simply memorizing a small subset.
One implementation question: when using DistributedSampler with multiple workers, do you reset the without-replacement pool independently at the start of each epoch, or maintain a shared cursor across workers? I’m wondering how you avoid the same clip being selected by different workers in the same epoch.