GOAT EngineerPreparing your learning space…

AI Engineering · Interview breakdown · Free article

Design a RAG System

A RAG system answers from a company’s private documents, with citations, using two pipelines: one turns documents into a searchable index, the other retrieves, reranks and generates a grounded answer. In the interview, the production half sets the bar: permissions, freshness, cost and evals.

Ask ten AI-engineering candidates to "design a system that answers questions over our internal documents" and most will bolt a vector database onto a language model and call it done — which is exactly the trap. Three inversions separate a strong answer. The model is the least important box: answer quality is decided by what you put in front of it, so retrieval is where the design lives. You are designing two systems, not one: an offline pipeline that turns documents into something findable, and an online path that answers in two seconds — they scale, fail, and get debugged separately. And the failure you're designing against is a confident wrong answer, not downtime — so grounding, citations, and evaluation are architecture, not afterthoughts. This breakdown walks the whole round: scope it, size the corpus in vectors and dollars, draw the two pipelines, then go deep where the round is won — retrieval quality and the production half (permissions, freshness, cost) that almost nobody designs.

A new employee types a question into the company assistant: "Do my unused days off carry into next year?" The model answers instantly, in perfect corporate prose: "Yes — up to ten unused days roll over automatically." It sounds authoritative. It cites nothing. And it's wrong: the real policy, sitting in a PDF nobody opened, allows five days, and only if you use them by March. The employee plans a January trip around an answer the model made up.

That is the wound this interview is about. A language model on its own knows nothing about your company — its training data ends somewhere in the past and never included your policies, your runbooks, your contracts. Ask it anyway and it does the one thing it's built to do: produce plausible text. Plausible, specific, confident — and unanchored to anything true.

The fix is deceptively simple to say: before the model answers, go find the actual documents that bear on the question, hand them to the model, and instruct it to answer only from what it was handed — with citations, so every claim can be checked. Retrieve, then generate. That's retrieval-augmented generation, and designing it well is currently the single most common AI-engineering interview.

Name those three in the first few minutes and you've already separated yourself: the interviewer now knows you've shipped one of these, or thought like someone who has. The rest of the hour is backing them up.

Scope it before you build anything

The usual scenario is an enterprise knowledge assistant: employees ask questions in plain language; the corpus is everything the company has written down — the wiki, the shared drives, the ticket tracker, the policy PDFs. Scope it to the three requirements everything else hangs on:

The three requirements everything hangs on

  1. Ask a question, get a grounded, cited answer. Natural-language question in; an answer synthesized from the company's documents out, with citations linking each claim back to its source so a skeptical reader can verify. If the documents don't contain the answer, the assistant says so instead of improvising.
  2. The corpus stays current. Documents are added, edited, and deleted all day. A policy updated this morning should shape answers by this afternoon — not after next quarter's re-index. Freshness is a feature users notice immediately when it's missing.
  3. Permissions are respected. The corpus includes documents most employees cannot open — compensation plans, legal matters, unreleased plans. An answer must never be built from a document its asker couldn't read directly. This one requirement will reshape the retrieval design more than any other.

Then park the rest explicitly, with a reason each — showing you know these exist and why they're separable is itself signal:

Deferred on purpose — say the reason, not just the name
FeatureWhy it is a separate problem
Multi-turn conversation memoryA context-management layer on top of the core answer loop; the retrieval story is unchanged. (The conversational side is its own round — see Design ChatGPT.)
Images, diagrams, tables-as-picturesMultimodal parsing and embedding is its own ingestion problem; start with text and structure.
Multi-hop research questionsQuestions that require chaining several retrievals ("compare our Q3 policy to the vendor contract") push toward agentic loops — name it as an extension.
Fine-tuning the model on company dataA different tool for a different job (style and skills, not facts) — and the closing section explains why.
Analytics on what people askValuable, but downstream of the answer loop.

The properties that shape the design

State each NFR as a number or a hard rule, because each one drives a specific decision later. Interviewers increasingly hand you these as explicit budgets — including a cost target, which used to be unheard of in design rounds.

