Design comment ranking for a news feed
MetaMachine Learning Engineer · OnsiteLast updated
This question tests the ability to design an end-to-end machine learning system for ranking comments, covering feature engineering, model architecture, and the trade-offs between engagement, quality, and latency.
Problem Statement
Design a machine learning system to rank comments on a high-traffic news feed platform. The goal is to maximize user engagement (replies, likes) and conversation quality while suppressing spam and inflammatory content. The platform serves millions of daily active users, with popular posts receiving thousands of comments.
Requirements
- Functional: Provide a ranked list of comments for a given post when a user opens the comment thread.
- Non-functional: The ranking must be low-latency (e.g., < 100ms) and scalable to handle high read/write volumes.
- Quality: The system must handle cold-start issues for new comments and mitigate toxic or irrelevant content.
Scope
Your design should cover:
- Problem Formulation: What is the ML task? How do you define the label?
- Data Pipeline: How do you handle real-time vs. batch features?
- Modeling: What architecture (e.g., two-tower, MLP) would you use and why?
- System Architecture: High-level serving flow, including candidate retrieval and ranking stages.
- Evaluation: Offline metrics and online A/B testing strategy.
Hints
Hint 1
Consider a multi-stage approach: use a fast retrieval stage (candidate generation) to narrow down thousands of comments before applying a complex ranking model.
Hint 2
Think about the difference between features that change frequently (like current vote count) and static ones (like author reputation or text embeddings).
Hint 3
How would you address the 'quality' requirement beyond just predicting clicks—perhaps by incorporating a separate toxicity score as a post-processing filter or a multi-task learning objective?
Follow-up questions
- How would you handle the 'freshness' problem, ensuring that high-quality new comments are surfaced quickly despite having few historical interactions?
- If the system starts promoting controversial content because it generates high 'engagement' (comments), how would you adjust the model objective to optimize for healthy discourse?
- How do you monitor for model drift or a sudden spike in coordinated bot activity within the comment section?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.