← Latest papers
🤖 AI

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

This paper proposes a method for training open-weight language models to simulate student programming behavior by converting temporal process logs into conversational dialogues and applying a supervised fine-tuning plus preference optimization pipeline, which significantly improves the models' ability to replicate authentic debugging patterns compared to code-only approaches and prompted baselines.

Original authors: Charles Koutcheme, Arto Hellas, Juho Leinonen

Published 2026-04-14
📖 4 min read☕ Coffee break read

Original authors: Charles Koutcheme, Arto Hellas, Juho Leinonen

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are a teacher trying to figure out the best way to help a student learn to code. You want to test different teaching strategies, but you can't ask 1,000 real students to try them out every time—it's too expensive, takes too long, and invades their privacy.

So, you wish you had a "Digital Twin" of a student: a computer program that acts exactly like a real learner. It makes the same mistakes, gets frustrated at the same points, and slowly figures things out just like a human would.

This paper is about building that Digital Twin using Artificial Intelligence. Here is the simple breakdown of how they did it and why it works.

1. The Problem: AI is Too Perfect

Usually, when we ask big AI models (like the ones that write essays or code) to act like a student, they fail. Why? Because they are too smart. If you ask them, "Write a Python function to calculate an average," they instantly write the perfect code.

Real students don't do that. Real students:

  • Write code with a typo.
  • Get an error message.
  • Panic a little.
  • Fix the typo.
  • Get a "half-right" result.
  • Try again.

The AI skips all the messy middle steps. It jumps straight to the answer, which makes it useless for testing how to teach someone.

2. The Solution: Turning Logs into a Chat

The researchers realized that real students leave a "digital trail" of their work. Every time a student submits code, the computer system replies with feedback (like "Error: Variable not found" or "Test Passed: 8/8").

The team's big idea was to turn this history into a conversation.

Think of it like a chat log between a student and a robot teacher:

  • Student (Assistant): "Here is my code."
  • Robot Teacher (User): "Error! You forgot a colon."
  • Student (Assistant): "Oh, fixed it. Here is the new code."
  • Robot Teacher (User): "Good, but now 3 tests failed."
  • Student (Assistant): "Okay, I see the pattern. Here is the next try."

By formatting the data this way, the AI learns that learning is a dialogue, not a magic trick. It learns that you have to talk to the computer, get feedback, and try again.

3. The Training: "Show, Don't Just Tell"

They didn't just show the AI these chats; they taught it how to think like a student using two main steps:

  • Step 1: The Homework (Supervised Fine-Tuning): They showed the AI thousands of these chat logs so it could memorize the pattern: "When I see an error, I usually change this specific part of the code."

  • Step 2: The Coach (Preference Optimization): This is the secret sauce. Imagine the AI is taking a test. It generates two possible next steps:

    • Option A: A perfect solution (too smart, not realistic).
    • Option B: A messy, slightly broken solution that looks exactly like what a real student would write next.

    The "Coach" tells the AI: "No, don't pick Option A. Pick Option B. Real students make mistakes before they get it right." The AI learns to prefer the "messy" path because that's what real humans do.

4. The Results: A Realistic Student

They tested their new AI students (called "Artificial Learners") against real data from a university computer science course.

  • The Old Way (Prompting): The AI tried to act like a student but kept accidentally writing perfect code. It was like a child actor who suddenly speaks Shakespearean English.
  • The New Way: The AI they trained actually stumbled. It made the same types of errors, got the same grades, and took the same number of attempts to solve a problem as the real students.

Why Does This Matter?

Think of this as a Flight Simulator for Teachers.

Just as pilots practice in simulators before flying real planes, teachers and educational researchers can now use these "Artificial Students" to practice.

  • They can test a new tutoring app on 1,000 AI students to see if it actually helps.
  • They can see if a specific type of feedback confuses students or helps them.
  • They can do all this without bothering real humans or risking real grades.

The Bottom Line

The researchers figured out how to teach AI to be bad at coding in the right way. By turning student logs into conversations and teaching the AI to prefer "messy" progress over "perfect" answers, they created a tool that can simulate the real, frustrating, and rewarding journey of learning to code. This allows educators to build better tools for real students in the future.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →