arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2507.16754cs.SEcs.AI
收藏

从不空手而归:用于改进 LLM 开发者支持的自适应 HyDE 检索

Never Come Up Empty: Adaptive HyDE Retrieval for Improving LLM Developer Support

Queen's University(皇后大学);Royal Military College of Canada(加拿大皇家军事学院)

Fangjian Lei, Mariam El Mezouar, Shayan Noei, Ying Zou

AI总结:

本文构建了超300万条Stack Overflow帖子的检索语料库,系统评估了63种RAG流水线变体,提出结合HyDE与完整答案上下文的自适应检索方法,并在4个开源LLM上验证其一致优于零样本基线。

摘要:

大型语言模型(LLMs)在协助开发者回答代码相关问题方面已展现出潜力;然而,LLMs 存在生成不可靠答案的风险。为解决这一问题,检索增强生成(RAG)被提出以降低 LLMs 的不可靠性(即幻觉)。然而,由于存在大量设计选择,构建有效的流水线仍然具有挑战性。在本文中,我们构建了一个包含超过 300 万个 Java 和 Python 相关 Stack Overflow 帖子(均带有已采纳答案)的检索语料库,并探索了多种 RAG 流水线设计来回答开发者问题,评估它们在生成准确且可靠响应方面的有效性。更具体地说,我们(1)设计并评估了 7 种不同的 RAG 流水线和 63 种流水线变体,以回答历史上具有相似匹配的问题;(2)通过在检索过程中自动降低相似度阈值来处理没有任何相近历史匹配的新问题,从而增加找到部分相关上下文的机会,并提高对未见案例的覆盖率。我们发现,将假设文档嵌入(HyDE)与完整答案上下文相结合的 RAG 流水线在检索和回答 Stack Overflow 问题的相似内容方面表现最佳。最后,我们将最优 RAG 流水线应用于 4 个开源 LLMs,并将其结果与它们的零样本性能进行比较。我们的研究结果表明,采用最优 RAG 流水线的 RAG 在不同模型上一致优于零样本基线,在以 LLM 作为评判者时,在有用性、正确性和详细程度方面均获得更高分数。这些发现表明,我们的最优 RAG 流水线能够稳健地提升各类开发者查询的答案质量,包括跨不同 LLMs 的已见问题和全新问题。

英文摘要:

Large Language Models (LLMs) have shown promise in assisting developers with code-related questions; however, LLMs carry the risk of generating unreliable answers. To address this, Retrieval-Augmented Generation (RAG) has been proposed to reduce the unreliability (i.e., hallucinations) of LLMs. However, designing effective pipelines remains challenging due to numerous design choices. In this paper, we construct a retrieval corpus of over 3 million Java and Python related Stack Overflow posts with accepted answers, and explore various RAG pipeline designs to answer developer questions, evaluating their effectiveness in generating accurate and reliable responses. More specifically, we (1) design and evaluate 7 different RAG pipelines and 63 pipeline variants to answer questions that have historically similar matches, and (2) address new questions without any close prior matches by automatically lowering the similarity threshold during retrieval, thereby increasing the chance of finding partially relevant context and improving coverage for unseen cases. We find that implementing a RAG pipeline combining hypothetical-documentation-embedding (HyDE) with the full-answer context performs best in retrieving and answering similarcontent for Stack Overflow questions. Finally, we apply our optimal RAG pipeline to 4 open-source LLMs and compare the results to their zero-shot performance. Our findings show that RAG with our optimal RAG pipeline consistently outperforms zero-shot baselines across models, achieving higher scores for helpfulness, correctness, and detail with LLM-as-a-judge. These findings demonstrate that our optimal RAG pipelines robustly enhance answer quality for a wide range of developer queries including both previously seen and novel questions across different LLMs

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

↑