Design a PDF Ingestion and Retrieval-Augmented Generation Pipeline
NikeSoftware Engineer · Technical ScreenLast updated
This problem tests the ability to design an end-to-end RAG pipeline capable of handling complex document parsing, chunking strategies for citations, and efficient synchronization of updates.
System Design: PDF RAG Pipeline
Design a scalable system that ingests PDFs and provides a Retrieval-Augmented Generation (RAG) service. The system must support accurate citations to specific page numbers even when documents contain complex layouts, tables, and scanned images.
Functional Requirements:
- Ingestion: Handle selectable text, OCR for scans, and table parsing.
- Retrieval: Provide context with explicit page-level citations.
- Updates: Allow users to update or delete documents, ensuring the index reflects the latest version.
Non-Functional Requirements:
- Accuracy: Minimize hallucination and ensure citation-to-text alignment.
- Latency: Ingestion can be asynchronous; retrieval should be sub-second.
- Scalability: Support thousands of documents.
Requirements for your response:
- Parsing Strategy: How do you handle non-linear structures like multi-column layouts and tables?
- Indexing: Define the data model for storing chunks and their metadata (page number, document ID).
- Retrieval Logic: How do you ensure the LLM returns accurate page numbers during generation?
- Lifecycle Management: Describe the workflow for document versioning and purging stale chunks.
Constraints:
- Assume a volume of 5,000 PDF documents (avg 50 pages each).
- System must support high-concurrency read operations.
Hints
Hint 1
Consider a multimodal parsing approach using LayoutLM or similar vision-language models to handle tables and headers correctly.
Hint 2
Store page identifiers as metadata in your vector database and include them in the LLM prompt context to force citation generation.
Hint 3
Implement a versioning scheme (e.g., DocID + Version) and a 'delete-and-reindex' flow to maintain search consistency during document updates.
Follow-up questions
- How would you measure the performance of your retrieval component in terms of citation accuracy?
- If a document contains repeating headers or footers on every page, how would you prevent this noise from degrading the embedding quality?
- How would you implement access control so users only retrieve information from PDFs they are authorized to view?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.