TL;DR
By training language models on 3.8 million real programming edit sequences (traces) rather than just final code snapshots, researchers successfully modeled not just what code is written, but how students write it. This approach allows models to capture individual student styles, predict future programming behaviors like backtracking, and provide personalized, style-preserving error recovery.
What Problem Does This Paper Address?
Traditional code generation models are trained on massive datasets of static, final code repositories (like GitHub). While highly effective for generating standard code snippets, this paradigm completely ignores the iterative, messy process of human programming—the debugging loops, the trial-and-error, and the strategic shifts.
This gap is especially problematic in educational contexts, where understanding a student's learning trajectory and problem-solving strategy is more important than just evaluating their final submission. The authors tackle this by asking: What can language models learn if we train them on full, step-by-step development traces rather than just the final product?
Methods
The authors perform continued pretraining on language models (a 124M parameter GPT-2 and a 1B parameter OLMo-2) using three distinct paradigms for comparison:
- Trace: Training on the full sequence of real, chronological program states.
- Last: Training only on the final program state.
- Synthetic: Training on artificially generated edit sequences derived from the final program.
Crucially, the architecture incorporates a student embedding layer that maps unique student IDs to a 768-dimensional "soft token" prepended to the input sequence. This allows the model to condition its generations on individual student identities. To evaluate what these models actually learn, the authors use ridge regression and MLP probes on the learned code and student representations to predict future behaviors (e.g., whether a student will backtrack or how many attempts they will make).
Datasets
The paper introduces a massive, newly curated dataset from Pencil Code, a free online educational platform that uses a dual-modality (visual block-based and text-based) editor.
- Size: 248 GB containing 3.8 million unique programming traces.
- Scope: Spans 9 years (2015–2024) and covers over 1 million unique students.
- Contents: Each trace includes a hashed student ID, assignment title (e.g., "snowman"), and a temporally ordered sequence of executed program states with timestamps.
Key Insights and Ideas
- Code properties are student properties: A student's programming style—such as their tendency to add comments, their specific color choices, or how often they backtrack when stuck—is consistently captured by the student embedding layer.
- Real traces beat synthetic data: Models trained on actual human edit sequences learn significantly richer representations of problem-solving than models trained on clean, synthetically generated edit paths. Human programming is non-linear, and models need to see the "struggle" to accurately simulate it.
- Personalized Error Recovery: Because the model understands individual student styles, it can be steered to help a student recover from a broken code state. By swapping in a "strong student" embedding or adjusting time headers, the model can generate a path to correctness that respects the student's original coding style rather than forcing a generic solution.
Key Results
- Higher Quality & Diversity: The
tracemodel generates final programs that are more similar to ground truth (higher BLEU score) and show greater stylistic diversity (lower Self-BLEU score) than thelastorsyntheticbaselines.
- Predicting the Future: Probes trained on the
tracemodel's student embeddings successfully predicted trace-level metrics like goal backtracking ratios, total time spent, and the number of future attempts, significantly outperforming shuffled baseline controls.
- Rapid Few-Shot Adaptation: For entirely new students, the model can effectively adapt its student embedding with as few as 2 to 4 historical traces, making it highly practical for real-world classrooms.
- Effective Error Correction: In error-recovery tasks, the trace model successfully guided a failed program state to a working final state over 60% of the time, outperforming synthetic baselines.
Limitations and Future Work
- Novice Domain: The dataset is entirely sourced from Pencil Code, which focuses on novice programmers learning basic concepts. It remains an open question how well this approach scales to professional software engineering workflows or complex languages like C++ or Rust.
- Cold Start Problem: The model requires a few initial traces (2–4) to personalize to a new student; it cannot predict individual style for a completely unseen user from the first keystroke.
- Future Directions: The authors suggest integrating these models into intelligent tutoring systems for automated, personalized hint generation that evaluates the process of learning rather than just final correctness.
Summary updated