COUNT:计数N-gram解锁主机内存扩展与免训练适配
研究论文 · 2026/10/15
语言模型的计算与性能缩放关系已被广泛研究;最近,模型也被设计为可扩展内存使用。特别是,为n-gram添加嵌入可以独立于计算使用来扩展内存,因为每次传递只处理单个嵌入行,这些行远小于整个嵌入表的存储。然而,现有方法从头训练嵌入,这需要昂贵的GPU内存进行快速读写。同时,主机系统的普通内存便宜且在这些训练方法中未被充分利用。为了在主机内存上扩展,我们引入了COUNT(Counting Offline Unlocks N-gram Transformers),它通过在主機上存储预计算的n-gram计数来构建n-gram嵌入,而不添加学习参数。我们使用语料频率来加权LM自身对当前n-gram历史之后最常出现的下一个token的unembeddings。在固定计算预算下,COUNT可以作为额外的输入嵌入添加到预训练1B参数LM中,以改善验证损失,相当于计算量多57%的LM。如果GPU内存有限,使用COUNT让主干参数填满GPU内存比与额外的学习n-gram嵌入分割内存获得更好的性能。除了效率之外,COUNT允许在推理时切换来自领域特定语料库的不同n-gram计数表,以适应新任务而无需任何训练。
COUNT提出了一种利用主机内存扩展语言模型的新方法,无需训练即可适应新任务,在计算效率和内存使用上具有显著优势,为资源受限场景提供了实用解决方案。
The scaling relationship of compute and performance for language models (LMs) has been extensively studied; more recently, models are being designed to scale memory use, as well. In particular, adding embeddings for n-grams scales memory separately from compute use, because each pass only processes individual embedding rows, which are much smaller than the storage used for the whole embedding table. However, existing methods train embeddings from scratch, which needs expensive GPU memory for fast reading and writing. Meanwhile, the ordinary memory of the host system is cheap and underutilized by these training methods. To scale on host memory, we introduce COUNT (Counting Offline Unlocks N-gram Transformers), which builds n-gram embeddings without adding learned parameters by storing precomputed n-gram counts on host. We use the corpus frequencies to weight together the LM's own unembeddings of the next tokens most often following the current n-gram history. At a fixed compute budget, COUNT can be added as an additional input embedding for pretraining 1B-parameter LMs to improve validation loss as much as an LM with 57% more compute. If GPU memory is limited, using COUNT to let backbone parameters fill GPU memory gives better performance than splitting memory with additional learned n-gram embeddings. Beyond efficiency, COUNT allows switching in a different table of n-gram counts from a domain-specific corpus at inference time to adapt to a new task without any training.