mlsanityData to 7 Oct 2026

Correctness Assessment of Code Generated by Large Language Models Using Internal Representations

arXiv 2501.12934 ↗First posted 22 Jan 2025cs.SE cs.LGcited by 17

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

  1. 2020Language Models are Few-Shot Learnerscited by 32,199
  2. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
  3. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  4. 2021Program Synthesis with Large Language Modelscited by 3,509
  5. 2023A Survey of Large Language Modelscited by 2,537
  6. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  7. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
  8. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
  9. 2023Inference-Time Intervention: Eliciting Truthful Answers from a Language Modelcited by 1,259
  10. 2023A Survey on Evaluation of Large Language Modelscited by 1,227
  11. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
  12. 2023The Internal State of an LLM Knows When It's Lyingcited by 644
38 more
  1. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
  2. 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 389
  3. 2022A Systematic Evaluation of Large Language Models of Codecited by 360
  4. 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
  5. 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 327
  6. 2024INSIDE: LLMs' Internal States Retain the Power of Hallucination Detectioncited by 317
  7. 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 294
  8. 2019Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networkscited by 266
  9. 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 193
  10. 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
  11. 2023Large Language Models for Software Engineering: Survey and Open Problemscited by 178
  12. 2024Fact-Checking the Output of Large Language Models via Token-Level Uncertainty Quantificationcited by 159
  13. 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
  14. 2020Deep Learning based Vulnerability Detection: Are We There Yet?cited by 142
  15. 2024Lookback Lens: Detecting and Mitigating Contextual Hallucinations in Large Language Models Using Only Attention Mapscited by 140
  16. 2022ReACC: A Retrieval-Augmented Code Completion Frameworkcited by 117
  17. 2024LLM Hallucinations in Practical Code Generation: Phenomena, Mechanism, and Mitigationcited by 92
  18. 2018SySeVR: A Framework for Using Deep Learning to Detect Software Vulnerabilitiescited by 91
  19. 2022Lost at C: A User Study on the Security Implications of Large Language Model Code Assistantscited by 87
  20. 2023Impact of Code Language Models on Automated Program Repaircited by 85
  21. 2024A Primer on the Inner Workings of Transformer-based Language Modelscited by 83
  22. 2024LLM Internal States Reveal Hallucination Risk Faced With a Querycited by 80
  23. 2023How Secure is Code Generated by ChatGPT?cited by 77
  24. 2023A Large-Scale Survey on the Usability of AI Programming Assistants: Successes and Challengescited by 75
  25. 2024DevEval: A Manually-Annotated Code Generation Benchmark Aligned with Real-World Code Repositoriescited by 71
  26. 2023Attention Satisfies: A Constraint-Satisfaction Lens on Factual Errors of Language Modelscited by 67
  27. 2024Bugs in Large Language Models Generated Code: An Empirical Studycited by 59
  28. 2021Vulnerability Detection with Fine-grained Interpretationscited by 56
  29. 2024Repoformer: Selective Retrieval for Repository-Level Code Completioncited by 55
  30. 2023The Curious Case of Hallucinatory (Un)answerability: Finding Truths in the Hidden States of Over-Confident Large Language Modelscited by 54
  31. 2023On Early Detection of Hallucinations in Factual Question Answeringcited by 54
  32. 2020Big Code != Big Vocabulary: Open-Vocabulary Models for Source Codecited by 53
  33. 2024Calibration and Correctness of Language Models for Codecited by 49
  34. 2023Large Language Models and Simple, Stupid Bugscited by 45
  35. 2023No Need to Lift a Finger Anymore? Assessing the Quality of Code Generation by ChatGPTcited by 45
  36. 2024Characterizing Truthfulness in Large Language Model Generations with Local Intrinsic Dimensioncited by 45
  37. 2024Estimating Knowledge in Large Language Models Without Generating a Single Tokencited by 39
  38. 2022LineVD: Statement-level Vulnerability Detection using Graph Neural Networkscited by 35

50 most cited of 69 All 69 (JSON)

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 6; 2026: 11.

17 papers.

Sort:

By area:

  1. 2025On LLMs' Internal Representation of Code Correctnesscited by 5
  2. 2025MERA Code: A Unified Framework for Evaluating Code Generation Across Taskscited by 4
  3. 2025Lightweight Latent Verifiers for Efficient Meta-Generation Strategiescited by 3
  4. 2025Localized Calibrated Uncertainty in Code Language Modelscited by 3
  5. 2026CodeCircuit: Toward Inferring LLM-Generated Code Correctness via Attribution Graphscited by 3
  6. 2025Multicalibration for LLM-based Code Generationcited by 2
  7. 2025On Developers' Self-Declaration of AI-Generated Code: An Analysis of Practicescited by 1
  8. 2026Towards Secure Logging: Characterizing and Benchmarking Logging Code Security Issues with LLMscited by 1
  9. 2026Minimal Prompt Perturbations Lead to Code Vulnerabilities: Prompt Fragility and Hidden-State Signals in Coding LLMscited by 1
  10. 2026When the Reward Suite Is Leaky: A Preregistered Causal Contrast of Natural Verifier False Positives in RLVRcited by 1
  11. 2026On the Robustness of LLMs' Internal Representation of Code Correctnesscited by 1
  12. 2026AgenticSum: An Agentic Inference-Time Framework for Faithful Clinical Text Summarizationcited by 0
5 more
  1. 2026Safer Builders, Risky Maintainers: A Comparative Study of Breaking Changes in Human vs Agentic PRscited by 0
  2. 2026Towards the Readability of LLM-Generated Codes through Multitask Representation Engineeringcited by 0
  3. 2026The Role of Rigor in Artificial Intelligencecited by 0
  4. 2026Latent Programming Horizons in Coding Agentscited by 0
  5. 2026TruthLens: Object Hallucination Detection via Self-Evaluating Truthfulness Scores in LVLMscited by 0