Design a RAG Pipeline for AI-Powered Search

Last updated: September 4, 2025

Quick Overview

Design an end-to-end retrieval-augmented generation pipeline covering query parsing, hybrid retrieval, multi-stage reranking, context window packing, and hallucination mitigation.

Perplexity
System Design
Software Engineer
Perplexity
September 4, 2025
Software Engineer
System Design Round
System Design
Hard

14

6

3,076 solved


Design an end-to-end retrieval-augmented generation pipeline covering query parsing, hybrid retrieval, multi-stage reranking, context window packing, and hallucination mitigation.

RAG is the core technology behind Perplexity's product. This question tests deep understanding of every stage from retrieval to generation.

What the Interviewer Expects
  • Design query intent parsing and classification
  • Implement hybrid retrieval with BM25 and dense embeddings
  • Build a multi-stage reranking pipeline with latency budgets
  • Address context window packing and citation attribution
  • Discuss hallucination detection and mitigation strategies
Key Topics to Cover
RAG architecture
Hybrid retrieval
Reranking
Hallucination mitigation
Embedding models
How to Approach This
  1. Start by clarifying functional and non-functional requirements with the interviewer.
  2. Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
  3. Draw a high-level architecture first, then deep dive into 1-2 critical components.
  4. Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
  5. Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
  • How do you handle queries that require multi-hop reasoning?
  • What chunking strategy do you use for long documents?
  • How do you evaluate retrieval quality in production?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Functional Requirements

  1. Query Intent Parsing: Implement a module to extract intent from user queries to enhance retrieval accuracy.
  2. Hybrid Retrieval System: Combine BM25 for keyword-...
Capacity Estimation

Assuming 10 million queries per day:

  • Queries per second: 10,000,000 queries / 86,400 seconds = ~115.74 queries per second.
  • Retrieval Latency: Allocating 100ms for retrieval and 100ms for g...

Submit Your Answer
Markdown supported

Related Questions