π€ AI Summary
This study systematically investigates whether large language models (LLMs) internally encode robust representations of code correctnessβa question left unresolved despite widespread use of LLM-generated code. By constructing program pairs that differ only by a single error and leveraging hidden state analysis, contrastive learning, and execution-free correctness assessment, the authors extract internal signals across diverse model configurations. Their findings reveal that no universally optimal signal extraction strategy exists, and merely isolating erroneous tokens does not enhance signal quality. These results indicate that the internal representation of correctness in LLMs is highly contingent on the specific extraction methodology employed, exhibiting strong configuration-dependent behavior rather than a stable, intrinsic encoding.
π Abstract
Code generated by modern language models often reads naturally. Yet, it also often fails to implement what was asked. This should be no surprise, as research shows the models' own confidence signals are poorly calibrated with actual correctness. A promising way to assess correctness looks inside the model: by contrasting the hidden states of correct and incorrect programs, recent work captured an internal signal of code correctness that is able to judge candidate solutions better than the model's token-level or stated confidence, with no test execution. However, this signal was captured under one particular way, leaving open an important question: whether it reflects a robust property of the model or an artifact of that choice. We study this question systematically, varying how the signal is extracted from the model internals. Besides this, we also ask if the signal's quality is limited by the data used to extract it, by constructing program pairs that differ only in the fault that makes them incorrect. Our results show that no single configuration is best, and that isolating the fault does not help.