Skip to content
Retrieval & context · 2 of 4 · about 25 minutes · With a year

Rank a retrieval baseline

Retrieval means finding the few documents that can answer a question, out of many. The simplest way is to count shared words: a document that contains more of the question's words is probably more relevant. This shared-word ranking misses synonyms, but it is cheap, easy to inspect, and gives you a score to beat. Build it first. Only then can you tell whether a search by meaning, with embeddings, does better.

About this lesson

Words to know

retrieval
Finding the few documents, out of many, that can help answer a question.
baseline
The simplest working version, measured first, so that every later change can be compared with it.
lexical search
Search that matches the words themselves, not their meaning. It finds car only where the text says car.
embedding
A vector that a trained model produces for a piece of text. Texts with similar meaning get vectors that point in similar directions.

Why it matters

This is the search step of a document assistant. The first portfolio project starts from this ranking, measures it, and only then tries embeddings against the same questions.

With a year

How it works, a worked example, the exercise with its tests, three hints and the explained solution are in the app, with a year of Algo150 for $19. The first chapter, Model foundations, is free for everyone: start with Vector dot product.

What a year includes