All jobs / AI engineer / RAG — Retrieval-Augmented Generation
AI engineer interview question · 3–5 years
In a multi-turn chat about leave policy, the user asks “and what about for contractors?”. Retrieval returns unrelated passages.
Why does that happen, and what do you do about it?
The strongest answer
The follow-up is not a standalone query; embedded alone it carries no topic. I rewrite it into a self-contained question using the conversation — a cheap model call — retrieve on that, and log the rewrites
Why it works
Exactly — retrieval sees only the query string, not the chat. A rewrite step restores what the user meant, and because it can also get it wrong, you log it and evaluate it.
What a good answer covers
- Retrieval sees the query, not the chat.
- Rewrite follow-ups into standalone questions.
- Retrieve on the rewrite.
- Log and evaluate the rewrite step.
Answers that fall short
- Close, but not the strongest: Embed the whole conversation so far together with the new message, and search with that
It carries the context, but also every earlier topic, so the query drifts toward whatever was discussed most. A focused rewrite is sharper. - Weak: Raise top-k for follow-up messages so that something relevant is likely to be included
“And what about for contractors?” has no topic to match; more results from a bad query are more bad results. - Red flag: Tell users to write complete questions; the assistant cannot be expected to guess what they mean
People talk in follow-ups; that is what a chat is. Blaming users for the product’s gap is a red flag in any interview.
Who gets asked this
More RAG — Retrieval-Augmented Generation questions
- The assistant gave a wrong answer to a question the documentation clearly covers. How do you find out which…
- The right chunk is nearly always in your top 50 results but rarely in the 5 you send to the model. What do…
- You own the RAG system. What do you ask for before this merges?
- Leadership wants one assistant over all internal documents — HR, legal, finance, engineering — for every…
- Since you added “answer only from the retrieved context, otherwise say you don’t know”, the assistant refuses…
- Walk me through a RAG system, from a document being uploaded to a user getting an answer.
- Why do we split documents into chunks before embedding them, instead of making one vector per document?
- What is chunk overlap for, and what does too much of it cost?