NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Code-DKT: A Code-based Knowledge Tracing Model for Programming Tasks

Yang Shi, Min Chi, Tiffany Barnes, Thomas W. Price · DOI

Introduction

Knowledge Tracing (KT) serves as the backbone of modern Intelligent Tutoring Systems (ITS), enabling platforms to predict a student's future performance based on their historical interactions. Traditionally, KT models have been domain-general, treating student attempts as a sequence of binary outcomes: correct (1) or incorrect (0). While effective for simple multiple-choice questions, this binary approach is significantly limited in complex domains like computer science education.

In programming, an "incorrect" submission can range from a trivial syntax error to a deep-seated logical misconception. Conversely, two "correct" solutions might reflect different levels of mastery—one being a brute-force approach and the other an elegant, efficient implementation. By ignoring the rich structural information within the source code, standard KT models lose critical context. Code-DKT addresses this gap by integrating code structure analysis directly into the knowledge tracing process.

Methodology: Beyond Binary Labels

Code-DKT enhances the standard Deep Knowledge Tracing (DKT) framework by incorporating structural features of student code. The architecture relies on two primary components:

  1. Deep Knowledge Tracing (DKT): A baseline model using Long Short-Term Memory (LSTM) networks to maintain a hidden "knowledge state" that evolves as students progress through a curriculum.
  2. code2vec Integration: To process raw source code, the model utilizes code2vec, which represents programs as a collection of paths through an Abstract Syntax Tree (AST). This allows the model to capture structural logic, such as loops, conditional branches, and variable declarations, rather than just keyword counts.

Score-Attended Path Selection

A key innovation of Code-DKT is its attention mechanism. The researchers found that naive methods, such as TF-IDF, often degrade performance. To solve this, Code-DKT uses a "Score-Attended" layer. By concatenating the student's current correctness score with code path embeddings before the attention layer, the model learns to "attend" to specific code structures most associated with success or failure. This ensures the model focuses on the most pedagogically relevant parts of the code.

Experimental Setup

The model was evaluated using a dataset from an introductory Java programming course at a large US university. The dataset, stored in the standardized ProgSnap2 format, included:

  • 410 students
  • 50 unique problems across five assignments
  • Imbalanced outcomes: Only 23.7% of attempts were correct, reflecting the iterative nature of learning to program.

Key Results and Insights

Performance Gains

Code-DKT consistently outperformed traditional models. Across all assignments, it achieved a 3.07% to 4.00% improvement in AUC (Area Under the Curve) compared to standard DKT. On the first assignment, Code-DKT reached 74.31% AUC, significantly higher than standard DKT (71.24%) and the classic Bayesian Knowledge Tracing (BKT) (63.78%). These gains are notable because they are comparable to the improvements typically seen when moving from simple LSTMs to complex transformer-based architectures, suggesting that data quality (code features) is just as vital as model complexity.

Predicting the "First Attempt"

One of the model's most significant strengths is its ability to predict performance on a student's very first attempt at a new problem. Because Code-DKT understands underlying structural patterns (like nested if statements), it can recognize when a student has demonstrated mastery of a concept in a previous, different problem. This cross-problem transfer of knowledge is difficult for models that only see binary success/failure strings.

The Overconfidence Trap

Case studies revealed that Code-DKT tends to be more "confident" in its predictions (values closer to 0 or 1) than standard DKT. While this usually leads to higher accuracy, it can occasionally lead to "overconfidence." For example, if a student's code looks structurally sound but contains a single logical flaw, the model might prematurely predict success.

Conclusion and Future Work

Code-DKT demonstrates that the structural content of student work is a powerful signal for knowledge tracing in programming. By moving beyond binary outcomes, the model provides a more nuanced understanding of student mastery.

Future research directions include:

  • Scaling the Data: Testing the model on larger datasets (100k+ users) to further refine the deep learning components.
  • Language Generalization: Exploring representations like CodeBERT to extend the model's utility across multiple programming languages beyond Java.
  • Proactive Intervention: Utilizing these high-accuracy predictions to trigger "proactive" help, such as offering a hint or a worked example before a student even makes their first attempt at a challenging new task.

Summary updated

BibTeX
@inproceedings{shi2022code,
  author = {Yang Shi and Min Chi and Tiffany Barnes and Thomas W. Price},
  title = {{Code-DKT: A Code-based Knowledge Tracing Model for Programming Tasks}},
  booktitle = {EDM},
  year = {2022},
}
Figure