Study Context and Objective
Writing high-quality software documentation requires considerable effort from development teams. Large language models (LLMs) have been proposed as a way to streamline this process by generating descriptions from source code without direct human intervention.
Magdalena Kneidinger, Markus Feneberger, and Reinhold Plösch, researchers at the Institute of Business Informatics and Software Engineering at Johannes Kepler University, published an experimental study in 2024 to assess whether GPT-4, developed by OpenAI, can generate valid documentation for classes and methods based solely on code. The work appeared in WiPiEC Journal under the Creative Commons Attribution-NonCommercial 4.0 International license.
Methodology: Zero-Shot Prompts
The study used a zero-shot prompting technique, meaning the model received no prior examples or specific formatting instructions beyond the request to produce documentation. This approach makes it possible to assess the model’s intrinsic ability to infer code intent without additional training or project context.
The primary metric was similarity to reference documentation—that is, the documentation text originally written by developers. The researchers compared GPT-4’s output with this reference text to determine how closely the automatically generated documentation matched standard human-written documentation.
Results at the Method Level
At the method level, GPT-4 achieved higher similarity scores compared with the reference documentation. The study’s authors concluded that the model could be considered applicable for this specific use case. This suggests GPT-4 can capture the functional logic of individual functions and generate descriptions that reasonably align with what a developer might write.
This result is relevant to teams looking to automate the generation of inline comments or function-level API documentation, where the context is narrower and the logic more direct.
Results at the Class Level
By contrast, results were significantly worse at the class level. GPT-4 produced documentation with low similarity to the reference. The authors therefore concluded that GPT-4 is not yet usable for generating class documentation reliably.
Class documentation requires a more abstract understanding of a component’s purpose, its relationships with other modules, and its role within the system. The model’s inability to generate similar text at this level indicates a limitation in high-level synthesis when the context is broader and more complex.
Comparison of Results by Level of Abstraction
| Level of abstraction | Similarity result | Authors’ conclusion |
|---|---|---|
| Method | Higher similarity | Applicable for the use case |
| Class | Low similarity | Not yet usable |
Limits of the Evidence and Scope
This is a specific experimental study that evaluates GPT-4 in a particular configuration (zero-shot) using a specific metric (textual similarity). It does not compare GPT-4 with GPT-3.5 or other language models, so it cannot be used to establish a general ranking of capabilities across model versions.
Furthermore, the conclusion that the model is “applicable” for methods is based on similarity to a human-written reference, not on an independent validation of the technical correctness of the generated documentation. The evidence does not support claims about the model’s safety, commercial availability, or current performance beyond this controlled experiment.
Keep exploring
Corrections and transparency
If you spot incorrect or outdated information, send us a correction with the page and source we should review.
Submit a correction