KatInterview

Design a Personalized Food Delivery Home Feed Ranker

Machine LearningModel answer
HardModel answerMachine Learningrecommendation systemsrankingtwo-tower

Last updated

Design an end-to-end ML system that ranks restaurants on a food delivery app's home screen to maximize orders and long-term user satisfaction.

Scenario

You work as a senior ML engineer at a food delivery platform. Every time a user opens the app, they land on a home feed showing a ranked list of restaurants. The ranking decision happens in under 200 ms and directly drives revenue, retention, and courier utilization.

Your task is to design the full ML system behind that ranked feed — from raw signals to what gets shown at position 1.

What to cover

Walk through each of the following. Be concrete: name models, features, and trade-offs rather than speaking in vague generalities.

  1. Objectives and metrics — What are you optimizing for, and how do you measure success both offline and in production? What guardrails prevent you from gaming a metric at the expense of the user or the marketplace?

  2. Problem framing as a funnel — How do you go from every restaurant on the platform down to a ranked list of ~50 in under 200 ms? Describe each stage, its input/output size, and its latency budget.

  3. Candidate generation (retrieval) — What sources of candidates do you use? How do you merge them? When and why would you use a two-tower embedding model vs. a simpler heuristic?

  4. Ranking model — What model architecture do you choose, what target(s) does it predict, and how do you combine multiple predicted quantities into a single ranking score?

  5. Feature engineering — What user, restaurant, contextual, and cross features matter most? Which ones need to be fresh in real time?

  6. Training data and labels — How do you construct training examples, handle position bias, and avoid feedback loops that entrench already-popular restaurants?

  7. Cold start and exploration — How does the system behave for a brand-new user with zero order history? For a restaurant that joined the platform yesterday? How do you balance exploitation of known preferences with exploration of new options?

  8. Re-ranking and business rules — After the model scores, what post-processing happens before the feed is served? Think diversity, fairness, sponsored slots, and quality gates.

  9. Online serving architecture — How does the system meet the latency budget? Where does each piece live (feature store, model server, cache)? How do you keep real-time signals like ETA and surge fresh?

  10. Experimentation, monitoring, and failure modes — How do you run A/B tests safely? What signals tell you the system is silently degrading? Name two or three concrete failure modes and how you'd catch them.

  11. Phased rollout / MVP — If you had to ship something useful in six weeks, what would it be? What comes in phase 2 and 3?

Constraints and realities to address

  • A user can only order from restaurants that deliver to their address and are open right now — this eligible set is typically 200–2,000 restaurants, far smaller than the full catalog.
  • ETA, delivery fee, restaurant busyness, and courier supply change in real time.
  • Items can go out of stock mid-session.
  • New restaurants need exposure even before they have order history.
  • Concentrating demand on a small set of popular restaurants overloads couriers in that area and hurts marketplace health.
  • Sponsored placements must coexist with organic results without destroying feed quality.

Expected output

A structured verbal walkthrough (no code required, though pseudocode or schema snippets are welcome). Prioritize depth on the ranking model, feature design, and serving architecture. Show that you understand the difference between what is technically elegant and what is actually practical to build.

Hints

Hint 1

Start with the eligible set, not the full catalog. Since only 200–2,000 restaurants are deliverable to any address at any moment, retrieval is less about recall against millions of items and more about ranking well within a small, hard-filtered set. That changes how much work you need to put into candidate generation vs. ranking.

Hint 2

For the ranking model, think about why a single target like click-through rate is dangerous. Clicks, orders, basket value, cancellations, and ratings each tell you something different. A multi-task model that jointly predicts several of these is more robust than optimizing one proxy — and it lets you tune the business trade-off at score combination time rather than baking it into the label.

Hint 3

Position bias is one of the most common mistakes candidates gloss over. An impression at position 1 converts at a much higher rate than one at position 10 — not because the restaurant is better, but because it was shown first. If you train naively on impression logs, your model learns to recommend whatever was already ranked highly, reinforcing the existing order. Name at least one concrete mitiga…