Retrieval-Augmented Generation from Scratch
LESSON 1.3

Similarity metrics and thresholds

Learn key techniques and workflows in Retrieval-Augmented Generation from Scratch.

7m
advanced
8,187 students

Overview

Cosine similarity is the usual default, but the number it gives you is only meaningful relative to your own corpus. Calibrate the threshold, do not guess it.

In this lesson you will:

  • Compare cosine, dot product, and euclidean distance
  • Calibrate a relevance threshold on real queries
  • Detect the case where nothing is actually relevant

Pro Tip

A similarity score has no absolute meaning. Calibrate the cutoff against queries you know the answers to.

Resources