Advanced RAG interview question

Generative AIAdvanced RAGContext Managementhard

To save tokens, a bank adds an LLM extractor after retrieval that keeps only the sentences relevant to the question from each of the top 8 chunks. Context tokens fall by 60% and p95 latency rises by 700 ms. Overall answer correctness is unchanged, but it drops on questions whose answers depend on conditions such as "unless the card is a corporate card". What is happening, and what is the best fix?

  1. AThe extractor invents sentences that are not in the chunks; replace it with an LLM that summarises each chunk instead, because summaries stay grounded in the chunk text by design.
  2. BThe extractor drops qualifying sentences that do not echo the question's wording; make it keep conditions and exceptions, or filter whole chunks, and test on condition-heavy questions.
  3. CCompression left the key sentences in the middle of a long context, where models overlook them; reorder the kept sentences so the ones most similar to the question come first in the prompt.
  4. DThe extractor is still too permissive; compress harder, because a shorter prompt cuts latency and cost and leaves less surrounding text to distract the model from each condition.
Show the answer and explanation

Correct answer: B, The extractor drops qualifying sentences that do not echo the question's wording; make it keep conditions and exceptions, or filter whole chunks, and test on condition-heavy questions.

Explanation Advanced RAG

Contextual compression runs after retrieval: an LLM extractor keeps only the query-relevant sentences, or a filter (LLM or embedding similarity) drops whole irrelevant chunks. It saves prompt tokens and can remove distracting text, at the price of an extra model call (here +700 ms at p95) and a new failure mode.

The failure here is typical: the extractor judges relevance against the question, and qualifiers rarely share its wording. "What is the late fee on my card?" matches "The late fee is 250 TL", but the next sentence, "This does not apply to corporate cards, which follow the commercial tariff", looks off-topic and is dropped. The generator then answers confidently without the exception. The average hides it because most questions involve no conditions.

Fixes:

  • Instruct and test the extractor to keep conditions, exceptions, dates and amounts, plus neighbouring sentences.
  • Use coarser units for policy text: filter whole chunks or keep sentence windows instead of single sentences.
  • Build an evaluation slice of condition-heavy questions and track correctness and faithfulness on it, not only the average.
  • Re-check the trade-off: if 60% fewer tokens are not worth 700 ms, a reranker with a smaller top-k may be simpler.

Why the other answers fail: the symptom is missing conditions, not invented text, and abstractive summaries drop qualifiers too while adding hallucination risk. The context became shorter, so position effects shrank, and reordering cannot restore deleted sentences. Compressing harder drops more qualifiers, and the added latency comes from the extractor call, not prompt length.

Interview tip: name the trade-off in one line, "compression saves tokens but adds latency and can delete qualifiers", and say you would evaluate it on a slice of exception-heavy questions.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Generative AI questions

  1. A telecom's support assistant has no reference answers for live traffic, so the team wants implicit signals as quality proxies: the user rephrases the…
  2. A retailer trained a LoRA adapter on acme-8b (the base model). The serving team loads it onto acme-8b-instruct, which has the same architecture. It loads…
  3. Which statement about the HNSW parameters M, efConstruction and efSearch is correct?
  4. An e-commerce team writes product descriptions with a prompt that includes three example descriptions, all for one brand's running shoes. New descriptions for…
  5. What is a large language model (LLM)?