KatInterview

Building a Cited Question-Answering Service Over Text, PDFs and Images

System DesignModel answer
MediumModel answerSystem Designragmultimodalretrieval

Last updated

Design an enterprise assistant that retrieves evidence from text, PDFs and images, then generates answers with citations while respecting access controls, latency and cost limits.

Problem

Your company wants an internal assistant that answers employees' natural-language questions using the company's own knowledge base. Every answer must be backed by evidence the user can inspect.

The knowledge base contains several kinds of content:

  • Text documents, such as wiki pages and support tickets.
  • PDFs that mix prose, tables and embedded figures.
  • Standalone images, such as architecture diagrams and screenshots, which have little or no descriptive metadata.

The assistant must find relevant evidence across these formats, hand it to an LLM, and return an answer that cites its sources.

What to cover

  1. How each content type is ingested and preprocessed.
  2. The indexing approach (dense, keyword or hybrid) and how metadata is stored.
  3. Query-time retrieval, including how a text question can surface an image.
  4. Chunking, embedding choices and re-ranking.
  5. Prompting, grounding and how citations are produced and validated.
  6. Evaluation (offline and online), latency and cost.
  7. Failure modes (fabricated claims, outdated content, a modality that cannot be parsed) and how you would mitigate them.

State your assumptions about scale, latency targets and security up front. Use rough numbers where they help justify a decision.

Hints

Hint 1

Give every chunk, whatever its modality, a text surrogate (raw text, a table as markdown, or caption plus OCR for an image). That lets one text query search everything, and you can add a true image-embedding index on top for cases where captions miss detail.

Hint 2

Use a staged retrieval funnel: parallel dense, keyword and visual candidate generation, merge with rank fusion, then a cross-encoder re-ranker to keep only a handful of items. Apply access-control filters inside the search, not afterward.

Hint 3

Treat grounding as a pipeline, not just a prompt: label each evidence item with an ID, require the model to cite those IDs, discard citations that do not map to provided evidence, verify claims against sources, and refuse to answer when retrieval confidence is low.