paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Detecting Semantic Clones of Unseen Functionality

检测未见功能的语义克隆
ASE 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE)2025匹配度 4/10 · 论文位于机器学习与程序语言交叉点,且属于问题驱动、揭示模型在未见功能上失效的研究,评估了任务模型与 LLM;但其核心是语义代码克隆检测,并非用户关注的静态分析/形式化验证、Agentic 程序、浮点程序分析或贝叶斯程序分析,且改进目标偏向提升 LLM/模型能力本身。引用 2 inbox
Konstantinos Kitsios, Francesco Sovrano, Earl T. Barr, Alberto Bacchelli
crossref: 2026-09-12

AI 速览

一句话:揭示神经语义克隆检测在未见功能上性能骤降,并提出对比学习提升任务模型与 LLM 的泛化能力。

语义代码克隆检测旨在判断两段代码是否实现相同功能。现有神经模型在训练分布内近乎完美,但面对训练中未出现的新功能会如何?作者通过文献综述确认三类实际任务要求检测未见过功能的克隆,并重新评估六种 SOTA 模型(任务专用模型与生成式 LLM)。实验显示任务专用模型 F1 最多下降 48%(平均 31%),LLM 无需显式训练即可持平且泛化更好,F1 最多下降 5%(平均 3%)。为此,作者为任务模型引入对比分类器,并为 LLM 提出对比式上下文学习。改进后未见功能上的 F1 最多提升 26%(平均 9%)与 5%(平均 3%)。

问题
现有语义代码克隆检测神经模型依赖训练数据,可能无法检测训练中未出现的新功能克隆;论文研究此类 unseen functionality 上的检测性能与改进方法。
方法
重新评估六种任务专用模型与生成式 LLM,并为任务模型替换最终分类器为对比分类器,为 LLM 提出对比式上下文学习,以增强对克隆/非克隆差异的敏感度。
评估
在未见功能克隆任务上比较 F1 变化;任务模型 F1 最多降 48%、平均 31%,LLM 最多降 5%、平均 3%,所提方法将任务模型 F1 最多提升 26%、平均 9%,LLM 最多提升 5%、平均 3%。
原文摘要(Abstract)

Semantic code clone detection is the task of detecting whether two snippets of code implement the same functionality (e.g., Sort Array). Recently, many neural models achieved near-perfect performance on this task. These models seek to make inferences based on their training data. Consequently, they better detect clones similar to those they have seen during training and may struggle to detect those they have not. Developers seeking clones are, of course, interested in both types of clones. We confirm this claim through a literature review, identifying three practical clone detection tasks in which the model’s goal is to detect clones of a functionality even if it was trained on clones of different functionalities. In light of this finding, we re-evaluate six state-of-the-art models, including both task-specific models and generative LLMs, on the task of detecting clones of unseen functionality. Our experiments reveal a drop in F1 of up to 48% (average 31%) for task-specific models. LLMs perform on par with task-specific models without explicit training for clone detection, but generalize better to unseen functionalities, where F1 drops up to 5% (average 3%) instead.We propose and evaluate the use of contrastive learning to improve the performance of existing models on clones of unseen functionality. We draw inspiration from the computer vision and natural language processing fields where contrastive learning excels at measuring similarity between two objects, even if they come from classes unseen during training. We replace the final classifier of the task-specific models with a contrastive classifier, while for the generative LLMs we propose contrastive in-context learning, guiding the LLMs to focus on the differences between clones and non-clones. The F1 on clones of unseen functionality is improved by up to 26% (average 9%) for task-specific models and up to 5% (average 3%) for LLMs.Data and material: https://doi.org/10.5281/zenodo.17238379

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot9412,
  title = {Detecting Semantic Clones of Unseen Functionality},
  author = {Konstantinos Kitsios and Francesco Sovrano and Earl T. Barr and Alberto Bacchelli},
  booktitle = {ASE},
  year = {2025},
  doi = {10.1109/ase63991.2025.00112}
}