← Latest papers
💬 NLP

From Where Words Come: Efficient Regularization of Code Tokenizers Through Source Attribution

This paper introduces Source-Attributed BPE (SA-BPE), a regularization technique that modifies the standard BPE training objective to mitigate token imbalance and overfitting caused by diverse data sources, thereby reducing under-trained tokens in code tokenizers while maintaining inference efficiency and safety.

Original authors: Pavel Chizhov, Egor Bogomolov, Ivan P. Yamshchikov

Published 2026-04-16
📖 4 min read☕ Coffee break read

Original authors: Pavel Chizhov, Egor Bogomolov, Ivan P. Yamshchikov

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 teaching a robot to read and write computer code. To do this, you first have to teach the robot how to break sentences down into smaller, manageable pieces called tokens. Think of these tokens like LEGO bricks. If you want the robot to build a castle (write code), it needs a box of LEGO bricks that are the right shapes and sizes.

The standard way to make these bricks is called BPE (Byte-Pair Encoding). It's like a machine that looks at a huge pile of code from the internet and says, "Hey, these two letters appear together a lot, let's glue them into one brick!" It keeps gluing the most common pairs together until it has a vocabulary of bricks.

The Problem: The "Junk Drawer" Effect

The paper points out a major flaw in this standard method: The robot ends up with a box full of useless, weird bricks.

Because the training data comes from millions of different code repositories (projects), the standard BPE gets confused by specific, one-off things.

  • The Analogy: Imagine you are learning English by reading every book ever written. If one author accidentally types "ipsum" instead of "ipsum" in a placeholder text, the standard BPE might decide, "Oh, 'ipsum' is a real word!" and make a special brick for it.
  • The Result: The robot now has a brick for "ipsum" (with a typo), a brick for a variable name that only existed in one specific project 5 years ago, or a brick for a random string of numbers that never appears again.
  • Why it matters: These "junk bricks" take up space in the robot's memory. Worse, because the robot never actually uses them to build anything real, it doesn't know what they mean. When the robot sees them later, it might get confused, hallucinate (make things up), or even be tricked by hackers (jailbreaks) who use these weird bricks to bypass safety rules.

The Solution: Source-Attributed BPE (SA-BPE)

The authors propose a new method called SA-BPE. Instead of just asking, "How often does this pair of letters appear?" they ask, "Where does this pair appear?"

They introduce two new rules for making the LEGO bricks:

  1. The "Popularity Contest" (Repository Count): A brick is only allowed if it appears in many different code projects (repositories). If a weird variable name only shows up in one single project, SA-BPE says, "Nope, that's too specific. Don't make a brick for that."
  2. The "Language Passport" (Language Count): A brick is only allowed if it appears in many different programming languages. If a pattern only exists in Python but never in Java or C++, it might be too specific to Python's quirks and shouldn't get a special brick.

The Creative Metaphor:
Think of the standard BPE as a chef who makes a soup by throwing in every ingredient they find in the kitchen, regardless of whether it's a carrot or a rusty spoon. The soup tastes weird and has hard chunks.

SA-BPE is like a strict head chef who says: "We only add ingredients that are found in many different recipes. If a spice only appears in one single, weird recipe from 1995, we leave it out." The result is a cleaner, more versatile soup that tastes good no matter who is eating it.

What Happens When They Use SA-BPE?

The researchers tested this on several coding models (like StarCoder2 and CodeGemma) and found:

  • Fewer Junk Bricks: The number of useless, "under-trained" tokens dropped dramatically (in some cases, down to just 44 bad tokens out of hundreds of thousands).
  • Better Compression: The robot can still read the code efficiently. It doesn't need more bricks to do the job; in fact, it uses fewer, better-quality bricks.
  • No Speed Loss: The best part? The robot reads the code just as fast as before. The new rules only changed how the bricks were made in the factory, not how the robot uses them in the kitchen.

The Big Takeaway

This paper is about cleaning up the "dictionary" of AI models. By making sure the AI only learns words and symbols that are truly common and useful across the entire world of coding (rather than just specific to one project), we get models that are:

  1. Smarter (less likely to hallucinate).
  2. Safer (harder to trick).
  3. More Efficient (less wasted memory).

It's a simple but powerful idea: Don't let the AI memorize the typos and inside jokes of a single project; teach it the universal language of code.

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 →