SemDeDup: Data-efficient learning at web-scale through semantic deduplication

Amro Kamal Mohamed Abbas, Kushal Tirumala, Daniel Simig, Surya Ganguli, Ari S. Morcos

TL;DR

Web-scale datasets like LAION and C4 are filled with hidden "semantic duplicates"—examples that convey virtually identical information despite differing in pixel values or phrasing. The authors introduce SemDeDup, an efficient clustering-and-embedding pipeline that detects and prunes semantic duplicates. Removing up to 50% of training data cuts training compute in half with virtually no performance loss and even improves out-of-distribution robustness.

What Problem Does This Paper Address?

State-of-the-art vision and language foundation models require billions of scraped web examples to train. Standard data curation pipelines only filter out exact or near-exact duplicates (e.g., identical URLs, identical strings, or tiny pixel shifts).

However, web data remains flooded with semantic duplicates: images with slight crops, different aspect ratios, or color grading, and text generated from boilerplate templates. These redundant examples waste massive amounts of GPU compute and cause models to underfit new concepts. At the same time, computing pairwise semantic similarity across billions of data points naively requires $O(n^2)$ comparisons—an intractable barrier at web scale.

Methods

SemDeDup provides a computationally tractable way to find semantic duplicates:

  1. Embedding: Feature vectors are extracted from data points using an off-the-shelf foundation model (e.g., CLIP ViT-B/16 for images, OPT-125M for text).
  2. Clustering: The embeddings are clustered using spherical $k$-means (e.g., $k=50{,}000$ clusters for LAION; $k=11{,}000$ for C4). This restricts pairwise comparisons strictly within clusters, slashing computational complexity from $O(n^2)$ to $O(n^2/k)$—a 5 orders of magnitude reduction in FLOPs.
  3. Thresholding & Pruning: Within each cluster, all pairwise cosine similarities are calculated. For pairs with cosine distance below a threshold $\epsilon$ (i.e., similarity above $1 - \epsilon$), the redundant instance is pruned. By default, the method keeps the example with the lowest cosine similarity to the cluster centroid to preserve diversity.

The deduplication pipeline is lightweight: deduplicating LAION-440M takes less than 1% of the GPU hours required to pre-train CLIP on the dataset.

Datasets

  • Vision/Multimodal:
  • LAION-440M (a CAT-filtered subset of LAION-2B) and LAION-233M (an uncurated subset of LAION-400M).
  • Evaluated on 30 zero-shot datasets, including ImageNet-1k, 23 common classification tasks (e.g., CIFAR, Caltech101, Flowers), and 6 Out-of-Distribution (OOD) benchmarks: ImageNet-A, ImageNet-O, ImageNet-R, ImageNet-Sketch, ImageNetV2, and ObjectNet.
  • Language:
  • C4 (Colossal Clean Crawled Corpus).
  • Evaluated on the C4 validation set, OPT validation benchmarks (opt_valid), and instruction-tuning evaluation data (prompts_with_answers).

Key Insights and Ideas

  • Extreme redundancy in supposedly clean data: In LAION-440M (which had already undergone text and complexity filtering), 30% of images possess a semantic duplicate at an extremely strict distance threshold ($\epsilon = 0.00095$), and 50% match at $\epsilon = 0.124$.
  • Small embedders work just fine: The foundation model used to generate embeddings does not need to be massive or trained on web-scale data. A standard self-supervised DINO model trained only on ImageNet-1k (1.2M images) performed as effectively at deduplicating LAION-440M as a 400M-scale CLIP model.
  • Data pruning beats random downsampling: Randomly dropping data causes immediate downstream performance decay. Pruning semantic duplicates preserves accuracy and frequently improves generalization.

Key Results

  • 2x Faster Pre-training: Pruning 50% of LAION-440M matched baseline CLIP zero-shot ImageNet accuracy within 0.38% (68.27% vs. 68.65%) while taking half the training time.
  • Better Generalization on Less Data: When keeping 63% of the data, CLIP outperformed the 100% baseline on 19 out of 30 vision tasks and achieved higher average OOD zero-shot accuracy (56.08% vs. 55.84%).
  • Language Modeling Compute Savings: On C4, SemDeDup enabled 125M and 1.3B OPT models to reach the baseline perplexity of a 1-epoch run using 10–15% less compute by training across multiple epochs on smaller, deduplicated subsets. It also matched the performance of previous near-duplicate string-matching baselines while discarding significantly more data (keeping only 80%).

Limitations and Future Work

  • Intra-cluster boundary misses: Because comparisons are strictly confined to clusters, duplicate pairs that happen to be assigned to adjacent clusters are overlooked (though author approximations indicate SemDeDup still captures 89–95% of all duplicates).
  • Unimodal filtering for multimodal data: On vision-language datasets, SemDeDup only embeds the image, entirely ignoring the corresponding text captions. Future multimodal extensions could jointly condition on both text and images.
  • Manual threshold tuning: The threshold $\epsilon$ currently needs manual interpolation across cluster subsets to achieve a target pruning ratio.

Summary updated

BibTeX
@inproceedings{abbas2023semdedup,
  author = {Amro Kamal Mohamed Abbas and Kushal Tirumala and Daniel Simig and Surya Ganguli and Ari S. Morcos},
  title = {{SemDeDup: Data-efficient learning at web-scale through semantic deduplication}},
  booktitle = {ME-FoMo @ ICLR},
  year = {2023},
  url = {https://openreview.net/forum?id=4vlGm9gv6c},
}
Figure