EmbeddedKittens: An Evaluation of Code Embeddings for Scratch

2026-07-21Software Engineering

Software Engineering
AI summary

The authors studied how to turn Scratch programs into formats that computers can understand for learning analysis. They tested nine different ways to embed Scratch code, including four large language models (LLMs) and five other popular methods. Their experiments showed that these embeddings can capture important information about the code's structure and meaning. This helps predict if a student's program will work correctly, even with small data from typical classrooms and no extra fine-tuning.

code embeddingmachine learninglearning analyticsScratch programminglarge language modelstoken sequencetransfer learningclassification taskfunctional correctnessblock-based programming
Authors
Benedikt Fein, Gordon Fraser
Abstract
The trend of embedding source code for machine learning applications also enables new opportunities in learning analytics in programming education, but which code embedding approach is most suitable for learning analytics remains an open question. A common approach to embedding source code lies in treating the code as a token sequence similar to natural language when training large language models~(LLMs). However, in case of visual block-based programming languages like Scratch, this approach cannot be applied directly. While text-based representations of block-based code can be created to apply LLMs to this problem, other dedicated embedding models could potentially exhibit improved performance by capturing additional structural information. In this paper, we therefore instantiate four LLMs and five different popular embedding approaches for Scratch programs, create a token-prediction and two different classification tasks with corresponding datasets, and empirically evaluate the models on them. Our experiments demonstrate that a transfer of code embeddings to the educational environment of Scratch is feasible. The embedding models trained on large open Scratch datasets capture relevant structural and semantic information about the code to enable learning analytics like predicting functional correctness of student programs, in the typically small classroom setting without requiring further task-specific model fine-tuning.