Search papers, labs, and topics across Lattice.
This paper introduces SPECTRA-Siam, a Siamese latent graph learning network designed to enhance code clone detection (CCD) by learning a discriminative spectral representation of code functionality across different programming languages. By optimizing the latent graph's spectrum derived from abstract syntax trees and data dependencies, the method significantly improves performance metrics, achieving an F1 score increase from 0.37 to 0.67 on BigCloneBench and an accuracy boost from 0.60 to 0.71 on AtCoder. The model demonstrates remarkable generalizability, with minimal performance degradation in cross-language scenarios, outperforming traditional fixed graph methods.
Switching from rigid graph representations to learned latent graph spectra can double F1 scores in code clone detection.
Current code clone detection (CCD) methods rely on fixed, language-specific graph representations like abstract syntax trees (ASTs) or program dependency graphs (PDGs). Because functionally identical code fragments can yield wildly different structures, these rigid graphs produce non-discriminative spectra that perform close to chance. To address this, we propose SPECTRA-Siam, a Siamese latent graph learning network that learns a latent space such that the graph's spectrum serves as a discriminative signature of code functionality by optimizing downstream CCD performance. Given a fragment's AST and data-dependencies, SPECTRA-Siam induces a fixed-size weighted latent graph through soft slot assignment and multi-head attention, and extracts a multi-scale spectral representation from its normalized Laplacian. Mapping all fragments into this shared space yields comparable spectra across programming languages. Experiments on BigCloneBench, AtCoder, and a four-language CodeNet benchmark (Java, Python, C++, C#) support this design choice. Using the same downstream classifier, moving from fixed to learned latent graphs spectra jumps F1 from 0.37 to 0.67 on BigCloneBench and accuracy from 0.60 to 0.71 on AtCoder. On CodeNet, the full model reaches 0.69 accuracy in four epochs and 0.79 after thirty epochs. In bridge-assisted language transfer across 60 unseen paths, SPECTRA-Siam's performance degrades by only 0.058, versus 0.112--0.228 for baselines, showing that learned graph spectra provide a highly generalizable representation for cross-language clone detection.