arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.24869cs.CL
收藏

Lngram: 潜在空间中的N-gram条件记忆

Lngram: N-gram Conditional Memory in Latent Space

Beijing University of Posts and Telecommunications (BUPT)(北京邮电大学);Li Auto Inc.(Li Auto公司)

Yunao Zheng, Guoyang Xia, Xiaojie Wang, Lei Ren

AI总结:

提出Lngram,一种在潜在空间中学习离散符号并执行N-gram查找的条件记忆模块,以解耦检索与骨干网络,提升长上下文语言建模和跨模态任务性能。

摘要:

序列建模需要组合推理和局部静态知识检索,而标准Transformer通过密集计算处理两者。Engram部分地将检索与骨干网络解耦,但其基于token的键仍依赖于文本分词和哈希压缩。我们提出Lngram,一种潜在空间中的条件记忆模块,直接从隐藏状态学习离散符号,并对这些符号执行N-gram查找。该设计消除了对分词器ID的依赖,并自然地扩展到非文本模态。在我们的评估设置中,Lngram优于Transformer和Engram基线,在长上下文语言建模中持续降低困惑度,并在事后添加到预训练模型时有效注入领域知识。与骨干网络的联合训练进一步超越了完全微调,而在视觉-语言和视觉-语言-动作任务上的实验显示了整体提升。使用LogitLens和CKA的分析表明,Lngram使预测相关信息更早出现,在有限的推理和内存开销下增加了有效深度。代码可在https://github.com/zyaaa-ux/Lngram获取。

英文摘要:

Sequence modeling requires both compositional reasoning and local static knowledge retrieval, yet standard Transformers handle both through dense computation. Engram partially decouples retrieval from the backbone, but its token-based keys remain tied to text tokenization and hash compression. We propose Lngram, a latent-space conditional memory module that learns discrete symbols directly from hidden states and performs N-gram lookup over these symbols. This design removes the dependence on tokenizer IDs and naturally extends to non-text modalities. In our evaluated settings, Lngram outperforms Transformer and Engram baselines, consistently reduces perplexity in long-context language modeling, and effectively injects domain knowledge when added post hoc to pretrained models. Joint training with the backbone further surpasses full fine-tuning, while experiments on vision-language and vision-language-action tasks show overall gains. Analyses with LogitLens and CKA suggest that Lngram enables prediction-relevant information to emerge earlier, increasing effective depth with limited inference and memory overhead. Code is available at https://github.com/zyaaa-ux/Lngram.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