[Paper Review] Generation Probabilities Are Not Enough: Uncertainty Highlighting in AI Code Completions
The paper compares two uncertainty highlighting approaches for AI-assisted code completion and shows that highlighting tokens likely to be edited (not their generation probability) speeds up work and yields more targeted edits, while generation-probability highlights offer no clear benefit.
Large-scale generative models enabled the development of AI-powered code completion tools to assist programmers in writing code. However, much like other AI-powered tools, AI-powered code completions are not always accurate, potentially introducing bugs or even security vulnerabilities into code if not properly detected and corrected by a human programmer. One technique that has been proposed and implemented to help programmers identify potential errors is to highlight uncertain tokens. However, there have been no empirical studies exploring the effectiveness of this technique -- nor investigating the different and not-yet-agreed-upon notions of uncertainty in the context of generative models. We explore the question of whether conveying information about uncertainty enables programmers to more quickly and accurately produce code when collaborating with an AI-powered code completion tool, and if so, what measure of uncertainty best fits programmers' needs. Through a mixed-methods study with 30 programmers, we compare three conditions: providing the AI system's code completion alone, highlighting tokens with the lowest likelihood of being generated by the underlying generative model, and highlighting tokens with the highest predicted likelihood of being edited by a programmer. We find that highlighting tokens with the highest predicted likelihood of being edited leads to faster task completion and more targeted edits, and is subjectively preferred by study participants. In contrast, highlighting tokens according to their probability of being generated does not provide any benefit over the baseline with no highlighting. We further explore the design space of how to convey uncertainty in AI-powered code completion tools, and find that programmers prefer highlights that are granular, informative, interpretable, and not overwhelming.
Motivation & Objective
- Understand how uncertainty highlighting affects programmer performance when using AI-powered code completions.
- Compare two uncertainty notions—generation probability vs. edit likelihood—across multiple coding tasks.
- Identify design preferences for how uncertainty should be conveyed to programmers.
- Investigate subjective utility and cognitive load associated with different uncertainty highlighting schemes.
Proposed method
- Conduct a mixed-methods within-subjects study with 30 programmers performing three coding tasks.
- Implement two uncertainty highlighting conditions: generation probability-based highlights (threshold around 69.4%) and an edit-model-based highlight (tokens edited by at least 4 of 6 participants).
- Train a closed-world edit model to predict the likelihood that a token will be edited, based on participant edits to Codex-generated completions.
- Compare against a no-highlights baseline across multiple performance and subjective metrics.
- Pre-register and analyze nine hypotheses related to time, accuracy, token survival, cognitive load, and perceived utility.
Experimental results
Research questions
- RQ1Does highlighting uncertainty improve task completion time and accuracy in AI-assisted coding?
- RQ2Which notion of uncertainty (generation probability vs. edit likelihood) is more beneficial to programmers?
- RQ3What are programmers' design preferences for uncertainty highlighting in code completions?
Key findings
- Highlighting tokens with the highest predicted likelihood of being edited leads to faster task completion and more targeted edits.
- Highlighting tokens based on generation probability provides no performance benefit over the no-highlights baseline.
- The edit-model highlights increase the likelihood that participants edit highlighted tokens and are subjectively preferred.
- Programmers prefer uncertainty highlights that are granular, informative, interpretable, and not overwhelming, with shading favored over exact probabilities.
- There is evidence suggesting improved accuracy across tasks with the edit-model highlights, though not always statistically significant due to sample size.
- A simple, closed-world edit model trained on program-edit data can serve as a viable probe for uncertainty in code generation.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.