arXiv:2410.05864cs.CLcs.AI2024-10ICLR被引 50

大模型内部能自动组合子词成完整词汇,理解未见过的词。

From Tokens to Words: On the Inner Lexicon of LLMs

  • 模型在中早期层将子词合并为完整词表征
  • 对拆分、拼写错误和生僻词仍能准确识别
  • 无需微调即可扩展词库,提升推理效率

自然语言由词构成,但现代大语言模型(LLMs)以子词为输入。这一差异引发一个问题:模型是否在内部编码词?如果有,如何实现?我们提出证据表明,LLMs会进行内在的解分词过程,即在最后一层将子词序列组合成连贯的整体词表征。实验显示该过程主要发生在模型的早期与中层。我们进一步证明其对任意切分(如"cats"拆为"ca"和"ts")、拼写错误以及关键在于词汇外词具有鲁棒性:当将这些词的最后层内部表征作为输入时,模型仍能将其理解为完整单词,尽管训练中从未见过此类表征。研究揭示了大模型维持着超出分词器范围的潜在词库。这一发现可直接用于无需微调的词库扩展,通过添加新词汇减少输入长度与推理迭代次数,显著降低空间占用与模型延迟,且几乎不损失准确性。

原文摘要 · Abstract (English)

Natural language is composed of words, but modern large language models (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 whole-word representations at their last token. Our experiments show that this process primarily takes place within the early and middle layers of the model. We further demonstrate its robustness to arbitrary splits (e.g., "cats" to "ca" and "ts"), typos, and importantly-to out-of-vocabulary words: when feeding the last token internal representations of such words to the model as input, it can "understand" them as the complete word despite never seeing such representations as input 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.

大模型机制词表征解分词词库扩展

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。