10/35
Part 2 of 6 · Clean and map the pileLearn and do

Clusters give the pile a map

k-means over the embeddings, with something like 100,000 clusters, gives the pile a map. DataComp clustered its candidate pool into 100,000 groups using Faiss, and DINOv2's retrieval by cluster used 100,000 clusters too.

The map shows how lopsided the pile is. Vo and coauthors, writing about automatic curation, describe a long tail: in data gathered this way, a few dominant concepts take up a large share, and the rest appear less often.

Their example: on web image sites, website or dog shows up far more than plunger. Their fix is hierarchical k-means with sampling balanced across clusters, so the head doesn't swamp the tail.

Beyond dedup, you'll use the clusters three ways:

  • Coverage. Which clusters have no labeled images at all? There, the model has seen nothing.
  • Budget caps. No cluster gets more than a fixed share of a batch, so 5,000 near-identical uncertain images can't take 5,000 slots.
  • Rare concepts. A small, tight cluster far from the training data is a candidate new concept.

Training k-means takes a sample, not the pile. Faiss's guidance is 30 × K to 256 × K training vectors, the more the better. For K=100,000K = 100{,}000 that's 3 to 25.6 million vectors.

Then every image goes to its nearest centroid. By brute force that's 109×105×768×2≈1.5×101710^9 \times 10^5 \times 768 \times 2 \approx 1.5 \times 10^{17} operations, about 26 minutes on one GPU at the same 100 TFLOPS.

In the editor, write capped(ranked, cap). ranked is a scored list, best first, of (image, cluster) pairs, and four of its top five images come from cluster c7.