Correctness Assessment of Code Generated by Large Language Models Using Internal Representations
Not on the map. Why?
Abstract (arXiv)
Ensuring the correctness of code generated by Large Language Models (LLMs) presents a significant challenge in AI-driven software development. Existing approaches predominantly rely on black-box (closed-box) approaches that evaluate correctness post-generation, failing to utilize the rich insights embedded in the LLMs' internal states during code generation. In this paper, we introduce OPENIA, a novel white-box (open-box) framework that leverages these internal representations to assess the correctness of LLM-generated code. OPENIA systematically analyzes the intermediate states of representative open-source LLMs specialized for code, including DeepSeek-Coder, CodeLlama, and MagicCoder, across diverse code generation benchmarks. Our empirical analysis reveals that these internal representations encode latent information, which strongly correlates with the correctness of the generated code. Building on these insights, OPENIA uses a white-box/open-box approach to make informed predictions about code correctness, offering significant advantages in adaptability and robustness over traditional classification-based methods and zero-shot approaches. Experimental results demonstrate that OPENIA consistently outperforms baseline models, achieving higher accuracy, precision, recall, and F1-Scores with up to a 2X improvement in standalone code generation and a 46% enhancement in repository-specific scenarios. By unlocking the potential of in-process signals, OPENIA paves the way for more proactive and efficient quality assurance mechanisms in LLM-assisted code generation.
Key facts. Cited by 17 papers in the map (data through 7 Oct 2026). Builds on 69 of its 94 references that are in the map. First posted on arXiv 22 Jan 2025.
Builds on
69 of 94 references.
References · 69
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023A Survey of Large Language Modelscited by 2,537
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2023Inference-Time Intervention: Eliciting Truthful Answers from a Language Modelcited by 1,259
- 2023A Survey on Evaluation of Large Language Modelscited by 1,227
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2023The Internal State of an LLM Knows When It's Lyingcited by 644
38 more
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 389
- 2022A Systematic Evaluation of Large Language Models of Codecited by 360
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
- 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 327
- 2024INSIDE: LLMs' Internal States Retain the Power of Hallucination Detectioncited by 317
- 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 294
- 2019Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networkscited by 266
- 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 193
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
- 2023Large Language Models for Software Engineering: Survey and Open Problemscited by 178
- 2024Fact-Checking the Output of Large Language Models via Token-Level Uncertainty Quantificationcited by 159
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
- 2020Deep Learning based Vulnerability Detection: Are We There Yet?cited by 142
- 2024Lookback Lens: Detecting and Mitigating Contextual Hallucinations in Large Language Models Using Only Attention Mapscited by 140
- 2022ReACC: A Retrieval-Augmented Code Completion Frameworkcited by 117
- 2024LLM Hallucinations in Practical Code Generation: Phenomena, Mechanism, and Mitigationcited by 92
- 2018SySeVR: A Framework for Using Deep Learning to Detect Software Vulnerabilitiescited by 91
- 2022Lost at C: A User Study on the Security Implications of Large Language Model Code Assistantscited by 87
- 2023Impact of Code Language Models on Automated Program Repaircited by 85
- 2024A Primer on the Inner Workings of Transformer-based Language Modelscited by 83
- 2024LLM Internal States Reveal Hallucination Risk Faced With a Querycited by 80
- 2023How Secure is Code Generated by ChatGPT?cited by 77
- 2023A Large-Scale Survey on the Usability of AI Programming Assistants: Successes and Challengescited by 75
- 2024DevEval: A Manually-Annotated Code Generation Benchmark Aligned with Real-World Code Repositoriescited by 71
- 2023Attention Satisfies: A Constraint-Satisfaction Lens on Factual Errors of Language Modelscited by 67
- 2024Bugs in Large Language Models Generated Code: An Empirical Studycited by 59
- 2021Vulnerability Detection with Fine-grained Interpretationscited by 56
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completioncited by 55
- 2023The Curious Case of Hallucinatory (Un)answerability: Finding Truths in the Hidden States of Over-Confident Large Language Modelscited by 54
- 2023On Early Detection of Hallucinations in Factual Question Answeringcited by 54
- 2020Big Code != Big Vocabulary: Open-Vocabulary Models for Source Codecited by 53
- 2024Calibration and Correctness of Language Models for Codecited by 49
- 2023Large Language Models and Simple, Stupid Bugscited by 45
- 2023No Need to Lift a Finger Anymore? Assessing the Quality of Code Generation by ChatGPTcited by 45
- 2024Characterizing Truthfulness in Large Language Model Generations with Local Intrinsic Dimensioncited by 45
- 2024Estimating Knowledge in Large Language Models Without Generating a Single Tokencited by 39
- 2022LineVD: Statement-level Vulnerability Detection using Graph Neural Networkscited by 35
50 most cited of 69 All 69 (JSON)
Built on by
Citing papers per year: 2025: 6; 2026: 11.
17 papers.
Sort:
By area:
- 2025On LLMs' Internal Representation of Code Correctnesscited by 5
- 2025MERA Code: A Unified Framework for Evaluating Code Generation Across Taskscited by 4
- 2025Lightweight Latent Verifiers for Efficient Meta-Generation Strategiescited by 3
- 2025Localized Calibrated Uncertainty in Code Language Modelscited by 3
- 2026CodeCircuit: Toward Inferring LLM-Generated Code Correctness via Attribution Graphscited by 3
- 2025Multicalibration for LLM-based Code Generationcited by 2
- 2025On Developers' Self-Declaration of AI-Generated Code: An Analysis of Practicescited by 1
- 2026Towards Secure Logging: Characterizing and Benchmarking Logging Code Security Issues with LLMscited by 1
- 2026Minimal Prompt Perturbations Lead to Code Vulnerabilities: Prompt Fragility and Hidden-State Signals in Coding LLMscited by 1
- 2026When the Reward Suite Is Leaky: A Preregistered Causal Contrast of Natural Verifier False Positives in RLVRcited by 1
- 2026On the Robustness of LLMs' Internal Representation of Code Correctnesscited by 1
- 2026AgenticSum: An Agentic Inference-Time Framework for Faithful Clinical Text Summarizationcited by 0
5 more
- 2026Safer Builders, Risky Maintainers: A Comparative Study of Breaking Changes in Human vs Agentic PRscited by 0
- 2026Towards the Readability of LLM-Generated Codes through Multitask Representation Engineeringcited by 0
- 2026The Role of Rigor in Artificial Intelligencecited by 0
- 2026Latent Programming Horizons in Coding Agentscited by 0
- 2026TruthLens: Object Hallucination Detection via Self-Evaluating Truthfulness Scores in LVLMscited by 0
- 2026On the Robustness of LLMs' Internal Representation of Code Correctness8 Aug 2026
- 2026TruthLens: Object Hallucination Detection via Self-Evaluating Truthfulness Scores in LVLMs6 Aug 2026
- 2026When the Reward Suite Is Leaky: A Preregistered Causal Contrast of Natural Verifier False Positives in RLVR13 Jul 2026
- 2026Latent Programming Horizons in Coding Agents6 Jul 2026
- 2026Towards the Readability of LLM-Generated Codes through Multitask Representation Engineering4 Jun 2026
- 2026Minimal Prompt Perturbations Lead to Code Vulnerabilities: Prompt Fragility and Hidden-State Signals in Coding LLMs28 May 2026
- 2026The Role of Rigor in Artificial Intelligence19 May 2026
- 2026Towards Secure Logging: Characterizing and Benchmarking Logging Code Security Issues with LLMs22 Apr 2026
- 2026Safer Builders, Risky Maintainers: A Comparative Study of Breaking Changes in Human vs Agentic PRs29 Mar 2026
- 2026AgenticSum: An Agentic Inference-Time Framework for Faithful Clinical Text Summarization23 Feb 2026
- 2026CodeCircuit: Toward Inferring LLM-Generated Code Correctness via Attribution Graphs6 Feb 2026
- 2025Localized Calibrated Uncertainty in Code Language Models31 Dec 2025
5 more
- 2025Multicalibration for LLM-based Code Generation9 Dec 2025
- 2025On LLMs' Internal Representation of Code Correctness8 Dec 2025
- 2025MERA Code: A Unified Framework for Evaluating Code Generation Across Tasks16 Jul 2025
- 2025Lightweight Latent Verifiers for Efficient Meta-Generation Strategies23 Apr 2025
- 2025On Developers' Self-Declaration of AI-Generated Code: An Analysis of Practices23 Apr 2025
- 2025On LLMs' Internal Representation of Code Correctnesscited by 5
- 2025MERA Code: A Unified Framework for Evaluating Code Generation Across Taskscited by 4
- 2025Lightweight Latent Verifiers for Efficient Meta-Generation Strategiescited by 3
- 2025Localized Calibrated Uncertainty in Code Language Modelscited by 3
- 2026CodeCircuit: Toward Inferring LLM-Generated Code Correctness via Attribution Graphscited by 3
- 2025Multicalibration for LLM-based Code Generationcited by 2
- 2025On Developers' Self-Declaration of AI-Generated Code: An Analysis of Practicescited by 1
- 2026Towards Secure Logging: Characterizing and Benchmarking Logging Code Security Issues with LLMscited by 1
- 2026Minimal Prompt Perturbations Lead to Code Vulnerabilities: Prompt Fragility and Hidden-State Signals in Coding LLMscited by 1
- 2026When the Reward Suite Is Leaky: A Preregistered Causal Contrast of Natural Verifier False Positives in RLVRcited by 1
- 2026On the Robustness of LLMs' Internal Representation of Code Correctnesscited by 1
- 2026Towards the Readability of LLM-Generated Codes through Multitask Representation Engineeringcited by 0
12 most cited of 13 All 13 (JSON)
- 2026On the Robustness of LLMs' Internal Representation of Code Correctness8 Aug 2026
- 2026When the Reward Suite Is Leaky: A Preregistered Causal Contrast of Natural Verifier False Positives in RLVR13 Jul 2026
- 2026Towards the Readability of LLM-Generated Codes through Multitask Representation Engineering4 Jun 2026
- 2026Minimal Prompt Perturbations Lead to Code Vulnerabilities: Prompt Fragility and Hidden-State Signals in Coding LLMs28 May 2026
- 2026The Role of Rigor in Artificial Intelligence19 May 2026
- 2026Towards Secure Logging: Characterizing and Benchmarking Logging Code Security Issues with LLMs22 Apr 2026
- 2026CodeCircuit: Toward Inferring LLM-Generated Code Correctness via Attribution Graphs6 Feb 2026
- 2025Localized Calibrated Uncertainty in Code Language Models31 Dec 2025
- 2025Multicalibration for LLM-based Code Generation9 Dec 2025
- 2025On LLMs' Internal Representation of Code Correctness8 Dec 2025
- 2025MERA Code: A Unified Framework for Evaluating Code Generation Across Tasks16 Jul 2025
- 2025Lightweight Latent Verifiers for Efficient Meta-Generation Strategies23 Apr 2025
12 newest of 13 All 13 (JSON)