Intermediate level · Module 6: Retrieval-Augmented Generation Pipelines · Lesson 1 of 3
The RAG Pipeline End to End
Learners build a minimal RAG application: retrieve passages for a question, assemble them into a prompt and generate an answer that uses them.
In this lesson you will
- Describe each stage of a RAG pipeline
- Build a minimal working RAG application
Key concepts
retrievalcontext assemblygenerationgroundingapproved collection
The lesson
Retrieval-Augmented Generation answers questions from documents the model was not trained on: retrieve relevant passages, place them in the prompt with instructions, and generate an answer that uses only them. This keeps answers current and specific to an organisation.
The collection must be approved: documents the organisation is allowed to use and share with the chosen model. Retrieval quality limits answer quality; if the right passage is not retrieved, the answer will be wrong or missing.
The AI programme introduces RAG briefly; this module builds a complete, evaluated pipeline.
Step by step
- Use the semantic search from Module 3 as the retriever.
- Assemble the top three passages with IDs into a prompt.
- Generate an answer with a local or practice model.
- Run ten questions and inspect the passages used.
From approved documents to a cited answer: a RAG pipeline
The stages of a document-based assistant, from ingestion to evaluation, with the checks at each step.
Approve documents
A named owner approves which documents go in, records their access level and version, and removes personal data that is not needed.
document owner
Ingest and chunk
Text is extracted and cleaned, split by headings into chunks of a few hundred tokens, and labelled with document ID, section, date and access level.
pipeline script
Embed and store
Chunks are embedded with a small open model and stored in a local Chroma collection that a script can rebuild at any time.
pipeline script
Retrieve and rerank
For each question, hybrid search (meaning plus keywords) finds 20 candidates, filtered by the user's access level; a reranker keeps the best 3.
application
Generate a grounded answer
The model answers only from the 3 passages, cites their IDs, or says the documents do not contain the answer. Output is validated against a schema.
language model + validator
Check and show
Code checks that the citations were retrieved and that key facts appear in them; the user sees the answer with its sources.
application
Evaluate and improve
A 40-question set is run after every change; failures and user reports are added to it.
developer
When a document is updated, its old chunks are removed and the new version is indexed, then the evaluation set is re-run before release.
Why it works
No step sends restricted or personal documents to an external service without authorisation; a local model can be used for sensitive collections. Retrieved text is treated as information, never as instructions.
Practice activity
Build a minimal RAG application over the project collection.
Expected result: Answers that use retrieved passages, with retrieval failures noted.
Check your understanding
-
What problem does RAG solve?
Show answer
Answering from documents the model was not trained on, with current, specific information.
-
What limits RAG answer quality?
Show answer
Retrieval: if the right passage is not found, the answer suffers.
Further learning
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.