Get the daily emailDaily email
  1. Home
  2. Research
  3. This story

Embeddings vs grep: rethinking dense retrieval's edge in code search

The paper introduces Repo-Premium, a repository-level code-search benchmark over 91 real repos in six languages with raw and curated queries and pull requests from 2022 to 2026. It finds that dense retrieval's advantage over BM25 comes largely from evaluation…

Published Read the original

Ranked #15 of 25 on Saturday, November 21

Embeddings vs grep: rethinking dense retrieval's edge in code search

Why it matters

Teams building code RAG or coding agents may get comparable results from grep plus LLM query expansion, or should fuse both, before investing in embedding infrastructure.

What happened

1 min read

The paper introduces Repo-Premium, a repository-level code-search benchmark over 91 real repos in six languages with raw and curated queries and pull requests from 2022 to 2026. It finds that dense retrieval's advantage over BM25 comes largely from evaluation choices (chunking files for BM25, counting edited tests as relevant) and from queries lacking the code's rare identifiers. Expanding queries with LLM-written identifiers (generate-then-grep) lets BM25 match dense retrieval in every Python pool.

inscraper analysis

Our analysis

This helps explain why agents like Claude Code and Codex do well with grep while benchmarks favor embeddings. A preregistered test pool and pull requests opened after the LLM's release are methodological strengths. The finding that no method predicts which retriever wins on a given query makes the fusion recommendation sensible. It is not yet peer reviewed, and full parity is reported only for Python pools.

More in Research