Where to cut, how deep: BPE and Unigram-LM on chemistry SMILES
This study demonstrates that Byte-Pair Encoding (BPE) and Unigram-LM produce fundamentally distinct and near-disjoint subword vocabularies for chemical SMILES, revealing that the choice of tokenization algorithm is a critical modeling decision rather than a neutral default.
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
The Big Question: How Do We Teach Computers to Read Chemical Formulas?
Imagine you are trying to teach a computer to understand the language of chemistry. Chemists write molecules using a code called SMILES (a string of letters and symbols like CC(=O)Oc1ccccc1).
Before a computer can learn anything, it needs a tokenizer. Think of a tokenizer as a translator that breaks a long sentence into smaller, manageable chunks (words or sub-words) that the computer can understand.
For years, the field of chemistry has blindly copied a method from natural language processing (like how computers read English) called BPE (Byte-Pair Encoding). The researchers in this paper asked a simple question: "Is this the best way to cut up chemical formulas, or is there a better way?"
They compared the standard method (BPE) against a different method called Unigram-LM.
The Experiment: Two Different Scissors
Imagine you have a long, complex necklace made of different colored beads (the chemical formula). You need to cut this necklace into smaller pieces to study it. You have two different pairs of scissors:
- The Greedy Scissors (BPE): These scissors look for the two beads that appear next to each other the most often in the whole pile of necklaces. They glue those two together into a single "super-bead" and repeat the process. They are aggressive and greedy, trying to make big chunks out of frequent patterns.
- The Probabilistic Scissors (Unigram-LM): These scissors start with a huge pile of tiny beads and ask, "If I remove this specific bead, how much does it hurt the overall picture?" They carefully prune away pieces that aren't essential, keeping a more granular, detailed view.
The Surprising Discovery: They Don't Agree
The researchers expected that because chemical formulas are very strict (atoms must connect in specific ways), both scissors might end up cutting the necklace in almost the same places. They thought the "rules of chemistry" would force the two methods to converge.
They were wrong.
Even when they used the exact same chemical data, the exact same starting rules, and the exact same vocabulary size, the two methods produced completely different sets of "words."
- The Overlap is Tiny: If you took the list of "super-beads" created by BPE and compared it to the list created by Unigram-LM, they shared almost nothing. In the worst case, they shared less than 16% of their pieces. In the best case (looking at the most important, high-frequency pieces), they shared less than 5%.
- The "Cut" Depth: The two methods agreed on where to make the cuts (the skeleton of the molecule), but they disagreed on how deep to cut.
- BPE tended to make coarser cuts. It would glue whole rings of atoms together into one big token.
- Unigram-LM made finer cuts. It kept the rings broken down into smaller, near-atomic pieces.
- Result: Unigram-LM ended up using 29% to 41% more tokens (pieces) to describe the same molecule than BPE did.
A Visual Analogy: The Map vs. The Street View
Imagine you are looking at a map of a city.
- BPE is like a map that groups entire neighborhoods into single blocks. It says, "This whole area is 'Downtown'." It's efficient and uses fewer words.
- Unigram-LM is like a street view that lists every single building and street corner. It says, "Here is a bakery, here is a park, here is a house." It uses many more words but gives a more detailed breakdown.
The paper found that these two maps are not interchangeable. If you switch from one to the other, the computer sees a fundamentally different structure of the data.
Key Findings in Plain English
- It's a Design Choice, Not a Default: The field has been using BPE by default because it's what natural language models use. This paper proves that in chemistry, you cannot just copy-paste that choice. You have to actively decide which "scissors" to use because they produce different results.
- The Difference is Stable: This disagreement didn't happen just by chance. It happened across different types of chemicals (common drugs, rare natural products, and diverse molecules) and even when they changed the rules about how to handle complex atoms.
- Scale Doesn't Fix It: Usually, if you give a computer more data or a bigger vocabulary, things might smooth out. The researchers tested this by making the vocabulary 8 times larger. The two methods still didn't agree. They remained distinct.
- The "Nesting" Effect: Even though they use different words, they don't fight each other. The Unigram-LM cuts are almost always "inside" the BPE cuts. It's like BPE says "Cut the whole pizza," and Unigram-LM says "Cut the pizza, then cut the slices." They are compatible, just at different levels of detail.
What This Means for the Reader
The paper concludes that the algorithm you choose is a major modeling decision.
- If you choose BPE, you get shorter sequences (fewer tokens), which is cheaper for the computer to process, but you lose some granular detail about the molecule's structure.
- If you choose Unigram-LM, you get a more detailed, fine-grained view of the molecule, but it requires the computer to process more tokens.
The authors did not test which one makes the computer smarter at predicting chemical reactions or drug properties. They only proved that the two methods create different languages. Therefore, the chemistry community can no longer assume they are the same; they must choose their "scissors" carefully.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.