passdrill
AI & LLM Engineering · RAG & Embeddings · Card 008/012 medium

A RAG system retrieves 8 relevant passages for a query and inserts all of them into a single long prompt in an arbitrary order before generation. Research studying how language models use long contexts documented a failure mode directly relevant here. What is that failure mode, and what does it suggest about how the 8 passages should be arranged in the prompt?

  1. Models cannot process context windows longer than a few thousand tokens at all, so several of the 8 passages would simply be truncated and never reach the model regardless of their order
  2. Models weight every position in the context equally when generating an answer, so the order in which the 8 passages appear has no measurable effect on the result
  3. Models process the context strictly from the last token backward, so only the very last of the 8 passages in the prompt has any influence on the generated answer
  4. Performance on tasks that require using information from within a long context follows a U-shaped curve, staying strongest for information near the very beginning or the very end of the context and degrading for information placed in the middle, so the most relevant of the 8 passages should be placed near the start or end of the prompt rather than buried in the middle
Next card → Shuffle