← Questions

Design an answer engine with citations

0
PerplexitySystem design

An AI system design interview question asked in Perplexity's ML / LLM design round. It tests search, rag and citations.

Design an answer engine. A user asks a question in plain language and gets a direct, current answer written by a model, with numbered citations to the web pages it used. The answer starts streaming within a second or two, and the user can ask follow-up questions in the same conversation.

Requirements

  • Functional: understand the question in the context of the conversation; search the web and fetch pages; pick the passages that matter; write an answer with a citation on each claim; show the sources; follow-up questions; fresh results for news and fast-changing topics.
  • Non-functional: first token in about 1 to 2 seconds; about 30 million queries a day; every citation actually supports its sentence; cost per query low enough for a free tier.

Clarifying questions

  • Do we run our own web index, use a search API, or both?
  • What share of queries need fresh results (news, prices, scores)?
  • What latency target for the first token and for the full answer?
  • Which models are available, and what is the cost budget per query?
  • Are some sources preferred or blocked, and how are publishers treated (robots rules, attribution)?

What a strong answer covers

  • The pipeline with a latency budget per stage: query rewriting with the conversation context (a small fast model), search (own index or API, parallel queries), fetching pages (cached, with strict timeouts), passage extraction and reranking, then generation with the passages numbered in the prompt.
  • Citations that hold up: the model cites passage numbers per sentence; a check (an entailment model or a second pass) that each cited passage supports its sentence, removing or fixing unsupported claims; and showing sources even when the answer is short.
  • Freshness: a fast lane for news with a frequently updated index or live search, cache lifetimes that depend on the topic, and dates shown on sources.
  • Caching: query and result caches for popular questions, fetched page cache, and prompt caching for the generation step.
  • Capacity: 30 million a day is about 350 queries a second on average and perhaps 1,000 at peak; tokens per answer times queries gives model cost; how many fetches per query the budget allows.
  • Follow-ups reuse earlier sources and only search again when the question needs it.
  • Quality measurement: citation accuracy, answer correctness on a labeled set, user feedback and clicks on sources.

Follow-ups

  • The model writes a claim that none of the sources support. How do you catch it before the user sees it?
  • A news event breaks and queries spike tenfold on one topic.
  • Add a "deep research" mode that runs for minutes. What changes?
  • Sources disagree with each other. What does the answer say?

Where it's asked

What it tests

search · rag · citations · latency

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing