The Behavior of Large Language Models When Prompted to Generate Code Explanations
Not on the map. Why?
Abstract (arXiv)
This paper systematically investigates the generation of code explanations by Large Language Models (LLMs) for code examples commonly encountered in introductory programming courses. Our findings reveal significant variations in the nature of code explanations produced by LLMs, influenced by factors such as the wording of the prompt, the specific code examples under consideration, the programming language involved, the temperature parameter, and the version of the LLM. However, a consistent pattern emerges for Java and Python, where explanations exhibit a Flesch-Kincaid readability level of approximately 7-8 grade and a consistent lexical density, indicating the proportion of meaningful words relative to the total explanation size. Additionally, the generated explanations consistently achieve high scores for correctness, but lower scores on three other metrics: completeness, conciseness, and specificity.
Key facts. Cited by 3 papers in the map (data through 7 Oct 2026). Builds on 10 of its 23 references that are in the map. First posted on arXiv 2 Nov 2023.
Builds on
10 of 23 references.
References · 10
- 2023GPT-4 Technical Reportcited by 18,132
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2020A Primer in BERTology: What we know about how BERT workscited by 807
- 2023Time Travel in LLMs: Tracing Data Contamination in Large Language Modelscited by 175
- 2022Large Language Models Meet NL2Code: A Surveycited by 135
- 2022Automatic Generation of Programming Exercises and Code Explanations using Large Language Modelscited by 124
- 2023ChatGPT is not all you need. A State of the Art Review of large Generative AI modelscited by 85
- 2022Experiences from Using Code Explanations Generated by Large Language Models in a Web Software Development E-Bookcited by 84
- 2021What do pre-trained code models know about code?cited by 36
- 2023Distilled GPT for Source Code Summarizationcited by 30
Built on by
Citing papers per year: 2024: 2; 2025: 1.
3 papers.
- 2024Generative AI for Education (GAIED): Advances, Opportunities, and Challengescited by 13
- 2024Language Models are Alignable Decision-Makers: Dataset and Application to the Medical Triage Domaincited by 13
- 2025Synthesizing High-Quality Programming Tasks with LLM-based Expert and Student Agentscited by 3
- 2025Synthesizing High-Quality Programming Tasks with LLM-based Expert and Student Agents10 Apr 2025
- 2024Language Models are Alignable Decision-Makers: Dataset and Application to the Medical Triage Domain10 Jun 2024
- 2024Generative AI for Education (GAIED): Advances, Opportunities, and Challenges2 Feb 2024