Papers
Topics
Authors
Recent
Search
2000 character limit reached

The Fools are Certain; the Wise are Doubtful: Exploring LLM Confidence in Code Completion

Published 22 Aug 2025 in cs.SE and cs.AI | (2508.16131v1)

Abstract: Code completion entails the task of providing missing tokens given a surrounding context. It can boost developer productivity while providing a powerful code discovery tool. Following the LLM wave, code completion has been approached with diverse 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 can serve 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 1008 files from 657 GitHub projects. We find that strongly-typed languages exhibit lower perplexity than dynamically typed languages. Scripting languages also demonstrate higher perplexity. Perl appears universally high in perplexity, whereas Java appears low. Code perplexity depends on the employed LLM, but not on the code dataset. Although code comments often increase perplexity, the language ranking based on perplexity is barely affected by their presence. LLM researchers, developers, and users can employ our findings to assess the benefits and suitability of LLM-based code completion in specific software projects based on how language, model choice, and code characteristics impact model confidence.

Summary

  • The paper demonstrates that code perplexity can effectively serve as an intrinsic confidence indicator for LLM-based code completion.
  • It shows that programming language properties, such as strong typing and clear syntax, significantly affect LLM predictive confidence.
  • The analysis emphasizes the importance of model selection, revealing that perplexity patterns vary by LLM architecture independent of datasets.

Analysis of "The Fools are Certain; the Wise are Doubtful: Exploring LLM Confidence in Code Completion"

Introduction

The study titled "The Fools are Certain; the Wise are Doubtful: Exploring LLM Confidence in Code Completion" (2508.16131) explores the utilization of LLMs for code completion tasks. Code completion is an essential feature in modern integrated development environments (IDEs), enabling developers to gain productivity by suggesting complete code blocks based on a given context. The paper investigates how various intrinsic metrics, specifically code perplexity, can serve as indicators of model confidence, potentially offering insights beyond traditional downstream metrics.

Code Perplexity as a Confidence Indicator

Perplexity measures the uncertainty of a model in predicting the next token in a sequence. The authors argue that intrinsic metrics like perplexity are more versatile and universal compared to complex, domain-specific downstream metrics. The study examines code perplexity across multiple programming languages, models, and datasets using a variety of LLMs, resulting in several key observations:

  1. Variation Across Languages: The study finds significant differences in perplexity across programming languages. Strongly-typed languages such as Java and C# exhibit lower perplexity, indicating greater model confidence, while scripting languages like Perl demonstrate higher perplexity. This suggests that LLMs have greater predictive accuracy in environments where typing constraints are more stringent.
  2. Effect of Language Properties: The authors examine how intrinsic language properties and code structure features, like language age and code comments, affect perplexity. They find that newer languages with clearer syntax and stronger typing systems generally result in lower perplexity. Comments tend to increase perplexity, possibly due to the unpredictability of human language compared to code syntax.
  3. Model Dependency: Code perplexity varies significantly across different LLMs. Models from the same family tend to produce similar perplexity patterns, implying that architectural features of LLMs heavily influence their prediction confidence.
  4. Dataset Independence: The analysis suggests that code perplexity is more dependent on the chosen LLM than on the specific datasets used for evaluation. This highlights the potential for perplexity to serve as a reliable, model-centric metric.

Implications for Software Development

The findings of this research have several practical implications for software engineering and the development of LLM-based tools:

  • Language-Specific Impact: Developers and teams should consider the characteristics of their project's programming language when adopting LLM-based code completion tools. Strongly-typed and newer languages seem to benefit more from LLM assistance due to higher prediction confidence.
  • Model Selection and Evaluation: Given the variability of perplexity across different LLMs, careful selection and evaluation of models are crucial. Organizations might prioritize investing in specific LLMs that demonstrate lower perplexity for their chosen language stack, thereby improving the quality of code suggestions.
  • Use in Code Review: Perplexity can serve as an early indicator of code correctness and hallucination risk. Development teams can incorporate perplexity measurements into code reviews, assigning greater scrutiny to high perplexity suggestions to reduce the likelihood of errors being introduced into the codebase.

Conclusion

In conclusion, the paper explores the utility of code perplexity as a versatile and insightful indicator of LLM confidence in code completion tasks. The findings indicate that intrinsic language properties and model architecture play a significant role in determining code perplexity. By focusing on perplexity, developers and researchers can better assess the effectiveness and reliability of LLMs in software projects, paving the way for more informed decisions in the integration of AI models into development workflows. Future research might expand on these findings by exploring additional factors that influence perplexity and further validating the practical utility of this metric across broader contexts and LLM architectures.

Paper to Video (Beta)

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.

HackerNews