HalluJudge: A Reference-Free Hallucination Detection for Context Misalignment in Code Review Automation
作者: Kla Tantithamthavorn, Hong Yi Lin, Patanamon Thongtanunam, Wachiraphan Charoenwet, Minwoo Jeong, Ming Wu
分类: cs.SE, cs.AI
发布日期: 2026-06-12
💡 一句话要点
提出HalluJudge以解决代码审查自动化中的幻觉检测问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 代码审查 幻觉检测 大型语言模型 上下文对齐 自动化工具 多分支推理 软件工程
📋 核心要点
- 现有的代码审查自动化方法在生成审查评论时容易出现幻觉,导致评论与实际代码不一致,影响开发者的信任。
- HalluJudge通过上下文对齐评估生成的审查评论,采用直接评估和结构化多分支推理等四种策略,提供了一种无参考的幻觉检测方法。
- 实验结果显示,HalluJudge在企业级项目中的F1得分达到0.85,且67%的评估结果与开发者偏好一致,展现出良好的成本效益。
📝 摘要(中文)
大型语言模型(LLMs)在代码审查自动化中展现出强大的能力,例如生成审查评论,但它们存在幻觉问题,即生成的审查评论与实际代码无关,这对LLMs在代码审查工作流中的应用构成了重大挑战。为此,我们探索了一种有效且可扩展的方法,设计了HalluJudge,旨在基于上下文对生成的审查评论进行评估。HalluJudge包括四个关键策略,从直接评估到结构化的多分支推理(如思维树)。我们在Atlassian的企业级软件项目中进行了全面评估,结果表明HalluJudge的幻觉评估具有成本效益,F1得分为0.85,平均成本为0.009美元。HalluJudge的评估与开发者对实际LLM生成的审查评论的偏好有67%的对齐率,表明HalluJudge可以作为减少开发者接触幻觉评论的有效保障,增强对AI辅助代码审查的信任。
🔬 方法详解
问题定义:本文旨在解决大型语言模型生成的代码审查评论中存在的幻觉问题,即评论内容与实际代码不一致,导致开发者对AI生成内容的信任度降低。现有方法往往依赖于参考数据,难以在无参考情况下进行有效评估。
核心思路:HalluJudge的核心思路是通过上下文对齐来评估生成评论的有效性,采用多种评估策略以提高检测的准确性和可扩展性。通过这种设计,HalluJudge能够在没有参考的情况下有效识别幻觉评论。
技术框架:HalluJudge的整体架构包括四个主要模块:直接评估、结构化多分支推理、上下文对齐分析和结果整合。每个模块负责不同的评估任务,最终汇总评估结果以判断评论的有效性。
关键创新:HalluJudge的主要创新在于其无参考的幻觉检测能力,结合了多种评估策略,尤其是结构化多分支推理(如思维树),与传统依赖参考的方法相比,提供了更灵活和高效的解决方案。
关键设计:在设计中,HalluJudge采用了特定的参数设置和损失函数,以优化评估过程的准确性。此外,网络结构经过精心设计,以支持多分支推理的复杂性,确保评估结果的可靠性。
🖼️ 关键图片
📊 实验亮点
HalluJudge在实验中取得了显著的成果,F1得分达到0.85,表明其在幻觉检测方面的高效性。同时,评估的平均成本仅为0.009美元,显示出其在实际应用中的成本效益。此外,67%的评估结果与开发者的偏好一致,进一步验证了HalluJudge的实用性。
🎯 应用场景
HalluJudge的研究成果在软件开发和代码审查领域具有广泛的应用潜力。它可以作为AI辅助工具,帮助开发者在代码审查过程中识别和过滤幻觉评论,从而提高审查的质量和效率。未来,该技术还可以扩展到其他领域,如自动化文档生成和内容审核等,进一步提升AI系统的可信度。
📄 摘要(原文)
Large Language models (LLMs) have shown strong capabilities in code review automation, such as review comment generation, yet they suffer from hallucinations -- where the generated review comments are ungrounded in the actual code -- poses a significant challenge to the adoption of LLMs in code review workflows. To address this, we explore effective and scalable methods for a hallucination detection in LLM-generated code review comments without the reference. In this work, we design HalluJudge that aims to assess the grounding of generated review comments based on the context alignment. HalluJudge includes four key strategies ranging from direct assessment to structured multi-branch reasoning (e.g., Tree-of-Thoughts). We conduct a comprehensive evaluation of these assessment strategies across Atlassian's enterprise-scale software projects to examine the effectiveness and cost-efficiency of HalluJudge. Furthermore, we analyze the alignment between HalluJudge's judgment and developer preference of the actual LLM-generated code review comments in the real-world production. Our results show that the hallucination assessment in HalluJudge is cost-effective with an F1 score of 0.85 and an average cost of $0.009. On average, 67% of the HalluJudge assessments are aligned with the developer preference of the actual LLM-generated review comments in the online production. Our results suggest that HalluJudge can serve as a practical safeguard to reduce developers' exposure to hallucinated comments, fostering trust in AI-assisted code reviews.