Skip to main navigation Skip to search Skip to main content

Two Sides of the Same Coin: Exploiting the Impact of Identifiers in Neural Code Comprehension

  • Shuzheng Gao
  • , Cuiyun Gao
  • , Chaozheng Wang*
  • , Jun Sun
  • , David Lo
  • , Yue Yu
  • *Corresponding author for this work
  • School of Computer Science and Technology, Harbin Institute of Technology
  • Singapore Management University
  • National University of Defense Technology

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

Abstract

Previous studies have demonstrated that neural code comprehension models are vulnerable to identifier naming. By renaming as few as one identifier in the source code, the models would output completely irrelevant results, indicating that identifiers can be misleading for model prediction. However, identifiers are not completely detrimental to code comprehension, since the semantics of identifier names can be related to the program semantics. Well exploiting the two opposite impacts of identifiers is essential for enhancing the robustness and accuracy of neural code comprehension, and still remains under-explored. In this work, we propose to model the impact of identifiers from a novel causal perspective, and propose a counterfactual reasoning-based framework named CREAM. CREAM explicitly captures the misleading information of identifiers through multi-task learning in the training stage, and reduces the misleading impact by counterfactual inference in the inference stage. We evaluate CREAM on three popular neural code comprehension tasks, including function naming, defect detection and code classification. Experiment results show that CREAM not only significantly outperforms baselines in terms of robustness (e.g., +37.9% on the function naming task at F1 score), but also achieve improved results on the original datasets (e.g., +0.5% on the function naming task at F1 score).

Original languageEnglish
Title of host publicationProceedings - 2023 IEEE/ACM 45th International Conference on Software Engineering, ICSE 2023
PublisherIEEE Computer Society
Pages1933-1945
Number of pages13
ISBN (Electronic)9781665457019
DOIs
StatePublished - 26 Jul 2023
Externally publishedYes
Event45th IEEE/ACM International Conference on Software Engineering, ICSE 2023 - Melbourne, Australia
Duration: 15 May 202316 May 2023

Publication series

NameProceedings - International Conference on Software Engineering
ISSN (Print)0270-5257

Conference

Conference45th IEEE/ACM International Conference on Software Engineering, ICSE 2023
Country/TerritoryAustralia
CityMelbourne
Period15/05/2316/05/23

Fingerprint

Dive into the research topics of 'Two Sides of the Same Coin: Exploiting the Impact of Identifiers in Neural Code Comprehension'. Together they form a unique fingerprint.

Cite this