Large Language Models (LLMs) have demonstrated remarkable success in various natural language processing and software engineering tasks, such as code generation. The LLMs are mainly utilized in the prompt-based zero/few-shot paradigm to guide the model in accomplishing the task. GPT-based models are one of the popular ones studied for tasks such as code comment generation or test generation. These tasks are `generative' tasks. However, there is limited research on the usage of LLMs for `non-generative' tasks such as classification using the prompt-based paradigm. In this preliminary exploratory study, we investigated the applicability of LLMs for Code Clone Detection (CCD), a non-generative task. By building a mono-lingual and cross-lingual CCD dataset derived from CodeNet, we first investigated two different prompts using ChatGPT to detect Type-4 code clones in Java-Java and Java-Ruby pairs in a zero-shot setting. We then conducted an analysis to understand the strengths and weaknesses of ChatGPT in CCD. ChatGPT surpasses the baselines in cross-language CCD attaining an F1-score of 0.877 and achieves comparable performance to fully fine-tuned models for mono-lingual CCD, with an F1-score of 0.878. Also, the prompt and the difficulty level of the problems has an impact on the performance of ChatGPT. Finally we provide insights and future directions based on our initial analysis
翻译:大型语言模型(LLM)在各类自然语言处理和软件工程任务(如代码生成)中展现出显著成效。LLM主要采用基于提示的零样本/少样本范式来引导模型完成任务,其中基于GPT的模型是代码注释生成、测试生成等任务的热门研究对象。这些任务属于"生成式"任务,然而,目前关于LLM在"非生成式"任务(如基于提示范式的分类任务)中的应用研究仍十分有限。在本项初步探索性研究中,我们考察了LLM在非生成式任务——代码克隆检测(CCD)中的适用性。通过构建源自CodeNet的单语和跨语CCD数据集,我们首先使用两种不同提示词,在零样本场景下探究ChatGPT对Java-Java和Java-Ruby代码对中第四类克隆的检测能力。随后通过分析揭示ChatGPT在CCD中的优势与不足:ChatGPT在跨语言CCD中以0.877的F1值超越基线模型,在单语CCD中以0.878的F1值达到与完全微调模型相当的性能。此外,提示词设计及问题难度等级均对ChatGPT的表现产生影响。最后,我们基于初步分析提出了相关见解与未来研究方向。