Downloads · 30 days
0
prasadbhoite/medical-bpe-16k
medical-bpe-16k is a machine learning model from prasadbhoite. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
A domain-specific byte-level BPE tokenizer trained on biomedical text, built to test one specific claim: for specialized text, what the tokenizer was trained on matters more than how big its vocabulary is.
Downloads · 30 days
0
Access
Public
Updated Sep 6, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.json1.1 MB · 100%
From the Hugging Face model README
A domain-specific byte-level BPE tokenizer trained on biomedical text, built to test one specific claim: for specialized text, what the tokenizer was trained on matters more than how big its vocabulary is.
A general-purpose tokenizer (e.g., GPT-4's cl100k, ~100K vocab) fragments specialized biomedical vocabulary — drug names, biochemical terms, diagnostic codes — into multiple pieces, even with a vocabulary 6x larger than this one. This tokenizer is a controlled test of that claim: trained on domain text at a small (16K) vocabulary, and compared against a same-size tokenizer trained on general text (general-bpe, on WikiText-103) to isolate whether domain or vocabulary size actually drives tokenization efficiency.
Held-out PubMed abstracts (5,000 docs, never seen during training):
| Tokenizer | Vocab size | Trained on | Fertility | Tokens/100 chars |
|---|---|---|---|---|
| custom-med (this model) | 16,000 | PubMed abstracts | 1.375 🏆 | 20.23 |
| o200k (GPT-4o) | ~200,000 | General web | 1.430 | 21.03 |
| cl100k (GPT-4) | ~100,000 | General web | 1.460 | 21.48 |
| qwen | ~150,000 | General web | 1.487 | 21.87 |
| general-bpe | 16,000 | Wikipedia (fairness control) | 1.747 | 25.71 |
Held-out WikiText-103 (5,000 docs, general English) — the flip side:
| Tokenizer | Fertility | Tokens/100 chars |
|---|---|---|
| o200k | 1.163 | 21.90 |
| cl100k | 1.173 | 22.08 |
| qwen | 1.213 | 22.83 |
| general-bpe | 1.208 | 22.75 |
| custom-med (this model) | 1.577 | 29.69 |
The key comparison is custom-med vs. general-bpe — identical vocabulary size (16,000), identical algorithm, trained on different corpora. custom-med wins on medical text (1.375 vs. 1.747) and loses on general text (1.577 vs. 1.208) — a clean crossover that isolates domain training, not vocabulary size, as the cause. This tokenizer even outperforms general-purpose tokenizers with vocabularies up to 12x larger (o200k, cl100k) on medical text specifically.
from transformers import PreTrainedTokenizerFast
tok = PreTrainedTokenizerFast.from_pretrained("prasadbhoite/medical-bpe-16k")
print(tok.tokenize("The patient was prescribed empagliflozin for management of SGLT2-related complications."))
Built as a hands-on exercise to demonstrate BPE mechanics, domain-specific tokenizer training, and fertility-based evaluation methodology.