use case · multi-model
The standard production retrieval shape, running entirely on-device. Stage one: EmbeddingGemma embeds every passage and the query and pulls a shortlist by cosine — fast, because each passage was embedded once. Stage two: a BGE cross-encoder reranker reads the query and each shortlisted passage together and re-scores for precision. Watch the order change between the two stages.
The reranker (~of order 300 MB) loads on demand when you first run the pipeline.
Why two stages? The bi-encoder is cheap and scales to millions of passages (each embedded once, offline), but it scores query and passage independently. The cross-encoder is far more precise because it reads them together — but it's too slow to run over a whole corpus, so you only run it on the shortlist. EmbeddingGemma's small vectors make stage one especially cheap on-device.