Design Feed Ranking and HTML Generation
FigmaMachine Learning Engineer · OnsiteLast updated
This problem tests the design of a dual-purpose ML system: a personalized content feed ranker and an LLM-based component that translates user intent into rendered HTML widgets.
System Design: Feed Ranking and Intent-to-HTML Generation
You are tasked with designing a system for a creative platform where users view a feed of community-generated designs and can use a prompt-based interface to generate custom UI components (HTML/CSS) to embed in their work.
Part 1: Personalized Feed Ranking
Design a ranking system that orders content for a user's feed. Your design should account for:
- Candidate Generation: How do you retrieve relevant designs at scale (millions of items)?
- Ranking: Describe the ranking architecture (e.g., multi-stage models, objective functions).
- Cold Start: How do you handle new creators or users with no interaction history?
- Evaluation: Define offline metrics (e.g., NDCG, MRR) and online metrics (e.g., Click-Through Rate, dwell time, long-term retention).
Part 2: Intent-to-HTML Generation
Design a service that takes a natural language prompt (e.g., "Create a glassmorphism login button") and generates a functional HTML/CSS snippet.
- Model Architecture: Choose an appropriate approach (e.g., fine-tuned LLM, RAG for pattern matching, or multi-modal encoder-decoder).
- Safety & Constraints: How do you prevent the generation of malicious code or non-performant UI layouts?
- Evaluation: How do you measure the quality and functional correctness of the generated code?
Requirements
- Provide a high-level system architecture diagram (in text) identifying components like the feature store, model serving layer, and data logging pipeline.
- Discuss trade-offs between latency and model complexity for both the ranker and the generator.
- Explain how you would manage data loops: how do you incorporate user feedback (likes, edits, or re-prompts) back into the system?
Hints
Hint 1
For the ranker, consider using a two-tower architecture for fast retrieval, followed by a heavy cross-encoder model for fine-grained ranking.
Hint 2
For the HTML generator, consider using a hybrid approach: a specialized LLM for code generation coupled with a deterministic sandbox environment for real-time functional validation.
Hint 3
For system feedback loops, consider how 'reject' or 'edit' actions in the UI can serve as negative training signals for the code generation model.
Follow-up questions
- How would you handle 'concept drift' if users' design preferences shift significantly over time?
- If the HTML generation is too slow, what caching strategies or distillation techniques would you implement to improve latency?
- How do you design a 'Human-in-the-loop' system to verify generated HTML before it is fully committed to the production design assets library?
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.