Code Clone Detection via an AlphaFold-Inspired Framework

📅 2025-07-20
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
Existing code clone detection methods struggle to simultaneously achieve strong semantic modeling capability and cross-language generalizability. To address this, we propose the first language-agnostic semantic clone detection framework inspired by AlphaFold’s protein structure prediction paradigm—specifically, its integration of multiple sequence alignment (MSA) and attention mechanisms. Our approach constructs tokenized sequences, performs cross-language MSA alignment, employs a modified attention-based encoder to capture deep semantic representations, and incorporates interactive similarity computation for binary classification. Evaluated on three multilingual benchmark datasets, our method significantly outperforms all baselines, achieving both higher accuracy (+4.2% F1 score) and practical efficiency (3.1× faster inference). This work establishes a scalable, semantics-driven paradigm for cross-language software maintenance and vulnerability discovery.

Technology Category

Application Category

📝 Abstract
Code clone detection, which aims to identify functionally equivalent code fragments, plays a critical role in software maintenance and vulnerability analysis. Substantial methods have been proposed to detect code clones, but they fall short in capturing code semantics or relying on language-specific analyzers. Inspired by the remarkable success of AlphaFold in predicting three-dimensional protein structures from protein sequences, in this paper, we leverage AlphaFold for code clone detection based on the insight that protein sequences and token sequences share a common linear sequential structure. In particular, we propose AlphaCC, which represents code fragments as token sequences to ensure multi-language applicability and adapts AlphaFold's sequence-to-structure modeling capability to infer code semantics. The pipeline of AlphaCC goes through three steps. First, AlphaCC transforms each input code fragment into a token sequence and, motivated by AlphaFold's use of multiple sequence alignment (MSA) to enhance contextual understanding, constructs an MSA from lexically similar token sequences. Second, AlphaCC adopts a modified attention-based encoder based on AlphaFold to model dependencies within and across token sequences. Finally, unlike AlphaFold's protein structure prediction task, AlphaCC computes similarity scores between token sequences through a late interaction strategy and performs binary classification to determine code clone pairs. Comprehensive evaluations on three language-diverse datasets demonstrate AlphaCC's applicability across multiple programming languages. On two semantic clone detection datasets, it consistently outperforms all baselines, showing strong semantic understanding. Moreover, AlphaCC maintains competitive efficiency, enabling practical usage in large-scale clone detection tasks.
Problem

Research questions and friction points this paper is trying to address.

Detects code clones across multiple programming languages
Improves semantic understanding of code fragments
Enhances efficiency for large-scale clone detection
Innovation

Methods, ideas, or system contributions that make the work stand out.

Adapts AlphaFold for multi-language code clone detection
Uses token sequences and MSA for semantic understanding
Late interaction strategy for similarity scoring
🔎 Similar Papers
No similar papers found.
Changguo Jia
Changguo Jia
Peking University
Software EngineeringArtificial Intelligence
Y
Yi Zhan
School of Computer Science, Peking University, Key Laboratory of High Confidence Software Technologies, Ministry of Education, Beijing, China
Tianqi Zhao
Tianqi Zhao
Zhongguancun Laboratory
formal methodssymbolic computation
H
Hengzhi Ye
School of Computer Science, Peking University, Key Laboratory of High Confidence Software Technologies, Ministry of Education, Beijing, China
M
Minghui Zhou
School of Computer Science, Peking University, Key Laboratory of High Confidence Software Technologies, Ministry of Education, Beijing, China