arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2404.08335cs.CLcs.LG
收藏

迈向LLM中分词的理论

Toward a Theory of Tokenization in LLMs

University of California, Berkeley(加州大学伯克利分校)

Nived Rajaraman, Jiantao Jiao, Kannan Ramchandran

AI总结:

本文从理论上研究LLM分词的必要性,通过分析Transformer在k阶马尔可夫数据上的行为,证明适当分词能使简单一元模型近乎最优地建模序列分布,为实践中使用分词提供了理论依据。

摘要:

尽管已有大量研究试图在语言建模中规避分词(Clark et al., 2022; Xue et al., 2022),当前共识仍是:分词是设计最先进高性能语言模型的必要初始步骤。本文从理论视角研究分词问题,考察Transformer在简单数据生成过程上的行为。当在来自某些简单k阶马尔可夫过程(k > 1)的数据上训练时,Transformer表现出一个令人惊讶的现象——在没有分词的情况下,它们在经验上无法学到正确的分布,而是按照一元模型(unigram model)来预测字符(Makkuva et al., 2024)。然而,加入分词后,我们在经验上观察到Transformer突破了这一障碍,能够近乎最优地建模来自该源的序列概率,并取得较小的交叉熵损失。以这一观察为出发点,我们研究了Transformer在有分词和无分词情况下所取得的端到端交叉熵损失。我们证明,在采用适当分词的情况下,即使是Transformer学到的最简单的一元模型(基于token)也能近乎最优地建模来自k阶马尔可夫源的序列概率。通过研究Transformer在马尔可夫数据上的行为,我们的分析为实践中使用分词提供了理论依据。

英文摘要:

While there has been a large body of research attempting to circumvent tokenization for language modeling (Clark et al., 2022; Xue et al., 2022), the current consensus is that it is a necessary initial step for designing state-of-the-art performant language models. In this paper, we investigate tokenization from a theoretical point of view by studying the behavior of transformers on simple data generating processes. When trained on data drawn from certain simple $k^{\text{th}}$-order Markov processes for $k > 1$, transformers exhibit a surprising phenomenon - in the absence of tokenization, they empirically fail to learn the right distribution and predict characters according to a unigram model (Makkuva et al., 2024). With the addition of tokenization, however, we empirically observe that transformers break through this barrier and are able to model the probabilities of sequences drawn from the source near-optimally, achieving small cross-entropy loss. With this observation as starting point, we study the end-to-end cross-entropy loss achieved by transformers with and without tokenization. With the appropriate tokenization, we show that even the simplest unigram models (over tokens) learnt by transformers are able to model the probability of sequences drawn from $k^{\text{th}}$-order Markov sources near optimally. Our analysis provides a justification for the use of tokenization in practice through studying the behavior of transformers on Markovian data.

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

↑