Ingest and chunk the documents with structure aware splitting, embed the chunks, and index them in a vector store alongside metadata for filtering. At query time, embed the question, retrieve candidates, optionally rerank with a cross encoder, then build a prompt with the retrieved passages and citations. Evaluate retrieval and generation separately, and keep the index refreshed as documents change.
Why interviewers ask this
RAG is the most common applied ML system being built right now, so interviewers want to know you can reason about it as an engineering system rather than a demo. They listen for chunking strategy, a reranking stage, metadata filtering, and above all separate evaluation of retrieval and generation, because most RAG failures are retrieval failures misdiagnosed as the model being bad.
How to structure your answer
- Walk the offline path: chunk, embed, index, with metadata.
- Walk the online path: embed, retrieve, rerank, prompt.
- Insist on evaluating retrieval separately from generation.
- Cover freshness, permissions, and citing sources.
Example answer
Offline, I chunk on structure rather than a fixed character count, so headings and sections stay intact, with a little overlap so a sentence spanning a boundary is not lost. Each chunk gets an embedding plus metadata: source, section, last modified, and access group, because permissions have to be enforced at retrieval time, not by asking the model nicely. That goes into a vector index with a keyword index alongside it, since hybrid search consistently beats pure vector on internal docs full of error codes and product names that embeddings handle badly. Online, I embed the query, pull maybe fifty candidates, rerank with a cross encoder down to five or six, then build the prompt with those passages and instructions to cite them and to say plainly when the context does not cover the question. The part I insist on is separate evaluation. I build a set of real questions with known correct source documents and measure recall at k for retrieval on its own. Most of the time when an answer is wrong, retrieval never surfaced the right chunk, and no amount of prompt work fixes that.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- How would you choose a chunk size for a given corpus?
- What do you do when the retrieved context contradicts itself?
- How do you keep the index in sync with documents that change daily?
Related machine learning engineer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions