Practice track
RAG building blocks
Dense and sparse retrieval scores that a RAG system ranks with. 3 problems, about 52 minutes. Do them in order: each problem uses ideas from the problems before it.
- 01Cosine similarity top-k search
Normalize embedding rows, score queries against documents with cosine similarity, and return the top k documents with a fixed tie rule.
ImplementEasy15 min - 02Reciprocal rank fusion
Merge several ranked lists of document ids into one ranking with reciprocal rank fusion, optional list weights and a fixed tie rule.
ImplementEasy12 min - 03BM25 ranking
Score tokenized documents against a query with BM25: the lesson idf, term frequency saturation with k1, length normalization with b, and a ranked list.
ImplementMedium25 min