The interview problem

Practice prompt

A marketplace receives one million new or edited product listings each day. Assign each listing a primary category in a taxonomy of 8,000 leaves. Some titles are vague, seller labels are unreliable, and categories split or merge quarterly. Design a model and serving pipeline that can return a useful ancestor or request review rather than inventing a precise category.

Original ML design practice, not a reported company interview. Taxonomy, workloads and calculations are illustrative. Primary sources retrieved September 27, 2026; publication dates not stated; interview date not applicable.

1. Define what a correct label means

Assume a rooted tree and one primary leaf per product according to a written merchandising policy. A label identifies the item being sold, not every object mentioned in its description. A protective sleeve compatible with a tablet is not itself a tablet. Multi-product bundles need an explicit primary-function rule or a dedicated category; annotators must not improvise a different convention for each example.

Store immutable category IDs, taxonomy version, parent relationships, definitions and examples. Display names may change without changing identity; semantic changes need an explicit versioned mapping. Treat the root as uninformative, not a successful prediction. If multiple primary categories are genuinely required, redesign the target as multilabel instead of forcing this single-label solution onto it.

A category prediction supports discovery and routing. It is not by itself a decision about product safety or sale eligibility. Separate those rules and their evidence. Define acceptable outputs as an active leaf, a supported non-root ancestor, or an unresolved result with a reason.

2. Build labels that survive an audit

Start with adjudicated catalog labels and a stratified sample of new listings. Preserve the exact title, description, image references and structured fields visible when each judgment was made. Store taxonomy version, annotator decision, disagreements and whether the label was inferred from a seller category or confirmed by review.

Seller-supplied labels are useful weak supervision but not unquestioned truth. Maintain a clean evaluation set with independent adjudication, covering common sibling confusions, rare categories, accessories, bundles and missing inputs. Training on a model's own accepted predictions without tracking provenance can reinforce its errors.

Split by product family and time so nearly identical variants or duplicated seller listings do not appear on both sides. Test new sellers separately. A random row split can look strong because the same manufacturer's template occurs repeatedly. Audit any existing category field for target leakage; report separately whether the intended product includes or excludes seller-category input.

3. Establish a baseline and coherent hierarchy

listing event + immutable listing revision
                    ↓
       input validation and text/image preparation
                    ↓
       versioned text classifier → optional image fusion
                    ↓
          normalized probabilities over active leaves
                    ↓
      ancestor aggregation + calibrated decision policy
                    ↓
   leaf / ancestor / review, with taxonomy and model versions
                    ↓
       revision-checked write → search/catalog consumers

Begin with a text baseline using title, description and reliable structured fields. Compare a sparse linear model with a fine-tuned text encoder before adding images. A BERT-style classifier is one possible encoder baseline; its preprocessing and vocabulary must match the trained model. It is not a requirement to use a large generative model.

For a flat leaf softmax, compute an ancestor's probability by summing probabilities of its descendant leaves. This is coherent under the assumed mutually exclusive, exhaustive leaf target. It does not automatically make probabilities calibrated, and it is not the same calculation for overlapping multilabel categories.

An alternative predicts a conditional distribution over children at each node and multiplies probabilities along each path. Greedy routing can lose the best leaf: if branch A has probability 0.6 but its best child is a leaf with conditional probability 0.4, its best leaf is 0.24; branch B at 0.4 with a leaf child at 0.9 produces 0.36. Retain multiple branches or evaluate full path probabilities instead of committing too early.

Images can help when text is sparse, but packaging photos and compatibility diagrams can mislead. Compare text-only and multimodal results on missing-image and conflicting-input slices. Cache representations by content revision and encoder version; a changed image must invalidate the appropriate features.

4. Work through leaf versus ancestor decisions

Suppose the calibrated leaf probabilities are 0.46 for tablet sleeves, 0.39 for tablet stands and 0.15 outside the accessories parent. That parent has probability 0.85. The model is uncertain about the subtype while being more confident about the branch.

Use an illustrative cost model: a wrong leaf costs 10, a correct leaf costs 0, and a correct ancestor costs 2 because downstream browsing remains less specific. A wrong ancestor costs 10. Returning the best leaf has expected cost 10×0.54=5.4. Returning the accessories parent has cost 2×0.85+10×0.15=3.2. If review costs 3 including expected residual error and delay, review is preferable under these assumptions.

If review cost rises to 4, the ancestor becomes preferable. This does not justify silently changing quality promises when reviewers are busy. Queue limits should be part of the product contract, with explicit unresolved status where required. Estimate calibration and costs on representative data; a softmax number is not evidence that its confidence is trustworthy.

Choosing the root could trivially claim complete coverage. Forbid that shortcut through the output contract and a specificity cost. Report the depth and correctness of ancestor outputs alongside review rate and leaf coverage.

5. Handle category splits without fabricating labels

In taxonomy V1, suppose Travel Mugs is a leaf. V2 turns it into a parent with Insulated Travel Mugs and Non-insulated Travel Mugs beneath it. An old Travel Mugs label does not reveal which new child is correct. A one-to-many mapping is not a valid deterministic relabeling rule.

Retain old examples as partial supervision at the parent when their meaning supports it. A possible loss is −log of the total probability assigned to valid descendant leaves. This encourages the correct branch without pretending to know the child; it cannot identify the split from those examples alone. This assumes the retained parent annotation is a valid constraint, not a mislabeled item. Obtain newly adjudicated child labels and evaluate them separately; audit whether fine-grained labels were collected only for unusually easy products.

