This paper explores the practical utility of Large Language Models (LLMs) in computer science education by integrating AI-generated code explanations into a web development e-book. The researchers found that while students frequently engaged with these automated explanations—particularly for complex code—they preferred high-level summaries over granular, line-by-line breakdowns.
TL;DR
The researchers deployed GPT-3-generated code explanations in a live university course to see if AI could alleviate the burden of manual content creation. Their findings suggest that students find LLM-generated summaries helpful for learning, though engagement is heavily influenced by code complexity and user interface design.
What Problem Does This Paper Address?
Providing high-quality, multi-level explanations for code snippets is a significant pedagogical challenge. Students benefit from different levels of abstraction: a novice might need a line-by-line syntax breakdown, while a more experienced student might only need a high-level summary of a function's purpose.
However, manually authoring these varied explanations for every code snippet in a textbook is incredibly time-consuming for instructors. While previous automated tools existed, they often required significant manual setup or were limited to specific programming languages. This paper investigates whether modern LLMs can fill this gap by generating accurate, helpful explanations on demand and how students actually interact with them in a real-world learning environment.
Methods
The researchers conducted an in-situ study within a web software development course at Aalto University. Their approach involved several key steps:
- Model Selection & Prompt Engineering: They compared OpenAI Codex and GPT-3 (text-davinci-002). Through iterative prompt engineering, they discovered that GPT-3 produced more concise and natural language explanations, whereas Codex often included unwanted code or went off-topic.
- Explanation Types: They generated three distinct types of explanations for 13 different code snippets:
- Line-by-line: Detailed syntax and logic for each line.
- Summary: A high-level overview of the code's purpose.
- Concepts: A list of the key programming concepts used.
- Integration: These explanations were embedded into an interactive e-book. Students could access them via buttons placed directly beneath code snippets.
- Data Collection: The team logged interaction data (which buttons were clicked, time spent viewing) and collected subjective ratings via 5-point Likert scales regarding the accuracy and usefulness of the explanations.
Datasets
This study did not introduce a new machine learning dataset. Instead, it utilized:
- Course Materials: 13 JavaScript/Deno code snippets from a web development e-book.
- Student Interaction Data: Logs from 58 students who viewed a total of 176 explanations during a three-week study period.
Key Insights and Ideas
- Abstraction Preference: Even though "line-by-line" explanations were the most viewed (likely due to being the leftmost button in the UI), students rated "summary" explanations as the most useful for their learning.
- Complexity Drives Demand: Students were significantly more likely to request explanations for challenging code snippets (e.g., in advanced chapters) than for simple "Hello World" examples.
- GPT-3 vs. Codex for Education: While Codex is specialized for code generation, the researchers found GPT-3 better suited for explaining code in natural language. Codex tended to "overfit" the response structure or include extraneous code snippets.
- The "Curiosity" Factor: Initial engagement was high as students explored the new AI feature, but sustained use was primarily linked to the perceived difficulty of the material.
Key Results
- Accuracy: Students rated the explanations as highly accurate, with a mean score of 4.5/5 for matching the code.
- Helpfulness: The perceived usefulness for learning averaged 3.8/5.
- Engagement Correlation: There was a strong positive correlation (r = 0.92) between the length of a code snippet and the time students spent reading the AI-generated explanation.
- UI Bias: Line-by-line explanations accounted for 58.5% of all views, but they were consistently rated lower in helpfulness compared to summaries and concept lists.
Limitations and Future Work
The authors acknowledge several limitations:
- Selection Bias: The study only tracked students who chose to click the buttons; these may be more motivated or, conversely, more struggling than the average student.
- UI Influence: The placement of buttons likely skewed which explanation types were viewed most often.
- Language Barriers: While the course was in English, many students were native Finnish speakers, which might affect their interaction with natural language explanations.
- Default Value Errors: The feedback form had a default value of 3, which may have led to "noisy" data if students closed the form without intentionally rating.
Future Directions: The researchers suggest moving toward "Live Code Explanations," where LLMs provide real-time feedback on code written by the students themselves, rather than just explaining static textbook examples. They also propose using "learnersourcing" to have students help refine and improve AI-generated explanations over time.
Summary updated