The NFRs that actually move the design

  • Answer latency: p95 around 2 seconds end-to-end, streaming. The user should see the answer starting well under a second — retrieval must therefore fit in a few hundred milliseconds, because generation needs the rest. This budget is what forces the fast-then-precise retrieval funnel later.
  • Retrieval quality as a measured target, not a vibe. Something like "the passage that answers the question is in what we hand the model at least 9 times in 10, on a golden question set." Naming a measurable retrieval target tells the interviewer your evaluation section is coming.
  • Freshness: minutes, not days. An edited document is reflected in answers within ~15 minutes; a deleted one stops being citable just as fast. This forces incremental indexing rather than nightly rebuilds.
  • Permission correctness is binary. One leaked passage from a restricted document is an incident, not a quality dip. There is no "99% correct" here — this NFR is a hard constraint that dictates where filtering happens.
  • A cost ceiling per query. Budgets like a fifth of a cent to a couple of cents per query are now stated in real interviews. Every retrieval and generation choice moves this number, so keep it on the board.
  • Scale envelope: on the order of 10M documents, low hundreds of queries per second at peak. Modest QPS by web standards — the hard part is corpus size and the quality bar, not raw traffic.

Size the corpus before you draw boxes

Estimation here isn't QPS math — it's corpus math, and it produces two numbers that shape the design: how much memory the searchable index needs, and what it costs to build and query. Work the chain: documents → tokens → chunks → vectors → RAM → dollars. State every assumption; the method is the point.

The estimation chain (state each assumption as you go)

  1. Corpus. Say 10M documents — wiki pages, PDFs, tickets — averaging ~2,000 tokens each. That's ~20B tokens of company text.
  2. Chunks. You'll index pieces of documents, not whole ones (the next deep dive explains why). At ~400 tokens per chunk that's ~50M chunks — and one vector each, so ~50M vectors.
  3. Index memory. A common embedding width is 1,536 numbers per vector at 4 bytes each ≈ ~6 KB per vector. Raw: 50M × 6 KB ≈ ~300 GB. The graph structure that makes search fast adds roughly half again — call it ~450 GB of RAM. That's a few large nodes — or compress the vectors (8-bit instead of 32-bit floats cuts ~4×) and it fits on one.
  4. One-time embedding cost. 20B tokens through a small embedding model at ~$0.02 per million tokens ≈ ~$400 — and batch pricing halves it. Embedding the entire company costs less than a laptop.
  5. The daily delta. If ~1% of the corpus changes daily, that's ~200M tokens/day to re-embed ≈ a few dollars. Freshness is architecturally hard but computationally cheap.
  6. Per-query cost. Embedding the query is a rounding error. Vector search is amortized infrastructure. The real line items are the reranker (~a fifth of a cent per query on hosted APIs) and generation — a few thousand context tokens plus the answer, another half cent or so. Generation dominates.

The interactive version of this example is available when JavaScript loads.

Two pipelines, one index

Now draw it — and draw it as two pipelines meeting at an index, because that shape is the design. The offline pipeline runs continuously in the background, turning documents into searchable pieces. The online path runs per question, under a two-second budget. They share exactly one thing: the index the first one writes and the second one reads.

The offline ingestion pipeline — runs on every new or changed document
StageWhat it does
Source connectorsWatch the wiki, drives, and trackers for changes — ideally event-driven (webhooks / change feeds), not nightly crawls. Also sync each document’s permission list.
ParserTurns each format (PDF, HTML, slides) into clean text plus structure — headings, sections, tables. Garbage parsing here silently caps answer quality forever.
ChunkerSplits each document into retrieval-sized pieces along its structure, carrying metadata: source, section, timestamp, and who may read it.
EmbedderBatch-converts each chunk into a vector — a list of numbers positioned so that similar meanings land near each other.
Index + metadata storeThe vector index for meaning search, a keyword index for exact-term search, and a document store holding the chunk text + metadata. Upserts and deletes, not just inserts.
The online query path — runs per question, in ~2 seconds
StageWhat it does
Auth + query understandingIdentify the asker (their permissions matter in a moment). Clean up the query — expand shorthand, resolve “it” from conversation context if multi-turn.
Hybrid retrievalSearch by meaning (vectors) AND by exact terms (keyword index) in parallel, fuse the rankings — filtered to documents this user may read, at the index level.
RerankerA second, more careful model re-scores the top candidates against the query and keeps the best few. The precision stage of the funnel.
Context assemblyDeduplicate, order, and pack the surviving chunks into the prompt with citation markers, alongside the instruction to answer only from them.
GenerationThe LLM writes the answer, streaming, citing chunk markers as it goes. If the context doesn’t contain the answer: say so.
Feedback captureThumbs, “wrong source” flags, escalations — logged. This is the raw material of the evaluation flywheel later.

