arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.16987cs.CL
收藏

回到字节:通过 UTF-8 重新审视分词

Back to Bytes: Revisiting Tokenization Through UTF-8

ETH Zürich(苏黎世联邦理工学院);University of Edinburgh(爱丁堡大学);University of Copenhagen(哥本哈根大学)

Amit Moryossef, Clara Meister, Pavel Stepachev, Desmond Elliott

AI总结:

本文提出极简字节级分词器 UTF8Tokenizer,利用 UTF-8 字节与 C0 控制字节实现无越界、无辅助词元的统一编码,并在速度、传输、嵌入复用和训练收敛上取得收益。

摘要:

我们提出 UTF8Tokenizer,这是一种极简的字节级分词器,可将文本精确映射到与文本 UTF-8 编码底层字节相对应的 ID(例如,字节 x09 对应词元 ID 9)。与以往的字节级方法(Xue 等人,2021;Pagnoni 等人,2025)不同,我们的实现从不引入超出范围的 ID(即不存在词元 ID 256)或辅助词元:所有特殊行为(例如填充、边界、对话结构、注意力分段、工具调用、“思考”片段等)都使用 C0 控制字节进行编码——正如 ASCII 最初被设计为在可打印文本之外嵌入控制信息那样。这些设计原则带来了实际收益:(1)更快的分词速度(14 倍),并显著降低主机到设备的传输量(比 int64 少 8 倍);(2)简单、可共享的 256*d 嵌入表,可在不同模型之间对齐;(3)通过位偏置嵌入实现训练时增强,该方法暴露逐字节的位结构,并可在训练后添加到嵌入表中,从而消除推理成本。我们兼容 HuggingFace 的实现改善了语言建模的收敛性。

英文摘要:

We present UTF8Tokenizer, a minimalist byte-level tokenizer that maps text exactly to IDs corresponding to the bytes underlying the text's UTF-8 encoding (e.g., byte x09 is token ID 9). Unlike prior byte-level approaches (Xue et al., 2021; Pagnoni et al., 2025), our implementation never introduces out-of-range IDs (i.e. there is no token ID 256) or auxiliary tokens: all special behavior (e.g., padding, boundaries, conversation structure, attention segments, tool calling, "thinking" spans, etc.) is encoded using C0 control bytes - just as ASCII was originally designed to embed control information alongside printable text. These design principles yield practical benefits: (1) faster tokenization (14x) and significantly lower host-device transfer (8x less than int64); (2) simple, shareable 256*d embedding tables that can be aligned across models; and (3) a training-time enhancement via bit-biased embeddings, which exposes per-byte bit structure and can be added to the embedding table post-training, removing inference costs. Our HuggingFace-compatible implementation improves language modeling convergence.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