Despite the effectiveness of large language models (LLMs) for code generation, they often output incorrect code. One reason is that model output probabilities are often not well-correlated with correctness, and reflect only the final output of the generation process. Inspired by findings that LLMs internally encode concepts like truthfulness, this paper explores if LLMs similarly represent code correctness. Specifically, we identify a correctness representation inside LLMs by contrasting the hidden states between pairs of correct and incorrect code for the same programming tasks. By experimenting on four LLMs, we show that exploiting this extracted correctness representation outperforms standard log-likelihood ranking, as well as verbalized model confidence. Furthermore, we explore how this internal correctness signal can be used to select higher-quality code samples, without requiring test execution. Ultimately, this work demonstrates how leveraging internal representations can enhance code generation systems and make LLMs more reliable, thus improving confidence in automatically generated code.
Thu 16 AprDisplayed time zone: Brasilia, Distrito Federal, Brazil change
14:00 - 15:30 | AI for Software Engineering 13SE In Practice (SEIP) / Research Track at Asia I Chair(s): Dalal Alrajeh Imperial College London | ||
14:00 15mTalk | Improving Code Generation via Small Language Model-as-a-judge Research Track Giuseppe Crupi Università della Svizzera italiana, Rosalia Tufano Università della Svizzera Italiana, Gabriele Bavota Software Institute @ Università della Svizzera Italiana Pre-print | ||
14:15 15mTalk | Think Like Human Developers: Harnessing Community Knowledge for Structured Code ReasoningDistinguished Paper Award Research Track Chengran Yang Singapore Management University, Singapore, Zhensu Sun Singapore Management University, Hong Jin Kang University of Sydney, Jieke Shi Singapore Management University, David Lo Singapore Management University | ||
14:30 15mTalk | On LLMs’ Internal Representation of Code Correctness Research Track Francisco Ribeiro New York University Abu Dhabi, Claudio Spiess University of California, Davis, Prem Devanbu University of California at Davis, Sarah Nadi New York University Abu Dhabi Pre-print | ||
14:45 15mTalk | Write Your Own Code Checker: An Automated Test-Driven Checker Development Approach with LLMs Research Track Jun Liu Institute of Software, Chinese Academy of Sciences, Yuanyuan Xie Institute of Software, Chinese Academy of Sciences, Jiwei Yan Institute of Software at Chinese Academy of Sciences, Jinhao Huang Institute of Software, Chinese Academy of Sciences, Jun Yan Institute of Software, Chinese Academy of Sciences, Jian Zhang Institute of Software at Chinese Academy of Sciences; University of Chinese Academy of Sciences | ||
15:00 15mTalk | RovoDev Code Reviewer: A Large-Scale Online Evaluation of LLM-based Code Review Automation at Atlassian SE In Practice (SEIP) Kla Tantithamthavorn Monash University, Yaotian Zou Atlassian, Andy Wong Atlassian, Michael Gupta Atlassian, Zhe Wang Atlassian, Mike Buller Atlassian, Ryan Jiang Atlassian, Matthew Watson Atlassian, Minwoo Jeong Atlassian, Kun Chen Atlassian, Ming Wu Atlassian Pre-print | ||
15:15 15mTalk | Spec2Control: Automating PLC/DCS Control-Logic Engineering from Natural Language Requirements with LLMs - A Multi-Plant Evaluation SE In Practice (SEIP) Heiko Koziolek ABB Corporate Research, Thilo Braun ABB, Virendra Ashiwal ABB Research, Sofia Linsbauer ABB Research, Marthe Ahlgreen Hansen ABB, Karoline Grotterud ABB | ||