LLM-itation is the Sincerest Form of Data: Generating Synthetic Buggy Code Submissions for Computing Education

Juho Leinonen, Paul Denny, Olli Kiljunen, Stephen MacNeil, Sami Sarsa, Arto HellasarXiv 2024

TL;DR

Researchers have demonstrated that GPT-4o can generate synthetic "buggy" code submissions that statistically mirror the error patterns of real students. By providing the model with real-world test failure frequencies, the resulting synthetic datasets become indistinguishable from actual student data in terms of test case failure distributions, offering a powerful, privacy-preserving tool for computing education research.

What Problem Does This Paper Address?

In computing education research (CER), data is the lifeblood of progress. It is essential for understanding student behavior, training predictive models, and validating new assessment tools. However, high-quality datasets of student code submissions are notoriously difficult to share. Strict privacy regulations like GDPR and the inherent challenges of anonymizing source code mean that most valuable data remains siloed within individual institutions.

While Large Language Models (LLMs) have proven exceptionally good at generating correct code, their ability to deliberately generate incorrect code—specifically code that fails in the same subtle ways students' code does—is less explored. If LLMs can successfully "imitate" student errors, researchers could generate massive, shareable, and privacy-compliant synthetic datasets to accelerate the field.

Methods

The authors evaluated the state-of-the-art GPT-4o model's ability to generate semantically incorrect (but compilable) solutions for 20 different programming exercises. They tested three distinct prompting strategies to see how much "context" the model needed to be realistic:

  1. Baseline: A simple request to generate five incorrect solutions with semantic bugs.
  2. Test-case-informed: The baseline prompt plus the actual unit tests for the exercise.
  3. Frequency-informed: The baseline prompt plus unit tests and the real-world failure frequencies (how often students failed each specific test).

The researchers then ran these synthetic submissions through the same autograders used in the original courses. They compared the "pass rates" of individual unit tests between the synthetic data and real student data using statistical methods like the Kruskal-Wallis H test and Mann-Whitney U tests.

Figure 1: The prompts used in the study. The baseline prompt did not include the blue and yellow highlighted parts. The test-case-informed prompt included the blue highlighted part on top of the baseline prompt. The frequency-informed prompt included both the blue and yel- low highlighted parts on top of the baseline prompt. The bolded parts indicate variables for which content depended on the exercise.

Datasets

The study utilized two diverse datasets to test the generalizability of the approach:

  • C Context: 10 functions from a C programming project at the University of Auckland, involving 2,405 incorrect submissions from 1,751 students.
  • Dart Context: 10 exercises from introductory and advanced Dart courses at Aalto University, comprising 24,719 incorrect submissions from 5,322 students.

Summary of the C programming project functions used for evaluation. Summary of the Dart programming exercises used for evaluation.

Key Insights and Ideas

  • The "Subtlety" Gap: LLMs often struggle to be "partially" wrong. In some exercises, the model generated bugs that were too obvious, causing the code to fail every test, whereas real student bugs are often more subtle and pass a subset of tests.
  • Language and Complexity Paradox: Surprisingly, the synthetic data for Dart (a less common language) was more similar to real data than the C data. The authors hypothesize this is because the Dart exercises were less complex, making it easier for the model to hit the "sweet spot" of student-like errors.
  • Data-Driven Prompting Wins: For the more complex C exercises, only the frequency-informed prompt produced data that was not statistically different from real student data. This suggests that for LLMs to truly mimic students, they need to be "told" what common failure patterns look like.
  • Privacy-Preserving Research: This work validates that synthetic data can serve as a high-fidelity proxy for real student submissions, potentially bypassing the legal and ethical hurdles of sharing sensitive educational data.

Key Results

The core finding is that LLMs can generate synthetic incorrect submissions that are statistically similar to real student data regarding test case failure distributions.

As shown in the results table below, for the Dart exercises, all three prompting strategies produced distributions that were statistically equivalent to real data (p = 0.83). For the C exercises, while the baseline and test-case-informed prompts were significantly different from real data, the frequency-informed prompt achieved statistical similarity (p = 0.07).

Table 3: Results of the analysis. The “Real” column shows statistics for the real student data (only incorrect solutions). The other three columns show the statistics for each of the three prompts we used. For each exercise, there were multiple unit tests. The range, mean, and standard deviation of the percentage of buggy solutions that pass at least one unit test are shown for each condition (real, baseline, test-case informed, frequency-informed). In addition, the average differences (deltas) between the real data and the synthetic data are shown for the means and standard deviations.

Limitations and Future Work

The authors acknowledge several limitations:

  • Semantic Focus: The study only looked at semantic bugs (logic errors) and required the code to compile. Real student data often includes syntax errors that prevent compilation.
  • Black-Box Evaluation: The similarity was measured by test failures, not by analyzing the actual code structure or the logic of the bugs themselves. An LLM might fail a test for a completely different reason than a student would.
  • Prompting Modalities: Some C exercises included diagrams in their original descriptions that were not provided to the LLM, which likely hindered the model's performance on those specific tasks (e.g., the "Bounding Rectangle" exercise).

Future research could explore whether LLMs can generate realistic correct solutions (which have their own distinct patterns) and whether these models can simulate the "learning trajectory" of a student over multiple failed attempts.

Summary updated

BibTeX
@misc{leinonen2024llm,
  author = {Juho Leinonen and Paul Denny and Olli Kiljunen and Stephen MacNeil and Sami Sarsa and Arto Hellas},
  title = {{LLM-itation is the Sincerest Form of Data: Generating Synthetic Buggy Code Submissions for Computing Education}},
  year = {2024},
  eprint = {2411.10455},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.10455},
}
Figure