Generative AI · Intermediate level

Intermediate level · Module 8: Vector Databases and Semantic Retrieval · Lesson 2 of 3

Metadata Filters and Hybrid Retrieval

Learners filter retrieval by metadata (document type, date, access level) and combine vector and keyword scores.

In this lesson you will

  • Apply metadata filters in queries
  • Implement hybrid retrieval

Key concepts

where filtersaccess-level filteringdate filtershybrid scoreweighting

The lesson

Chroma queries accept a where filter on metadata, such as {'access': 'public'} or a document type. Apply access filters in every query so restricted chunks are never returned to unauthorised users.

Hybrid retrieval combines vector similarity with keyword (TF-IDF or BM25) scores, which helps with names, codes and numbers. Normalise both scores before combining them with weights.

Tune weights on the retrieval test set rather than guessing.

Step by step

  1. Add access and document-type filters to queries.
  2. Compute keyword scores for the same candidates.
  3. Combine scores with weights.
  4. Tune weights on 20 test questions.

Practice activity

Add filtered hybrid retrieval to the project assistant.

Expected result: Correct access filtering and measured improvement from hybrid retrieval.

Check your understanding

  1. Why apply access filters in every query?

    Show answer

    So restricted chunks are never returned to unauthorised users.

  2. Why normalise scores before combining them?

    Show answer

    Vector and keyword scores are on different scales.

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.