The Struggles of LLMs in Cross-Lingual Code Clone Detection
Open Access
- 19 June 2025
- journal article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Software Engineering
- Vol. 2 (FSE) , 1023-1045
Abstract
With the involvement of multiple programming languages in modern software development, cross-lingual code clone detection has gained traction within the software engineering community. Numerous studies have explored this topic, proposing various promising approaches. Inspired by the significant advances in machine learning in recent years, particularly Large Language Models (LLMs), which have demonstrated their ability to tackle various tasks, this paper revisits cross-lingual code clone detection. We evaluate the performance of five (05) LLMs and, eight prompts (08) for the identification of cross-lingual code clones. Additionally, we compare these results against two baseline methods. Finally, we evaluate a pre-trained embedding model to assess the effectiveness of the generated representations for classifying clone and non-clone pairs. The studies involving LLMs and Embedding models are evaluated using two widely used cross-lingual datasets, XLCoST and CodeNet. Our results show that LLMs can achieve high F1 scores, up to 0.99, for straightforward programming examples. However, they not only perform less well on programs associated with complex programming challenges but also do not necessarily understand the meaning of “code clones” in a cross-lingual setting. We show that embedding models used to represent code fragments from different programming languages in the same representation space enable the training of a basic classifier that outperforms all LLMs by ∼1 and ∼20 percentage points on the XLCoST and CodeNet datasets, respectively. This finding suggests that, despite the apparent capabilities of LLMs, embeddings provided by embedding models offer suitable representations to achieve state-of-the-art performance in cross-lingual code clone detection.Keywords
All Related Versions
This publication has 26 references indexed in Scilit:
- Should We Respect LLMs? A Cross-Lingual Study on the Influence of Prompt Politeness on LLM Performance2024
- OneSpace: Detecting cross-language clones by learning a common embedding spaceJournal of Systems and Software, 2023
- TCCCD: Triplet-Based Cross-Language Code Clone DetectionApplied Sciences, 2023
- Prompt Engineering For ChatGPT: A Quick Guide To Techniques, Tips, And Best PracticesTechRxiv, 2023
- UniXcoder: Unified Cross-Modal Pre-training for Code Representation2022
- What You See is What it Means! Semantic Representation Learning of Code based on Visualization and Transfer LearningACM Transactions on Software Engineering and Methodology, 2021
- CLCMiner: Detecting Cross-Language Clones without IntermediatesIEICE Transactions on Information and Systems, 2017
- Comparison and evaluation of code clone detection techniques and tools: A qualitative approachScience of Computer Programming, 2009
- CCFinder: a multilinguistic token-based code clone detection system for large scale source codeIEEE Transactions on Software Engineering, 2002
- Support-Vector NetworksMachine Learning, 1995