When should you reframe a classifier with tens of thousands of classes as embedding retrieval instead of a softmax?

Quick Overview

Asks when a classification task with tens of thousands of labels should be reframed as embedding-based retrieval instead of one softmax over every class. Tests reasoning about when the label space makes a full softmax a poor fit, how retrieval models are trained, and what approximate nearest-neighbor search gives up.

When should you reframe a classifier with tens of thousands of classes as embedding retrieval instead of a softmax?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: hard

Interview Round: Other

You are building a classifier whose label space has tens of thousands of classes, such as products, entities or documents. When would you reframe the problem as embedding-based retrieval instead of a single `softmax` over all classes? ```hint Look past the class count Ask what happens to the output layer when a new class appears tomorrow, or when a class has only three training examples. ``` ```hint Count the costs too Think about what you give up at inference time when an exact score for every class is replaced by a nearest-neighbor lookup. ``` ### What a Strong Answer Covers - The conditions that favor retrieval, and whether the class count alone decides it - How a retrieval model is trained: the model structure, the loss, and how negatives are chosen - The inference cost of a full softmax compared with approximate nearest-neighbor search - What retrieval gives up compared with an exact softmax - When a plain softmax is still the better choice ### Follow-up Questions - In-batch negatives are drawn in proportion to class popularity. What does that do to popular classes, and how do you correct it? - A downstream system needs calibrated probabilities. How do you get them from a retrieval model? - How would you evaluate the system offline so that the model's errors and the ANN index's recall loss are measured separately? - A new class arrives with only a text description and no labeled examples. Walk through how it gets predicted on its first day.

Overview: Asks when a classification task with tens of thousands of labels should be reframed as embedding-based retrieval instead of one softmax over every class. Tests reasoning about when the label space makes a full softmax a poor fit, how retrieval models are trained, and what approximate nearest-neighbor search gives up.

Nov 24, 2026
hardMachine Learning EngineerOtherMachine Learning
0
0

You are building a classifier whose label space has tens of thousands of classes, such as products, entities or documents. When would you reframe the problem as embedding-based retrieval instead of a single softmax over all classes?

What a Strong Answer Covers Guidance

  • The conditions that favor retrieval, and whether the class count alone decides it
  • How a retrieval model is trained: the model structure, the loss, and how negatives are chosen
  • The inference cost of a full softmax compared with approximate nearest-neighbor search
  • What retrieval gives up compared with an exact softmax
  • When a plain softmax is still the better choice

Follow-up Questions Guidance

  • In-batch negatives are drawn in proportion to class popularity. What does that do to popular classes, and how do you correct it?
  • A downstream system needs calibrated probabilities. How do you get them from a retrieval model?
  • How would you evaluate the system offline so that the model's errors and the ANN index's recall loss are measured separately?
  • A new class arrives with only a text description and no labeled examples. Walk through how it gets predicted on its first day.