ExecRetrieval: コード埋め込み検索における機能的正しさのギャップの測定
ExecRetrieval: Measuring the Functional-Correctness Gap in Code-Embedding Retrieval
September 1, 2026
著者: Aaryan Kapoor, Md Abdullah Al Hafiz Khan
cs.AI
要旨
埋め込みベースのコード検索は、コーディングエージェントや検索拡張型コード生成の中核的要素であり、そこでは語彙的に類似したコードを取得することよりも、正しいコードを取得することのほうが重要となる。既存のコード検索ベンチマークは、各クエリのカノニカル実装を対象とした、制御された実行検証済みの単一編集バリアントを検索プール内に配置しておらず、そのため、埋め込み表現が正しいコードと、ニアクローンだが誤ったコードとを機能的に判別できるかという問いは、検索の枠組みでは未解決のまま残されている。この問いに答えるには、検索プール自体に、対象となる反事実例、すなわち各カノニカル実装とほぼ同一の実行検証済みバグ付きバリアントが含まれるベンチマークが必要であり、それによって検索器のランク順序を、トピックやコード同一性の重なりではなく、機能的な判別の観点から直接検証できる。本稿では、ExecRetrievalを導入する。ExecRetrievalは939件のPythonタスクからなり、各タスクには実行検証済みのカノニカル実装1件と、実行検証済みのバグ付きディストラクタ最大4件が対応付けられている。各ディストラクタは、特定の1箇所を変更する機械的変異によって生成される。評価では、23種類のdense埋め込み構成とBM25を、各プロバイダーのネイティブAPI呼び出しで用い、対応のあるMcNemar検定とクエリ単位のブートストラップ信頼区間を適用した。プール内にニアクローン反事実例が存在する場合、最上位のホスト型システムはexec@10 = 1.00を達成する一方で、exec@1は0.331にとどまる。上位4システムでは、カノニカル実装がランク1にならなかった場合に、そのランク1に入るコードが、ペアとなっているバグ付きディストラクタである割合は91.5〜99.4%に達する。また、上位システムでは、クエリの67〜78%において、カノニカル実装のスコアが、対応する4つのディストラクタのうち少なくとも1つのスコアを下回る。完全なデータセット、実行オラクル、埋め込み行列、環境スナップショット、およびペアごとの統計検定は、付録DのURLで公開されている。
English
Embedding-based code retrieval is a core component of coding agents and retrieval-augmented code generation, where retrieving correct code matters more than retrieving lexically similar code. Existing code-retrieval benchmarks do not plant controlled, execution-verified single-edit variants of each query's canonical implementation in the search pool, leaving the question of whether embeddings can functionally discriminate correct from near-clone-but-incorrect code unanswered in a retrieval setting. Resolving this requires a benchmark whose search pool itself contains the relevant counterfactuals -- execution-verified buggy variants near-identical to each canonical -- so that a retriever's rank ordering can be directly tested for functional discrimination rather than topical or identity overlap. We introduce ExecRetrieval, 939 Python tasks each paired with one execution-verified canonical implementation and up to four execution-verified buggy distractors, each generated by a mechanical mutation making a single targeted edit, and evaluate 23 dense embedding configurations plus BM25 under provider-native invocation with paired McNemar tests and query-level bootstrap intervals. With near-clone counterfactuals in the pool, the top hosted system reaches exec@10 = 1.00 but only exec@1 = 0.331; rank-1 misses are paired buggy variants 91.5-99.4% of the time across the four leading systems, and the canonical scores below at least one of its four paired distractors in 67-78% of queries on the leading systems. The full dataset, execution oracle, embedding matrices, environment snapshot, and pairwise statistical tests are released at the URL in Appendix D.