Teaching Language Models How to Code Like Learners: Conversational Serialization for Student Simulation

Charles Koutcheme, Juho Leinonen, Arto HellasarXiv 2026

TL;DR

This paper introduces a framework to train open-weight language models to act as "artificial students" by serializing raw programming logs into a conversational format. By framing the student-grader interaction as a multi-turn dialogue and applying preference optimization, the trained models accurately mimic the step-by-step, error-prone debugging trajectories of real human learners rather than jumping straight to perfect code.

What Problem Does This Paper Address?

In computer science education, evaluating new tutoring strategies, automated feedback tools, or assignment difficulties at scale is incredibly difficult without repeatedly disrupting real classrooms. "Artificial students"—AI models that simulate how real students behave—offer a solution.

However, existing approaches typically rely on prompting large, proprietary LLMs. These models suffer from a major flaw: they are too good at coding. Even when explicitly told to act like a novice, a model like GPT-4 or GPT-5-mini defaults to expert-like solutions, fixing bugs instantly. They fail to capture the dynamic, iterative, and often messy nature of a student's actual debugging process. Furthermore, relying on proprietary APIs raises severe data privacy, cost, and institutional dependency concerns.

Methods

The authors address this by training smaller, open-weight models (Qwen 4B and 8B) directly on authentic student process data using a three-part pipeline:

  1. Conversational Serialization: The core innovation is turning raw programming logs into a standard chat format. The System prompt establishes the persona of a novice student. The User turns represent the learning environment (providing the initial assignment description and subsequent autograder feedback like compiler errors or test case counts). The Assistant turns contain the student's actual code submissions.
  2. Supervised Fine-Tuning (SFT): The model is trained to predict the student's code submissions (Assistant turns) given the prior history of code and grader feedback.
  3. Preference Optimization (DPO & DAPO): To prevent the model from "cheating" and skipping straight to the correct answer, the authors use Direct Preference Optimization (DPO). They construct pairs where the preferred completion is the student's actual next step, and the dispreferred completion is a later step in the trajectory with a different grade. They also experiment with an online reinforcement learning variant called DAPO (based on GRPO).
Example of conversational serialization mapping student attempts and grader feedback into a dialogue format.

Datasets

The framework was evaluated using FalconCode, a large-scale, multi-year dataset containing Python code submissions from an introductory computer science course (CS1) at the United States Air Force Academy.

  • Training Set: 1,762 trajectories from Spring 2021.
  • Test Set: 1,000 randomly sampled trajectories from Spring 2022 to mimic a realistic deployment scenario.
  • Only medium-sized "Lab" assignments (10–50 lines of code) were used, filtering out non-compiling syntax errors and completely inactive trajectories.

Key Insights and Ideas

  • Autograder Feedback is More Valuable than Code History: Models trained with environment feedback (SFT) outperformed models trained purely on a history of prior code edits (PARA). Grader feedback provides a direct, high-signal condition for the next logical edit, whereas long code histories eventually suffer from diminishing returns.
  • The "Expert Bias" of Large Models: Prompted proprietary models like GPT-5-mini fail as simulators because their strong coding capabilities override their personification prompts. They immediately generate near-perfect code, resulting in low simulation "coverage" because they refuse to make the realistic intermediate mistakes that human students make.
  • DPO Acts as a Behavioral Brake: By explicitly penalizing the model for jumping ahead to later, higher-scoring code states prematurely, DPO successfully forces the model to follow the incremental, step-by-step progression of a real learner.

Key Results

The models were evaluated on three main metrics over a 5-step autoregressive rollout: Coverage (how long the model tracks the student before prematurely generating a 100% correct solution), Grade Proximity (functional alignment with the student's scores), and CodeBLEU (syntactic similarity).

Figure 1: Performance across rollout steps. Coverage (top), Grade Proximity (middle) and CodeBLEU (bottom) as a function of autoregressive steps ahead (k=1 to k=5).
  • DPO Dominates Coverage: The DPO-tuned Qwen-4B model achieved a stunning 0.982 coverage score, meaning it almost never skipped ahead to the final solution prematurely. In comparison, the baseline GPT-5-mini scored a dismal 0.340 due to its tendency to solve the problem immediately.
  • Tracking Grade Progression: As shown in the rollout analysis, DPO-trained models closely mirrored the gradual, upward trajectory of real student grades across an assignment, whereas untrained base models generated flat, random performance lines independent of the student's actual position.
Figure 2: Grade progression across normalized trajectory po- sition. Comparison of predicted grades between artificial stu- dent models and real students (black dashed, the average). The x-axis represents normalized position (by length) within a student’s problem-solving trajectory (0 = start, 1 = end). Shaded regions indicate 95% confidence intervals. The ground truth line does not reach 1.0 as some students failed. The abrupt jump reflects the proportion of students who resolve multiple failing test cases in a single revision.

Limitations and Future Work

  • Success Skew: The dataset is heavily skewed toward successful students; 95% of the trajectories end in a perfect score. The current framework does not reliably simulate struggling students who ultimately abandon the assignment.
  • Lack of Tools & Reasoning: The current model generates code blindly without an internal execution loop. The authors propose exploring agent-based architectures where the artificial student can interact with an IDE, run its own code, and generate "Chain-of-Thought" reasoning traces before submitting.
  • Single-Course Scope: The evaluation was limited to one dataset (FalconCode), one language (Python), and one model family (Qwen). Cross-institutional validation remains an open task.

Summary updated

BibTeX
@misc{koutcheme2026teaching,
  author = {Charles Koutcheme and Juho Leinonen and Arto Hellas},
  title = {{Teaching Language Models How to Code Like Learners: Conversational Serialization for Student Simulation}},
  year = {2026},
  eprint = {2604.10720},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.10720},
}
Figure