Cross Domain Few-Shot Line-Level Defect Prediction in Open Software Development via Meta Learning

Zhengdao Li, Shikai Guo, Lehuan Zhang, Hui Li, Zhiguo Yang, Ning Qiao, Qian Ma · IEEE Transactions on Consumer Electronics · 2025

Defect prediction tools are designed to assist practitioners in effectively prioritizing the risk files that are most likely to manifest software defects after release, with limited software quality assurance resources. It plays a vital role in code inspection activities. Currently, numerous automated defect prediction methods have been proposed to enhance the efficiency of code review and software quality. However, most previous methods often rely on a substantial number of labeled samples for training. Additionally, when confronted with tasks involving a broad domain span, these methods frequently struggle to effectively identify defective files and lines. To address this issue, we propose a model named DEF-Hunter for rapidly adapting to new file-level and line-level defect predictions when encountering new technical domains. DEF-Hunter consists of two components: defect identification component and transfer learning component. The defect identification component employs a hierarchical attention network to learn the hierarchical structure of the source code, capturing the surrounding code tokens and neighboring lines. It utilizes attention mechanisms to calculate risk scores for code tokens contributing to the prediction of defective files. The transfer learning component employs meta-learning to enhance the model’s cross-domain generalization ability, achieving few-shot line-level defect prediction. The experimental results demonstrate that DEF-Hunter outperforms the state-of-the-art methods in both performance, cost-effectiveness and across metrics such as Balance Accuracy, AUC, MCC, and Recall@Top20%LOC, e.g., compared to state-of-the-art methods, DEF-Hunter improves the Balance Accuracy score by 29%, 29%, 17.49%, 7.32%, and 2.38%, respectively.

Read the paper · More papers on PaperTik