Build your own RAG and make it trustworthy

By LessonFolk

Build your own retrieval-augmented generation pipeline over documents you choose, from extraction to cited answers, then measure retrieval and answers separately and fix the stage that fails most.

About 5 hours 5 milestones

What you need

  • A computer with the programming language of your choice installed, and a code editor
  • A free model for answers and a free embedding model, run on your own computer or through a hosted API on its free tier
  • 5 to 30 documents that are not confidential (rules of a club, product manuals, course notes, public reports)
  • A spreadsheet to record test results
  • An AI coding agent that edits your project from your instructions (optional, if you prefer to direct the work rather than type the code)

Courses it builds on

The project puts these courses to work. You can start it without them: your tutor explains what you need.

The brief

Build a system that answers questions from a set of documents you choose, and that you can trust: it finds the right passages, answers from them, cites them, and says when the documents do not cover a question. You build the whole pipeline yourself: extract the text, cut it into chunks, index them, retrieve the best ones for a question, and generate an answer from them. Then you measure where it fails and fix it.

You choose the documents, the programming language and the models, local or hosted. You also choose how you build: you can write the code yourself, asking an AI chat app for help when you need it, or direct an AI coding agent that writes and edits the code from your instructions. Either way, you decide how each stage works, you check what was written, and you must be able to explain every stage: each milestone asks you to.

Your tutor is your coach: it explains the ideas, asks questions, helps you read your results and reviews your choices, but it will not write the pipeline, the test set or the fixes for you.

Use documents that are not confidential and contain no personal data. If you use a hosted API, your key is a password: never paste it into a chat or into your code.

Milestones

Reach them in order. Your tutor checks each one with you before the next.

  1. Choose the documents and design the pipeline

    Pick the collection and decide what each stage of the pipeline will do.

  2. Prepare and search the documents

    Turn the documents into chunks that make sense on their own, index them, and retrieve the best ones for a question.

  3. Generate answers grounded in the passages

    Send the retrieved chunks and the question to the model, and get an answer that relies on them.

  4. Build a test set and measure stage by stage

    Write questions with the passages that should answer them, and measure retrieval and answers separately.

  5. Fix the weakest stage and say what it can be trusted for

    Improve the stage that fails most, measure again, and state the system's limits.