English

Incoherence as Oracle-less Measure of Error in LLM-Based Code Generation

Programming Languages 2025-12-16 v2 Artificial Intelligence Machine Learning Software Engineering

Abstract

Generating code from a natural language programming task is one of the most successful applications of Large Language Models (LLMs). Yet, the generated program may be buggy. Without an oracle, such as an existing, correct implementation or a formal specification, can we somehow estimate how likely the generated program is correct? In this paper, we propose a measure of incorrectness, called *incoherence*, that can be estimated efficiently in the absence of an oracle and allows us to establish a lower bound on the error, i.e., the probability that the LLM-generated program for that specification is incorrect. In our experiments, our incoherence-based methodology can automatically identify about two-thirds of incorrect programs without reports of false positives for the average task. In fact, *an oracle-based evaluation of LLMs can be reliably replaced by an incoherence-based evaluation*. In particular, we find a very strong agreement between the ranking of LLMs by the number of programs deemed correct via an oracle (pass@1) and the ranking of LLMs by the number of programs deemed correct via incoherence.

Keywords

Cite

@article{arxiv.2507.00057,
  title  = {Incoherence as Oracle-less Measure of Error in LLM-Based Code Generation},
  author = {Thomas Valentin and Ardi Madadi and Gaetano Sapia and Marcel Böhme},
  journal= {arXiv preprint arXiv:2507.00057},
  year   = {2025}
}

Comments

Accepted at AAAI'26 (extended version). 8 pages + refs and appendix

R2 v1 2026-07-01T03:40:08.089Z