Finding the interesting images in an unlabeled pile
- Turn "interesting" into a label a person can judge in about ten seconds, before you pick any model
- Clean a billion raw images in order, with exact, perceptual and semantic dedup, quality filters, embeddings and clusters
- Why the most novel images are usually junk, and how quality filters, a density floor and scoring whole clusters fix it
- Spend a label budget with uncertainty, disagreement, core-sets and CLIP text queries, and split one batch between them
- Run a labeling loop with gold questions and Cohen's kappa, where each round's labels pick the next round
- Prove it worked, with precision and its interval, planted examples for recall, and a retrain against random picks at the same cost
- Size it for a billion images, covering embedding time, storage with and without compression, and nearest-neighbor search
Find the interesting images in a huge unlabeled pile
Design an ML system that can find interesting images out of a huge pile of images. Nobody has labeled the pile, and it's far too big for people to look through. Tell me what you'd build, how you'd know it's finding the right images, and roughly what it costs.
One OpenAI machine learning engineer candidate, interviewed in April 2026, reported a phone screen made of four one-hour rounds (1 report). In that same report, the ML system design round was titled "Mining novel data from a large unlabeled corpus," and its whole prompt was one line: "Design an ML system that can find interesting images out of a huge pile of images." (1 report)
That's one report. Treat it as one round someone faced, not as the way every loop runs.
It sounds like a modeling question. It's a budgeting question. People can look at a tiny share of the pile, so the design decides which images they see. You start with that budget and with what interesting means. Then you build the system in the order you present it in the round:
The first two stages clean the pile and give it a shape. The last four are a loop, and each round sharpens the next. Several scores feed the score stage, because each one fails in its own way. Labeling is the only ground truth you have.
After the design come the proof that it worked and the cost of the whole thing. The lesson ends on a mock interview: eight questions in the order a 45-minute round runs, from what interesting means to what a full pass costs. The design method lesson has the general plan for any 45-minute design round.
Almost none of the pile will ever get a person's look
The design starts from one fact: almost none of the pile will ever be seen by a person.
A billion images, and the label budget covers 100,000 a round. What share gets a person's look?
Pin down what interesting means, before any model
Interesting is the word the whole design turns on, so define it.
Interesting has four meanings, and a labeler can judge three
| Meaning | Example | What scores it | What a labeler is asked |
|---|---|---|---|
| Novel | a scene or object type the model has never seen | distance from everything in the training set | Is there something here the model has no category for? |
| Rare | a known slice with few examples, like low light | slice queries, small clusters | Does this image show the slice? |
| Hard | images the current model gets wrong | uncertainty, disagreement, predicted error | Is the model's output on this image wrong? The output is shown. |
| Valuable | images that improve the model once added | only a retrain can tell | Nobody can judge this from one image. |
Each meaning leads to a different system, so ask the stakeholder which one they mean.
The last row is the one everyone wants, and no labeler can judge it. So you approximate it with the other three, and measure it at the end with a retrain. Say that out loud in the round. It shows you know the difference between a proxy and the goal.
In the editor, write meanings(image) for the three meanings a labeler can judge. Each dict in images holds an image's novelty score, its slice and whether the model got it wrong, and RARE_SLICES holds two known rare slices.
Turn the meaning into a rubric a person applies in ten seconds
Labelers need that meaning as questions they can answer quickly.
| One labeling task, an example | Answers |
|---|---|
| 1. Usable? Not blank, corrupted, unsafe or a copy. | yes, no |
| 2. Is the model's output wrong, or missing something? | yes, no, unsure |
| 3. Which slice? | low light, e-scooters, ..., other |
The image and the model's output sit next to the questions. The answers are grouped each round into the next round's pick list.
Say the team wants failure cases and unseen examples for a vision model. Three questions on one screen work.
Question 1 catches junk. Question 2 is the failure label, and the labeler answers it with the prediction in view. Question 3 has a pick list of known weak slices, plus other, with a short description.
The other answers are how unknown problems become known ones. Group them each round, and they become the next round's slices.
In the editor, write next_slices(others, min_count). The list others holds what labelers typed after they picked other, with messy capitals and stray spaces, and the function turns the repeats into next round's slices.
Clean the pile: copies first, then junk
Before any scoring, the pile needs cleaning.
Copies burn labels, fake density and leak into tests
A photo appears 500 times in the pile. What do the copies do to a density score?
Three passes catch copies, cheapest first
No single test catches every kind of copy.
| Pass | Catches | Misses | For a billion |
|---|---|---|---|
| exact, SHA-256 | byte-identical files | any re-save | 32 GB |
| perceptual, PDQ | re-saves and resizes | crops, big edits | 32 GB |
| semantic | crops, margins, filters | 1.5 TB |
Exact. Take the SHA-256 of each file's bytes, a 32-byte digest. A sort or a hash join over a billion of them finds every byte-identical copy.
Perceptual. A perceptual hash summarizes what an image looks like, so a resized or recompressed copy gets a nearby hash. Meta's open-source PDQ is built for this job:
- Each hash is 256 bits. Two hashes are compared by Hamming distance, the number of bits that differ.
- PDQ's README treats two hashes as a match at a distance of 31 or less, 31 of the 256 bits.
- Each hash comes with a quality score from 0 to 100 that measures detail, for spotting blurry or featureless images.
Semantic. The third pass needs a vector for each image, so it runs once the embeddings exist.
In the editor, write hamming(a, b) and same_photo(a, b). The stub builds three 256-bit PDQ hashes as Python ints: an original, a resaved copy 31 bits away and a cropped copy 40 bits away.
Filter junk first, then check which slices the filters drop
Junk comes in a few kinds:
- files that won't decode
- thumbnails
- blank or solid frames
- heavy blur
- extreme aspect ratios
- screenshots
- unsafe content
Cheap signals catch most of it: whether the file decodes, its pixel dimensions, its pixel variance, and PDQ's quality score. That score exists for exactly this. PDQ's README says it lets a system filter junky or featureless images out, and suggests discarding hashes with a quality of 49 or less.
Filters run before any novelty score, because junk is the most novel thing in the pile.
Night photos are dark. Fog is low in detail. Motion blur is blur. A filter tuned to drop low quality drops the very slices a vision team usually wants.
So find out what each filter costs before you trust it:
- Measure each filter's drop rate on a labeled random sample, slice by slice.
- Send borderline images to a maybe junk, maybe hard bucket, with a small labeling budget of its own, instead of deleting them.
In the editor, write drop_rates(sample) and costly(rates, limit). sample is a labeled random sample of 170 images, each a (slice, dropped) pair that says whether the junk filters threw it away.
Give every image a vector, then a map
With a clean pile, the next stage gives it a shape.
Novelty depends on the space you measure it in
Two images look nearly the same to a person, but one is rotated. In pixel space, how far apart are they?
The third dedup pass compares pairs only inside clusters
Comparing every pair of N images is about N² / 2 pairs. Comparing pairs only inside k equal clusters is N² / (2k): 4 clusters cut the work 4 times.
The same scene with a new crop or filter gets a different hash, and nearly the same embedding. The SemDeDup paper describes these duplicates: the same image with distortions that get past exact dedup, such as different margins, crops, aspect ratios and color filters.
Its method has two steps. First, cluster the embeddings with k-means, which splits the vectors into k groups around k centers. Then, within each cluster, compute the cosine similarity of every pair, and call pairs above a threshold duplicates. On a subset of LAION, SemDeDup could remove 50% of the data with minimal performance loss, effectively halving training time.
The clusters are what make it affordable. All pairs among a billion images is about . SemDeDup used 50,000 clusters for CLIP image embeddings. With 20,000 images in each:
That's 50,000 times fewer. With equal clusters, the saving always equals the number of clusters.
Each pair is a dot product over 768 dimensions: a multiply and an add for each one. So the pass is floating-point operations. Assume a GPU sustains 100 TFLOPS, 100 trillion floating-point operations a second, on large matrix multiplies. Then the pass takes about 150 seconds.
Real clusters aren't equal. The cost grows with the sum of the squared cluster sizes, so one giant cluster can dominate. Split any cluster above a size cap before the pairwise pass.
In the editor, write pairs(sizes) and saving(n, sizes), where sizes lists how many images each cluster holds. The last line checks SemDeDup's case: a billion images in 50,000 clusters of 20,000.
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 that's 3 to 25.6 million vectors.
Then every image goes to its nearest centroid. By brute force that's 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.
Score the pile three ways
Three kinds of score find candidates: novelty, the model's own signals, and text queries. Each one fails in its own way, so a design uses all three.
The most novel images are junk
Rank a filtered pile by distance to the nearest training images. What's at the top?
A real new concept shows up many times
Novelty alone has a flaw: the most novel images are often broken ones.
| Image | Novelty vs. the training set | Pile neighbors above cosine 0.85 | What it is |
|---|---|---|---|
| A | 0.92 | 0 | corrupted JPEG, gray blocks |
| B | 0.88 | 1 | blank frame |
| C | 0.61 | 340 | delivery robots on sidewalks |
| D | 0.55 | 2,100 | e-scooters, a known rare slice |
| E | 0.20 | 50,000 | an ordinary street scene |
A real new concept behaves differently from junk. In a billion images it shows up many times. A delivery robot on a sidewalk appears in thousands of photos, while a corrupted file is corrupted in its own way. So add a second number: how dense the image's neighborhood is in the pile itself.
Ranking by novelty alone puts A and B on top. Require at least 20 neighbors in the pile, a density floor, and A and B drop out. C and D lead.
Three fixes, in the order you add them
- Filter first. Quality filters and PDQ's quality score remove most images like A and B before any scoring.
- Put a density floor under novelty. Only images with enough neighbors in the pile can score as novel. Settles calls the general idea information density: an informative example is not only uncertain, it's also representative of the data, in a dense region of it.
- Score clusters, not points. Take clusters whose centroid sits far from . Label five images from each, and promote or drop the whole cluster. Five labels judge all 340 delivery-robot images at once.
Here is a pile with ordinary images near the training set, a tight group of a new concept, and a sprinkle of junk. Rank it by distance alone, then raise the density floor.
- Junk
- 14
- New concept
- 6
- Ordinary
- 0
Novelty is the distance to the 3rd nearest training image. Neighbors are pile images within 0.35 of a point. Junk sits alone, far from everything. A real new concept is far from the training set too, but it shows up many times.
In the editor, write novelty(X, R, k=10) with NumPy, then pick(scores, neighbors, floor=20). The tests use images A to E from the table: scores holds their novelty and neighbors their count of neighbors in the pile.
The rows of X (n, d) and R (m, d) are unit vectors. Write novelty(X, R, k=10): one minus each row's cosine similarity to its k-th nearest row of R, shape (n,). Then pick(scores, neighbors, floor=20): the indices of the images with at least floor neighbors in the pile, most novel first.
The model can point at its own mistakes
If interesting means failure cases, the model is its own best detector. Three kinds of signal:
- Uncertainty. Least confident, : one minus the probability of the top class. Or the margin between the top two classes, or the entropy of the prediction. It's cheap, and it finds the decision boundary. It also loves ambiguous and junk images, because a model is unsure about anything unlike its training data.
- Disagreement. When two models disagree, one of them is wrong. Compare the current model with the last version, a big model with a small one, the model with a weak signal like metadata, or one video frame with the next. A prediction that flickers between frames is a free error signal.
- Predicted error. After a round or two you have labeled mistakes. Train a small classifier on the embeddings to predict whether the model got an image wrong, and run it over the pile. Last round's errors become a detector for next round's.
Once a failure mode has a name, train a quick classifier for that slice, run it over everything, and label what it fires on. These per-slice classifiers are probes: linear models on the embeddings, trained on a few hundred yes and no labels.
Expect a noisy stream. In a talk on Tesla's data engine, Karpathy describes doing this for occluded stop signs, and says roughly one in ten returned images was the real thing. That's fine. A labeler rejects a false positive in a second, and the true ones are images random sampling would almost never surface.
In the editor, write least_confident(p) and margin(p). Each list holds the model's class probabilities for one image: p_close_call splits nearly evenly between two classes, and p_sure doesn't.
Karpathy on Tesla's data engine. Hard cases come from uncertainty, flicker and map-versus-vision disagreement, a small detector runs over the fleet's stream and returns a noisy set to label, and curated test sets decide whether the loop worked.
Text queries fill a slice someone can name
Scores find what nobody asked for. Sometimes the team knows exactly what it wants.
When the team can name what it wants, like pedestrians at night in the rain or a forklift indoors, write it down. Embed the prompt with CLIP's text encoder, and score every image by its cosine similarity to the prompt.
The math is one matrix multiply. Scoring a billion 768-dimension vectors against 1,000 prompts at once is operations, about 15 seconds on one GPU. Reading 1.5 TB of embeddings takes far longer than the math, so batch every prompt you have into one pass.
Two cautions:
- A CLIP similarity has no fixed meaning. LAION-2B, for example, kept the image and caption pairs with an English caption and a similarity above 0.28 under one trained ViT-B/32 CLIP model. That cutoff fits one model and one use. Pick thresholds from labeled samples, never from a hunch about what 0.3 means.
- Text queries only find what someone thought to ask for. They're the best way to fill a known slice, and no help with unknown ones.
The positives you label from a text query become seeds. A probe needs only a few hundred yes and no labels, and it scores the whole pile for that slice in one pass.
Large curation pipelines work the same way: they retrieve toward a target set. DataComp's image-based filter clustered its pool, found the nearest cluster for every ImageNet training example, and kept those clusters.
Combined with filtering by CLIP score, that filter produced DataComp-1B. A CLIP model trained from scratch on it reached 79.2% zero-shot accuracy on ImageNet, which means with no ImageNet training at all. The model was a ViT-L/14, a large vision transformer. It beat OpenAI's own CLIP ViT-L/14 by 3.7 percentage points, with the same training procedure and compute.
DINOv2 built its curated training set the same way: it retrieved images from its uncurated source that were close to images in its curated sources.
In the editor, write precision_at(labeled, cutoff) and lowest_cutoff(labeled, target). labeled holds ten images from the top of a text query's list, each with its similarity to the prompt and whether a person said yes.
Spend the label budget: active learning
Everything so far produces candidates. Active learning is choosing among them. Settles' survey starts from its key idea: a learning algorithm can reach higher accuracy with fewer labels if it gets to choose the data it learns from.
Here it runs in batches: score the pool, pick a batch, label it, retrain, re-score.
A batch of the most uncertain images is one confusing thing, many times
The batch is where simple strategies break. The 10,000 most uncertain images are often 10,000 views of the same confusing thing.
Sener and Savarese found that many active learning heuristics from the literature, the usual rules for what to pick, aren't effective for CNNs in the batch setting, where you pick many images at once. They recast the problem as covering the data, as core-set selection: choose a set of points so that a model trained on that subset does about as well on the remaining points as on the subset itself.
Their greedy k-center algorithm is simple. Repeatedly add the candidate farthest from everything already selected or labeled. It spreads the batch across the space.
It also reaches for the farthest points first, and those are outliers. Put two junk images in the pool, and they become its first two picks, before any real candidate. The paper adds an outlier budget to make k-center robust: it assumes an upper limit on the number of outliers. In practice, run k-center inside a filtered candidate set, never over the raw pile.
The editor holds a greedy k_center with a bug, so run it first: all three picks land in one corner. labeled is the one image already labeled at (0, 0), three of the five candidates sit together near (10, 10), and Point is a name for an (x, y) pair.
Mix the sources in every batch
A round has one batch of labels, and several sources of candidates compete for it.
Why not fill a whole batch from the single best source?
Search only near what you've already found
Rescoring a billion candidates is slow when the scorer changes every round. Coleman and coauthors' SEALS narrows the search. It limits the candidates for labeling to the nearest neighbors of the images already labeled, instead of scanning all the unlabeled data.
With 100,000 labeled images and 100 neighbors each, the pool is 10 million candidates instead of a billion.
They tested it on a de-identified and aggregated dataset of 10 billion images from a large internet company. Mean average precision and recall stayed similar to the global approach, while the cost of selection fell by up to three orders of magnitude.
SEALS only searches near what you've already found. That's one more reason to keep the coverage and random shares in every batch.
In the editor, write candidate_pool(labeled, neighbors) and max_pool(n_labeled, k, pile). neighbors maps three images to their nearest neighbors in the pile, and images a and b are already labeled.
From MIT's Data-Centric AI course. Cody Coleman on active learning when the unlabeled pool is billions of images, why scanning all of it is intractable, searching only near the labeled examples, and core-set selection.
Label, check the labels, and loop
The batch goes to people next, and their time is the real cost.
A round of labels takes about 370 hours of people's time
| Step | Computation | Result |
|---|---|---|
| judgments | 100,000 images × 1.2 | 120,000 |
| tasks | 120,000 ÷ 0.9, gold included | ≈ 133,333 |
| time | 133,333 × 10 seconds | ≈ 370 labeler-hours |
| cost | 370 hours × $30 | ≈ $11,100 a round |
The assumptions behind each line:
- Every image gets one judgment, and 20% get a second one: every unsure answer, plus a random slice.
- Gold questions, items with known answers, are 10% of all tasks.
- A judgment takes 10 seconds, and a labeler costs $30 an hour.
Say it out loud: a round costs days of human time, and more money than embedding the entire pile.
Gold questions grade the labelers
Mix items with known answers into the queue, unannounced. These are gold questions, and they measure every labeler, all the time. Three rules:
- Make gold hard. Include hard cases and junk, not only easy images, or gold measures attention instead of judgment.
- Refresh it. Labelers learn to recognize repeated gold items.
- Act on it. A labeler below the bar, say 85% on gold, gets retrained, and their recent labels get a second look.
In the editor, write round_cost(images) with the defaults from the table: 20% second judgments, 10% gold, 10 seconds a judgment and 30 dollars an hour. It returns the tasks, the labeler-hours and the dollars for one round.
Write round_cost(images, second=0.2, gold=0.1, seconds=10, hourly=30). Every image gets one judgment, a second share get another, and gold is the share of all tasks that are gold questions. Return (tasks, hours, dollars).
Kappa takes the chance out of agreement
How do you know the labels are any good? Start with whether labelers agree.
Two labelers agree on 80% of the images. What else do you need, to know whether that's good?
A rare label makes raw agreement meaningless
Kappa matters most when the answer is usually no.
| Raw agreement | Kappa | |
|---|---|---|
| labelers A and B | 80% | 0.56 |
| two labelers saying yes 5% of the time, at random | 90.5% | 0 |
Suppose a label is rare, a slice that shows up in 5% of what labelers see. Two labelers each say yes 5% of the time, purely at random. They still agree of the time, more than A and B, and .
Report kappa, per question and per slice.
Low kappa points at a hole in the rubric
Two careful labelers keep disagreeing on the same kind of image. What do you fix?
Each round's labels pick the next round
Each round's labels do four jobs:
- Train the downstream model. The images where it was wrong, now labeled correctly, are training data. That was the point.
- Train the probes. A logistic regression on 768-dimension embeddings fits in seconds on a few thousand labels, and scores the pile in one pass.
- Update the error predictor with the new mistakes.
- Move the budget toward the sources with the best measured yield.
Here's a made-up round:
| Source | Labeled | Judged interesting | Yield |
|---|---|---|---|
| Probes and text queries | 40,000 | 24,800 | 62% |
| Uncertainty, spread with k-center | 25,000 | 12,000 | 48% |
| Clusters with no labels | 20,000 | 3,600 | 18% |
| Maybe-junk bucket | 5,000 | 600 | 12% |
| Random | 10,000 | 300 | 3% |
| All | 100,000 | 41,300 | 41% |
Probes and text queries win on yield and deserve more budget next round, though not all of it. They only find what someone asked for. The 18% from unlabeled clusters is where the slices nobody had named come from. The 3% random row is your base rate.
The editor holds yields(rows) and a buggy overall(rows), with rows copied from the made-up round's table. Run it: overall prints 28.6%, though the round's 100,000 labels found 41,300 hits.
Prove it worked: three questions, three measurements
Three questions prove it: is what we surface interesting, what are we missing, and did the model improve? Each needs its own measurement, and most designs answer only the first.
Is what we surface interesting? Precision per source, with an interval
Every selected image gets labeled, so each source's precision comes straight out of the round, as in the yield table. Precision is the share of a source's picks that were judged interesting.
The interval matters when a source is new. Say you try a new text query on 400 images, and 248 are judged interesting. Its precision is 62%, with a standard error of
So the 95% interval is 62% plus or minus 4.8 points, about 57% to 67%.
Give a source a big share of the next batch only after a test like this. And always report precision per source, since the round's blended 41% hides which sources earn their budget.
In the editor, write half_width(p, n) and labels_needed(p, half). The first checks the new text query's 248 of 400, and the second turns the question around: how many labels buy an interval that narrow.
What are we missing? Planted examples and a random audit
Precision can't see misses. Two tools can.
Planted examples. Take 1,000 images known to be interesting, kept out of every seed set and probe. Last quarter's labeled failures would do. Hide them in the pile and run the pipeline. If 640 land in the selected top 100,000, recall on the planted set is 64%. Recall here is the share of the planted images the pipeline found.
A random pick of 100,000 would catch of them. So the pipeline is about 6,400 times better than random, for this kind of image.
This kind is the catch. Planted images are known failure types, so they measure recall on what you already know about. Treat 64% as an optimistic number for unknown types.
A random audit. The random 10% of each batch is the audit. In the made-up round, 300 of 10,000 random images were interesting. That's a base rate of 3%, with a standard error of , so plus or minus 0.33 points.
So the pile holds about 30 million interesting images. The round found 41,300 of them, about 0.14%.
That last number reframes the problem. Recall over the whole pile will always be tiny, because the budget guarantees it. What matters is whether the 0.14% you find covers the slices that matter, and whether the model gets better.
In the editor, write interval(hits, n) for any measured share, and lift(found, planted, selected, pile) for the planted examples. The tests use the planted run: 640 of 1,000 found in a top 100,000 out of a billion.
Write interval(hits, n, z=1.96): the 95% interval (low, high) around a measured share hits / n. Then lift(found, planted, selected, pile): how many times more of the planted images the pipeline put among its selected than a random pick of the same size from the pile would.
Did the model improve? Retrain against random picks at the same cost
The final test of the whole system is the model it trains.
| Added to the same start | Then | |
|---|---|---|
| model 1 | N mined images | the same three tests |
| model 2 | N random images, labeled at the same cost | the same three tests |
Run both arms from the same starting point, with the same number of images, , labeled at the same cost. Then evaluate both on the same three tests:
- a test set for the target slices, built by a separate labeling pass that never used the miner's scores
- the standard test set, to catch regressions
- a fresh random sample of production traffic
The random arm is the control that matters. We added 50,000 images and the model improved is true of almost any 50,000 labeled images. The claim worth making is that these 50,000 beat 50,000 random ones.
Retrain each arm with several seeds, since the noise between two retrains can be larger than the gain.
In the editor, write mean_gain(mined, random) and clear_win(mined, random). Each list holds the slice error, in percent, of three retrains with different seeds: mined added the miner's images, and random added random ones at the same cost.
A worked example: a billion images, sized
State the assumptions, then do the arithmetic in front of the interviewer.
| Assumption | Value |
|---|---|
| Images | 1,000,000,000 |
| Average file | 200 KB, so 200 TB in all |
| Embedding size | 768 dimensions |
| Embedding throughput | 1,000 images per second per GPU, decoding included |
| Sustained math rate | 100 TFLOPS per GPU on large matrix multiplies |
| Price | $2 per GPU-hour |
Embedding the pile is cheap, and the effort goes into reading the files
A billion images at 1,000 a second on one GPU. About how many GPU-hours?
Keep float16 vectors, and search compressed codes in an inverted file
A billion vectors need a storage plan before they need a search.
Bytes for each vector: 3,328, 3,072, 1,536, 768, 64 and 32.
Keep the float16 vectors in object storage as the source of truth, and build compressed indexes for search.
At this size, compression isn't optional. The Faiss documentation says every Faiss index is stored in RAM. Its page on billion-scale indexes says that for 10 million to a billion vectors per server, compression becomes mandatory.
Product quantization (PQ) stores each vector as a short code. Faiss's PQ index makes M-byte codes, so with M = 64 a vector takes 64 bytes. Then 64 GB of codes plus 8 GB of 64-bit IDs fits on one large machine.
The popular graph index, HNSW, doesn't fit: it's the top bar. Faiss gives its memory use as bytes per vector, where is the dimension and the number of links per vector. With and , that's bytes, or 3.3 TB of RAM for a billion.
For 100 million to a billion vectors, the same guide recommends an inverted file with about a million lists over compressed codes, IVF1048576_HNSW32. Read the name in two parts:
IVF1048576is the inverted file, with lists.HNSW32is an HNSW graph over the million list centroids. It finds the lists nearest a query.
The design method lesson shows how IVF and HNSW work inside. What matters here is which searches you need.
In the editor, write bytes_per_vector(kind) for the five ways to store one vector in the chart, and total_tb(n, per_vector) for a billion of them.
Novelty against the training set is exact, and costs about 85 dollars
Compare each of the billion pile images with a reference set of, say, 10 million training images. By brute force that's dot products at 768 dimensions:
At 100 TFLOPS that's seconds, about 43 GPU-hours, roughly $85. It's exact, with no index to tune and no recall lost. It's tempting to assume billion-scale search needs approximation. This one doesn't.
Density within the pile: probe an index, or count in a 1% sample
Every image against every other image is dot products, about 4,300 GPU-hours by brute force.
An inverted file cuts that. With lists, each list holds about 954 vectors. Probing 64 lists scans about 61,000 vectors per query instead of a billion, about 16,000 times fewer. The Faiss paper reports results at this scale: a high-accuracy k-NN graph on 95 million images in 35 minutes, and a graph over 1 billion vectors in less than 12 hours on 4 Maxwell Titan X GPUs.
There's a cheaper move. A density floor doesn't need exact neighbors among a billion images. Count neighbors within a radius among a uniform 1% sample, 10 million images, and multiply by 100. That costs the same 43 GPU-hours as the novelty search, and the two can share one pass.
Semantic dedup and clustering, from earlier, take minutes to under an hour each.
In the editor, write brute_force_hours(queries, refs) and ivf_scanned(n, lists, probes). The last line prices the billion against 10 million novelty search, and the inverted file that probes 64 of its 1,048,576 lists.
Put the compute bill next to the labeling bill
Add up the compute, and compare it with the labeling bill.
Which costs more: one full pass of compute over the pile, or one round of labels?
What interviewers ask next
Your top-scored novel images are mostly blank frames and corrupted files
That's expected. It means the novelty score ran on an unfiltered pile. Three fixes:
- quality filters and PDQ's quality score before scoring
- a density floor, so only images with enough neighbors in the pile can be novel
- scoring clusters instead of single images
Then check what the filters drop, slice by slice, because dark, blurry and low-detail images are often the hard ones.
The mined images look great, but retraining barely moves the test set
Work through it in order:
- Look at the slice test. If the test set has 40 night images, a large gain at night barely moves the average.
- Check labeler accuracy on gold for that slice.
- Count clusters among the mined images. 5,000 views of one scene teach one thing.
- Plot slice error against the number of mined images added.
- Compare against random at equal budget. Otherwise you can't tell whether barely moving is worse than doing nothing clever.
In the editor, write average_change(slice_count, total, slice_change) and slice_needed(total, slice_change, visible). The last line asks about 40 night images in a 10,000-image test set, where night error falls by 15 points.
Labelers agree only 70% of the time
One follow-up: the labels come back noisy.
Labelers agree only 70% of the time. Where do you look first?
Pace the 45 minutes
The plan in the editor puts the whole round on one clock. Each block has a budget, and a slow start always comes out of the last two blocks: evaluation and scale.
In the editor, write block_at(plan, minute) and minutes_behind(plan, block, minute). plan is the 45-minute clock as (block, start minute, end minute) rows.
The practice round, start to finish
That's every piece the practice round needs. Here it is in order, from the first question to the last minute.
1.You rank a filtered pile by distance to the nearest training images, and the top 100 are mostly blank frames and corrupted files. What's the best fix?
2.Interesting images are 5% of what two labelers see, and they agree 90% of the time. What can you conclude?
3.How much RAM does an HNSW index with M = 32 need for a billion 768-dimensional float32 vectors, using Faiss's formula of d × 4 + M × 2 × 4 bytes per vector?
4.You retrain with 50,000 mined images and slice error falls from 18% to 12%. What's the most important missing comparison?
5.SemDeDup clusters a billion embeddings into 50,000 equal clusters before comparing pairs. About how many times fewer comparisons is that than all pairs?
6.640 of 1,000 planted known-interesting images land in the selected top 100,000. What does that tell you?
Where this shows up
The reports behind this lesson, each with its source.
Same report, ML system design round (titled 'Mining novel data from a large unlabeled corpus' on the page): design an ML system that finds interesting images in a huge pile of images.
MLE candidate (interviewed April 2026, onsite pending): the phone screen was four one-hour rounds.
Practice
Sources (15)
- SemDeDup: Data-efficient learning at web-scale through semantic deduplication · arXiv 2303.09540 · Mar 16, 2023
“Analyzing a subset of LAION, we show that SemDeDup can remove 50% of the data with minimal performance loss, effectively halving training time.”
- Learning Transferable Visual Models From Natural Language Supervision · arXiv 2103.00020 (CLIP) · Feb 26, 2021
“After pre-training, natural language is used to reference learned visual concepts (or describe new ones) enabling zero-shot transfer of the model to downstream tasks.”
- DINOv2: Learning Robust Visual Features without Supervision · arXiv 2304.07193 · Apr 14, 2023
“The whole processing is distributed on a compute cluster of 20 nodes equipped with 8 V100-32GB GPUs and takes less than two days to produce the LVD-142M dataset.”
- The TMK+PDQF video-hashing algorithm and the PDQ image-hashing algorithm · Meta ThreatExchange (hashing.pdf) · Aug 1, 2019
“Hashes are 256 bits with hamming distance, accompanied by a 0-100 quality metric which quantifies level of detail, e.g. for identifying blurry/featureless images.”
- PDQ reference implementation · Meta ThreatExchange on GitHub (pdq/README.md) · Oct 29, 2026
“Distance Threshold to consider two hashes to be similar/matching: <=31”
- Automatic Data Curation for Self-Supervised Learning: A Clustering-Based Approach · arXiv 2405.15613 · May 24, 2024
“However, datasets assembled that way exhibit a long-tailed distribution of concepts, i.e., a few dominant concepts take up a large portion of the dataset, while others appear less frequently.”
- DataComp: In search of the next generation of multimodal datasets · arXiv 2304.14108 (NeurIPS 2023 Datasets and Benchmarks) · Apr 27, 2023
“We then find the nearest neighbor group for every ImageNet training example, and keep examples belonging to these groups.”
- Active Learning Literature Survey · University of Wisconsin, Madison, Computer Sciences Technical Report 1648 · Jan 26, 2010
“The key idea behind active learning is that a machine learning algorithm can achieve greater accuracy with fewer training labels if it is allowed to choose the data from which it learns.”
- Active Learning for Convolutional Neural Networks: A Core-Set Approach · arXiv 1708.00489 (ICLR 2018) · Aug 1, 2017
“we define the problem of active learning as core-set selection, i.e. choosing set of points such that a model learned over the selected subset is competitive for the remaining data points.”
- Similarity Search for Efficient Active Learning and Search of Rare Concepts · arXiv 2007.00077 · Jun 30, 2020
“we improve the computational efficiency of active learning and search methods by restricting the candidate pool for labeling to the nearest neighbors of the currently labeled set instead of scanning over all of the unlabeled data.”
- Billion-scale similarity search with GPUs · arXiv 1702.08734 · Feb 28, 2017
“Our implementation enables the construction of a high accuracy k-NN graph on 95 million images from the Yfcc100M dataset in 35 minutes, and of a graph connecting 1 billion vectors in less than 12 hours on 4 Maxwell Titan X GPUs.”
- Guidelines to choose an index · Faiss wiki on GitHub · Oct 1, 2026
“The memory usage is (d * 4 + M * 2 * 4) bytes per vector.”
- Indexing 1G vectors · Faiss wiki on GitHub · Apr 1, 2021
“For those datasets, compression becomes mandatory (we are talking here about 10M-1G per server).”
- sklearn.metrics.cohen_kappa_score · scikit-learn 1.9.1 documentation · Sep 11, 2026
“a score that expresses the level of agreement between two annotators on a classification problem”
- clip-retrieval README · rom1504/clip-retrieval on GitHub · Jan 7, 2024
“clip inference allows you to quickly (1500 sample/s on a 3080) compute image and text embeddings”