Two things to say while drawing. First, the two-pipeline separation is operational, not cosmetic: ingestion can lag, backfill, or crash without taking answers down, and the query path can be scaled or debugged without touching ingestion. Second, everything between the user and the model is ordinary, testable code — retrieval choices, filters, and fallbacks live in services you can unit-test, not in prompt incantations you hope the model obeys.

With the skeleton up, the interviewer picks a box and says "go deeper." For this question it's almost always chunking, retrieval quality, or — from the strongest interviewers — permissions and freshness. Take them in order.

Turning documents into something findable

Why not index whole documents? Two reasons, and they're both about focus. An embedding is one vector — one point of meaning — per piece of text. Embed a 40-page policy and you get one mushy point that averages every topic in it: it matches everything weakly and nothing well. And even when a whole document is retrieved, you pay to stuff all of it into the model's context window when only three sentences mattered.

So you split documents into chunks — and chunk size becomes a real tuning decision with failure on both ends. Too small, and a rule gets separated from its exception; the retrieved fragment is sharp but incomplete. Too large, and you're back to mushy vectors and padded prompts. In practice the sweet spot for prose sits around a few hundred tokens — 400–800 is a defensible starting range, tuned on your own eval set — with a modest overlap (~10–15%) so a sentence that straddles a boundary survives in at least one piece.

The interactive version of this example is available when JavaScript loads.

What separates competent chunking from naive chunking

  • Split along structure, not byte counts. Documents have headings, sections, list items. A splitter that respects those boundaries (section-aware, recursively falling back to paragraphs, then sentences) keeps each chunk a coherent idea. Fixed-length slicing through the middle of a table is how retrieval quality quietly dies.
  • Carry metadata on every chunk. Source document, section heading, last-modified time, and the permission list. The heading often disambiguates the text ("Probation period" means different things in HR and legal docs); the timestamp powers freshness; the permission list powers everything in deep dive 4.
  • Give each chunk its context back. A chunk that says "the limit is five days" embeds poorly — five days of what? Prepending a line of document-level context to each chunk before embedding ("From the annual-leave policy, section: rollover…") measurably cuts retrieval failures — published results report on the order of a third to a half fewer misses. It costs one cheap LLM pass per chunk at index time, and it's the kind of detail that signals real production experience.

Then the embedding model itself. The practical decision is a table lookup, not a research project: public retrieval leaderboards rank models; you weigh quality against dimensions (wider vectors = more RAM, linearly) and price (small hosted models run ~$0.02 per million tokens; the large tiers ~5–6× that; open-weight models are free per token but you own the serving). The senior move is knowing where embeddings are weak, whatever the leaderboard says: they blur negation ("policies that do NOT apply to contractors" retrieves the ones that do), and they're unreliable on opaque identifiers — error codes, part numbers, ticket IDs — which is precisely the gap the next section closes.

Finding the right ten chunks in fifty million

Retrieval is where this round is won or lost, so slow down here. First, the mechanics: comparing the query vector against 50M vectors exactly would take seconds; instead, vector indexes use a graph that hops toward the neighborhood of the answer, checking a tiny fraction of the vectors — approximate search that finds 95–99% of the true nearest neighbors in single-digit milliseconds. That last few percent is a tunable dial (how many graph paths to explore): more recall for more latency. Know that the dial exists; say it's tuned against your eval set.

