How Does Naming Affect Language Models on Code Analysis Tasks?
- 1 College of Information Science and Technology, The Pennsylvania State University, State College, USA
- 2 School of Informatics, Computing, and Cyber Systems, Northern Arizona University, Flagstaff, USA
- 3 College of Information Science and Technology, The Pennsylvania State University, State College, USA
- 4 College of Information Science and Technology, The Pennsylvania State University, State College, USA
- 5 Heinz College, Carnegie Mellon University, Pittsburgh, USA
- 6 College of Information Science and Technology, The Pennsylvania State University, State College, USA
Abstract
The Large Language Models (LLMs), such as GPT and BERT, were proposed for natural language processing (NLP) and have shown promising results as general-purpose language models. An increasing number of industry professionals and researchers are adopting LLMs for program analysis tasks. However, one significant difference between programming languages and natural languages is that a programmer has the flexibility to assign any names to variables, methods, and functions in the program, whereas a natural language writer does not. Intuitively, the quality of naming in a program affects the performance of LLMs in program analysis tasks. This paper investigates how naming affects LLMs on code analysis tasks. Specifically, we create a set of datasets with code containing nonsense or misleading names for variables, methods, and functions, respectively. We then use well-trained models (CodeBERT) to perform code analysis tasks on these datasets. The experimental results show that naming has a significant impact on the performance of code analysis tasks based on LLMs, indicating that code representation learning based on LLMs heavily relies on well-defined names in code. Additionally, we conduct a case study on some special code analysis tasks using GPT, providing further insights.
- Sarzynska-Wawer, J., Wawer, A., Pawlak, A., Szymanowska, J., Stefaniak, I., Jarkiewicz, M., et al . (2021) Detecting Formal Thought Disorder by Deep Contextualized Word Representations. Psychiatry Research , 304, Article ID: 114135. https://doi.org/10.1016/j.psychres.2021.114135
- Radford, A., Narasimhan, K., Salimans, T. and Sutskever, I. (2018) Improving Language Understanding by Generative Pre-Training.
- Devlin, J., Chang, M.-W., Lee, K. and Toutanova, K. (2018) Bert: Pre-Training of Deep Bidirectional Transformers for Language Understanding.
- Feng, Z., Guo, D., Tang, D., Duan, N., Feng, X., Gong, M., et al . (2020) Codebert: A Pre-Trained Model for Programming and Natural Languages. Findings of the Association for Computational Linguistics : EMNLP 2020, November 2020, 1536-1547. https://doi.org/10.18653/v1/2020.findings-emnlp.139
- Guo, D.Y., Ren, S., Lu, S., Feng, Z.Y., Tang, D.Y., Liu, S.J., Zhou, L. and Duan, N., et al . (2020) Graphcodebert: Pre-Training Code Representations with Data Flow.
- Guo, Q., Cao, J., Xie, X., Liu, S., Li, X., Chen, B., et al . (2024) Exploring the Potential of ChatGPT in Automated Code Refinement: An Empirical Study. Proceedings of the IEEE / ACM 46 th International Conference on Software Engineering , Lisbon, 14-20 April 2024, 1-13. https://doi.org/10.1145/3597503.3623306
- Chen, C., Su, J.Z., Chen, J.C., Wang, Y.L., Bi, T.T., Wang, Y.L., et al . (2023) When ChatGPT Meets Smart Contract Vulnerability Detection: How Far Are We?
- (2023) Github Copilot.
- Katz, D.S., Ruchti, J. and Schulte, E. (2018) Using Recurrent Neural Networks for Decompilation. 2018 IEEE 25 th International Conference on Software Analysis , Evolution and Reengineering ( SANER ), Campobasso, 20-23 March 2018, 346-356. https://doi.org/10.1109/saner.2018.8330222
- Butler, S., Wermelinger, M. and Yu, Y. (2015) Investigating Naming Convention Adherence in Java References. 2015 IEEE International Conference on Software Maintenance and Evolution ( ICSME ), Bremen, 29 September-1 October 2015, 41-50. https://doi.org/10.1109/icsm.2015.7332450
- OpenAI (2023) Introducing ChatGPT.
- Feng, Z.Y., Guo, D.Y., Tang, D.Y., Duan, N., Feng, X.C., Gong, M., et al . (2021) Code Pretraining Models.
- Husain, H., Wu, H.-H., Gazit, T., Allamanis, M. and Brockschmidt, M. (2019) CodeSearchNet Challenge: Evaluating the State of Semantic Code Search.