AI Campus • Practical resources

Retrieval-Augmented Study Assistant (RAG)

Start with cited keyword retrieval, then build and evaluate an optional local semantic retrieval and answer pipeline.

Build guide and prerequisites

Follow this roadmap to implement and validate your own application, then record your observed results.

  • Python basics; the difference between search and generated text.
  • A small set of notes you may use, with stable filenames and page or line references.

Required tools and free options

  • Python
  • Optional local Chroma database and embedding model
  • Optional local Ollama model

Cost: The downloadable lexical starter is offline and uses Python only. Semantic retrieval and local generation need model downloads and sufficient hardware. No cloud database or paid API is necessary.

Start with a smaller working example

Downloadable cited study-search starter →

This is lexical word-overlap retrieval with file/line citations. It does not use embeddings, a vector database or generated answers and is not a completed RAG system.

Build it step by step

  1. 1. Run cited lexical retrieval

    Download the starter and create notes.txt as instructed. Check both a query with a supporting passage and one without support. Inspect the actual source line rather than trusting the citation label alone.

  2. 2. Preserve source metadata

    Split several documents into passages with document ID, page/line range and chunk ID. Keep the original text immutable; do not cite a generated summary as if it were the original passage.

  3. 3. Write retrieval test questions

    Author ten questions and manually identify the supporting chunk IDs. Include synonyms, two similar topics and questions absent from the notes. Save this reference set before trying a vector database.

  4. 4. Add semantic retrieval locally

    Choose a local embedding model and record its version/dimensions. Embed chunks and queries with the same model, store text and source metadata in local Chroma and inspect the top three results. Rebuild the collection if the embedding model changes.

  5. 5. Introduce a constrained answer step

    Optionally send only the retrieved passages and question to a local model. Require citations to provided chunk IDs and an insufficient-evidence answer when support is absent. Validate citation IDs in code; prompting alone cannot ensure factual support.

  6. 6. Compare against the baseline

    Count how often a correct supporting chunk appears in the top three for your labeled questions. Review generated claims against cited passages separately. Keep the simpler lexical route if semantic search does not improve your actual question set.

Expected output and validation

A source-preserving retrieval demonstration, with optional generated answers added by you. A recorded evaluation explains where lexical and semantic methods succeed or fail.

  • Unsupported questions produce no invented source.
  • Citation IDs resolve to the original passages after a restart.
  • Retrieval quality and answer faithfulness are assessed separately.

Official references

Free to read. Software setup, model access and hosted services have their own requirements. References checked 3 November 2026.

AI Campus Weekly Dispatch

Keep learning with AI Campus

Get AI news, tools, skills and opportunities in the weekly dispatch.

Weekly curated AI intelligence for students. Unsubscribe anytime in 1 click.

Essential cookies keep the site working. Language and subscription preferences stay on your device. We do not currently use optional analytics or advertising cookies.

Details and settings