EmbeddedKittens: An Evaluation of Code Embeddings for Scratch
This paper empirically evaluates four large language models and five embedding approaches for Scratch programs, demonstrating that models trained on large open datasets can effectively capture structural and semantic information to support learning analytics tasks like predicting functional correctness in small classroom settings without requiring further fine-tuning.
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 trying to teach a super-smart robot how to understand human language. You feed it millions of books, movies, and websites, and eventually, it learns to predict the next word in a sentence with amazing accuracy. This is the magic of Large Language Models (LLMs). Now, imagine you want that same robot to understand source code—the instructions programmers write to tell computers what to do. Since code looks a bit like a strange, structured language, researchers have found that these robots can learn to understand it too, helping developers write software faster or even fixing bugs automatically.
But here's the twist: not all code looks like text. In schools, many kids learn to program using Scratch, a colorful, block-based system where you snap puzzle pieces together on a screen instead of typing lines of text. It's like building with Lego bricks rather than writing a story. The big question for scientists is: Can the same "robot brains" that read text-based code also understand these visual block puzzles? And if they can, which method works best? This matters because if we can teach robots to understand Scratch, we could build tools to help teachers grade homework, spot struggling students, or give instant hints, making learning to code much smoother for the next generation.
The Great Code Translator Challenge
In this study, researchers Benedikt Fein and Gordon Fraser set out to answer a tricky question: Can we teach computers to "understand" Scratch programs well enough to help in a classroom? They didn't just guess; they built a digital playground to test different kinds of "code translators."
Think of a code translator as a way to turn a complex Scratch program into a single, secret number (or a "vector") that captures the program's essence. If two programs are similar, their secret numbers should be close together. If they are different, the numbers should be far apart. The researchers wanted to see which translator was the best at this game.
The Contenders
They lined up five different types of translators to compete:
- The "Flat" Readers: These models treat the code like a simple list of words, ignoring the structure. It's like reading a recipe but ignoring the fact that some steps happen inside a "mixing bowl" and others on the "stove."
- The "Tree" Readers: These models look at the code's structure, like a family tree of instructions. They understand that some blocks are nested inside others.
- The "Flow" Readers: These are the most advanced. They don't just see the structure; they track how information moves through the program, like watching water flow through pipes. They know if a variable changes in one block and is used in another.
- The "Big Brains" (LLMs): These are the giant, pre-trained AI models (like the ones that power chatbots) that have already read millions of text documents. The researchers asked them to look at Scratch code and guess what it was doing.
The Test: Naming the Characters
To test these translators, the researchers created a game called "Sprite Naming." In Scratch, every character (or "sprite") has a name. The task was simple: show the model the code inside a sprite, and ask it to guess the sprite's name. It's like showing someone a character's diary and asking, "What is this character's name?"
The results showed a clear hierarchy. The winners were the "Flow" readers (specifically a model called GGNN). By paying attention to how the blocks connect and how data moves between them, these models were much better at understanding the "story" of the code. They guessed the sprite's name with significantly higher accuracy than the others.
The giant "Big Brain" models (LLMs) and the "Flat" readers performed poorly on this specific naming task. They struggled to guess the correct names because Scratch programs rarely use the fancy variable names or custom functions that these big models are used to seeing in text-based code. Instead, Scratch relies heavily on the structure of the blocks and how they connect. However, it is important to note that even the winning "Flow" model didn't get it perfect; it still made mistakes, meaning no model was a flawless oracle. The LLMs weren't the only ones failing to achieve perfect scores, but they were consistently outperformed by the models that understood the program's structure and flow.
The Language Barrier
The researchers also tested if the language the students used mattered. Scratch is used all over the world, in Brazil, China, Poland, and many other places. They found that the models worked best when the code was written in English or other languages using the Latin alphabet (like A, B, C). When the code used other writing systems (like Chinese characters or Russian Cyrillic), the models got confused. This suggests that for these tools to work globally, they need to get better at understanding different languages and symbols, not just English.
From Naming to Grading: Can We Use This in Class?
The real magic happened next. The researchers asked: "If these models are good at naming sprites, can they also help teachers?"
They tested two big ideas:
- Checking for Correctness: Can the model look at a student's messy program and tell if it works, even without running it? They found a strong link between the model's "understanding" of the code and whether the code actually passed tests. If the model thought the code was "close" to the solution, the code usually worked. This means these models could act as a "surrogate" to check homework instantly.
- Tracking Progress: Can the model show how much a student has improved? They used a special map to plot student progress. As students added features to their games, their "code map" moved closer to the final solution. The models successfully tracked this journey, showing teachers exactly where a student was stuck or how far they had come.
Interestingly, for these broader tasks (like classifying the type of project or tracking progress), the LLMs actually performed quite well, sometimes even matching or beating the specialized structural models. This suggests that while LLMs might miss the tiny structural details needed for naming a specific character, they are very good at understanding the "big picture" of a project.
The Verdict
The study concludes that yes, it is possible to use code embeddings for Scratch, but you have to choose the right tool for the job. For tasks requiring deep structural understanding (like naming a sprite), specialized models that understand the flow and structure of the blocks are the champions. The giant chatbots (LLMs) aren't the best fit for those specific puzzles because they miss the structural details that Scratch relies on.
However, for broader educational tasks like grading or tracking progress, the LLMs are surprisingly effective and can be just as good as the specialized models. Even better, these specialized models, once trained, can be used for other tasks—like grading or tracking progress—without needing to be retrained for every single new assignment. This is a huge win for teachers, as it means they could have powerful, automated tools to help students learn, even in small classrooms where there isn't enough data to train a new AI from scratch.
In short, the researchers found a way to give computers a "sense" of Scratch code that goes beyond just reading words. By understanding the shape and flow of the blocks, these models can help us build a smarter, more supportive future for programming education.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.