Skip to main content
QUICK REVIEW

[论文解读] Fast Nearest Neighbor Machine Translation

Yuxian Meng, Xiaoya Li|arXiv (Cornell University)|May 30, 2021
Natural Language Processing Techniques被引用 14
一句话总结

本文提出 Fast k-NN-MT,这是 k-最近邻机器翻译(k-Nearest Neighbor Machine Translation)的一种高度高效变体,通过仅将搜索空间限制在与先前选择的参考源词对应的目标题词上,从而加速推理过程。通过将最近邻搜索限制在同类型词的邻居范围内,并在每个解码步骤动态缩小数据存储库,Fast k-NN-MT 在保持近乎相同性能的同时,实现了比原始 k-NN-MT 快两个数量级的推理速度,仅比标准 NMT 模型慢两倍。

ABSTRACT

Though nearest neighbor Machine Translation ($k$NN-MT) \citep{khandelwal2020nearest} has proved to introduce significant performance boosts over standard neural MT systems, it is prohibitively slow since it uses the entire reference corpus as the datastore for the nearest neighbor search. This means each step for each beam in the beam search has to search over the entire reference corpus. $k$NN-MT is thus two-orders slower than vanilla MT models, making it hard to be applied to real-world applications, especially online services. In this work, we propose Fast $k$NN-MT to address this issue. Fast $k$NN-MT constructs a significantly smaller datastore for the nearest neighbor search: for each word in a source sentence, Fast $k$NN-MT first selects its nearest token-level neighbors, which is limited to tokens that are the same as the query token. Then at each decoding step, in contrast to using the entire corpus as the datastore, the search space is limited to target tokens corresponding to the previously selected reference source tokens. This strategy avoids search through the whole datastore for nearest neighbors and drastically improves decoding efficiency. Without loss of performance, Fast $k$NN-MT is two-orders faster than $k$NN-MT, and is only two times slower than the standard NMT model. Fast $k$NN-MT enables the practical use of $k$NN-MT systems in real-world MT applications. The code is available at \url{https://github.com/ShannonAI/fast-knn-nmt}

研究动机与目标

  • 为解决 k-NN-MT 的推理延迟过高问题,其在每个解码步骤中需对整个语料库进行最近邻搜索,导致推理速度比标准 NMT 慢两个数量级。
  • 通过大幅提高解码效率而不牺牲翻译质量,实现 k-NN-MT 在真实在线机器翻译服务中的实际部署。
  • 设计一种可扩展且高效的检索机制,基于源端上下文仅将数据存储库限制在相关参考词上。
  • 在受限检索设置下,研究搜索空间大小、邻居数量与模型性能之间的权衡。

提出的方法

  • 通过仅选择与查询词类型匹配(例如,相同词形)的词级别邻居,为每个源词构建更小的数据存储库。
  • 在每个解码步骤中,将最近邻搜索限制在与先前选择的参考源词对应的目标词上,形成通过参考样本从源到目标的映射链。
  • 使用 FastAlign 建立源词与目标词之间的跨语言对齐,以高效检索参考样本。
  • 在 k-NN 推理过程中,仅将搜索空间限制在与先前检索到的源参考词相关联的目标词上,从而减少每步的候选数量。
  • 对高维词表示应用量化,以减少内存占用,且对性能影响极小。
  • 由于余弦相似度在性能上优于 L2 和内积,因此选择其作为最近邻检索的距离度量。

实验结果

研究问题

  • RQ1我们能否在不降低翻译质量的前提下,显著减少 k-NN-MT 的推理延迟?
  • RQ2将搜索空间限制在仅相关参考源词上,对模型性能和速度有何影响?
  • RQ3每个源词最优的邻居数量(c)是多少,才能在准确率与效率之间实现平衡?
  • RQ4目标侧邻居数量(k)如何影响性能,是否存在收益递减的临界点?
  • RQ5向量表示的量化在检索流水线中在多大程度上影响模型性能?

主要发现

  • Fast k-NN-MT 相比原始 k-NN-MT 实现了 100 倍的加速,推理时间仅比标准 NMT 模型慢两倍。
  • 在 WMT’19 De-En 数据集上,Fast k-NN-MT 达到了 39.3 的 SacreBLEU 分数,与原始 k-NN-MT 性能完全一致。
  • 在 WMT’14 En-Fr 数据集上,Fast k-NN-MT 取得了 41.7 的 SacreBLEU 分数,与原始 k-NN-MT 模型表现相当。
  • 在领域适应任务中,Fast k-NN-MT 平均获得 41.4 的 SacreBLEU 分数,表现出在不同领域间的强大泛化能力。
  • 对词表示进行量化仅导致平均分数下降 0.1 BLEU 点,表明这是实现内存效率的可行权衡。
  • 最优的源端邻居数量(c)为 512,超过该值后性能提升趋于平缓;而目标端邻居数量(k)在最优值附近表现出明显的性能峰值。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。