The bigger insight is that searching by meaning alone is not enough. Vectors are brilliant at paraphrase — "days off" finds "annual leave" — but an opaque token like an error code has no meaning to embed. Someone pastes QX-4471 into the assistant; the runbook entry for it is the single most relevant chunk in the company; pure semantic search shrugs. Meanwhile the classic keyword approach (score rare exact terms highly) nails the error code and completely misses the paraphrase. Neither survives real queries alone:

The interactive version of this example is available when JavaScript loads.

So production systems run both searches in parallel and fuse the rankings — most simply by reciprocal rank fusion: each list votes for its results by rank position (a candidate ranked 3rd earns more than one ranked 40th), votes sum across lists, no fragile score-normalisation needed. The keyword leg adds tens of milliseconds and rescues exactly the queries vectors fumble; reported gains from hybrid over dense-only are double-digit percentage points of recall.

Then the funnel's second stage. The first stage was built for speed — it compares the query to each chunk independently, using vectors computed before the query existed. A reranker is a slower, smarter model that reads the query and each candidate together and scores how well that specific passage answers that specific question. Too slow to run against 50M chunks; perfect against 100. So: cast wide with fast hybrid search (top ~50–150), rerank, keep the best ~5–20. Published pipelines report roughly two-thirds fewer retrieval failures with the full stack (contextual chunks + hybrid + rerank) versus plain vector search — at a price of ~100–300 ms and a fraction of a cent per query, which is exactly what your latency and cost budgets reserved for it.

The interactive version of this example is available when JavaScript loads.

Round out retrieval with query understanding — a fast pass before the search: expand internal shorthand and acronyms, condense a multi-turn exchange into a standalone question ("what about contractors?" means nothing without the previous turn), split genuinely compound questions, and route trivia ("hi", "thanks") away from retrieval entirely. Each is cheap; together they rescue a surprising share of real-world queries, because users don't phrase questions the way documents phrase answers.

From retrieved chunks to a grounded answer

Retrieval hands you ten good chunks; the last leg is making the model use them — and only them. This is mostly careful assembly plus an explicit contract, and it's where the "confident wrong answer" failure mode gets designed out.

