Research Article
Large language model generation of plausible semantic distractors for data science Parsons problems
Synthesis: Zou, Oliveira, and Chee asked Gemini-2.5-flash to write semantic distractors for 315 Python data science Parsons problems drawn from a second-year undergraduate subject, then tested each distractor for compilability and output divergence before and after four validated exemplars were added to the prompt. Under zero-shot chain-of-thought prompting, 750 of 1,260 distractors (59.52%) passed every inclusion check, and 90.78% of those that compiled also changed the program's output. The few-shot refinement made generated code run more reliably, a relative gain of 10.91%, but it improved semantic misconception targeting only for logic-based distractors, not method-based ones.
Parsons problems, a scaffolded code-rearrangement format, are well studied in introductory programming and thin in data science. Distractors carry the pedagogy: a wrong block that compiles and then computes something else forces a student to reason about why the near-identical line is wrong. Authoring them by hand needs both domain knowledge and teaching judgment, and that is the bottleneck this paper attacks.
Key Findings
- An LLM can write usable distractors, but about six in ten survive the filters. 750 of 1,260 met every inclusion criterion, split almost evenly between logic-based and method-based errors.
- Syntactic breakage, not semantic emptiness, is the dominant failure. Just over half compiled, but 90.78% of those that did changed the program's output, so compilability is the filter that carries the quality gain.
- Validated exemplars reliably improve syntax. Four hand-picked distractors in the prompt raised compilability from 0.5787 to 0.6417, a 10.91% relative gain.
- Exemplars help logic errors and hurt method errors. Divergent logic-based distractors rose from 30.4% to 34.2%; for method-based ones the ideal outcome slipped from 22.1% to 21.3% while useless compile-success-with-output-match cases rose from 1.5% to 4.0%.
- Method-based distractors are the harder design problem. The refined model produced legal code that swapped one scaling function for another with the same net result: it looks like a distractor and assesses nothing.
- The educator stays in the loop by design. The model proposes candidates with a stated rationale; a human decides whether each reflects a misconception worth testing.
How the workflow runs
Materials came from an automated Parsons platform at the University of Melbourne: 315 puzzles, each with a problem description, the correct Python 3 lines, the expected output, and CSV data where needed, built from seven data science topics crossed with nine application contexts from a second-year undergraduate subject. The same 315 puzzles went to the model in both rounds, so the batches are comparable puzzle for puzzle.
Stage 1 prompted Gemini-2.5-flash at a temperature of 0.7 with zero-shot chain-of-thought prompting, asking for two logic-based and two method-based distractors per puzzle plus a short rationale for each: 1,260 in all. A logic-based distractor keeps the procedure and breaks the reasoning inside one step, as when Mean Squared Error replaces Mean Absolute Error. A method-based one swaps the method, as when a sum replaces a mean.
Stage 2 replaced the matching correct line with each distractor and checked the modified program twice: did it compile without errors, and did its output diverge from the correct solution. Code that ran and changed nothing counted as a failure. Two authors reviewed a sample of roughly 20% of the distractors and their stated objectives.
What the first batch produced
Of the 1,260 distractors, 750 (59.52%) passed: 372 of 630 logic-based (59.05%) and 378 of 630 method-based (60.00%). Functional testing was harsher. 57.87% compiled inside the original program and 52.53% produced divergent output. The ratio is the point: once a distractor cleared compilation, 90.78% of them changed behavior. The retained distractors are the familiar silent errors, confused metrics and plausible but wrong Pandas functions, which raise no exception in data science.
What the exemplars changed, and where they did not
Stage 3 kept the 315 puzzles and appended four distractors that had passed every check: an aggregation logic error, covariance where correlation was intended, tokenization in place of lemmatization, and reversed ground-truth and predicted values. Few-shot prompting raised compilability to 0.6417 from 0.5787 and divergence to 0.5557 from 0.5253, relative gains of 10.91% and 5.78%.
The average hides a split. For logic-based distractors, compile failures fell from 15.3% to 11.1% and the ideal compile-success-with-divergence outcome rose from 30.4% to 34.2%, so syntax gains became pedagogical value. For method-based distractors, compile failures fell from 26.8% to 24.7%, yet compile-success-with-divergence slipped from 22.1% to 21.3% and compile-success-with-output-match rose from 1.5% to 4.0%. Taught by method-based exemplars, the model optimized for code that runs and then chose substitutions that leave the arithmetic unchanged.
What this means for practice
- Instructors. Generate candidates, then keep the compile-and-compare check as a hard filter. Plan on roughly six in ten surviving, and treat survivors as candidates for judgment rather than a finished item bank.
- Instructional designers. Add validated exemplars when the target error is a reasoning error. For method-substitution errors they can cost diagnostic value, so review that category line by line or leave it to zero-shot generation.
- Educational technology developers. Build both checks into the authoring pipeline. Compilability catches most failures; comparing output against the reference solution catches the compiled-but-identical distractors a syntax check misses.
- Researchers. These are proxy metrics. Whether a divergent distractor produces the productive struggle the design assumes needs classroom testing, not another generation round.
Limitations
- 315 puzzles came from one platform and one second-year course, so the rates may not transfer to open-ended machine learning workflows or other languages such as R.
- No learners took part. Plausibility rests on two authors reviewing about 20% of the output, and compilability and divergence are automated proxies for pedagogical quality.
- One model at one temperature was tested, so the prompting comparison does not show how far the effect generalizes.
- The method-based decline rests on small shares: differences of a few percentage points on a per-type base.
- The study shows the workflow is feasible, not that Parsons problems work as well in data science as in introductory programming.
Citation
Zou, L., Oliveira, E., & Chee, G. V. F. (2026). Large language model generation of plausible semantic distractors for data science Parsons problems. In Proceedings of ASCILITE 2026: The Future is Connection (pp. 441–450).