跳到主要内容Skip to main content

子词分词Subword Tokenization

Subword Tokenization

  • 核心概念Core concepts
  • 第四段 · 看懂Stage 4 · Under the Hood
  • 引用核验 2026-11-19refs checked 2026-11-19
解决什么问题What problem it solves

把词切成更小的碎片,让模型遇到没见过的词也能拼出来。Cuts words into smaller fragments so a model can still assemble words it has never seen.

这是什么What it is

最常见的方案是 BPE:从字符出发,按出现频率反复合并相邻片段,得到一套子词。

「未登录词」问题由此缓解——整词不在词表里,它的碎片多半在。

The dominant scheme is BPE: start from characters, repeatedly merge the most frequent adjacent pairs into a subword inventory.

It eases the out-of-vocabulary problem — a whole word may miss the vocabulary, but its fragments usually are in it.

Text is split into subword pieces and mapped to integer IDs; unseen words are broken into known pieces.
文本先被切成子词,再映射成整数 ID;词表外的词会被拆成已知片段。Text is split into subword pieces and mapped to integer IDs; unseen words are broken into known pieces.
为什么需要知道Why it matters

你看到模型把生僻词拆成奇怪片段,不是「不认识」,是子词分词在工作。词表大小与合并规则共同决定模型对中文、代码的友好度。When a model splits a rare word into odd fragments, it is not "failing to recognize" it — subword tokenization is at work. Vocabulary size and merge rules together decide how friendly a model is to Chinese and code.

出处Sources
  • BPE 原论文(Subword Units)Neural Machine Translation of Rare Words with Subword Units (paper) ↗
  • Hugging Face 分词器课程Hugging Face NLP Course: Tokenizers chapter ↗
用这个术语做任务Use this term in a task

别停在定义:去任务手册看按什么顺序做、验收什么;或者按你手头的任务,筛 3 个工具候选。Don’t stop at the definition: use the task handbook for the order and checks, or filter three tool candidates for the job at hand.

任务手册 →Task handbooks → · 按任务筛 3 个候选 →Filter three candidates →