Multi-model · E5 + cross-encoder · WASM
This is how real search works. Stage one: E5 embeds the query (query:) and every
passage (passage:) independently and ranks by cosine — fast, cheap, scales to millions.
Stage two: a MS MARCO cross-encoder reads
the query and each shortlisted passage together and re-scores them — slower, but far more
precise. Both models run locally. Watch the order change between the two stages.
A bi-encoder (E5) turns every document into a vector once, so retrieval is just nearest-neighbour math — it scales, but the query and document never "see" each other. A cross-encoder attends across the pair, catching relevance a cosine misses, but it must run the model for every candidate — too slow for a whole corpus. Retrieve wide and cheap, rerank narrow and sharp. E5's query/passage prefixes make it especially suited to the retrieval stage.