Hallucinations in LLM Code Comprehension
2026 (English)Independent thesis Advanced level (degree of Master (Two Years)), 20 credits / 30 HE credits
Student thesis
Abstract [en]
Background: Large language models (LLMs) are increasingly used to support software engineering tasks, including code comprehension. However, LLM-generated explanations may contain hallucinations that provide incorrect, unsupported, or misleading information about source code. These hallucinations can take different forms, making it important to systematically categorize them when evaluating LLM-generated code explanations.
Objectives: This thesis aims to identify, categorize, and investigate hallucinations in LLM-generated code explanations. To achieve this, the study first organizes hallucination symptoms reported in existing research and develops a taxonomy. The taxonomy is then contextualized for source-code explanations to develop criteria for identifying different hallucination types. Finally, these criteria are used to investigate the occurrence and frequency of hallucinations in LLM-generated source-code explanations.
Methods: The study employed two research methods: theoretical analysis and observational evaluation. Theoretical analysis was used to organize hallucination symptoms reported in existing research, and develop a taxonomy. Observational evaluation was then used to investigate the occurrence and frequency of hallucinations in LLM-generated code explanations.
Results: The study developed a taxonomy consisting of five hallucination categories: Missing Information, Overconfident Response, Factual Mismatch, Requirement Violation, and Logical Errors. The observational evaluation identified seven hallucinations in the generated explanations. Five were classified as Overconfident Response and two as Factual Mismatch. No hallucinations were classified as Missing Information, Requirement Violation, or Logical Errors in the evaluated explanations.
Conclusions: The findings show that hallucinations in LLM-generated source-code explanations can take different forms. Distinguishing these forms is useful for identifying specific problems in an explanation rather than treating all hallucinations as the same type of error. The developed taxonomy provides a structured framework for describing these hallucination behaviours and can support future studies of hallucinations in LLM-generated code explanations.
Place, publisher, year, edition, pages
2026. , p. 43
Keywords [en]
Hallucinations, Large Language Models, Code Explanation, Code Comprehension, Taxonomy
National Category
Software Engineering
Identifiers
URN: urn:nbn:se:bth-30653OAI: oai:DiVA.org:bth-30653DiVA, id: diva2:2113912
Subject / course
PA2534 Master's Thesis (120 credits) in Software Engineering
Educational program
PAASW Master's Programme in Software Engineering 120,0 hp
Presentation
2026-09-21, J1650, Blekinge Institute of Technology, 371 79 Karlskrona, Karlskrona, 13:00
Supervisors
Examiners
2026-11-022026-10-292026-11-02Bibliographically approved