Every code-search leaderboard I’ve seen puts dense encoders comfortably ahead of BM25, and yet the coding agents we actually run lean on grep and do fine. Embeddings vs. Grep takes that contradiction seriously and finds the leaderboard was partly measuring itself.

The authors build Repo-Premium — real repositories, curated and raw queries across six languages, PRs from 2022 to 2026, a preregistered pool over 91 repos — and trace the dense advantage to two unglamorous sources. Part of it is evaluation choices that quietly favor dense retrieval: chunking files for BM25, counting edited tests as relevant. The rest is queries that simply don’t contain the rare identifiers the code uses. Expand the query with LLM-written identifiers (generate-then-grep) and BM25 catches up to dense retrieval in every Python pool — even on PRs opened after the model’s training cutoff, so it isn’t memorization.

The finding I’d pin to the wall: no method they tried could predict which retriever wins on a given query. That kills the clean story where you pick an embedding model and declare retrieval solved. It argues instead for what production RAG already does under duress — fuse lexical and dense, and fix the query before you blame the retriever. The real discipline here isn’t “embeddings are overrated”; it’s measuring dense gains against a lexical baseline that wasn’t deliberately crippled, which is exactly the eval mistake that’s easy to ship without noticing.

The HF paper page has the full breakdown. If query expansion closes most of the gap, how much of your retrieval budget is paying for embeddings versus paying for a benchmark that never gave BM25 a fair fight?

tags: [ rag ] [ llm-ops ] [ research ]