Advanced code time complexity prediction approach using contrastive learning

被引:0
|
作者
Park, Shinwoo [1 ]
Hahn, Joonghyuk [1 ]
Orwig, Elizabeth [1 ]
Ko, Sang-Ki [2 ]
Han, Yo-Sub [1 ]
机构
[1] Yonsei Univ, Sch Comp, 50 Yonsei Ro, Seoul 03722, South Korea
[2] Univ Seoul, Dept Artificial Intelligence, 11-1 Seoulsiripdae Ro, Seoul 02592, South Korea
基金
新加坡国家研究基金会;
关键词
Code time complexity prediction; Contrastive learning; Multi-class classification; Representation learning; Deep learning;
D O I
10.1016/j.engappai.2025.110631
中图分类号
TP [自动化技术、计算机技术];
学科分类号
0812 ;
摘要
It is a crucial task to predict the algorithmic time complexity for estimating the efficiency of a software code. Since the problem is known to be undecidable in theory, there is no 100% accurate tools to solve the problem. Even humans often make mistakes when analyzing the time complexity of code, and this process requires considerable effort and time to thoroughly examine the code. Therefore, we aim to develop an automated method for analyzing code time complexity. We observe that solution codes submitted for coding problems in competitive programming contests tend to have similar time complexities due to constraints such as time limits and functional requirements of the problems. Based on this observation, we propose a contrastive learning-based training strategy that aligns solution codes for the same competitive programming problem. Our training strategy clusters codes with similar time complexities by using both natural language problem descriptions and a single reference code per problem as anchors. This design enables the model to capture core algorithmic features such as loops and recursion more accurately. Experiments in three scenarios-in-dataset, cross-dataset, and cross-language-demonstrate substantial gains on pre-trained code models, consistently surpassing existing methods in both accuracy and generalizability. Our proposed training strategy yields an average 12.54% improvement over cross-entropy-based training, and an 8.01% improvement over data augmentation-based contrastive learning.
引用
收藏
页数:12
相关论文
共 50 条
  • [1] Contrastive Code Representation Learning
    Jain, Paras
    Jain, Ajay
    Zhang, Tianjun
    Abbeel, Pieter
    Gonzalez, Joseph E.
    Stoica, Ion
    2021 CONFERENCE ON EMPIRICAL METHODS IN NATURAL LANGUAGE PROCESSING (EMNLP 2021), 2021, : 5954 - 5971
  • [2] Enzyme function prediction using contrastive learning
    Yu, Tianhao
    Cui, Haiyang
    Li, Jianan Canal
    Luo, Yunan
    Jiang, Guangde
    Zhao, Huimin
    SCIENCE, 2023, 379 (6639) : 1358 - +
  • [3] Time-Aware Smart City Services Based on QoS Prediction: A Contrastive Learning Approach
    Yin, Yuyu
    Di, Qianhui
    Wan, Jian
    Liang, Tingting
    IEEE INTERNET OF THINGS JOURNAL, 2023, 10 (21) : 18745 - 18753
  • [4] Bug prediction modeling using complexity of code changes
    Singh, V. B.
    Chaturvedi, K. K.
    Khatri, Sunil Kumar
    Kumar, Vijay
    INTERNATIONAL JOURNAL OF SYSTEM ASSURANCE ENGINEERING AND MANAGEMENT, 2015, 6 (01) : 44 - 60
  • [5] An integrated feature learning approach using deep learning for travel time prediction
    Abdollahi, Mohammad
    Khaleghi, Tannaz
    Yang, Kai
    EXPERT SYSTEMS WITH APPLICATIONS, 2020, 139
  • [6] Crystal synthesizability prediction using contrastive positive unlabeled learning
    Sun, Tao
    Yuan, Jianmei
    COMPUTER PHYSICS COMMUNICATIONS, 2025, 308
  • [7] Code Clone Detection Based on Contrastive Learning
    Xie, Chunli
    Liang, Yao
    Lv, Quanrun
    Wan, Zexuan
    2024 IEEE 4TH INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING AND ARTIFICIAL INTELLIGENCE, SEAI 2024, 2024, : 151 - 156
  • [8] SCodeSearcher: soft contrastive learning for code search
    Li, Jia
    Fang, Zheng
    Shi, Xianjie
    Jin, Zhi
    Liu, Fang
    Li, Jia
    Zhao, Yunfei
    Li, Ge
    EMPIRICAL SOFTWARE ENGINEERING, 2025, 30 (03)
  • [9] CoCoSoDa: Effective Contrastive Learning for Code Search
    Shi, Ensheng
    Wang, Yanlin
    Gu, Wenchao
    Du, Lun
    Zhang, Hongyu
    Han, Shi
    Zhang, Dongmei
    Sun, Hongbin
    2023 IEEE/ACM 45TH INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING, ICSE, 2023, : 2198 - 2210
  • [10] DP-CCL: A Supervised Contrastive Learning Approach Using CodeBERT Model in Software Defect Prediction
    Sahar, Sadia
    Younas, Muhammad
    Khan, Muhammad Murad
    Sarwar, Muhammad Umer
    IEEE ACCESS, 2024, 12 : 22582 - 22594