Byte-Pair Encoding tokenization - Hugging Face NLP Course
Byte-Pair Encoding (BPE) was initially developed as an algorithm to compress texts, and then used by OpenAI for tokenization when pretraining the GPT model. It’s used by a lot of Transformer models, including GPT, GPT-2, RoBERTa, BART, and DeBERTa. 💡 This section covers BPE in depth, going as far as showing a full implementation. You can skip to the end if you just want a general overview of the tokenization algorithm. BPE training starts by computing the unique set of words used in the corpus (after the normalization and pre-tokenization steps are completed), then building the vocabulary by taking all the symbols used to write those words. As a very simple example, let’s say our corpus uses these five words: The base vocabulary will then be ["b", "g", "h", "n", "p", "s", "u"]. For real-world cases, that base vocabulary will contain all the ASCII characters, at the very least, and probably some Unicode characters as well. If an example you are tokenizing uses a character that is not i
Byte-Pair Encoding (BPE) was initially developed as an algorithm to compress texts, and then used by OpenAI for tokenization when pretraining the GPT model. It’s used by a lot of Transformer models, including GPT, GPT-2, RoBERTa, BART, and DeBERTa. 💡 This section covers BPE in depth, going as far as showing a full implementation. You can skip to the end if you just want a general overview of the tokenization algorithm. Training algorithm BPE training starts by computing the unique set of words used in the corpus (after the normalization and pre-tokenization steps are completed), then…
related reading
- GitHub - karpathy/minbpe: Minimal, clean code for the Byte Pair Encoding (BPE) algorithm commonly used in LLM tokenization. · GitHubgithub.com
- Byte-pair encoding - Wikipediaen.wikipedia.org
- The Bitter Lesson is coming for Tokenization – ⛰️ lucalplucalp.dev
- [2605.22821] Tokenisation via Convex Relaxationsarxiv.org
- [2112.10508] Between words and characters: A Brief History of Open-Vocabulary Modeling and Tokenization in NLParxiv.org
- Sampling from Your Language Model One Byte at a Timearxiv.org
- Tokenizers · Hugging Facehuggingface.co
- The End of Tokenizationronaldyu.substack.com
- frontier model training methodologies | Alex Wa's Blogdjdumpling.github.io
- Byte Latent Transformer: Patches Scale Better Than Tokensarxiv.org
- The Annotated Transformernlp.seas.harvard.edu
- Transformer Explainer: LLM Transformer Model Visually Explainedpoloclub.github.io