Skip to lesson
Exit
AI-Editor Systems & Design1 / 2

1 min lesson

Three retrieval strategies and when to combine

Use two rows in "Three retrieval strategies and when to combine" to state the practical decision rules.

Step 1 of 2

Three retrieval strategies and when to combine

Candidates who only say "embeddings" undersell themselves. The honest answer is that each approach fails in a way the others cover, so production systems blend them and re-rank.

Approach
Lexical (grep/BM25)
Good at
Exact identifiers, error strings, rare tokens
Fails at
Synonyms and conceptual matches - "auth" vs "login"
Approach
Semantic (embeddings)
Good at
Conceptual similarity, "code that does X"
Fails at
Exact symbols; stale vectors after edits; index cost
Approach
Structural (graph/imports)
Good at
Precise types, callers, definitions
Fails at
Code that's relevant but not statically linked

Each column's weakness is another column's strength - hence hybrid retrieval plus a re-rank.

The combine move

Run lexical and semantic in parallel, union the candidates, then re-rank with cheap structural signals: is this symbol actually imported here, is it in an open tab, how recently was it edited. A small re-ranker over a fused candidate set beats any single retriever and it's the answer that reads as someone who has built one.