Tighter Clusters, Safer Code? Improving Vulnerability Detection with Enhanced Contrastive Loss

dc.contributor.authorKapparad, P.
dc.contributor.authorMohan, B.R.
dc.date.accessioned2026-02-06T06:35:16Z
dc.date.issued2023
dc.description.abstractDistinguishing vulnerable code from non-vulnerable code is challenging due to high inter-class similarity. Supervised contrastive learning (SCL) improves embedding separation but struggles with intra-class clustering, especially when variations within the same class are subtle. We propose CLUSTER-ENHANCED SUPERVISED CONTRASTIVE LOSS (CESCL), an extension of SCL with a distance-based regularization term that tightens intra-class clustering while maintaining inter-class separation. Evaluating on CodeBERT and GraphCodeBERT with Binary Cross Entropy (BCE), BCE + SCL, and BCE + CESCL, our method improves F1 score by 1.76% on CodeBERT and 4.1% on GraphCodeBERT, demonstrating its effectiveness in code vulnerability detection and broader applicability to high-similarity classification tasks. © 2025 Association for Computational Linguistics.
dc.identifier.citationProceedings of the 2025 Annual Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics: Human Language Technologies: Long Papers, NAACL-HLT 2025, 2023, Vol.4, , p. 247-252
dc.identifier.urihttps://doi.org/10.18653/v1/2025.naacl-srw.24
dc.identifier.urihttps://idr.nitk.ac.in/handle/123456789/29732
dc.publisherAssociation for Computational Linguistics (ACL)
dc.titleTighter Clusters, Safer Code? Improving Vulnerability Detection with Enhanced Contrastive Loss

Files