The Fools are Certain; the Wise are Doubtful: Exploring LLM Confidence in Code Completion
Not on the map. Why?
Abstract (arXiv)
Code completion entails the task of providing missing tokens given a surrounding context. It can boost developer productivity and serve as a code discovery tool. Code completion has recently been approached with Large Language Models (LLMs) fine-tuned on code (code LLMs). The performance of code LLMs can be assessed with downstream and intrinsic metrics. Downstream metrics are usually employed to evaluate the practical utility of a model, but can be unreliable and require complex calculations and domain-specific knowledge. In contrast, intrinsic metrics such as perplexity, entropy, and mutual information, which measure model confidence or uncertainty, are simple, versatile, and universal across LLMs and tasks, and have been proposed as proxies for functional correctness and hallucination risk in LLM-generated code. Motivated by this, we evaluate the confidence of LLMs when generating code by measuring code perplexity across programming languages, models, and datasets using various LLMs, and a sample of 2254 files from 881 GitHub projects. We find that strongly-typed languages exhibit lower perplexity than dynamically typed languages. Scripting languages also demonstrate higher perplexity. Shell appears universally high in perplexity, whereas Java appears low. Code perplexity depends on the employed LLM; under a fixed model, relative language-level rankings are largely stable across evaluation corpora. Although code comments modestly increase perplexity, the language ranking based on perplexity is barely affected by their presence. LLM researchers, developers, and users can use our findings to assess the suitability of LLM-based code completion in specific software projects based on how language, model choice, and code characteristics impact model confidence.
Key facts. Cited by 3 papers in the map (data through 14 Oct 2026). Builds on 41 of its 80 references that are in the map. First posted on arXiv 22 Aug 2025.
Builds on
41 of 80 references.
References · 41
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
- 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,372
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 13,028
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
- 2023A Survey on Evaluation of Large Language Modelscited by 1,242
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 885
- 2023StarCoder: may the source be with you!cited by 799
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 744
- 2022GPT-NeoX-20B: An Open-Source Autoregressive Language Modelcited by 713
29 more
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 502
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 498
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 399
- 2022A Systematic Evaluation of Large Language Models of Codecited by 363
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 361
- 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 300
- 2023Using an LLM to Help With Code Understandingcited by 228
- 2017A Survey of Machine Learning for Big Code and Naturalnesscited by 221
- 2022Grounded Copilot: How Programmers Interact with Code-Generating Modelscited by 218
- 2023SantaCoder: don't reach for the stars!cited by 170
- 2022Large Language Models Meet NL2Code: A Surveycited by 138
- 2023Generative AIcited by 120
- 2022ReCode: Robustness Evaluation of Code Generation Modelscited by 103
- 2020Code Prediction by Feeding Trees to Transformerscited by 70
- 2023A Survey of Large Language Models for Code: Evolution, Benchmarking, and Future Trendscited by 66
- 2020Big Code != Big Vocabulary: Open-Vocabulary Models for Source Codecited by 54
- 2024Calibration and Correctness of Language Models for Codecited by 49
- 2024Language Models for Code Completion: A Practical Evaluationcited by 39
- 2023ToolCoder: Teach Code Generation Models to use API search toolscited by 37
- 2015On the "Naturalness" of Buggy Codecited by 35
- 2023Unveiling Memorization in Code Modelscited by 30
- 2024CodeMirage: Hallucinations in Code Generated by Large Language Modelscited by 23
- 2021Sampling Projects in GitHub for MSR Studiescited by 21
- 2023A Static Evaluation of Code Completion by Large Language Modelscited by 14
- 2025Assessing Correctness in LLM-Based Code Generation via Uncertainty Estimationcited by 14
- 2025The Effects of GitHub Copilot on Computing Students' Programming Effectiveness, Efficiency, and Processes in Brownfield Programming Taskscited by 9
- 2025Experience with GitHub Copilot for Developer Productivity at Zoominfocited by 8
- 2020A Dataset for GitHub Repository Deduplication: Extended Descriptioncited by 6
- 2024CodeShell Technical Reportcited by 6
Built on by
Citing papers per year: 2025: 2; 2026: 1.
3 papers.