为什么最近邻语言模型有效?
Why do Nearest Neighbor Language Models Work?
摘要:
语言模型(LM)通过顺序计算已经看到的上下文的表示并使用该表示来预测下一个单词来计算文本的概率。目前,大多数LM通过神经网络消耗紧接在前的上下文来计算这些表示。然而,最近,检索增强的LM已经显示出比标准神经LM更好的性能,除了标准的、参数化的下一个词预测之外,还可以访问从大型数据库中检索到的信息。在本文中,我们开始理解为什么检索增强的语言模型,特别是为什么k-最近邻语言模型(kNN-LM)比标准参数LM表现更好,即使k-最近邻组件从LM最初训练的相同训练集中检索示例。为此,我们仔细分析了kNN-LM偏离标准LM的各个维度,并逐一研究这些维度。从经验上讲,我们确定了kNN-LM比标准LM表现更好的三个主要原因:使用不同的输入表示来预测下一个令牌,近似kNN搜索以及softmax温度对kNN分布的重要性。此外,我们将这些见解纳入标准参数LM的模型架构或训练过程中,从而在不需要显式检索组件的情况下改善其结果。该代码可在https://github.com/frankxu2004/knnlm-why上获得。
英文摘要:
Language models (LMs) compute the probability of a text by sequentially computing a representation of an already-seen context and using this representation to predict the next word. Currently, most LMs calculate these representations through a neural network consuming the immediate previous context. However recently, retrieval-augmented LMs have shown to improve over standard neural LMs, by accessing information retrieved from a large datastore, in addition to their standard, parametric, next-word prediction. In this paper, we set out to understand why retrieval-augmented language models, and specifically why k-nearest neighbor language models (kNN-LMs) perform better than standard parametric LMs, even when the k-nearest neighbor component retrieves examples from the same training set that the LM was originally trained on. To this end, we perform a careful analysis of the various dimensions over which kNN-LM diverges from standard LMs, and investigate these dimensions one by one. Empirically, we identify three main reasons why kNN-LM performs better than standard LMs: using a different input representation for predicting the next tokens, approximate kNN search, and the importance of softmax temperature for the kNN distribution. Further, we incorporate these insights into the model architecture or the training procedure of the standard parametric LM, improving its results without the need for an explicit retrieval component. The code is available at https://github.com/frankxu2004/knnlm-why.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。