AIOps Peach

RAG Optimization · Module 04

Re-ranking

What to do with the retrieved passages before the model sees them: cross-encoder re-ranking, MMR for diversity, compression and ordering.

Học tương tác →

Học xong bạn làm được

Bài học

  1. Re-ranking: Cross-Encoder

    The top-K list from retrieval is not good enough to feed the LLM directly - embeddings trade semantic accuracy for speed, and keyword matches bring noise. Re-ranking reads a small candidate set carefully. A bi-encoder encodes question and document separately; a cross-encoder reads them together with full self-attention - accurate but slow, so it is used in a funnel.

  2. Maximal Marginal Relevance (MMR)

    The most similar documents are not always the best set - five near-identical paragraphs waste the context window. MMR balances relevance to the question with diversity from what is already selected, controlled by lambda (usually 0.5). Use a cross-encoder for precise answers to hard questions, MMR for broad answers covering many aspects.

  3. Additional Post-Retrieval Techniques: Contextual Compression and Lost in the Middle

    Contextual compression sends the LLM only the relevant parts of retrieved documents, by extracting sentences or by summarising with a small model. LLMs attend most to the beginning and end of the context and lose the middle (Liu et al., 2023); U-shape reordering, fewer documents and compression before stuffing mitigate it.

  4. LLM-Based Re-ranking

    An LLM can be used as the re-ranker, instead of or as well as a cross-encoder. It follows complex instructions, can explain its ranking and needs no specially trained model, but it costs much more per document and is slower, so it suits small candidate sets of the top 10 to 20.

  5. Assignment: Post-Retrieval Processing

    Re-ranking with Cross-Encoder and Maximal Marginal Relevance