# A Unified Model for Cross-Domain Clone Detection via Model Merging

**Palash Ranjan Roy**, Banani Roy, Kevin A. Schneider, Chanchal K. Roy. *Proceedings of the 41st IEEE/ACM International Conference on Automated Software Engineering, pp. 13, 2026*. Venue ranking: CORE A*.

Role of Palash Ranjan Roy: Led the study; designed and ran all experiments; drafted the paper.

Areas: Software Maintenance & Evolution, Program Comprehension, Code Clones, AI for Software Engineering (AI4SE), Model Merging, Out-of-Distribution Generalization (OOD Generalization), Empirical Software Engineering (Empirical SE).

ML topics: Model Merging, Task Arithmetic (TIES, DARE), Out-of-Distribution Generalization, Multi-Task Learning, Code Language Models.

Page: https://palashroy.me/publications/cross-domain-clone-detection-model-merging/

- arXiv: https://arxiv.org/abs/2608.04215
- Slides: https://palashroy.me/slides/cross-domain-clone-detection-model-merging-slides.pdf
- DOI: https://doi.org/10.1145/3832783.3837415
- Replication package: https://doi.org/10.5281/zenodo.19187685

## 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 research on

- 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

## BibTeX

```bibtex
@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}
}
```
