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

评估编码任务中RAG里示例检索器的有效性与效率

Evaluating the Effectiveness and Efficiency of Demonstration Retrievers in RAG for Coding Tasks

Pengfei He, Shaowei Wang, Shaiful Chowdhury, Tse-Hsun Chen

AI总结:

该研究系统评估了6种检索器在3类编码任务RAG中的效率与有效性权衡,揭示了不同检索器的适用场景与示例数量的影响,为构建高效的编码任务RAG系统提供参考。

摘要:

检索增强生成(RAG)通过整合外部知识库来增强大语言模型(LLM),在各类编码任务中取得了当前最优结果。RAG的核心是检索示例样本,这对于平衡有效性(生成质量)与效率(检索时间)以实现最优性能至关重要。然而,代码表示的高维特性与庞大的知识库往往会造成效率瓶颈,这一点在以往研究中被忽视了。\n本文系统评估了检索器在三类编码任务中的效率-有效性权衡:程序合成、提交信息生成与断言生成。我们考察了六种检索器:两种稀疏检索器(BM25和BM25L),以及四种稠密检索器,包括一种穷举式稠密检索器(SBERT的语义搜索)和三种近似稠密检索器(ANNOY、LSH和HNSW)。\n研究结果表明,尽管BM25在有效性上表现优异,但当知识库规模超过1000条条目时,其效率会大幅下降。在大规模检索场景下,效率差异会更加显著,其中近似稠密检索器带来的效率提升最大。例如,在提交生成任务中,与BM25相比,HNSW实现了44倍的速度提升,而RougeL指标仅下降1.74%。\n研究结果还显示,增加提示中的示例数量并不总能提升有效性,反而可能增加延迟并导致错误输出。本研究的发现为致力于构建高效且高可用的编码任务RAG系统的从业者提供了宝贵参考。

英文摘要:

Retrieval-Augmented Generation (RAG) enhances Large Language Models (LLMs) by integrating external knowledge bases, achieving state-of-the-art results in various coding tasks. The core of RAG is retrieving demonstration examples, which is essential to balance effectiveness (generation quality) and efficiency (retrieval time) for optimal performance. However, the high-dimensional nature of code representations and large knowledge bases often create efficiency bottlenecks, which are overlooked in previous research. This paper systematically evaluates the efficiency-effectiveness trade-off of retrievers across three coding tasks: Program Synthesis, Commit Message Generation, and Assertion Generation. We examined six retrievers: two sparse (BM25 and BM25L) and four dense retrievers, including one exhaustive dense retriever (SBERT's Semantic Search) and three approximate dense retrievers (ANNOY, LSH, and HNSW). Our findings show that while BM25 excels in effectiveness, it suffers in efficiency as the knowledge base grows beyond 1000 entries. In large-scale retrieval, efficiency differences become more pronounced, with approximate dense retrievers offering the greatest gains. For instance, in Commit Generation task, HNSW achieves a 44x speed up, while only with a 1.74% drop in RougeL compared with BM25. Our results also show that increasing the number of demonstrations in the prompt doesn't always improve the effectiveness and can increase latency and lead to incorrect outputs. Our findings provide valuable insights for practitioners aiming to build efficient and effective RAG systems for coding tasks.

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

↑