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

The RAG Pattern

Retrieval-Augmented Generation (RAG) is the architecture you reach for when an AI feature must answer from a body of knowledge that changes β€” policy documents, a product catalogue, a help centre, or the lessons you're reading now. Instead of hoping the facts live in the model's frozen weights, you retrieve the relevant passages at query time, ground the prompt in them, and let the model generate an answer from that evidence. The AI Tutor in LyraLearn is a working RAG system, and this module is its blueprint.

The three-step RAG flow: a question retrieves passages from a database, the passages ground the prompt, and the model generates a cited answer.

Retrieve, ground, generate

Every RAG request runs the same three steps:

  1. Retrieve β€” embed the user's question and pull back the handful of passages most likely to contain the answer (vector search plus keyword matching).
  2. Ground β€” place those passages into the prompt as labelled reference data and instruct the model to answer only from them.
  3. Generate β€” the model writes the answer and cites which passage each claim came from.

When you ask the Tutor a question, that is exactly the path it takes: your question is embedded, the closest lesson chunks come back from SQL Server, they are graded for relevance, and only then is the model asked to answer with [Source N] citations. The model never reaches past the evidence you handed it.

Why RAG beats fine-tuning for changing knowledge

A tempting alternative is fine-tuning β€” retraining the model on your documents. For knowledge that changes, this is usually the wrong tool:

Fine-tuning still earns its place for teaching style, format, or tone β€” how the model should sound, not what facts it should know. The rule of thumb: fine-tune behaviour, retrieve knowledge.

What the rest of the module covers

The three steps each get their own lesson. Ingestion prepares your documents β€” chunking, embedding, and storing them so retrieval is fast and only changed content is re-processed. Retrieval and evidence grading finds the right chunks and decides whether they're strong enough to answer at all. Citations and evaluation make every answer auditable and let you measure quality over time. Together they are the difference between a demo and a system you can put in front of citizens.

🧠 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.