Beyond BLEU: A Semantic Evaluation Method for Code Translation
This paper proposes a novel semantic evaluation methodology for code translation that utilizes compiler testing to measure execution correctness, demonstrating that LLM-based decompilers significantly outperform heuristic approaches while traditional syntactic metrics like BLEU fail to correlate with functional accuracy.
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 translate a recipe from a foreign language into English.
The Old Way: Counting Words
Traditionally, when computers check if a translation is good, they use a method called BLEU. Think of this like a teacher grading a translation by simply counting how many words match the original, ignoring the meaning.
- The Problem: If the original recipe says "Add a pinch of salt," and the translation says "Add a tiny bit of salt," the computer thinks they are very different because the words don't match perfectly.
- The Bigger Problem: If the original says "Bake at 350°F" and the translation accidentally says "Bake at 500°F," the computer might still give them a high score because the words look similar. The result? You get a burnt cake, but the computer says, "Great job!"
The authors of this paper argue that for computer code, this "word-counting" method is useless. Two programs can look completely different on the page but do the exact same thing (like two different ways to tie a shoe). Conversely, two programs can look almost identical but do completely different things (like a recipe that says "add sugar" vs. "add salt").
The New Way: The Taste Test
Instead of just looking at the words, the authors propose a "Taste Test" approach. They want to see if the translated code actually works the same way as the original.
Here is how their new method works, using a creative analogy:
- The Generator (The Chef): They use a tool called Csmith to automatically cook up thousands of random, simple computer programs. It's like a robot chef making thousands of random, tiny dishes.
- The Reference Dish: They run these original programs and measure a specific "flavor profile" (a mathematical checksum) of the result. This is their baseline.
- The Translation: They feed the original code to a translator (either a human-like AI or a traditional rule-based tool) to get the "translated" code.
- The Re-Cooking: They take that translated code, cook it again, and measure the new "flavor profile."
- The Verdict: If the flavor profiles match perfectly, the translation is Semantically Correct. It means the code does the exact same job, even if the words look different. If the flavors don't match, the translation failed, even if the words looked similar.
What They Found
They tested this method on two types of translators:
- The Old School (Heuristic): These are traditional tools that follow strict rules.
- The New AI (LLM): A large language model trained to translate code.
The Results:
- The AI Wins: The AI translator was much better at keeping the "flavor" (the actual function) of the code intact compared to the old rule-based tools.
- The Old Metric is Broken: When they looked at the "word-count" scores (BLEU), they found zero connection to whether the code actually worked.
- Sometimes the AI got a low word-match score but the code worked perfectly.
- Sometimes the AI got a high word-match score, but the code was broken.
The Bottom Line
The paper concludes that we need to stop grading code translations by how much they look like the original. Instead, we must grade them by whether they act like the original. The old way of counting words is like judging a car by how much it looks like a Ferrari, while the new way is actually driving it to see if it runs. The authors show that the "driving test" reveals that AI is getting much better at this task, while the "look-alike" test is misleading us.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.