Navigating Pitfalls: Evaluating LLMs in Machine Learning Programming Education
Smitha Kumar, Michael A. Lones, Manuel Maarek, Hind Zantout
TL;DR
The paper investigates whether Large Language Models can reliably identify common ML code pitfalls and generate learner-focused feedback in an educational context. It compares one closed and three open code-focused LLMs using a semi-synthetic dataset of 20 ML-pipeline pitfalls coded into Python samples, evaluating recall (Recall@5) and the presence of knowledge of mistakes (KM) and knowledge of how to proceed (KH) in the feedback. Across pitfalls, average recall remains below 50% for all models, with preprocessing-stage errors being particularly hard to detect, while feedback tends to include actionable guidance when pitfalls are identified. The findings suggest open models offer a privacy-friendly, potentially configurable alternative to commercial models, but overall LLMs in their current form are not yet ready to support higher-level ML education or the transition to practice; the work highlights directions for improvement, including data selection, in-context learning, and targeted prompt design to enhance educational utility.
Abstract
The rapid advancement of Large Language Models (LLMs) has opened new avenues in education. This study examines the use of LLMs in supporting learning in machine learning education; in particular, it focuses on the ability of LLMs to identify common errors of practice (pitfalls) in machine learning code, and their ability to provide feedback that can guide learning. Using a portfolio of code samples, we consider four different LLMs: one closed model and three open models. Whilst the most basic pitfalls are readily identified by all models, many common pitfalls are not. They particularly struggle to identify pitfalls in the early stages of the ML pipeline, especially those which can lead to information leaks, a major source of failure within applied ML projects. They also exhibit limited success at identifying pitfalls around model selection, which is a concept that students often struggle with when first transitioning from theory to practice. This questions the use of current LLMs to support machine learning education, and also raises important questions about their use by novice practitioners. Nevertheless, when LLMs successfully identify pitfalls in code, they do provide feedback that includes advice on how to proceed, emphasising their potential role in guiding learners. We also compare the capability of closed and open LLM models, and find that the gap is relatively small given the large difference in model sizes. This presents an opportunity to deploy, and potentially customise, smaller more efficient LLM models within education, avoiding risks around cost and data sharing associated with commercial models.
