Agentic AI · Intermediate level

Intermediate level · Module 8: Retrieval-Augmented Generation for Agents · Lesson 1 of 3

Preparing and Indexing Approved Documents

Learners convert approved documents to text, split them into passages with metadata and build an offline search index that works without internet.

In this lesson you will

  • Chunk documents with metadata
  • Build an offline search index

Key concepts

approved collectionchunk size and overlapmetadata (document ID, section, date, access level)TF-IDF/BM25 indexoptional embeddings

The lesson

Only documents approved by the organisation go into the collection. Split each into passages of a few paragraphs with overlap, and store metadata: document ID, title, section, date and access level.

A TF-IDF or BM25 keyword index (built with scikit-learn or a few lines of Python) runs offline on any laptop and works well for formal documents. Embedding search (for example with a small Sentence Transformers model) finds paraphrases better but needs a model download and more computation; use it where it clearly helps.

Keep the index reproducible: a script rebuilds it from the approved folder, and the version of the collection is recorded.

Step by step

  1. Prepare 15 fictional NGO or business documents as text.
  2. Chunk them with metadata.
  3. Build a TF-IDF index and test five queries.
  4. Optionally compare with an embedding index on the same queries.

Practice activity

Build the project's document index and record retrieval quality on ten queries.

Expected result: A reproducible offline index with measured retrieval quality.

Check your understanding

  1. What metadata should each chunk carry?

    Show answer

    For example document ID, title, section, date and access level.

  2. What is an advantage of keyword indexes for this programme?

    Show answer

    They run offline on any laptop with no model download.

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.