Self-Improving Code Generation via Semantic Entropy and Behavioral Consensus

Huan Zhang, Wei Cheng, Wei Hu
3/31/2026
cs.SEcs.AIcs.PL

No official code found. Best implementation: nju-websoft/ConSelf (0 stars, GPL-3.0, last commit 2026-01-19).

Abstract

Improving the code generation capabilities of large language models (LLMs) typically relies on supervised fine-tuning or preference optimization, both of which require costly external resources such as powerful teacher models or reliable test units. However, in real-world scenarios, it is much harder to obtain reference solutions and test oracles than problem descriptions and test inputs. In this paper, we tackle a challenging yet realistic question: Can a code language model improve itself without access to a superior teacher and a test oracle? To answer this, we propose ConSelf, a self-improving approach built upon two key ideas. First, we introduce code semantic entropy, a novel metric that measures problem-level uncertainty by assessing the functional diversity of program behaviors, enabling a curriculum construction with the most learnable problems. Second, we present consensus-driven direct preference optimization (Con-DPO), a preference-based fine-tuning method that weights each preference pair by its behavioral consensus, thereby mitigating the impact of noisy self-generated supervision. Experiments on various benchmarks and backbone LLMs demonstrate that ConSelf significantly outperforms baselines, validating the effectiveness of semantic entropy-based curriculum construction and consensus-driven optimization in improving code generation without external supervision.

View on arXivView PDF

Code Implementations(1)

GPL-3.0

Self-Improving Code Generation via Semantic Entropy and Behavioral Consensus, ICPC 2026

00Jan 19, 20269 months agoGPL-3.0

Similar Papers

Cite this paper

@article{zhang2026selfimproving,
  title  = {Self-Improving Code Generation via Semantic Entropy and Behavioral Consensus},
  author = {Huan Zhang and Wei Cheng and Wei Hu},
  year   = {2026},
  eprint = {2603.29292},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2603.29292v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2603.29292.svg)](https://codeofpaper.com/paper/2603.29292)

Discussion