Identifying Inaccurate Descriptions in LLM-generated Code Comments via Test Execution
Not on the map. Why?
Abstract (arXiv)
Software comments are critical for human understanding of software, and as such many comment generation techniques have been proposed. However, we find that a systematic evaluation of the factual accuracy of generated comments is rare; only subjective accuracy labels have been given. Evaluating comments generated by three Large Language Models (LLMs), we find that even for the best-performing LLM, roughly a fifth of its comments contained demonstrably inaccurate statements. While it seems code-comment consistency detection techniques should be able to detect inaccurate comments, we perform experiments demonstrating they have no statistically significant relationship with comment accuracy, underscoring the substantial difficulty of this problem. To tackle this, we propose the concept of document testing, in which a document is verified by using an LLM to generate tests based on the document, running those tests, and observing whether they pass or fail. Furthermore, we implement our concept to verify Java comments. Experiments demonstrate that our approach has a robust statistical relationship with comment accuracy, making headway into a problem where prior techniques failed. Qualitative evaluation also reveals the promise of our approach in gaining developer trust, while highlighting the limitations of our current implementation.
Key facts. Cited by 7 papers in the map (data through 7 Oct 2026). First posted on arXiv 21 Jun 2024.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2024: 1; 2025: 1; 2026: 5.
7 papers.
- 2024ETF: An Entity Tracing Framework for Hallucination Detection in Code Summariescited by 5
- 2025Hallucinations in Code Change to Natural Language Generation: Prevalence and Evaluation of Detection Metricscited by 4
- 2026ReFEree: Reference-Free and Fine-Grained Method for Evaluating Factual Consistency in Real-World Code Summarizationcited by 1
- 2026Characterizing Readability Issue Patterns and the Role of Prompt Design in LLM-Generated Codecited by 1
- 2026XSearch: Explainable Code Search via Concept-to-Code Alignmentcited by 0
- 2026The Hitchhiker's Guide to Monoculture: AI Homogenizes Syntax, Not (Necessarily) Semanticscited by 0
- 2026Talking to Itself While Coding: What Makes Comments Help Code Generation?cited by 0
- 2026Talking to Itself While Coding: What Makes Comments Help Code Generation?8 Sep 2026
- 2026The Hitchhiker's Guide to Monoculture: AI Homogenizes Syntax, Not (Necessarily) Semantics12 Jul 2026
- 2026XSearch: Explainable Code Search via Concept-to-Code Alignment15 May 2026
- 2026Characterizing Readability Issue Patterns and the Role of Prompt Design in LLM-Generated Code13 May 2026
- 2026ReFEree: Reference-Free and Fine-Grained Method for Evaluating Factual Consistency in Real-World Code Summarization12 Apr 2026
- 2025Hallucinations in Code Change to Natural Language Generation: Prevalence and Evaluation of Detection Metrics12 Aug 2025
- 2024ETF: An Entity Tracing Framework for Hallucination Detection in Code Summaries17 Oct 2024