Where to cut, how deep: BPE and Unigram-LM on chemistry SMILES
Summary
A controlled comparison of byte-pair encoding (BPE) and Unigram-LM tokenizers on chemistry SMILES strings reveals they do not converge, building near-disjoint subword vocabularies. Across 22 matched conditions, including diverse, drug-like, and natural-products corpora, and both pre-tokenization boundary policies, the cross-algorithm Jaccard overlap on learned pieces never exceeds 0.161, and is at most 0.05 when weighted toward high-frequency pieces. Unigram-LM segments held-out molecules into 29–41% more tokens, indicating agreement on "where" to cut but not "how deeply". BPE's segmentation is a strict coarsening of Unigram-LM's on 80–99% of molecules. This separation persists even at eight times the headline vocabulary scale (V=256, 512, 1024), establishing the subword algorithm as a critical modeling decision, not a default.
Key takeaway
For AI Scientists and Machine Learning Engineers developing chemical language models, selecting a SMILES tokenizer is a critical design decision, not a default. You should explicitly evaluate both BPE and Unigram-LM based on your model's specific requirements for token granularity and vocabulary composition. This choice directly influences effective sequence length, embedding learnability, and the chemical interpretability of learned representations, impacting downstream model performance.
Key insights
BPE and Unigram-LM tokenizers yield near-disjoint vocabularies and different segmentation granularities for chemistry SMILES.
Principles
- Subword algorithm choice significantly impacts chemistry SMILES tokenization.
- Natural language tokenizer priors may not transfer to chemistry SMILES.
- Vocabulary overlap is minimal, especially for high-frequency pieces.
Method
Controlled comparison of BPE and Unigram-LM on a fixed 165-token OpenSMILES base across corpus typologies, vocabulary sizes, and boundary policies.
In practice
- Consider Unigram-LM for finer-grained, near-atomic SMILES segmentation.
- Use BPE for coarser, larger-piece SMILES tokenization, spanning rings.
- Evaluate tokenizer choice based on downstream model granularity needs.
Topics
- Chemistry Language Models
- SMILES Tokenization
- Byte-Pair Encoding
- Unigram-LM
- Subword Algorithms
- Molecular Representation
Best for: AI Engineer, AI Scientist, Machine Learning Engineer, Research Scientist
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by cs.CL updates on arXiv.org.