Empirical Evaluation of Prompting Strategies for Python Syntax Error Detection with LLMs
Source abstract
Abstract
As large language models (LLMs) are increasingly integrated into software development, there is a growing need to assess how effectively they address subtle programming errors in real-world environments. Accordingly, this study investigates the effectiveness of LLMs in identifying syntax errors within large Python code repositories. Building on the bug in the code stack (BICS) benchmark, this research expands the evaluation to include additional models, such as DeepSeek and Grok, while assessing their ability to detect errors across varying code lengths and depths. Two prompting strategies—two-shot and role-based prompting—were employed to compare the performance of models including DeepSeek-Chat, DeepSeek-Reasoner, DeepSeek-Coder, and Grok-2-Latest with GPT-4o serving as the baseline. The findings indicate that the DeepSeek models generally outperformed GPT-4o in terms of accuracy (Acc). Notably, DeepSeek-Reasoner exhibited the highest overall performance, achieving an Acc of 86.6% and surpassing all other models, particularly when integrated prompting strategies were used. Nevertheless, all models demonstrated decreased Acc with increasing input length and consistently struggled with certain types of errors, such as missing quotations (MQo). This work provides insight into the current strengths and weaknesses of LLMs within real-world debugging environments, thereby informing ongoing efforts to improve automated software tools.
Source: crossref · Quality: baseline
Research context
OpenAlex topics: Software Engineering Research · Natural Language Processing Techniques · Software Testing and Debugging Techniques
SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.
Affiliations
College of Computer Science and Engineering, Taibah University, Medina 41411, Saudi Arabia
References (33)
Show source-provided references
1. Syntax Error Detection and Correction in Python Code using ML
2. Alasmari, O.A., Singer, J., and Bikanga Ada, M. (2023, January 26–28). Do current online coding tutorial systems address novice programmer difficulties?. Proceedings of the 15th International Conference on Education Technology and Computers, Barcelona, Spain.10.1145/3629296.3629333 ↗
3. The effectiveness of supervised machine learning algorithms in predicting software refactoring10.1109/TSE.2020.3021736 ↗
4. Zhu, Q., Sun, Z., Xiao, Y.a., Zhang, W., Yuan, K., Xiong, Y., and Zhang, L. (2021, January 23–28). A syntax-guided edit decoder for neural program repair. Proceedings of the 29th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, Athens, Greece.10.1145/3468264.3468544 ↗
5. Wu, L., Li, F., Wu, Y., and Zheng, T. (2020, January 13–15). Ggf: A graph-based method for programming language syntax error correction. Proceedings of the 28th International Conference on Program Comprehension, Seoul, Republic of Korea.10.1145/3387904.3389252 ↗
6. Multilingual code refactoring detection based on deep learning10.1016/j.eswa.2024.125164 ↗
7. From Test Case Design to Test Data Generation: How AI is Redefining QA Processes
8. Code structure–guided transformer for source code summarization
9. Achiam, J., Adler, S., Agarwal, S., Ahmad, L., Akkaya, I., Aleman, F.L., Almeida, D., Altenschmidt, J., Altman, S., and Anadkat, S. (2023). Gpt-4 technical report. arXiv.
10. Liu, J., Chen, Y., Liu, M., Peng, X., and Lou, Y. (2024). Stall+: Boosting llm-based repository-level code completion with static analysis. arXiv.
11. Campos, V. (2024, January 24–26). Bug Detection and Localization using Pre-trained Code Language Models. Proceedings of the INFORMATIK 2024, Wiesbaden, Germany.
12. Li, Y., Parsert, J., and Polgreen, E. (2024, January 24–27). Guiding enumerative program synthesis with large language models. Proceedings of the International Conference on Computer Aided Verification, Montreal, QC, Canada.10.1007/978-3-031-65630-9_15 ↗
13. Kamradt, G. (2025, July 20). Needle In A Haystack—Pressure Testing LLMs. Available online: https://github.com/gkamradt/LLMTest_NeedleInAHaystack.
14. Lee, H., Sharma, S., and Hu, B. (2024). Bug in the code stack: Can llms find bugs in large python code stacks. arXiv.
15. Anthropic, A. (2025, July 01). Introducing the Next Generation of Claude. Available online: https://www.anthropic.com/news/claude-3-family.
16. Team, G., Georgiev, P., Lei, V.I., Burnell, R., Bai, L., Gulati, A., Tanzer, G., Vincent, D., Pan, Z., and Wang, S. (2024). Gemini 1.5: Unlocking multimodal understanding across millions of tokens of context. arXiv.
17. Liu, A., Feng, B., Xue, B., Wang, B., Wu, B., Lu, C., Zhao, C., Deng, C., Zhang, C., and Ruan, C. (2024). Deepseek-v3 technical report. arXiv.
18. xAI (2024). Grok-2 Beta Release, xAI.
19. Rahman, M.M., Watanobe, Y., and Nakamura, K. (2020). Source code assessment and classification based on estimated error probability using attentive LSTM language model and its application in programming education. Appl. Sci., 10.10.3390/app10082973 ↗
20. Kanoutas, T., Karanikiotis, T., and Symeonidis, A.L. (2024). Enhancing code readability through automated consistent formatting. Electronics, 13.10.3390/electronics13112073 ↗
21. Detecting and Explaining Python Name Errors10.1016/j.infsof.2024.107592 ↗
22. Yasunaga, M., and Liang, P. (2021, January 18–24). Break-it-fix-it: Unsupervised learning for program repair. Proceedings of the International Conference on Machine Learning, Virtual.
23. Synshine: Improved fixing of syntax errors10.1109/TSE.2022.3212635 ↗
24. Lutellier, T., Pham, H.V., Pang, L., Li, Y., Wei, M., and Tan, L. (2020, January 18–22). Coconut: Combining context-aware neural translation models using ensemble for program repair. Proceedings of the 29th ACM SIGSOFT International Symposium on Software Testing and Analysis, Virtual Event.10.1145/3395363.3397369 ↗
25. Dinella, E., Dai, H., Li, Z., Naik, M., Song, L., and Wang, K. (May, January 26). Hoppity: Learning graph transformations to detect and fix bugs in programs. Proceedings of the International Conference on Learning Representations (ICLR), Virtual.
26. Berabi, B., He, J., Raychev, V., and Vechev, M. (2021, January 18–24). Tfix: Learning to fix coding errors with a text-to-text transformer. Proceedings of the International Conference on Machine Learning, Virtual.
27. Phung, T., Cambronero, J., Gulwani, S., Kohn, T., Majumdar, R., Singla, A., and Soares, G. (2023). Generating high-precision feedback for programming syntax errors using large language models. arXiv.
28. Yang, Z., Wang, S., Yan, Y., and Deng, Y. (2025). Why Stop at One Error? Benchmarking LLMs as Data Science Code Debuggers for Multi-Hop and Multi-Bug Errors. arXiv.
29. Prenner, J.A., and Robbes, R. (2021). Automatic program repair with openai’s codex: Evaluating quixbugs. arXiv.
30. Bisht, T. (2025, July 20). python-code-instructions-18k-alpaca. Available online: https://huggingface.co/datasets/iamtarun/python_code_instructions_18k_alpaca.
31. Rajaraman, N., Jiao, J., and Ramchandran, K. (2024). Toward a theory of tokenization in llms. arXiv.
32. Language models are few-shot learners
33. Prompt engineering importance and applicability with generative AI10.4236/jcc.2024.1210002 ↗