From Tokens to Words: On the Inner Lexicon of LLMs

LLM Model Editing Latent Reasoning
2024年10月08日
自然语言由单词组成,但现代的LLM处理的是子词作为输入。这种差异引发的一个自然问题是LLM是否在内部编码单词,如果是,那么是怎样的过程。我们提供了证据表明LLM会进行内在的去分词过程,将子词序列组合成连贯的单词表示。我们的实验表明,这个过程主要发生在模型的早期和中间层。它们还表明,这个过程对于非形态切分、打字错误和重要的词汇外单词是稳健的:当将这些单词的内部表示作为输入向量馈送给模型时,它可以“理解”它们,尽管在训练期间从未见过它们。我们的发现表明,LLM在分词器范围之外维护一个潜在的词汇表。这些见解提供了一个实用的、无需微调的应用程序,用于扩展预训练模型的词汇量。通过增加新的词汇,我们减少了输入长度和推理迭代次数,从而减少了空间和模型延迟,同时几乎不损失模型的准确性。
Natural language is composed of words, but modern LLMs process sub-words as input. A natural question raised by this discrepancy is whether LLMs encode words internally, and if so how. We present evidence that LLMs engage in an intrinsic detokenization process, where sub-word sequences are combined into coherent word representations. Our experiments show that this process takes place primarily within the early and middle layers of the model. They also show that it is robust to non-morphemic splits, typos and perhaps importantly-to out-of-vocabulary words: when feeding the inner representation of such words to the model as input vectors, it can "understand" them despite never seeing them during training. Our findings suggest that LLMs maintain a latent vocabulary beyond the tokenizer's scope. These insights provide a practical, finetuning-free application for expanding the vocabulary of pre-trained models. By enabling the addition of new vocabulary words, we reduce input length and inference iterations, which reduces both space and model latency, with little to no loss in model accuracy.
许愿