For a merge, mapping several old labels to one new label may be valid only if their semantics fit the new definition. Reparenting can change ancestor metrics even when leaf identity is stable. Store the mapping type and unresolved cases rather than overwriting historical labels.

Deploy model, taxonomy, calibration and output policy as a compatible bundle. Consumers reject an unknown taxonomy version or use an explicit adapter. During backfill, compare the listing revision before writing so a result computed for yesterday's description cannot overwrite today's correction. Preserve human overrides according to a defined expiry and re-review policy.

6. Measure precision without hiding lost specificity

Consider 1,000 independently adjudicated V2 listings. The system returns 800 leaf predictions, of which 720 are correct. It returns 150 ancestors, of which 135 contain the true leaf, and sends 50 to review. Leaf coverage is 80%; accuracy among leaf predictions is 720/800=90%; correct leaf resolution across all arrivals is 72%.

Among all 950 automated outputs, (720+135)/950=90% are either correct leaves or valid ancestors. That coincidentally equals leaf accuracy here, but measures a different outcome and must not replace it. Across all arrivals, valid automated resolution is 85.5%, including 13.5% with reduced specificity. Do not count unresolved review items as correct merely because a human will eventually see them.

Report macro per-leaf recall and confusion between siblings, along with traffic-weighted accuracy. Tail categories can disappear behind popular ones. Add review completion delay, downstream search usefulness and repeat correction rates. For a taxonomy split, show the affected cohort separately and compare systems on the same V2-labeled set or an explicitly shared coarser mapping.

Ancestor containment and tree distance are diagnostics, not universal business utility. An error across a shallow but consequential boundary may matter more than one across several harmless levels. Audit category-specific consequences and preserve those distinctions in decision costs.

7. Size serving and review capacity

One million daily edits average about 11.57 events per second. A 20× peak is about 231.48 events per second. At an illustrative 40 ms of inference-resource time per event, that is 9.26 continuously busy resource-equivalents before headroom. Measure real batch throughput, latency and utilization on the chosen hardware; this arithmetic does not directly specify a GPU count.

A 768-by-8,000 float32 classification head has 6,144,000 weights, about 24.576 MB, plus 32 KB of biases. That makes a flat head plausible in memory, though encoder compute and quality may dominate. If retrieving a small set of candidate leaves first, measure candidate recall: the classifier cannot select a true leaf that retrieval omitted.

At 5% review, one million events produce 50,000 reviews daily. At 45 seconds each, that is 625 review-hours. At six productive hours per reviewer per day, the steady load needs about 104.17 reviewer-days, so at least 105 equally capable reviewers before variability and leave. Deduplicate repeated unchanged edits and distinguish review requests from unique product decisions; do not quietly drop difficult products to make this queue appear affordable.

8. Plan for drift and incomplete evidence

A new product type may not fit any leaf. A closed-set softmax still assigns its probability somewhere, possibly with high confidence. Monitor review reasons, seller corrections and embedding/input shifts, but validate novelty detection with known held-out categories. High confidence alone cannot prove the item belongs in the taxonomy.

When upstream images fail, use a tested text-only fallback if it meets policy; otherwise return unresolved. During model or taxonomy outages, reuse a previous decision only if the listing revision and compatibility contract still permit it. Never attach a new taxonomy version to an old prediction merely to satisfy a schema check.

Seller text can include misleading keywords or instructions. Treat it as product data, not authority to alter taxonomy or workflow rules. If an LLM is used to generate candidate labels, constrain outputs to active IDs and still apply evidence and calibration checks. A syntactically valid ID can be semantically wrong.

9. Trade-offs and follow-ups

A flat classifier avoids irreversible early routing but must learn many rare leaves. A hierarchical model shares branch structure yet can propagate top-level errors. Partial-label training preserves historical evidence after a split but needs new supervision for child distinctions. Human review improves some decisions while adding cost, delay and its own disagreement.

Follow-ups: When should an ancestor be preferred to review? How do you train on labels from an older taxonomy? Why is a category merge easier than a split only sometimes? How would the solution change for a DAG or multilabel products? What proves a new model improved rather than receiving an easier test set?

10. Self-review rubric

  • Define single-label semantics and ambiguous bundles.
  • Version the taxonomy and preserve label provenance.
  • Prevent product-family and temporal leakage.
  • Explain coherent ancestor probabilities and greedy-routing failure.
  • Compute leaf, ancestor and review decisions under stated costs.
  • Handle splits as partial labels, not invented child assignments.
  • Report coverage, specificity, tail quality and review completion separately.
  • Deploy compatible artifacts and reject stale listing writes.

Sources and related practice

Google Merchant Center: product category, publication date not stated; retrieved September 27, 2026. Primary example of an evolving hierarchical product taxonomy and specific category semantics. This guide's marketplace contract and migration design are original, not a description of Google's internal classifier.

TensorFlow: fine-tuning BERT, publication date not stated; retrieved September 27, 2026. Primary reference for the supervised text-classification baseline and matching preprocessing to the model. All taxonomy examples, calculations and decision policies here are original practice.

Continue with product attribute extraction and learning to defer.

Continue your preparation

Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.