TL;DR
This paper explores using OpenAI’s Codex model to automatically translate cryptic Python compiler error messages into novice-friendly, plain-English explanations and actionable code fixes. While the LLM-generated explanations are highly readable and often improve upon standard compiler errors, the suggested code fixes are frequently incorrect or misleading. The authors conclude that while LLMs show immense promise for computing education, they are not yet reliable enough to be deployed in classrooms without human oversight.
What Problem Does This Paper Address?
For anyone learning to program, standard Programming Error Messages (PEMs) are a notorious rite of passage. Opaque phrases like unexpected EOF while parsing or illegal target for annotation are designed for experienced developers or IDE parsers, not beginners. For over sixty years, computer science educators have tried to create "enhanced" error messages, but doing so manually is incredibly time-consuming and difficult to scale across different programming languages and libraries.
The authors investigate whether Large Language Models (LLMs)—specifically OpenAI's Codex—can bridge this gap by automatically parsing non-compiling code and its associated compiler error to generate clear, educational feedback.
Methods
The researchers used the code-davinci-002 version of OpenAI Codex. Through a process of prompt engineering, they tested five different prompt styles to find the one that minimized empty or broken responses. The winning prompt format was straightforward:
"Plain English explanation of why does running the above code cause an error and how to fix the problem".
For each error scenario, they generated outputs under two conditions:
- Deterministic (Temperature = 0.0): To get the model's most confident, stable response.
- Creative (Temperature = 0.7): To evaluate more varied, less predictable outputs (generating two samples per scenario).
The resulting explanations were qualitatively evaluated by two experienced computer science instructors across seven dimensions, including comprehensibility, correctness, and whether the output constituted an improvement over the original compiler error.
Datasets
Because no standard benchmark exists for this specific task, the authors curated a targeted evaluation dataset:
- Errors: They selected 9 Python error messages previously identified in the literature as the most unreadable for novices.
- Code Snippets: For each error, they manually constructed 3 Python 3.6 programs of varying complexity (a simple few-line script, a script using strings/functions, and a complex script utilizing external libraries like PyGame or pandas).
This resulted in 27 distinct code-error pairs. Multiplied by the 3 temperature variations, they evaluated a total of 81 unique Codex outputs.
Key Insights and Ideas
- Turn Down the Heat: Setting the LLM temperature to
0.0(deterministic) yielded significantly better results across the board. "Creative" generations (temperature0.7) were far more prone to hallucinations and unhelpful tangents. - Confident but Wrong: When Codex failed, it did so with a highly confident tone. A major pitfall was its tendency to blame indentation for errors actually caused by typos or missing brackets. For novices who already struggle with syntax, these authoritative but incorrect hints could easily introduce deep misconceptions.
- Directional Utility: Interestingly, the educators noted that an explanation could be technically flawed but still count as an "improvement" if it successfully nudged a stuck student toward the correct area of their code.
Key Results
The quantitative analysis revealed a stark contrast between the model's readability and its accuracy:
- High Readability: 88% of the generated explanations were deemed highly comprehensible and written in proper English.
- Mediocre Accuracy: While Codex provided an explanation 84% of the time, it was only factually correct in 48% of cases. Similarly, it offered a code fix 70% of the time, but only 33% of those fixes were actually correct.
- Net Improvement: Despite the errors, the instructors judged that Codex's output was a net improvement over the raw compiler error in 54% of all cases. When isolating only the deterministic (
temp=0.0) runs, this improvement rate jumped to over 70%.
Limitations and Future Work
The study notes several limitations: it relied on synthetic, short code snippets with singular bugs, whereas real student code is typically longer, messier, and contains multiple overlapping errors. Additionally, the evaluation used Python 3.6; newer iterations of Python (like 3.10+) have already natively improved some of these cryptic error messages.
For future work, the authors suggest exploring few-shot learning (providing Codex with a few examples of good explanations in the prompt) rather than the zero-shot approach used here. They also advocate for a "human-in-the-loop" framework, where LLMs are used by instructors to pre-generate error-explanation banks that are manually verified before being shown to students.
Summary updated