What challenges arise when a classification problem scales to an extreme number of classes?
Role: Machine Learning Engineer
Category: Machine Learning
Difficulty: hard
Interview Round: Other
What challenges arise when a classification problem scales to an extreme number of classes, for example tens of thousands to millions of labels?
```hint Count the cost
Estimate the size of the output layer and the work per example for a softmax over a million classes fed by a 1,024-dimensional representation.
```
```hint Look at the label counts
Think about how many training examples a typical class gets when label frequencies follow a long tail, and what that means for learning and for evaluation.
```
### What a Strong Answer Covers
- Training, memory and serving costs of a flat model that scores every class, with rough numbers
- The long-tailed label distribution, missing or noisy labels, and the multi-label nature of many such problems
- Evaluation metrics suited to ranking among many labels and to giving credit for rare labels
- Methods that avoid scoring every class: softmax approximations, label trees or partitions, and embedding retrieval with re-ranking
- The trade-offs of those methods, such as bias from sampling or errors from routing
### Follow-up Questions
- Sampled softmax trains faster. How do you correct for the sampling distribution, and what do you use at inference?
- How would you add new labels after deployment without retraining the whole model?
- In a label tree, what happens when a sample is routed down the wrong branch early, and how do methods reduce that error?
- Why do missing labels hurt precision@k, and what do propensity-scored metrics change?
Overview: Asks what breaks when a classifier has to choose among tens of thousands to millions of labels. Tests your grasp of the compute and memory cost of scoring every class, long-tailed and missing labels, suitable ranking metrics, and the methods that avoid scoring all classes for each example.