KatInterview

Build a text-to-image generation platform from scratch

Machine LearningModel answer
HardModel answerMachine Learninggenerative-modelsml-systemsinference-optimization

Last updated

Design the complete ML pipeline for producing images from text prompts: data, architecture, training, safety, evaluation, and serving at scale.

You're building a text-to-image generation platform that will serve millions of requests per day. Design the complete end-to-end system.

Your design should cover:

Core ML pipeline

  • Data sourcing, curation, and preparation (including captioning strategy)
  • Model architecture selection and conditioning mechanisms
  • Training approach, objectives, and compute requirements
  • Quality and safety evaluation frameworks

Production system

  • Inference optimization techniques to meet latency and cost targets
  • Safety controls at multiple layers
  • Monitoring and quality assurance
  • Cost management strategies

Extension task After covering the image generation system, extend your design to support multimodal generation—a system that can accept both text and images as input and produce both text and images as output. Address:

  • How the data requirements change
  • Architectural modifications for cross-modal understanding
  • Training strategies for aligned multimodal behavior
  • Product and safety considerations specific to multimodal scenarios

Be concrete about numbers, trade-offs, and failure modes. Assume you need to serve ~50 million images per day with p95 latency under 5 seconds and a target cost below $0.002 per image.

Hints

Hint 1

Start by defining scale targets clearly—peak queries per second drives your infrastructure decisions and makes distillation non-optional

Hint 2

Safety must be layered across prompt input, training data, and generated output; no single classifier catches everything

Hint 3

Precomputing and caching embeddings (text encoder outputs, VAE latents) often doubles throughput for nearly free