On the Robustness of LLMs' Internal Representation of Code Correctness

Francisco Ribeiro, Sohaila Abdulsattar, Renata Gonzalez, Mahmoud Kassem, Sarah Nadi
8/8/2026
cs.SEcs.AIcs.LG

No confident code implementation found for this paper.

Abstract

Code generated by modern language models often reads naturally. Yet, it also often fails to implement what was asked.

Show full abstract

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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{ribeiro2026robustness,
  title  = {On the Robustness of LLMs' Internal Representation of Code Correctness},
  author = {Francisco Ribeiro and Sohaila Abdulsattar and Renata Gonzalez and Mahmoud Kassem and Sarah Nadi},
  year   = {2026},
  eprint = {2608.08266},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2608.08266v1}
}

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/2608.08266.svg)](https://codeofpaper.com/paper/2608.08266)

Discussion