Design an Image Captioning System
Understanding the Problem
🖼️ What is an image captioning system? An image captioning system writes a short text description of an image: "A golden retriever catching a frisbee in a park." Its most important use is alt text: the description a screen reader speaks aloud to blind and low-vision users when they reach an image. Most images on the web and in social apps have no alt text written by a person, so platforms generate it automatically. The same models also power search over photos, content understanding and "describe this image" features in assistants.
You'll get this as "design automatic alt text for a social network," "design an image captioning service," or "how would you caption billions of images?" The modeling has moved from object tags to full vision-language models (VLMs), and the interesting parts of the design are the ones that come with that power: VLMs write fluent, confident descriptions that are sometimes wrong (hallucination), and a wrong description is worse than none for someone who can't see the image to check. A good answer treats accessibility as the product, which shapes everything from caption length to what the model must not guess.
Functional Requirements
We're the accessibility and media understanding team of a large social platform.
Core Requirements
- Every uploaded image without user-written alt text should get automatic alt text before it's widely viewed.
- Screen reader users should be able to request a detailed description of any image, including any text in it, and ask follow-up questions.
- Posters should be able to review, edit or replace the automatic alt text, and user-written alt text always wins.
- Descriptions should be accurate, avoid guessing sensitive attributes, and be available in the viewer's language.
Below the line (out of scope)
- Video descriptions (audio description of video), though the same model can caption sampled frames.
- Captions for search indexing and ads (they can reuse the pipeline, with different goals).
- Content moderation decisions (a separate system, see Design a Prohibited Item Detection System).
Non-Functional Requirements
Ask how many images and how fast they're viewed after upload. Our numbers: 500 million images uploaded a day, about 5,800 per second on average and 15,000 per second at peak. Many posts get most of their views in the first hour, so alt text should be ready within 10 seconds of upload for p95. Screen reader users are a small share of viewers, but they view images constantly.
Core Requirements
- Latency: automatic alt text within 10 seconds of upload (p95). Detailed on-demand descriptions within 2-3 seconds to first words.
- Accuracy over detail: a short, correct caption beats a long one with an invented object. Target a low hallucination rate (described objects that aren't there), measured on labeled samples.
- Coverage: alt text on 99%+ of images, including screenshots, memes, charts and photos of documents, which are a large share of social images.
- Cost: the per-image cost must work at 500M images a day.
- Privacy and fairness: no face recognition; no guesses at race, religion, health or similar attributes; quality measured across skin tones, ages and cultures.
Below the line (out of scope)
- Guaranteeing caption quality for artistic or abstract images (we'll hedge and describe what's visible).
- Real-time captioning of the camera feed (that's closer to Design Real-Time Video Understanding).
The arithmetic. A small VLM of ~2B parameters with a ~400M-parameter vision encoder processes an image as a few hundred image tokens, plus ~100 tokens of context (post text, OCR), and writes ~40 tokens. That's on the order of 2 TFLOPs per image, mostly in the prefill. With batching, a modern GPU handles on the order of 100-200 images per second, so the 15,000-per-second peak needs roughly 75-150 GPUs. Two things cut that further: many uploads are reposts of the same meme or screenshot, so a perceptual-hash cache skips a meaningful share, and images in private, rarely viewed albums can be captioned lazily on first view. A 70B-class VLM would cost tens of times more per image, so it can't caption everything, but it can serve the on-demand detailed descriptions, which are requested for a small fraction of images.
The opening framing interviewers like: "A small model writes short, safe alt text for every image at upload; a large model answers detailed on-demand requests. Hallucination is the main quality risk, so grounding checks sit between the model and the user."