KatInterview

Ranking a Design Gallery and Turning Prompts into Safe UI Snippets

Machine LearningModel answer
MediumModel answerMachine Learningml-system-designrecommendationranking

Last updated

Design an ML system that ranks a creative community's feed and also converts natural-language requests into validated, safe HTML/CSS components, including evaluation and feedback loops.

Design: A Personalized Gallery Feed Plus a Prompt-to-UI Generator

You are building two features for an online creative platform where members publish designs and browse a feed of work from the community. Members can also type a request into a prompt box and get back a ready-to-embed HTML/CSS component.

Part 1: Personalized gallery feed

Design the system that decides which designs each member sees and in what order. Cover:

  • Candidate generation: how to narrow a corpus of tens of millions of designs to a manageable shortlist.
  • Ranking: the model stages, inputs and training objectives you would use.
  • Cold start: how brand-new members and brand-new creators get a fair experience despite having no history.
  • Evaluation: offline metrics (for example NDCG, MRR, recall) and online metrics (for example CTR, dwell time, long-term retention).

Part 2: Prompt-to-component generation

Design a service that accepts a request such as "make a frosted-glass login button" and returns a working HTML/CSS snippet.

  • Modeling approach: for example a fine-tuned code LLM, retrieval-augmented generation over a component library, a multimodal model, or a combination.
  • Safety and quality constraints: how you prevent malicious output and slow or broken layouts.
  • Evaluation: how you measure visual quality and functional correctness.

What to deliver

  • A text-based architecture diagram showing the main components, including the feature store, model serving, and the event-logging pipeline.
  • A discussion of the latency versus model-complexity trade-off for both the ranker and the generator.
  • A description of the feedback loops: how likes, edits, and re-prompts flow back to improve both models.

State your scale assumptions up front and be explicit about trade-offs.

Hints

Hint 1

Begin by quantifying scale (users, feed loads, corpus size, prompts per day) and latency budgets; these numbers drive the funnel shape: many cheap retrievers, then a light ranker, then a heavy ranker, then re-ranking.

Hint 2

For cold start, lean on content-derived item features (image/text embeddings) and reserved exploration slots, and for new members seed from onboarding choices and context. For the generator, treat safety as layered: constrained output format, sanitization, then sandboxed rendering and checks, not just a prompt instruction.

Hint 3

Close the loop with implicit signals: feed saves, remixes, and hides into the ranker; accepted, edited, or re-prompted snippets into preference data for the generator. Remember to warn about position bias, clickbait optimization, and leakage from random train/test splits.