LyraLearn AI Learning Platform
Exams
← Module 6 Β· RAG Architecture
🎧 Listen

Retrieval and Evidence Grading

With documents chunked, embedded, and stored, the live request path has two jobs: find the passages most likely to answer the question, and judge whether they're strong enough to answer from at all. The second job is what separates a trustworthy RAG system from a confident fabricator. In LyraLearn this is the heart of what the AI Tutor does the moment you hit enter.

Retrieved chunks pass through an evidence grading gate with four tiers from strong to none; strong evidence proceeds to generation while no evidence triggers a refusal.

Hybrid search: vectors plus keywords

When a question arrives, it is embedded with the same model used at ingestion β€” Ollama nomic-embed-text, 768 dimensions β€” so the query vector lives in the same space as the chunk vectors. Retrieval then runs two complementary searches:

Combining them is hybrid search. Vectors handle paraphrase and synonyms; keywords pin down the exact terms that have to appear. The Tutor scores each candidate chunk on both and returns the top few as the evidence set.

Grading the evidence

Retrieval always returns something β€” the closest chunks, even when the corpus has nothing relevant. So before generating, LyraLearn grades how strongly the retrieved evidence actually supports an answer, using the distance scores and match quality:

Grading turns a raw similarity score into a decision the rest of the pipeline can act on. It is the gate between "we have evidence" and "we're guessing."

Fail closed: refuse when there's no grounding

The defining behaviour of a safe RAG system is what it does when grading returns None: it fails closed and refuses. The Tutor replies that the lessons don't cover the question rather than inventing an answer the model has no basis for. This is deliberate β€” the costly failure mode in enterprise and public-sector AI isn't "I don't know," it's a fluent, wrong answer that a user trusts.

Concretely: ask the Tutor something the lessons address and it answers with citations; ask it about today's weather and it declines. That refusal isn't a gap in coverage β€” it's the evidence grader working exactly as designed. Only when grading clears the bar does the request proceed to generation, where the model answers strictly from the graded evidence.

🧠 Quiz yourself on this lesson →

Ask the AI Tutor

Grounded in the course lessons β€” it cites its sources and says when it doesn't know.