Table of Contents
Fetching ...

Improving Source Code Similarity Detection Through GraphCodeBERT and Integration of Additional Features

Jorge Martinez-Gil

TL;DR

This work tackles code clone detection by augmenting GraphCodeBERT with an execution-derived behavioral signature computed from output agreement on a fixed test suite, integrated through a trainable projection and concatenation at the output head. The key formalism is $f_{out}(c_i,c_j) = \frac{1}{|T|} \sum_{t \in T} \mathbb{I}(out(c_i,t) = out(c_j,t))$, which provides explicit semantic evidence to guide predictions. Empirically, the approach yields consistent gains in precision, recall, and F-measure over GraphCodeBERT on the IR-Plag dataset, particularly for semantically equivalent but syntactically diverse clones, with only modest overhead. The framework is designed to be dataset-agnostic and extensible to other knowledge sources, though it acknowledges limitations related to test coverage and execution costs, and suggests future work on larger corpora and static behavior proxies.

Abstract

This paper investigates source code similarity detection using a transformer model augmented with an execution-derived signal. We extend GraphCodeBERT with an explicit, low-dimensional behavioral feature that captures observable agreement between code fragments, and fuse this signal with the pooled transformer representation through a trainable output head. We compute behavioral agreement via output comparisons under a fixed test suite and use this observed output agreement as an operational approximation of semantic similarity between code pairs. The resulting feature acts as an explicit behavioral signature that complements token- and graph-based representations. Experiments on established clone detection benchmarks show consistent improvements in precision, recall, and F$_1$ over the unmodified GraphCodeBERT baseline, with the largest gains on semantically equivalent but syntactically dissimilar pairs. The source code that illustrates our approach can be downloaded from https://www.github.com/jorge-martinez-gil/graphcodebert-feature-integration.

Improving Source Code Similarity Detection Through GraphCodeBERT and Integration of Additional Features

TL;DR

This work tackles code clone detection by augmenting GraphCodeBERT with an execution-derived behavioral signature computed from output agreement on a fixed test suite, integrated through a trainable projection and concatenation at the output head. The key formalism is , which provides explicit semantic evidence to guide predictions. Empirically, the approach yields consistent gains in precision, recall, and F-measure over GraphCodeBERT on the IR-Plag dataset, particularly for semantically equivalent but syntactically diverse clones, with only modest overhead. The framework is designed to be dataset-agnostic and extensible to other knowledge sources, though it acknowledges limitations related to test coverage and execution costs, and suggests future work on larger corpora and static behavior proxies.

Abstract

This paper investigates source code similarity detection using a transformer model augmented with an execution-derived signal. We extend GraphCodeBERT with an explicit, low-dimensional behavioral feature that captures observable agreement between code fragments, and fuse this signal with the pooled transformer representation through a trainable output head. We compute behavioral agreement via output comparisons under a fixed test suite and use this observed output agreement as an operational approximation of semantic similarity between code pairs. The resulting feature acts as an explicit behavioral signature that complements token- and graph-based representations. Experiments on established clone detection benchmarks show consistent improvements in precision, recall, and F over the unmodified GraphCodeBERT baseline, with the largest gains on semantically equivalent but syntactically dissimilar pairs. The source code that illustrates our approach can be downloaded from https://www.github.com/jorge-martinez-gil/graphcodebert-feature-integration.
Paper Structure (31 sections, 5 equations, 1 figure, 2 tables)

This paper contains 31 sections, 5 equations, 1 figure, 2 tables.

Figures (1)

  • Figure 1: Architecture of the proposed feature-fused GraphCodeBERT model. The pooled transformer output $\mathbf{p}$ is concatenated with a projected external feature $\mathbf{f} = \mathbf{W}_1 f_{\mathrm{out}}$, representing execution- or output-based similarity. The fused vector is then passed to the classification head to yield the final clone probability $\hat{y} \in [0,1]$. The integration of $f_{\mathrm{out}}$ distinguishes this model from the standard GraphCodeBERT baseline.