Skip to content

How does Self-RAG train models to dynamically decide when to retrieve, evaluate, and critique documents?

Advanced · 2 min read · RAG & Vector Databases

Open in study mode to save this question and track progress

Short answer: Self-RAG (Self-Reflective Retrieval-Augmented Generation) fine-tunes an LLM to generate special reflection tokens ([Retrieve], [IsRel], [IsSup], [IsUse]), allowing the model to dynamically decide when external retrieval is necessary, evaluate document relevance, check output grounding, and critique answer quality on-the-fly.

Detail

Standard RAG pipelines follow fixed execution paths: ALWAYS retrieve KK documents for every user query, even if the query is a simple greeting or common knowledge.

Standard RAG: User Query ──► ALWAYS Retrieve ──► Generate Answer

Self-RAG:     User Query ──► Generates Token: [Retrieve=Yes/No]
                             ├──► If No  ──► Generate directly from parametric memory
                             └──► If Yes ──► Retrieve Docs ──► Output [IsRel=Relevant]
                                                             ──► Output [IsSup=FullySupported]

Self-RAG Reflection Tokens

  • [Retrieve]: Values {Yes, No, Continue} — Decides if external retrieval is needed.
  • [IsRel]: Values {Relevant, Irrelevant} — Evaluates if retrieved document contains useful context.
  • [IsSup]: Values {FullySupported, PartiallySupported, NoSupport} — Verifies if output text is grounded in retrieved text (hallucination check).
  • [IsUse]: Values {5, 4, 3, 2, 1} — Rates overall utility of generated output.

Example

Python concept illustrating Self-RAG token-guided routing:

python
def self_rag_decide_retrieval(model_completion: str) -> bool:
    # Model generates special reflection token at position 0
    if "[Retrieve=Yes]" in model_completion:
        return True # Trigger external vector search
    elif "[Retrieve=No]" in model_completion:
        return False # Skip vector search; answer directly
    return False

Interview tips

  • Highlight that Self-RAG reduces inference latency and API cost on simple queries by skipping unnecessary vector retrievals.
  • Connect Self-RAG reflection tokens to RLHF / DPO fine-tuning setups.

Related Concepts


⬅ Back to RAG and Vector Databases · All topics