KatInterview

Designing a Restaurant Ranking System for a Food Delivery App

Machine LearningModel answer
HardModel answerMachine Learningrankingrecommendation-systemsmulti-task-learning

Last updated

Design an end-to-end personalized ranking system for a food delivery home feed, covering objectives, features, model architecture, evaluation, and feedback loops.

Background

You work on the machine learning team at a food delivery platform. The home screen shows users a ranked list of nearby restaurants. Your task is to design the ranking system that decides what order those restaurants appear in.

The platform connects three parties — customers, restaurants, and delivery couriers — so your system must account for all three, not just what the customer is most likely to click.

What You Need to Design

1. Objective Formulation

What is the system actually optimizing for? Define the prediction targets and explain how you combine them into a single ranking score. How do you balance short-term engagement (clicks and orders) against long-term outcomes like user retention and marketplace health?

2. Feature Engineering

Propose a concrete set of features across user, restaurant, and contextual dimensions. How do you handle new restaurants that have no engagement history? How do you avoid training-serving skew with real-time signals?

3. Model Architecture

The system must return results within 200ms end-to-end. Describe a multi-stage pipeline that fits within this budget. What model family would you use for each stage, and why?

4. Evaluation

How do you validate the system before shipping it? Define both offline metrics and online experiment metrics. Which metrics go beyond click-through rate, and why do they matter?

5. Deployment and Feedback Loops

How often do you retrain the model? How do you detect and correct position bias, where top-ranked items receive more orders simply because they appear first?

Constraints and Assumptions

  • Results must be returned in under 200ms (p99).
  • The candidate pool per request is roughly 500–5,000 open, in-range restaurants.
  • The system must account for real-time signals: live delivery estimates, restaurant prep queues, and courier availability.
  • Multi-objective optimization is required — driver availability, restaurant capacity, and user preferences all matter.

A strong answer will move through each section in order, attach approximate numbers where useful, and explicitly call out trade-offs rather than presenting one option as obviously correct.

Hints

Hint 1

Start by decomposing the problem into a funnel of separate predictions (P(click), P(order|click), P(good experience|order)) rather than collapsing everything into a single CTR target. This makes the objective more honest and easier to debug.

Hint 2

A two-stage pipeline (candidate retrieval → ranking) is standard, but explain *why* each stage exists — retrieval is about recall at low latency, ranking is about precision with richer features. Sketch a rough latency budget across the two stages.

Hint 3

Position bias is the central feedback-loop risk. Mention at least one concrete countermeasure: propensity-weighted training, randomized position experiments, or dedicated exploration traffic. Interviewers often probe here.