← Back to LLMs Mind Map
⚡ LLMsID: bpe-tokenization

Tokenization: BPE / WordPiece

分词 BPE/WordPiece
🎯Core Definition
BPE (Byte Pair Encoding) is a subword tokenization algorithm: start from byte/character-level units, count co-occurrence of adjacent symbol pairs, merge the most frequent byte pair into a new vocabulary symbol each iteration until the target vocab size VV is reached; encoding greedily matches the longest subword. Mainstream LLMs (GPT/LLaMA/Qwen) use byte-level BPE with vocabularies of 30K-150K tokens.
💡Use Cases
the tokenization stage before pretraining and inference; covering multilingual text and code (byte-level encodes any UTF-8 with no OOV), controlling token counts within fixed context windows, and subword splitting for compounding/agglutinative languages (German, Chinese, ...).
⚡Key Problems Solved
word-level tokenization yields huge vocabs and OOV on new words; character-level splitting costs 4-6 tokens per word and wastes context window. BPE encodes any text with a 30K-150K vocab at ~1-2 tokens per English word, balancing vocab size, sequence length, and cross-lingual coverage.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Tokenization: BPE / WordPiece.
Use Cases
In production engineering, what are the primary use cases for Tokenization: BPE / WordPiece and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
BPE training: starting unit, what each iteration does, stopping condition?
2
Why do LLM vocabs sit at 30K-150K? Trade-offs of larger/smaller vocabs?
3
How does byte-level BPE guarantee no OOV for arbitrary Unicode text?
4
Selection criteria of BPE vs WordPiece vs Unigram?
5
Tokenizer impact: average tokens per English word? Multilingual/code behavior?
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "Tokenization: BPE / WordPiece"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardPre-Training Objectives & Optimizer DetailsNext Card →Text Embeddings

🔗 More LLMs Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/LLM/card/bpe-tokenization
中文速览与面试要点

分词 BPE/WordPiece (Tokenization: BPE / WordPiece)

定义: BPE (Byte Pair Encoding, 字节对编码) 是一种子词(subword)分词算法:从字节/字符级最小单位出发,统计相邻符号对的共现频率,每次迭代把最高频的字节对合并成一个新符号并加入词表,直到词表达到预定大小 V;编码时按最长子词贪心匹配。GPT/LLaMA/Qwen 等主流 LLM 采用字节级 BPE,词表通常为 3-15 万。 使用场景: 大模型预训练与推理前的分词阶段;需要覆盖多语言与代码(字节级可编码任意 UTF-8 文本、无未登录词)、在固定上下文窗口内控制 token 数量,以及处理复合/黏着语言(德语、中文等)的子词切分。 解决的问题: 词级分词词表巨大且遇新词即 OOV;字符级分词每个词需 4-6 个 token,白白占用上下文窗口。BPE 以 3-15 万规模的词表即可编码任意文本,平均每个英文单词约 1-2 个 token,在词表规模、序列长度与跨语言覆盖之间取得平衡。

核心要点

  • BPE 的训练过程:从什么单位开始,每次迭代做什么,何时停止?
  • 为什么 LLM 词表普遍在 3-15 万?词表过大/过小的权衡?
  • 字节级 BPE 如何保证任意 Unicode 文本没有未登录词 (OOV)?
  • BPE 与 WordPiece、Unigram 的选择准则分别是什么?
  • tokenizer 对模型的影响:平均一个英文单词几个 token?多语言/代码表现?