解析分词方式如何影响Transformer模型的上下文表现
Effective Context in Transformers: An Analysis of Fragmentation and Tokenization

- 提出'碎片化'概念,说明更细粒度表示可能降低预测性能
- 证明碎片化会增加最优有限上下文对数损失,非优化问题
- 给出分词有效性诊断方法,适合研究模型输入设计者
Transformers通过序列的表示进行预测。同一数据可表示为字节、字符或子词标记,这些表示可能是无损的。但在固定上下文窗口下,它们未必向模型暴露相同信息。这引出一个基本问题:表示选择如何影响有限上下文预测器的表现?我们在马尔可夫源上研究此问题,发现两个互补现象。首先,即使扩大上下文窗口以覆盖相关源历史,使用更小表示单位仍可能损害预测性能。我们引入‘碎片化’:将每个源符号替换为多个更小单位的无损重编码。证明碎片化可严格增加最优有限上下文对数损失,表明该差距不仅是优化或容量问题,而是表示本身的内在属性。这为字节级和字符级模型(如ByT5、CANINE)与子词标记模型之间的有限上下文差距提供了理论解释。其次,我们研究相反方向:贪婪分词(如BPE、WordPiece)将源符号组合成更大单元。我们证明分词可使短标记窗口表现得如同更长源上下文窗口,并给出损失保证,描述其可行性。该保证取决于标记窗口可靠覆盖所需源历史的程度,以及分词器的压缩率。这也为真实分词器提供简单诊断:测量固定标记窗口可靠包含多少源上下文。两者共同建立了一个有限上下文信息论框架,用于分析Transformers中表示选择。
原文摘要 · Abstract (English)
Transformers predict over a representation of a sequence. The same data can be written as bytes, characters, or subword tokens, and these representations may be lossless. Yet, under a fixed context window, they need not expose the same information to the model. This raises a basic question: how does the choice of representation change what a finite-context predictor can achieve? We study this question on Markov sources and uncover two complementary phenomena. First, we observe that moving to smaller representation units can hurt prediction even when the context window is enlarged to cover the relevant source history. To explain this, we introduce fragmentation: a lossless recoding that replaces each source symbol by several smaller units. We prove that fragmentation can strictly increase the optimal finite-context log-loss, showing that the gap is not merely an optimization or capacity issue, but can be intrinsic to the representation. This gives a theoretical account of the finite-context gap observed in byte- and character-level models such as ByT5 and CANINE relative to subword-tokenized models. Second, we study the opposite direction: greedy tokenization -- BPE, WordPiece, and related methods -- which groups source symbols into larger units. We show that tokenization can make a short token window behave like a longer source-context window, and we give a loss guarantee describing when this is achievable. The guarantee depends on how reliably token windows span the needed source history, together with the compression rate of the tokenizer. This also yields a simple diagnostic for real tokenizers: measuring how much source context a fixed token window reliably contains. Together, the two directions establish a finite-context information-theoretic framework for reasoning about representation choices in Transformers.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。