Generative AI · Intermediate level

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

Reranking and When to Use a Vector Database

Learners rerank retrieved candidates with a small cross-encoder or LLM relevance check, and decide when a vector database is necessary at all.

In this lesson you will

  • Rerank candidates to improve precision
  • Judge when a vector database is worth it

Key concepts

rerankingcross-encodercandidate poolprecision at ksimplicity

The lesson

Retrieve a larger candidate pool (for example 20 chunks), then rerank them with a slower but more accurate model, such as a small cross-encoder from Sentence Transformers or an LLM relevance check, and keep the top three.

Reranking costs time; measure the precision gain against the delay.

For a few hundred chunks, an in-memory array with NumPy is enough; a vector database earns its place with larger collections, persistence, filtering and updates.

Step by step

  1. Retrieve 20 candidates per question.
  2. Rerank with a small cross-encoder.
  3. Compare precision@3 and latency.
  4. Write a recommendation on reranking and storage.

Practice activity

Evaluate reranking and storage options for the project.

Expected result: Measured precision and latency with a justified recommendation.

Check your understanding

  1. What does reranking do?

    Show answer

    Reorders a larger candidate set with a more accurate model to improve the top results.

  2. When is a vector database not needed?

    Show answer

    For small collections that fit easily in memory.

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.