arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.18561cs.IRcs.AIcs.SE
收藏

在固定通用分词下改进BM25代码检索:适应性q-对数比作为BM25的即插即用修复

Improving BM25 Code Retrieval Under Fixed Generic Tokenization: Adaptive q-Log Odds as a Drop-In BM25 Fix

AgentField

Santosh Kumar Radha, Oktay Goktas

AI总结:

该研究针对固定通用分词下BM25代码检索的不足,提出适应性q-对数比作为BM25的改进方法,通过替换RSJ对数比的外层对数为q对数,在保持BM25精度的同时提升检索性能,实验显示在CodeSearchNet Go数据集上NDCG@10显著提升。

摘要:

在检索增强的编程中,失败通常发生在相关文件不在检索上下文中的时候。在冻结通用分词的情况下,当BM25索引由不可控的搜索系统构建时,这种失败是常态:BM25的对数RSJ-比IDF无法区分不同函数的标识符尾部。我们用q对数替代RSJ比的外层对数。在q=1时,该变换通过洛必达法则恢复BM25的精确性,对于q<1的情况,它是对RSJ比的Box-Cox变换,其中lambda=1-q。在CoIR CodeSearchNet Go(182K文档)上,经过oracle调优的NDCG@10从0.2575提升到0.4874(绝对+0.2299;+89.3%相对;在10,000对的bootstrap重采样中,零符号反转,报告为p <= 10^-4)。该效果在不同编程语言中呈梯度变化,在BEIR文本上接近于零。一个一参数闭合形式估计一个语料库级别的q值,从hapax密度推导出来,并在BM25已经最优的语料库上保持接近q=1。索引时间成本是稀疏得分矩阵的一次遍历,查询延迟不变。一个分词消融实验显示,标识符意识的分词在很大程度上消除了q-IDF的增量增益。

英文摘要:

In retrieval-augmented coding, failures often begin when the relevant file is absent from the retrieved context. Under frozen generic tokenization, where a BM25 index has been built by a search system whose analyzer the practitioner does not control, this failure is routine: BM25's logarithmic RSJ-odds IDF under-separates the identifier tail that distinguishes one function from another. We replace the outer logarithm of the Robertson-Spärck-Jones odds with a q-logarithm. At q=1 the transform recovers BM25 exactly by L'Hôpital's rule, and for q<1 it is a Box-Cox transform of the RSJ odds with lambda = 1-q. On CoIR CodeSearchNet Go (182K documents), oracle-tuned NDCG@10 rises from 0.2575 to 0.4874 (absolute +0.2299; +89.3% relative; zero sign reversals in 10,000 paired-bootstrap resamples, reported as p <= 10^-4). The effect is graded across code languages and is near-zero on BEIR text. A one-parameter closed form estimates a corpus-level q from hapax density and stays near q=1 on corpora where BM25 is already optimal. The index-time cost is a single pass over the sparse score matrix and query latency is unchanged. A tokenizer ablation shows that identifier-aware tokenization largely removes the incremental gain from q-IDF.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