paperbot · PL 论文追踪

全部论文 待读 收藏

P2 When to Say What: Learning to Find Condition-Message Inconsistencies

何时说什么:学习发现条件-消息不一致
ICSE 2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE)2023匹配度 3/10 · 该论文利用神经网络检测代码条件与自然语言消息的不一致,属于机器学习在软件工程/缺陷检测中的应用,与用户关注的静态分析、Agentic程序、LLM/Agent改进静态分析、浮点程序分析及贝叶斯程序分析等核心方向均不直接相关。引用 10 inbox
Islem Bouzenia, Michael Pradel
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出 CMI-Finder,用神经网络判断代码条件与自然语言消息是否一致,从而自动发现缺陷。

程序常在日志或异常中输出自然语言消息,消息必须在语义上与触发它的条件保持一致,但条件以程序逻辑表达、消息以非正式自然语言表达,二者的一致性检查十分困难。本文提出 CMI-Finder:以条件与消息为输入,用神经模型预测二者是否一致。为获得真实、多样且大规模的监督数据,作者设计了六种自动生成大量不一致样本的技术,并实现与比较了三种神经模型,分别基于二分类、triplet loss 和微调。评估从 4200 万行 Python 代码中抽取 30 万条条件-消息语句,在历史 bug 修复数据集上最佳模型达到 78% 精确率与 72% 召回率;将该方法应用于流行开源项目的最新版本,发现 50 个此前未知的 bug,其中 19 个已被开发者确认。

问题
代码中的自然语言消息与其触发条件分属程序逻辑与自然语言两种表达形式,二者是否语义一致难以自动检查,不一致往往意味着真实的程序缺陷。
方法
CMI-Finder 使用神经模型接收条件与消息并预测其一致性,通过六种自动生成不一致样本的技术构造大规模训练数据,并比较了二分类、triplet loss 与微调三种建模方案。
评估
在从 4200 万行 Python 代码中提取的 30 万条条件-消息语句上训练与评估,最佳模型在历史 bug 修复数据集上取得 78% 精确率、72% 召回率,并在最新版开源项目中报告 50 个未知 bug,其中 19 个获开发者确认。
原文摘要(Abstract)

Programs often emit natural language messages, e.g., in logging statements or exceptions raised on unexpected paths. To be meaningful to users and developers, the message, i.e., what to say, must be consistent with the condition under which it gets triggered, i.e., when to say it. However, checking for inconsistencies between conditions and messages is challenging because the conditions are expressed in the logic of the programming language, while messages are informally expressed in natural language. This paper presents CMI-Finder, an approach for detecting condition-message inconsistencies. CMI-Finder is based on a neural model that takes a condition and a message as its input and then predicts whether the two are consistent. To address the problem of obtaining realistic, diverse, and large-scale training data, we present six techniques to generate large numbers of inconsistent examples to learn from automatically. Moreover, we describe and compare three neural models, which are based on binary classification, triplet loss, and fine-tuning, respectively. Our evaluation applies the approach to 300K condition-message statements extracted from 42 million lines of Python code. The best model achieves a precision of 78% at a recall of 72% on a dataset of past bug fixes. Applying the approach to the newest versions of popular open-source projects reveals 50 previously unknown bugs, 19 of which have been confirmed by the developers so far.

链接与引用

DOI 原文 · DBLP

BibTeX
@inproceedings{BouzeniaP23,
  title = {When to Say What: Learning to Find Condition-Message Inconsistencies},
  author = {Islem Bouzenia and Michael Pradel},
  booktitle = {ICSE},
  year = {2023},
  doi = {10.1109/icse48619.2023.00081}
}