A Unified Model for Cross-Domain Clone Detection via Model Merging
Role: Led the study; designed and ran all experiments; drafted the paper.
Palash Ranjan Roy (published as Palash Roy / Palash R. Roy) · ORCID 0000-0001-9470-4233
Abstract
The growing diversity of code clone types, from syntactic copies to cross-language semantic clones to AI-generated duplicates, has created a fragmentation crisis in clone detection. Current deep learning detectors are domain specialists that degrade significantly outside their training distribution. In our evaluation, F1 drops exceed 70% across domains. Deploying multiple specialized models is impractical, yet training a single cross-domain detector requires simultaneous access to all training data. To address this, we investigate model merging, a family of post-hoc techniques that operate solely on trained checkpoints. We systematically evaluate parameter merging with five task-vector methods (Task Arithmetic, TIES, DARE-TIES, WUDI, PCB), architecture merging via greedy layer stitching, and cross-tokenizer alignment. Our study spans four pre-trained code models, three benchmarks, and twelve merging configurations. Same-base TIES merging creates effective cross-domain detectors, validated across two model families and three random seeds. It reaches 0.865 combined F1 on UniXcoder, 93% of multi-task training performance without any training data at the merging step. WUDI achieves the highest in-distribution combined F1 at 0.899, but TIES generalizes better to unseen AI-generated clones. We therefore recommend TIES for the practical recipe. Cross-base merging yields only marginal and high-variance gains across all five methods. This indicates that task vector compatibility through a shared pre-trained base is the binding factor for effective merging in our setting. Merged encoder-based detectors also outperform zero-shot instruction-tuned code LLMs on GPTCloneBench (0.609 vs. 0.454 F1 for the strongest LLM baseline) at substantially lower per-pair inference cost. They also generalize up to 4× better than multi-task training to unseen AI-generated clones, suggesting a trade-off between in-domain performance and OOD robustness. This work provides one of the first systematic empirical studies of model merging for software engineering and a practical recipe for building cross-domain code clone detectors.
Problem addressed
Deep-learning clone detectors trained on one clone domain degrade sharply outside their training distribution, and training a single cross-domain detector requires simultaneous access to all training data.
Relevant to
- cross-domain code clone detection
- cross-language clone detection
- model merging
- task arithmetic and TIES merging
- out-of-distribution generalization of code models
- detection of AI-generated code clones
- pre-trained code models (UniXcoder, CodeBERT family)
- multi-task learning vs. post-hoc merging
- LLM baselines for clone detection
Cite
@inproceedings{Roy2026Unified,
author = {Roy, Palash R. and Roy, Banani and Schneider, Kevin A. and Roy, Chanchal K.},
title = {A Unified Model for Cross-Domain Clone Detection via Model Merging},
booktitle = {Proceedings of the 41st IEEE/ACM International Conference on Automated Software Engineering},
series = {ASE '26},
year = {2026},
month = oct,
location = {Munich, Germany},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
numpages = {13},
doi = {10.1145/3832783.3837415},
url = {https://doi.org/10.1145/3832783.3837415}
}