Skip to content
RED SAGSkills
mediumMachine Learning Engineer interview question

Walk me through how you would build a RAG system to answer questions over a company knowledge base.

What the interviewer wants to hear

  • Ingestion: parse, clean and chunk documents with metadata
  • Embed chunks and index them; consider hybrid search with BM25
  • Retrieve, rerank and fit the best chunks into the prompt
  • Prompt the model to answer from context and cite sources
  • Evaluate retrieval and answer quality with a labelled test set
  • Handle access control, freshness and monitoring

Model answer

I start with ingestion: parse documents, strip boilerplate, and split them into chunks of a few hundred tokens along headings, keeping metadata such as source, date and permissions. I embed each chunk and store it in a vector index, and I add BM25 keyword search because users often search exact product names or codes. At query time I retrieve candidates from both, merge them, and run a cross-encoder reranker to pick the top few that fit the context budget. The prompt tells the model to answer only from the provided passages, cite them, and say when it does not know. Before launch I build an evaluation set of real questions with known source passages, measure retrieval recall at k and answer faithfulness, and iterate on chunking and retrieval first. In production I enforce document permissions at retrieval time, re-index on updates, and monitor no-answer rates and user feedback.

Can you answer it under time pressure?

Take a timed medium round and get scored on every answer.

Start mock interview

More medium Machine Learning Engineer questions