A Preliminary Study on Explaining Risk of Code Changes using LLM-Based Prediction Models

📅 2026-07-02
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the limited trust developers place in just-in-time defect prediction due to its poor interpretability. The authors propose a novel approach that leverages attention weights from large language models (LLMs) over code diffs to aggregate token-level risk signals into human-readable risk regions at the line, block, or file level, providing lightweight hints directly within code review interfaces. The method incurs no additional computational overhead and integrates seamlessly into existing development workflows. Empirical evaluation on real-world faulty changes shows that highlighting only the top two riskiest code blocks covers 53.85% of fault-inducing lines, requiring developers to inspect merely 26.28% of changed lines on average. With low inference latency, the approach is suitable for large-scale deployment.
📝 Abstract
Predictions by machine learning (ML) and artificial intelligence (AI) models are often received skeptically unless they are paired with intelligible explanations. In the context of just-in-time defect prediction, highlighting small portions of a software change (diff) -- beyond rule-based lints -- where risk may be concentrated has not yet been extensively investigated. In this work, we leverage attention weights from an LLM-based Diff Risk Score (DRS) model to highlight parts of a diff that the model focuses on when predicting risk. We aggregate token-level attention into interpretable code units (lines, hunks, and files), and present the top-K units to developers as a lightweight form of guidance during code review. We evaluate our approach using expert-labeled changes that have caused real outages. Results show that the highlighted snippets cover expert-labeled outage-causing change lines 53.85% of the time when highlighting the top-2 hunks, while requiring developers to review 26.28% of the changed lines on average. Because attention is produced during standard model inference, the approach is scalable for large development workflows and can be surfaced in the code review UI with low additional latency.
Problem

Research questions and friction points this paper is trying to address.

just-in-time defect prediction
code change risk
explainable AI
code review
software diff
Innovation

Methods, ideas, or system contributions that make the work stand out.

LLM-based explanation
attention weights
just-in-time defect prediction
interpretable code units
code review assistance
🔎 Similar Papers
No similar papers found.
Y
Yalin Liu
Meta Platforms, Inc.
K
Kosay Jabre
Meta Platforms, Inc.
Rui Abreu
Rui Abreu
Meta Platforms, Inc and University of Porto/INESC-ID
SWESE4AIAI4SECyberSecQuantum Software
Z
Zachariah J. Carmichael
Meta Platforms, Inc.
Vijayaraghavan Murali
Vijayaraghavan Murali
Facebook
Programming LanguagesMachine LearningSoftware Engineering
A
Akshay Patel
Meta Platforms, Inc.
J
Jun Ge
Meta Platforms, Inc.
W
Weiyan Sun
Meta Platforms, Inc.
C
Cong Zhang
Meta Platforms, Inc.
Audris Mockus
Audris Mockus
University of Tennessee
Digital ArchaeologySoftware EngineeringVisualizationOptimization
D
David Khavari
Meta Platforms, Inc.
Nachiappan Nagappan
Nachiappan Nagappan
Facebook
Software ReliabilityProductivitySoftware Analytics
P
Peter C. Rigby
Meta Platforms, Inc.