---
title: Your team retrieves candidates for a 50-million-item video catalogue with a two-tower model and ANN search. A research…
url: https://gurkanozkan.ai/learn/questions/recent-b-recommendation-01/
markdown: https://gurkanozkan.ai/learn/questions/recent-b-recommendation-01.md
kind: question
role: ML engineering
stage: System design
difficulty: Hard
json: https://gurkanozkan.ai/api/learn/questions/recent-b-recommendation-01.json
robots: noindex
---

# Your team retrieves candidates for a 50-million-item video catalogue with a two-tower model and ANN search. A research group proposes replacing it with generative retrieval over semantic IDs, as YouTube (PLUM) and Spotify (GLIDE) have deployed. How would you build the semantic IDs, serve the model within the retrieval latency budget, and decide whether to ship it?

ML engineering · System design · Hard

## Answer

*Model answer, written in a candidate's voice*

### In short

- Quantise content and/or collaborative embeddings hierarchically (residual quantisation into a few codeword levels) so related items share prefixes.
- Measure collision chains and add an extra disambiguation token/level sized to them; constrain generation with a prefix-trie beam search or over-generate and filter invalid IDs.
- Cold start: new items get IDs from content alone and inherit prefixes of similar items.
- Serving: few autoregressive steps times beam width, batching, caching, smaller/distilled generator, merged with existing candidate sources rather than a hard cut-over.
- Offline recall@k sliced by item age and popularity, then A/B on engagement and discovery vs the incumbent retriever.
- Plan for ID instability: retraining the encoder or quantiser remaps IDs, so freeze the codebook or retrain the generator and version IDs.

### In full

I would treat this as a candidate-generation layer, not a wholesale replacement. First I'd build semantic IDs by residual-quantising content and collaborative embeddings into a few levels of codewords, so related items share prefixes and the generator can reason about coarse-to-fine structure; I'd measure collision chains and add a disambiguation token or level sized to them, and constrain decoding with a prefix-trie beam search (or over-generate and filter) so invalid IDs never reach ranking. The cold-start win is real: a new item gets an ID from content alone and inherits the prefixes of similar items, which is exactly what the two-tower/ANN path struggles with for fresh inventory. For serving, I'd keep the generator small or distilled, batch the few autoregressive steps across the beam, cache hot prefixes, and merge its candidates with the existing ANN and other sources rather than cutting over. Offline I'd compare recall@k sliced by item age and popularity, then A/B on engagement and discovery metrics against the incumbent, and I'd version the IDs and freeze the codebook (or retrain the generator) whenever the encoder or quantiser changes, since any remap invalidates the mapping. I'd ship it only if it wins on discovery and cold-start slices without hurting latency or engagement, and I'd keep the incumbent path as a fallback.

*Checked against sources by an independent AI reviewer.*

## What a strong answer covers

- Builds semantic IDs by quantising content and/or collaborative embeddings hierarchically (e.g. residual quantisation into a few levels of codewords) so related items share prefixes.
- Handles collisions (extra disambiguation token or level, sized from measured collision chains) and invalid generated IDs (prefix-trie constrained beam search or over-generate and filter).
- Explains the cold-start benefit: new items get IDs from content alone and inherit prefixes of similar items.
- Addresses serving cost: a few autoregressive steps times beam width, batching, caching, smaller or distilled models, and merging with existing candidate sources rather than a hard cut-over.
- Evaluates offline by recall@k sliced by item age and popularity, then A/B tests on engagement and discovery metrics against the incumbent retriever.
- Plans for ID instability: re-training the encoder or quantiser remaps IDs, so the generator must be retrained or the codebook frozen.

## Common mistakes

- Treating it as free-text title generation that is fuzzy-matched to the catalogue afterwards.
- Ignoring that re-quantising the catalogue invalidates what the generator has learned.

## Follow-ups

- How would you combine generative and two-tower candidates in one funnel?
- Your quantiser assigns 40% of items a non-zero disambiguation token. What do you change?

## Topic guides

- [Building LLM applications](https://gurkanozkan.ai/learn/topics/llm-applications.md)
- [ML and LLM system design](https://gurkanozkan.ai/learn/topics/system-design.md)
- [Recommendation and ranking systems](https://gurkanozkan.ai/learn/topics/recommendation.md)
---

*Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.*
