arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2204.10049cs.LGcs.PLcs.SE
收藏

基于学习的缺陷检测器中的分布偏移

On Distribution Shift in Learning-based Bug Detectors

ETH Zurich(苏黎世联邦理工学院)

Jingxuan He, Luca Beurer-Kellner, Martin Vechev

摘要:

深度学习最近在程序分析任务中取得了初步成功,例如bug检测。由于缺乏真正的错误,大多数现有的作品通过将合成错误注入正确的程序来构建训练和测试数据。尽管实现了高测试准确度(例如,90%),结果发现错误检测器在实践中令人惊讶地不可用,即,用于扫描真实软件存储库时精度<10%。在这项工作中,我们认为,这种巨大的性能差异是由分布偏移,即,真实的缺陷分布和用于训练和评估检测器的合成缺陷分布之间的根本不匹配。为了解决这个关键的挑战,我们建议训练一个错误检测器在两个阶段,首先在一个合成的错误分布,以适应该模型的错误检测域,然后在一个真正的错误分布,以驱动该模型向真正的分布。在这两个阶段,我们利用多任务层次、焦点丢失和对比学习来进一步提高性能。我们评估我们的方法广泛的三个广泛研究的错误类型,我们精心设计,以捕捉真正的错误分布构建新的数据集。结果表明,我们的方法实际上是有效的,并成功地减轻了分布偏移:我们学习的检测器在我们的测试集和最新版本的开源存储库上都具有很高的性能。我们的代码、数据集和模型可在https://github.com/eth-sri/learning-real-bug-detector上公开获取。

英文摘要:

Deep learning has recently achieved initial success in program analysis tasks such as bug detection. Lacking real bugs, most existing works construct training and test data by injecting synthetic bugs into correct programs. Despite achieving high test accuracy (e.g., 90%), the resulting bug detectors are found to be surprisingly unusable in practice, i.e., <10% precision when used to scan real software repositories. In this work, we argue that this massive performance difference is caused by a distribution shift, i.e., a fundamental mismatch between the real bug distribution and the synthetic bug distribution used to train and evaluate the detectors. To address this key challenge, we propose to train a bug detector in two phases, first on a synthetic bug distribution to adapt the model to the bug detection domain, and then on a real bug distribution to drive the model towards the real distribution. During these two phases, we leverage a multi-task hierarchy, focal loss, and contrastive learning to further boost performance. We evaluate our approach extensively on three widely studied bug types, for which we construct new datasets carefully designed to capture the real bug distribution. The results demonstrate that our approach is practically effective and successfully mitigates the distribution shift: our learned detectors are highly performant on both our test set and the latest version of open source repositories. Our code, datasets, and models are publicly available at https://github.com/eth-sri/learning-real-bug-detector.

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

↑