The assembly rules that matter

  • Deduplicate and diversify. The top ten often includes three near-copies of the same paragraph (the wiki page, its PDF export, last year's version). Drop near-duplicates so the window carries ten pieces of evidence, not one piece three times.
  • Pull in the neighbors when it helps. The chunk that matched isn't always the chunk that answers — the winning chunk's surrounding section often carries the caveat. Fetching adjacent chunks from the same document is a cheap completeness win.
  • Order for the model's attention. Models attend best to the start and end of a long prompt and slump in the middle — the lost-in-the-middle effect. Put the strongest evidence first (and the second-strongest last) rather than dumping chunks in arbitrary order.
  • Tag every chunk with a marker ([1], [2], source, date) and instruct the model to cite markers per claim. Now every sentence in the answer is checkable — and the citations double as an evaluation signal later.
  • Write the abstention path into the prompt contract: answer only from the provided passages; if they don't contain the answer, say "I couldn't find this in our documents" and suggest where a human might look. An honest "I don't know" preserves trust; a fluent guess destroys it — and this contract is also your first line of defense when a retrieved document itself contains adversarial text trying to redirect the assistant (treat retrieved content as untrusted data, never as instructions).

The production half: freshness and permissions

Everything so far, a well-read candidate can recite. This section is where interviewers find out who has actually run one of these — because the demo-versus-production gap in RAG lives in two questions that sound mundane: what happens when a document changes? and who is allowed to see what?

Freshness first. The naive design re-indexes nightly, and it fails the first time someone updates the security-incident runbook at 10am and the assistant cites the old one at noon. The production design is event-driven: connectors receive change notifications (webhooks, change feeds — polling only as a fallback), and each changed document flows through parse → chunk → embed → upsert within minutes. Updates mean replacing a document's old chunks with its new ones atomically — version-stamp them so a query never retrieves a half-old, half-new mix. Deletes are their own story: vector indexes built on graphs don't truly remove entries cheaply — they tombstone them (mark dead, filter at query time) and physically clean up when segments rebuild. Your freshness SLA is really "tombstoned within minutes, purged within days" — say those two numbers separately, because for a privacy deletion (an employee-data request, a legal hold) purged is the one that counts. "Deleted from the source system" is not "deleted from the index" until the index says so.

Permissions are the sharper edge. The requirement sounds like a filter; the design question is where the filter runs, and one of the two obvious answers is a security hole.

Filter after retrieval — fetch top-10, drop what the user can't read — and you've built two failures. The quality failure: a restricted-heavy query has its whole top-10 filtered away and the assistant answers from dregs or nothing. The security failure is worse: forbidden text sat in your application's hands one bug away from the prompt — and once it reaches the prompt, no instruction reliably stops a model from leaking what it was shown. The correct design pushes authorization into the index itself: every chunk carries its permission tags in metadata, and the vector search runs pre-filtered — the graph walk simply never visits chunks the asker can't read. Forbidden content doesn't rank lower; it doesn't exist for that query. Modern vector stores support filtered search natively precisely because of this.

Two follow-ups to preempt: permission sync lag — access revoked in the source system must propagate to chunk metadata on the same event-driven path as content changes, and the window in between is real exposure you acknowledge and shrink, not hand-wave; and groups amplify it — resolve group membership at query time (user → groups → allowed tags), don't bake expanded member lists into chunk metadata, or every re-org means re-indexing.

How do you know the answers are right?

Here's the question that quietly grades the whole interview: you change the chunk size, swap the embedding model, tweak the prompt — did answers get better or worse? "They seem fine" is how RAG quality rots invisibly. The senior answer rests on one structural fact: retrieval and generation fail independently, so you measure them separately. The right passage never made it into the net — that's a retrieval failure, and no prompt engineering will fix it. The right passage was in the window and the model contradicted it anyway — that's a generation failure, and no chunking change will fix it. One combined "answer quality" score hides which dial to turn; two separate dials tell you.

The two dials

  • Retrieval metrics, on a golden set. A few hundred real questions, each labeled with the passages that answer it (built once with subject-matter reviewers, grown from production). Measure: was the right passage in the candidates (recall at k)? How high did it rank? Cheap, fast, deterministic — run it on every chunking, embedding, or index change like a regression suite.
  • Generation metrics, judged. Given the retrieved context and the answer: is every claim supported by the context (faithfulness — the anti-hallucination dial)? Does it actually address the question? Are citations pointing at the passages that back each claim? There's no exact-match here, so a strong model grades against a rubric — spot-audited by humans so the judge itself stays honest.

The cost of a query

The estimation section found the inversion: the index is cheap, the query path is the bill. Itemize a single query to show where the money actually goes — assumptions: ~10 chunks × 400 tokens of context, a mid-tier generation model, hosted reranker.

Where one query’s money goes (illustrative, stated assumptions)
Line itemRough costShare
Embed the query (~50 tokens)~$0.000001noise
Vector + keyword searchamortized infrasmall
Rerank ~100 candidates (hosted)~$0.002~25–40%
Generation: ~4k context in + ~300 out~$0.004–0.008~60–75%
Total~half a cent to a cent—

The levers, in the order you pull them

  • Trim the context. Every chunk you pass costs input tokens on every query. If evals show top-5 answers as well as top-10, that's ~2,000 tokens saved per query — a double-digit percentage of total cost for free. This is why "how many chunks?" is an eval question, not a default.
  • Cache semantically. Real workloads repeat — the same benefits question in fifty phrasings. Serve a stored answer when a new query lands close enough in meaning to an old one (with the user's permissions re-checked and the source documents unchanged — a stale or over-shared cached answer is worse than a slow one).
  • Route by difficulty. A lookup question doesn't need the frontier model that a synthesis question needs. A cheap classifier routing the easy majority to a small model cuts the biggest line item on the biggest share of traffic.
  • Self-host the reranker. A hosted rerank API's per-query fee is a real fraction of the bill; an open-weight reranker on your own GPU flips it to fixed cost once volume justifies the ops. Same buy-vs-build crossover logic as model serving.

When it breaks

The failures worth designing for

  • The right document exists and wasn't retrieved. The silent killer — the user just gets a worse answer and never knows. Caught only by retrieval evals and by watching abstention rates on answerable questions. Diagnose down the funnel: was it indexed? chunked sanely? did hybrid miss it? did the reranker drop it?
  • The answer contradicts the retrieved context. Generation failure — the faithfulness dial. Tighten the prompt contract, or route to a model that follows it.
  • The index is stale. Yesterday's policy, confidently cited. Alert on ingestion lag (documents changed vs chunks updated) exactly like you'd alert on replication lag.
  • A permission leak. The one failure with an incident report. Defense in depth: filter in the index, re-check at assembly, audit-log which chunks entered which prompt — that log is also how you prove the blast radius of any bug.
  • Ingestion dies quietly. A connector loses auth, a parser chokes on a new format, and the corpus silently freezes. The two-pipeline split means answers keep flowing — monitor ingestion lag as a first-class SLO or you'll learn about it from a user citing a three-week-old doc.
  • Degraded dependencies. Reranker down: serve top-k un-reranked (quality dips, service lives). Vector store down: keyword-only search with a banner beats a hard 500. Generation down: return the retrieved passages with links — "here's what I found" is a useful degraded product.

When RAG is the wrong answer

The closing move that reads as staff-level: knowing the boundaries of the thing you just designed. The recurring interview form is "why not just fine-tune?" or "why not just use a million-token context?" — and the answer is a clean division of labor.

Fine-tuning teaches behavior; retrieval supplies facts. Fine-tuning bakes patterns into the model's weights — tone, format, domain vocabulary, tool-use habits. It's the right tool when the model should act differently. It's the wrong tool for knowledge: facts baked into weights are frozen at training time (your corpus changes daily), can't cite a source, can't be deleted per-user (permissions!), and updating them means training again. Retrieval keeps facts in an index you can update in minutes, cite line-by-line, filter per-user, and delete on demand. They compose: a fine-tuned model with retrieval — trained how to answer, told what's true — is common in production.

Long context changes the economics, not the architecture. Covered in the grounding section: stuffing is an order of magnitude more tokens per query forever, plus the mid-context accuracy slump. The honest exception — a small, stable corpus (hundreds of pages that rarely change) with real usage volume: cache the corpus in the model's context once and reuse it across queries; retrieval infrastructure would be over-engineering. Naming that exception unprompted is exactly the "it depends" judgment the top of the ladder is graded on.

What each level is expected to reach

The same question, five bars
LevelWhat a strong answer reaches
Intern / SDE-1The two-pipeline skeleton: parse → chunk → embed → index, then embed query → top-k → prompt → answer. Knows why RAG beats asking the bare model. Fixed-size chunks, single vector search, no eval story.
SDE-2Chunking as a tuned trade-off with structure-aware splitting and metadata. Justifies an embedding model choice. Knows vector search is approximate. Adds hybrid search because of exact-identifier queries. Basic golden-set testing.
Senior / SDE-3The full funnel with numbers: hybrid + fusion, rerank 100→10, latency budget per stage. Contextual chunk enrichment. Event-driven freshness with upserts + tombstones. Permission pre-filtering at the index. Separates retrieval evals from generation evals and runs them as regression gates.
Staff / PrincipalOwns the unit economics (per-query line items, the cache/route/trim levers) and the eval flywheel as the mechanism of safe iteration. Treats permission correctness as a hard constraint with defense-in-depth and audit. Draws the RAG / fine-tune / long-context boundary and names the exceptions. Designs for degraded modes and diagnoses quality drops down the funnel.

The follow-ups they will actually ask

Retrieval quality is bad — walk me through debugging it.
Down the funnel, with the eval set as the instrument. First split retrieval from generation: on failing golden-set questions, was the right passage in the candidates at all? If it's missing: check it was ingested and parsed (garbage text?), check the chunking (rule split from its context?), check the query-document vocabulary gap (would the keyword leg have caught it? is an acronym unexpanded?). If it's retrieved but ranked low: reranker or fusion weights. If it's in the window and the answer is still wrong: generation failure — prompt contract or model. Each stage has its own fix; the whole point of measuring per-stage is never guessing which one to turn.
A document was deleted for legal reasons — what has to happen?
More than most designs admit. The connector receives the delete event; the document's chunks are tombstoned in the index within the freshness SLA (minutes) so they stop being retrievable; the physical purge happens when index segments rebuild (days — state it as its own SLA, because for a legal deletion the tombstone isn't enough). Then the parts everyone forgets: the semantic cache may hold answers built from that document — invalidate by source; and if prompts are logged for audit, the text lives there too — the retention policy has to cover it. "Deleted" means deleted from every place the text landed, and being able to enumerate those places is the actual answer.
Why not fine-tune the model on our documents instead of all this?
Because fine-tuning teaches behavior, not facts. Weights are frozen at training time — the corpus changes daily; a model can't cite which weight an answer came from — this system's trust rests on citations; and there's no per-user filtering inside a model's parameters — permissions become impossible. Fine-tune when the model should act differently (tone, format, domain habits); retrieve when it needs to know things that are current, citable, and access-controlled. The strong version composes both.
Cut the cost per query by 10× — go.
In lever order, each gated by the eval suite. Semantic caching first — repetitive workloads can serve a large fraction of queries for near-zero. Then trim the window: if top-5 holds quality against top-10, that's roughly half the input tokens gone. Then route: a classifier sends lookup-grade questions to a model an order of magnitude cheaper. Then self-host the reranker once volume beats the API fee. The honest caveat: 10× usually isn't one lever, it's the cache handling half of traffic plus the other three shrinking the rest — and every step is only safe because the regression suite says quality held.

Common pitfalls

What sinks otherwise-competent answers

  • Naming tools instead of designing — "use a vector database and an orchestration framework" with no trade-offs. The tools are the easy 20%; the round is about the decisions.
  • Pure vector search — no answer for exact identifiers, acronyms, or names. The moment the interviewer says "a user searches for an error code," dense-only designs die.
  • One retrieval, no funnel — top-k straight into the prompt with no reranking and no reason for the chosen k.
  • Permission filtering in the application layer — the fastest senior-level fail. Authorization belongs in the retrieval query.
  • A static corpus assumption — no update path, no delete story, nightly full re-index as the freshness plan.
  • No evaluation story — or one blended "quality score" that can't say whether retrieval or generation broke.
  • No numbers anywhere — chunk sizes, top-k, latency budget, per-query cost. Ranges with stated assumptions beat false precision, but silence beats nothing at no level.
  • Treating abstention as failure — a system that always answers is a system that sometimes lies. "I couldn't find this" is a feature.

Takeaway

Design a RAG System rewards one shift above all: stop designing the model's answer and start designing the evidence that reaches it. Everything strong in this round is some form of that — chunking so each piece of evidence is sharp, hybrid search so no phrasing hides it, reranking so only the best of it spends your token budget, permission filters so forbidden evidence never exists for the query, freshness so the evidence is current, citations so the evidence is checkable, and evals proving the evidence pipeline still works after every change.

Walk the arc — scope it honestly (grounded, fresh, permissioned), size the corpus in vectors and dollars, draw the two pipelines meeting at the index, then go deep on retrieval and the production half — and close on the division of labor: retrieval for facts, fine-tuning for behavior, long context as an economics question. Do that and you haven't just wired a vector database to a model; you've designed the thing companies are actually trying to build — a system that tells employees the truth, only the truth they're allowed to see, and knows when it doesn't know.

By GOAT Engineer. Back to Interview breakdown. Privacy Policy · Contact.