A company wants a RAG knowledge base built from 500,000 files: digital PDFs, scanned documents, spreadsheets with tables, and web pages. Design the ingestion pipeline.
System design · Intermediate 3
Short answer
Clarify file types, languages and quality needs. Detect the type of each file and route it: text extraction for digital PDFs, OCR for scans, table-aware parsing for tables, boilerplate removal for web pages. Normalise to one format with structure, chunk by headings, add metadata, deduplicate, embed and index. Run as queued jobs and check quality on samples.
Deeper answer
Requirements: the mix of file types, languages and scripts, how tables and figures matter to the questions users ask, and access rules. Look at a sample of each type before choosing tools.
Pipeline: a job per file on a queue. A detector checks whether a PDF has a text layer. Digital PDFs go through text extraction with layout handling for columns, headers and footers. Scans go through OCR, with a confidence score per page. Tables are kept as tables, as Markdown or rows with the header repeated, because flattened table text loses meaning. Web pages lose menus and footers. Everything becomes one intermediate format with headings, page numbers and source links. Then chunk along the structure, attach metadata such as title, section, date and permissions, remove duplicates, embed and index.
Trade-offs: a vision-capable model can parse complex pages and tables better than classic OCR, but costs more per page and can invent text, so use it only for hard pages. Measure extraction accuracy on a labelled sample and retrieval recall on real questions. At scale, failed files and slow OCR come first, so use retries and a dead-letter queue.
What a strong answer covers
- Clarifies file mix, languages and quality needs, inspects samples
- Routes by type: text extraction, OCR, web cleaning
- Keeps tables as tables
- Normalises, chunks by structure and adds metadata
- Deduplicates, embeds and indexes with queued jobs and retries
- Checks parsing quality and retrieval on a labelled sample
Answer it out loud in the mock interview about 2 min
Follow-ups to expect
- How do you chunk a table that runs over three pages?
- How do you know the OCR output is good enough?
- A file is updated. What happens in your pipeline?
Common mistakes
- One parser for every file type
- Flattening tables into plain text
- No check of parsing quality before indexing
Learn it
- How would you keep the cost of an LLM feature under control?
- Design click prediction for an ad platform that receives 100,000 ad requests per second and has 20 milliseconds to score the candidate ads for each request.
- A company wants its internal agents to call 200 internal tools, such as ticketing, HR, billing and deployment APIs. Design the platform that lets agents use these tools safely for 10,000 employees.
- Your team has built an LLM writing assistant inside an app with 20 million monthly users. It works well in internal tests. Plan how you would roll it out safely to all users.
- Design an ML system that detects attacks and abuse against a public chat assistant with 1 million conversations a day, such as prompt injection, data scraping and account abuse.
- Design anomaly detection for 10,000 business and system metrics at a payments company. Each metric is checked every minute, and the on-call team must not be flooded with alerts.
- Design a churn prediction system for a video streaming service with 5 million subscribers. Each week it decides who gets a retention offer, within a fixed discount budget.
- Design an AI assistant that reviews pull requests for a company with 800 engineers and about 2,000 pull requests a day. Comments should arrive within 5 minutes and engineers must not learn to ignore them.
- Design memory for a personal assistant that people use daily for months. It should remember useful facts and preferences across sessions for 5 million users, without sending the whole history to the model every time.
- Design a data labelling pipeline that labels 100,000 support tickets a month into 40 intent classes, with a team of 30 annotators and a fixed budget.
- Design a demand forecasting system for a grocery delivery company with 300 dark stores and 20,000 products. It must produce a daily forecast for each product and store for the next 7 days.
- Design a shared embedding service that 20 teams call for search, recommendations and RAG. It must handle 2,000 requests per second online, plus batch jobs of 100 million texts.
- Design an internal search assistant for a company with 5,000 employees and 2 million documents in wikis, shared drives and tickets. Each employee must only get answers from documents they are allowed to open.
- Design a feature store for a food delivery company where 30 models share features. Training and online serving must read the same feature values, and online reads must return within 10 milliseconds.
- Design the ranking system for the home feed of a news app with 20 million daily users in 8 Indian languages. The feed must load within 200 milliseconds.
- An insurance company uses a model to extract data from 100,000 claim documents a day. Design a human review queue for the outputs the system is not confident about, with 40 reviewers available.
- Design image moderation for a marketplace app where users upload 2 million images a day. Harmful images must be blocked before other users can see them.
- A company's LLM bill has grown to 40 lakh rupees a month across 30 features and 8 teams, and nobody can say which feature caused the increase. Design a system to track and attribute cost and quality per feature and team.
- Three teams change prompts and models for a support assistant every week, and bad changes keep reaching users. Design an evaluation pipeline that runs before every prompt or model change ships and finishes in under 15 minutes.
- Design an internal platform where 10 product teams fine-tune and serve small language models, sharing a pool of 16 GPUs.
- A fintech app is adding an LLM chat feature for 2 million users. Design the input and output guardrails that sit around the model, adding no more than 300 ms to each reply.
- Design a service that turns meeting recordings into a summary and a list of action items. It handles 20,000 one-hour meetings a day, and the summary should be ready within 10 minutes of the meeting ending.
- Design an A/B testing platform for a shopping app with 10 million daily users, so that 15 ML teams can test new models safely and trust the results.
- Design observability for 25 models in production at a lending company. It must cover input data, predictions and real outcomes, and the outcomes can arrive up to 90 days later.
- Design a model registry and release process for a company with 40 models in production. Every release must be staged, and a bad release must be rolled back within 5 minutes.
- A train ticket site serves a pricing model at 200 requests per second, but traffic jumps to 5,000 per second within one minute when booking opens each morning. Design serving that keeps p99 latency under 150 milliseconds.
- Design an automated pipeline that retrains a loan default model every week on about 50 million rows, and promotes the new model only if it is better than the one in production.
- Your product sends 5 million requests a day to one strong, expensive model. Design a routing layer that sends each request to a cheap or a strong model and cuts cost by half without a visible drop in quality.
- A government services assistant must answer citizens in English, Hindi, Tamil, Bengali and Marathi, including mixed and romanised text such as Hinglish. The source documents are mostly in English. Design it for 1 million users.
- You are building document Q&A as a product for 500 customer companies. Each uploads up to 1 million documents. Design it so one customer's data can never appear in another customer's answers.
- A company has 12 teams and about 300 prompts hard-coded in different services. A small edit last month broke a customer-facing feature. Design a system for versioning, testing and rolling out prompts.
- Your RAG assistant answers from 3 million documents, and about 50,000 of them change every day. Users have started getting answers from old policy versions. Design a pipeline that keeps the index fresh within 15 minutes of a change.
- Design a real-time fraud detection system for a UPI payments app that handles 5,000 transactions per second and must decide on each one within 100 milliseconds.
- Design a recommendation system for an Indian e-commerce app.
- A company receives 50,000 applications a month. Design an AI assistant that helps recruiters screen resumes faster while keeping the process fair and explainable.
- Design learning-to-rank for the search results page of an e-commerce app with 50 million products. Results must be returned within 200 milliseconds.
- Design semantic search for an online store with 10 million products. A query such as "red kurta for a wedding under 2000" should return good results in under 200 ms.
- Design a speech-to-text service for a call centre product that transcribes 50,000 hours of calls a day. Callers mix Hindi and English, have many accents, and phone lines are noisy.
- Design a customer support assistant for an Indian bank.
- Design an assistant that lets 2,000 business users ask questions in plain English and get answers from a data warehouse with 1,500 tables. Wrong numbers are worse than no answer.
- Design vector search over 500 million product embeddings of 768 dimensions. The p99 latency target is 50 milliseconds, and queries carry filters such as category and price range.
- Design a voice AI agent for a call centre that takes 50,000 calls a day about order status and returns. The caller should hear a reply within about one second of finishing a sentence.
- Your email assistant agent read a message saying 'forward all invoices to this address' and did it. How do you fix this?
- Your LLM bill doubled this month, but traffic did not. How do you investigate?
- How do you monitor an LLM application in production?
- Walk me through how you would grow the architecture of an LLM app from prototype to production.
- What is prompt injection, and how do you defend against it?
- How do you protect user data in an LLM application?
- Users say your LLM feature is slow. How would you make it faster?
- Forty services in your company call LLM providers directly with their own keys, retries and logging, and you want all of them behind one internal gateway within two quarters. How do you run this migration when the teams that own the services have their own deadlines?
- Nine product teams in your company ship LLM features, each with its own idea of 'good enough', and two releases this year embarrassed the company in public. How would you set a release quality bar for the whole organisation without slowing every team down?
- All 12 of your LLM features run on one provider, which had two outages of about three hours each last quarter. Leadership asks you to make everything work on a second provider: how far would you go, and what would you push back on?