QA
Senior LevelAI, LLMs, Embeddings & MCP

How does Self-Corrective RAG (CRAG) evaluate retrieval quality and dynamically trigger web search fallbacks?

❓ Interview Prompt: Explain Corrective RAG (CRAG), retrieval evaluator scoring, query rewriting, and dynamic web search fallback triggers.

Standard RAG blindly passes retrieved vector chunks to the LLM even when retrieval quality is terrible. Corrective RAG (CRAG) adds an autonomous evaluation and correction loop.

CRAG Execution Logic:

1
Retrieval Evaluation: A lightweight Evaluator Model scores the relevance of retrieved vector chunks against the user query.
2
Confidence Actions:
•
Correct (High Confidence): Refines chunks and passes directly to LLM.
•
Incorrect (Low Confidence): Discards vector chunks entirely and triggers an external Web Search API fallback!
•
Ambiguous (Moderate Confidence): Combines both vector store chunks and web search results.

Code Implementation Example

typescript
async function correctiveRagPipeline(query: string): Promise<string> {
  const vectorChunks = await vectorStore.retrieve(query);
  const confidence = await evaluatorModel.score(query, vectorChunks);

  let finalContext = '';
  if (confidence === 'CORRECT') {
    finalContext = vectorChunks.join('\n');
  } else if (confidence === 'INCORRECT') {
    // Vector search failed! Trigger web search fallback!
    finalContext = await tavilySearchApi.search(query);
  } else {
    finalContext = vectorChunks.join('\n') + '\n' + await tavilySearchApi.search(query);
  }

  return await llmClient.generateWithContext(query, finalContext);
}
💡Corrective RAG (CRAG) evaluation triggering dynamic web search fallbacks.
🎯 Interview Key Takeaway

CRAG evaluates vector retrieval confidence and dynamically triggers web search fallbacks when vector search results are poor.

#CRAG#Corrective RAG#Agents#Web Search#Senior
Back to all AI, LLMs, Embeddings & MCP Questions→

More AI, LLMs, Embeddings & MCP Interview Questions

Beginner LevelAI, LLMs, Embeddings & MCP

What are Vector Embeddings and Cosine Similarity in AI Semantic Search?

Beginner LevelAI, LLMs, Embeddings & MCP

What is the Model Context Protocol (MCP) and how does it connect LLMs to external tools?

Beginner LevelAI, LLMs, Embeddings & MCP

What is Retrieval-Augmented Generation (RAG) and how does it prevent LLM hallucinations?