Multicalibration for LLM-based Code Generation
Viola Campos, Robin Kuschnereit, Adrian Ulges
TL;DR
The paper tackles the challenge of calibrating confidence scores for LLM-based code generation by introducing multicalibration that conditions on code-related factors such as complexity, length, and programming language. It evaluates four multicalibration methods across three code benchmarks using open-weight reasoning models, showing substantial improvements in both calibration metrics and practical accuracy over uncalibrated and traditional baseline methods. A key contribution is demonstrating that incorporating structured, task-relevant group information yields significant gains, with language and length emerging as strong signals and all three factors providing complementary benefits. The authors also release CALIBRI, a dataset of code generations with likelihoods and correctness labels to foster further research in code LLM calibration, and outline future directions in broader code-generation tasks and alternative confidence signals.
Abstract
As AI-based code generation becomes widespread, researchers are investigating the calibration of code LLMs - ensuring their confidence scores faithfully represent the true likelihood of code correctness. To do so, we investigate multicalibration, which can capture additional factors about a coding problem, such as complexity, code length, or programming language used. We study four multicalibration approaches on three function synthesis benchmarks, using latest-generation code LLMs (Qwen3 Coder, GPT-OSS, DeepSeek-R1-Distill). Our results demonstrate that multicalibration can yield distinct improvements over both uncalibrated token likelihoods (+1.03 in skill score) and baseline calibrations (+0.37 in skill score). We study the influence of the aforementioned factors in ablations, and make our dataset (consisting of code generations, likelihoods, and correctness labels) available for future research on code LLM calibration.
