mlsanityData to 14 Oct 2026

Risk Assessment Framework for Code LLMs via Leveraging Internal States

arXiv 2504.14640 ↗First posted 20 Apr 2025cs.SE cs.AI cs.CLcited by 9

Not on the map. Why?

Abstract (arXiv)

The pre-training paradigm plays a key role in the success of Large Language Models (LLMs), which have been recognized as one of the most significant advancements of AI recently. Building on these breakthroughs, code LLMs with advanced coding capabilities bring huge impacts on software engineering, showing the tendency to become an essential part of developers' daily routines. However, the current code LLMs still face serious challenges related to trustworthiness, as they can generate incorrect, insecure, or unreliable code. Recent exploratory studies find that it can be promising to detect such risky outputs by analyzing LLMs' internal states, akin to how the human brain unconsciously recognizes its own mistakes. Yet, most of these approaches are limited to narrow sub-domains of LLM operations and fall short of achieving industry-level scalability and practicability. To address these challenges, in this paper, we propose PtTrust, a two-stage risk assessment framework for code LLM based on internal state pre-training, designed to integrate seamlessly with the existing infrastructure of software companies. The core idea is that the risk assessment framework could also undergo a pre-training process similar to LLMs. Specifically, PtTrust first performs unsupervised pre-training on large-scale unlabeled source code to learn general representations of LLM states. Then, it uses a small, labeled dataset to train a risk predictor. We demonstrate the effectiveness of PtTrust through fine-grained, code line-level risk assessment and demonstrate that it generalizes across tasks and different programming languages. Further experiments also reveal that PtTrust provides highly intuitive and interpretable features, fostering greater user trust. We believe PtTrust makes a promising step toward scalable and trustworthy assurance for code LLMs.

Key facts. Cited by 9 papers in the map (data through 14 Oct 2026). Builds on 40 of its 77 references that are in the map. First posted on arXiv 20 Apr 2025.

Builds on

40 of 77 references.

References · 40

  1. 2017Attention Is All You Needcited by 60,361
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  3. 2020Supervised Contrastive Learningcited by 2,829
  4. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  5. 2023Sparse Autoencoders Find Highly Interpretable Features in Language Modelscited by 1,420
  6. 2023Representation Engineering: A Top-Down Approach to AI Transparencycited by 1,336
  7. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
  8. 2022Toy Models of Superpositioncited by 971
  9. 2023StarCoder: may the source be with you!cited by 799
  10. 2023The Geometry of Truth: Emergent Linear Structure in Large Language Model Representations of True/False Datasetscited by 712
  11. 2023The Internal State of an LLM Knows When It's Lyingcited by 659
  12. 2024Executable Code Actions Elicit Better LLM Agentscited by 564
28 more
  1. 2024StarCoder 2 and The Stack v2: The Next Generationcited by 502
  2. 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 498
  3. 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 399
  4. 2022CodeT: Code Generation with Generated Testscited by 384
  5. 2023Magicoder: Empowering Code Generation with OSS-Instructcited by 256
  6. 2022Grounded Copilot: How Programmers Interact with Code-Generating Modelscited by 218
  7. 2024Lookback Lens: Detecting and Mitigating Contextual Hallucinations in Large Language Models Using Only Attention Mapscited by 142
  8. 2023Self-planning Code Generation with Large Language Modelscited by 124
  9. 2024TruthX: Alleviating Hallucinations by Editing Large Language Models in Truthful Spacecited by 91
  10. 2023Refining ChatGPT-Generated Code: Characterizing and Mitigating Code Quality Issuescited by 79
  11. 2024DebugBench: Evaluating Debugging Capability of Large Language Modelscited by 76
  12. 2023Improving Activation Steering in Language Models with Mean-Centringcited by 68
  13. 2024CodexGraph: Bridging Large Language Models and Code Repositories via Code Graph Databasescited by 65
  14. 2024Calibration and Correctness of Language Models for Codecited by 49
  15. 2023What Makes Good In-context Demonstrations for Code Intelligence Tasks with LLMs?cited by 47
  16. 2023No Need to Lift a Finger Anymore? Assessing the Quality of Code Generation by ChatGPTcited by 47
  17. 2023Large Language Models and Simple, Stupid Bugscited by 45
  18. 2023WaveCoder: Widespread And Versatile Enhancement For Code Large Language Models By Instruction Tuningcited by 42
  19. 2024CYCLE: Learning to Self-Refine the Code Generationcited by 42
  20. 2021NeuralNDCG: Direct Optimisation of a Ranking Metric via Differentiable Relaxation of Sortingcited by 41
  21. 2024Contextual Feature Extraction Hierarchies Converge in Large Language Models and the Braincited by 32
  22. 2023InstructCoder: Instruction Tuning Large Language Models for Code Editingcited by 29
  23. 2023Exploring Distributional Shifts in Large Language Models for Code Analysiscited by 14
  24. 2023Do Large Language Models Pay Similar Attention Like Human Programmers When Generating Code?cited by 14
  25. 2023Nova: Generative Language Models for Assembly Code with Hierarchical Attention and Contrastive Learningcited by 12
  26. 2024A Study on Developer Behaviors for Validating and Repairing LLM-Generated Code Using Eye Tracking and IDE Actionscited by 12
  27. 2023DeepSeer: Interactive RNN Explanation and Debugging via State Abstractioncited by 6
  28. 2024Cluster-norm for Unsupervised Probing of Knowledgecited by 4

Built on by

Cited by year (2026 to 14 Oct)

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

9 papers.