KatInterview

Build a Product Taxonomy Classifier Across Inconsistent Labels

Machine LearningModel answer
HardModel answerMachine Learninghierarchical classificationmulti-labeltaxonomy

Last updated

Design a production ML system that assigns products to a noisy, multi-path category tree with consistent predictions, calibrated confidence, and sub-100ms latency.

Context

An e-commerce platform maintains a category tree for its product catalog. The tree has roughly 10,000 nodes, a depth of 5–7 levels, and a heavy long tail: the top 1% of nodes account for more than half of all labeled products.

Merchants tag their own products, so the label data is noisy. Tags are missing at some levels, contradictory at others, and use non-canonical synonyms throughout. A single product can legitimately belong to multiple paths through the tree — a ceramic mug gift set belongs under both Home > Kitchen > Drinkware and Gifts > Gift Sets.

The system is used by several downstream consumers: search facets, tax and shipping logic, ads targeting, and recommendations. Each consumer has different tolerance for precision versus recall errors. Tax logic requires high precision. Discovery features tolerate more recall.

What you are being asked to design

Walk through the complete design of a classifier for this setting. Your answer should cover:

  1. Label space definition — is this multi-class or multi-label? What constraint must every output satisfy?
  2. Data cleaning and taxonomy normalization — how do you turn noisy merchant tags into usable training labels?
  3. Model architecture — what encoder, label representation, and dependency-modeling approach would you use?
  4. Loss function — how do you handle unknown descendants, easy-negative flood, and class imbalance?
  5. Thresholding and decoding — how do you produce a consistent, calibrated set of paths at inference time?
  6. Evaluation — what metrics capture both head and tail performance, and how do you give partial credit for near-miss predictions?
  7. Operational concerns — training data volume, online latency target, and monitoring strategy.

For each decision, state your recommendation and explain why you prefer it over the main alternatives.

Hints

Hint 1

Before touching models, nail down exactly what a valid output looks like. If a leaf node is predicted positive, what must be true about every node above it? This constraint shapes every later decision.

Hint 2

Merchant tags are often present at the leaf level but missing at intermediate levels, or vice versa. These partial paths are not negative labels for the missing nodes — treating them as negatives is one of the most common mistakes. Think about how you signal 'unknown' to the loss function.

Hint 3

Three approaches exist for enforcing hierarchy consistency: (1) model conditional probabilities top-down, (2) apply a post-hoc fix after a flat sigmoid, or (3) build consistency into the architecture with a max-constraint layer. Think through where each approach fails before picking one.