← Latest papers
💻 computer science

Not All Tokens Matter: Data-Centric Optimization for Efficient Code Summarization

This paper demonstrates that efficient code summarization requires language-specific token curation strategies rather than uniform reduction, revealing that Abstract Syntax Trees significantly boost performance in Java while Function Signatures are optimal for Python, challenging the assumption of cross-language transferability in data-centric optimization.

Original authors: Saima Afrin, Zaiyu Cheng, Tushar Sharma, Alexander Serebrenik, Massimiliano Di Penta, Antonio Mastropaolo

Published 2026-07-20
📖 4 min read☕ Coffee break read

Original authors: Saima Afrin, Zaiyu Cheng, Tushar Sharma, Alexander Serebrenik, Massimiliano Di Penta, Antonio Mastropaolo

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 read a library of millions of books and write a short summary for each one. This is the world of Large Language Models (LLMs), the AI engines behind tools that can write code, answer questions, and even tell jokes. But here's the catch: these robots are incredibly hungry. To learn, they need to chew through massive amounts of text, which requires giant, expensive computers and a lot of electricity. It's like trying to feed a dragon a whole forest just to get it to say "hello."

In the world of software, this robot's job is code summarization: taking a block of computer instructions (code) and turning it into a simple sentence that explains what it does. Think of it as translating a complex recipe into a quick headline like "Make a cake." The problem is that computer code is often full of repetitive, boring words and symbols that don't actually change the meaning of the recipe. If you try to teach the robot by feeding it every single word, including the "and," "the," and "if," you waste time and energy. The big question researchers have been asking is: Can we teach the robot just the important parts, skip the fluff, and still get a perfect summary?

This paper, titled "Not All Tokens Matter," dives right into that question. The authors, a team of computer scientists, decided to test a bold idea: what if we don't need to feed the robot the whole code? What if we can cut out the boring parts before the robot even sees them? They didn't just guess; they ran three different experiments to see which way of "trimming the fat" works best. They tried turning code into a structural diagram, stripping it down to just the function names, and using a smart filter to remove common, useless words.

Here is the twist they discovered, and it's a bit like a magic trick that only works on certain days. They found that there is no single "best" way to trim the code. It depends entirely on the language the code is written in.

When they worked with Java (a language that is very strict and uses a lot of words to say simple things), the best strategy was to turn the code into a structural diagram (called an Abstract Syntax Tree). This method chopped out about 56% to 73% of the words but actually made the robot better at summarizing, improving its score by 37%. It was like taking a dense, wordy novel and turning it into a clear, organized outline—the robot understood it perfectly.

However, when they switched to Python (a language known for being short and sweet), that same structural diagram was a disaster. It made the robot's performance drop by nearly 50%. Why? Because Python relies heavily on the specific names of things to make sense. When they tried the diagram, they accidentally threw away the very clues the robot needed. Instead, for Python, the winning strategy was to throw away almost everything except the Function Signatures (the title and the ingredients list of the code). This method removed a massive 83% of the tokens but kept the quality high. It turned out that for Python, the "title" tells you everything you need to know.

There was also a third method, called CrystalBLEU, which acted like a smart eraser, removing common words that appear everywhere but don't add meaning. This one was a reliable "middle ground," working well for both languages and cutting out about 60% to 72% of the text without hurting the results too much.

The team also built a new, high-quality test set of Python code summaries called PyBench to make sure their results were real, and they created a new tool called SIDEpy to check if the code and the summary actually matched up in meaning, not just in words. They found that simply removing words isn't enough; you have to remove the right words. If you cut out the wrong ones, the robot gets confused.

In the end, the paper suggests that the old idea of "bigger is better" is wrong. You don't need to feed the robot the whole forest. If you know the language, you can give it a carefully curated handful of leaves, and it will learn just as well, if not better. The key takeaway is that one size does not fit all: what works for Java will break Python, and vice versa. To make AI efficient, we need to be careful editors, not just big feeders, tailoring our approach to the specific style of the code we are teaching.

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 →