Design Relevance Ranking for Search Within a Gmail Inbox
Last updated: November 29, 2026
Quick Overview
When a user searches their own Gmail, results are sorted by date today. Design a relevance-ranked 'top results' section that finds the email the user is looking for faster.
0
0
0 solved
When a user searches their own Gmail, results are sorted by date today. Design a relevance-ranked 'top results' section that finds the email the user is looking for faster.
Personal search differs from web search because each corpus is private and small, and labels are scarce per user. Interviewers check that you design a global model over per-user features and respect privacy, while keeping it simple enough for a screen.
What the Interviewer Expects
- Explain why a single global model with per-user features is needed
- Identify the label: the email the user opens after searching
- List features such as sender affinity, recency and term match
- Handle privacy: no human review of email content
- Define an offline metric like MRR
Key Topics to Cover
How to Approach This
- Start by mapping the business objective to a concrete ML objective and metric.
- Cover the full pipeline: data collection, feature engineering, model selection, training, serving.
- Discuss online vs offline evaluation. Plan an A/B test to validate real-world impact.
- Address the serving latency budget and whether batch or real-time inference is needed.
- Think about the data flywheel: how user feedback improves the model over time.
Possible Follow-up Questions
- How would you train if you cannot look at any email content?
- How do you handle queries that are a person's name?
- How would you measure if top results helped?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice ML System Design ProblemsSample Answer
Requirements
Show up to 3 'top results' above the date-sorted list. Corpus per user: up to hundreds of thousands of messages. Latency under 300 ms. Success: the user opens a top result without reformulating. Const...
High-Level Design
- Retrieval: the existing per-user inverted index returns all matching messages (often hundreds).
- Feature extraction: per candidate, compute query-independent and query-dependent features....