Skip to content

Which rows to label next: active learning with BADGE

Labels cost money, so choose which rows to label. BADGE picks a batch that is uncertain and varied, using gradient embeddings and k-means++ seeding. How it works, what it over-selects, and how to judge it fairly.

Advanced ~12 min8 steps

What runs in CodeSplash

You will be able to

  • Explain why pure uncertainty sampling picks redundant batches
  • Build a BADGE gradient embedding and say what its length and direction mean
  • Describe k-means++ seeding as a way to pick a varied, uncertain batch
  • Design a fair comparison with random labeling and say why acquired labels aren't a random sample

Read first

01

Spend labels where they teach

Read

Thousands of rows have no label, and labeling each one costs an expert's time. Active learningActive learningChoosing which unlabeled rows to label next so a few labels improve the model as much as possible. lets the current model choose which rows to label next, then retrains and repeats.

The obvious choice, label the rows the model is least sure about, breaks down in batches. The ten least certain rows are often near-duplicates sitting in the same confusing corner, so ten labels teach one lesson. A good batch is uncertain and varied.

02

Gradient embeddings

Read

BADGEBADGEAn active learning rule that picks rows with large, varied loss gradients, so they are both uncertain and different from each other. represents each unlabeled row by how the model's last layer would change if its own best guess y^\hat y turned out to be the label:

gx=(pθ(⋅∣x)−ey^)⊗hθ(x),g_x=\big(p_\theta(\cdot\mid x)-e_{\hat y}\big)\otimes h_\theta(x),

where hθ(x)h_\theta(x) is the row's representation feeding the last layer. The length of gxg_x grows with uncertainty (a confident row has p≈ey^p\approx e_{\hat y}, so gx≈0g_x\approx 0); its direction says which weights the row would move. In the reference's example, a confident row's embedding entries are about ±0.100, an uncertain row's ±0.450.

03

Picking a varied batch

Read

BADGE picks the batch the way k-means++ picks starting centers. Take the row with the longest embedding first; then pick each next row with probability proportional to its squared distance to the nearest row already chosen,

Pr⁡(x next)∝min⁡s∈S∥gx−gs∥22.\Pr(x\ \text{next})\propto\min_{s\in S}\lVert g_x-g_s\rVert_2^2.

Long embeddings (uncertain) and far from the chosen ones (different) both raise the chance, with no hand-tuned mix of the two. A fixed seed gives the same batch every time.

Give the pool near-duplicates and compare a batch of the most uncertain rows with a BADGE batch.

DExplorable · Which rows to label next: uncertainty against BADGE

With a labeling budget, should you ask about the rows the model is least sure of, or about rows that differ from each other too?

When the pool has near-duplicates, what will a batch of the most uncertain rows be full of?

How sure?
3

Each of the 100 pool points appears this many times with tiny jitter, as real pools often do.

10

Rows sent for labeling at once, before the model is refit.

5

Label, refit, choose again. Every strategy starts from the same 4 labeled rows.

0.90

Moves the two class centers toward each other.

Uncertainty sampling · 5 near-duplicates in the last batch

BADGE · 0 near-duplicates in the last batch

Red rings are the last batch each strategy asked for. Uncertainty sampling piles up on copies of the same doubtful points; BADGE's batches spread out. Random (gray) is the honest baseline every acquisition strategy has to beat.

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

04

Uncertain, or just odd?

Predict

Predict first

The pool contains corrupted rows and cases even experts disagree on. What will BADGE tend to pick among them?

Mostly the most informative rowsSome outliers and ambiguous rows too
Reveal

Some of them. Corrupted and ambiguous rows look uncertain and unusual, exactly what BADGE seeks. Labeling them can be slow or impossible. Filter the pool for obvious junk, let reviewers skip rows, and watch what the batches contain.

05

A fair comparison

Read

To show active learning helped, compare it with random selection from the same starting labels, the same annotators, the same training budget and several random seeds. Plot performance against the number of labels (and labeling time) on an evaluation set that never changes between rounds and is never used to choose anything.

Remember what you've built: acquired labels are not a random sample of the population. Don't estimate class frequencies or report accuracy from them; use the fixed evaluation set. Correlated rows (several from one patient or document) should be queried as one unit.

06

Where it stands in CodeSplash

Read
EntryIn CodeSplash
BADGE batch active learning (ROB008)Runs on the Predict run page as Acquire labels: the pool is the rows missing the target; the host scores them from the run's model and picks a batch with BADGE; you type labels, skip rows, and save a new dataset version

It isn't a registry method, so the readiness badge reads "Runs in CodeSplash (Predict)". The app's embeddings use the run's input features rather than a network's last hidden layer.

Reference · ROB008 · Runs in CodeSplash (Predict)BADGE batch active learningChoose an unlabeled batch using both predictive uncertainty and diversity in a hypothetical last-layer gradient representation.
07

Check your understanding

Checkpoint

Check yourself

Why does labeling the ten least certain rows often waste effort?

Show the answer

Answer: a

BADGE adds diversity: it spreads the batch across different directions of the gradient embedding.

Check yourself

A row's BADGE gradient embedding is nearly zero. What does that mean?

Show the answer

Answer: b

gx=(p−ey^)⊗hg_x=(p-e_{\hat y})\otimes h vanishes when p≈ey^p\approx e_{\hat y}. Long embeddings mark uncertain rows.

Check yourself

After the first pick, how does BADGE choose the next row?

Show the answer

Answer: b

That's k-means++ seeding on gradient embeddings: uncertain and different rows are both likely picks.

Check yourself

After five rounds of BADGE, can you estimate the share of each class in the population from the labels you collected?

Show the answer

Answer: b

Acquisition is deliberately non-random. Keep a fixed evaluation set for performance and population estimates.

08

Where this track leaves you

Recap

You've seen robustness to attacks, with and without guarantees; to shifted groups and domains; and to imperfect or missing labels. In every case the claim is only as strong as the threat model, the groups or the evaluation set you stated in advance.

Concepts in this lesson