Scaling language models to handle longer input sequences typically necessitates large key-value (KV) caches, resulting in substantial memory overhead during inference. In this paper, we propose Tensor Product Attention (TPA), a novel attention mechanism that uses tensor decompositions to represent queries, keys, and values compactly, substantially shrinking the KV cache size at inference time. By factorizing these representations into contextual low-rank components and seamlessly integrating with Rotary Position Embedding (RoPE), TPA achieves improved model quality alongside memory efficiency. Based on TPA, we introduce the Tensor ProducT ATTenTion Transformer (T6), a new model architecture for sequence modeling. Through extensive empirical evaluation on language modeling tasks, we demonstrate that T6 surpasses or matches the performance of standard Transformer baselines including Multi-Head Attention (MHA), Multi-Query Attention (MQA), Grouped-Query Attention (GQA), and Multi-Head Latent Attention (MLA) across various metrics, including perplexity and a range of established evaluation benchmarks. Notably, TPA's memory efficiency and computational efficiency at decoding stage enables processing longer sequences under fixed resource constraints, addressing a critical scalability challenge in modern language models. Project Page: https://github.com/tensorgi/TPA.


翻译:扩展语言模型以处理更长的输入序列通常需要大型键值(KV)缓存,导致推理过程中产生显著的内存开销。本文提出张量积注意力(TPA),这是一种新颖的注意力机制,利用张量分解紧凑地表示查询、键和值,从而在推理时大幅压缩KV缓存大小。通过将这些表示分解为上下文低秩分量,并与旋转位置嵌入(RoPE)无缝集成,TPA在实现内存效率的同时提升了模型质量。基于TPA,我们引入了张量积注意力Transformer(T6),这是一种用于序列建模的新模型架构。通过在语言建模任务上进行广泛的实证评估,我们证明T6在包括困惑度和一系列既定评估基准在内的多种指标上,超越或匹配了标准Transformer基线的性能,这些基线包括多头注意力(MHA)、多查询注意力(MQA)、分组查询注意力(GQA)和多头潜在注意力(MLA)。值得注意的是,TPA在解码阶段的内存效率和计算效率使其能够在固定资源约束下处理更长的序列,解决了现代语言模型中的一个关键可扩展性挑战。项目页面:https://github.com/tensorgi/TPA。

0
下载
关闭预览

相关内容

【ICML2023】SEGA:结构熵引导的图对比学习锚视图
专知会员服务
24+阅读 · 2023年5月10日
【ICML2022】知识图谱上逻辑查询的神经符号模型
专知会员服务
28+阅读 · 2022年5月25日
【AAAI2022】注意力机制的快速蒙特卡罗近似
专知会员服务
20+阅读 · 2022年2月5日
专知会员服务
29+阅读 · 2020年10月2日
论文浅尝 | GEOM-GCN: Geometric Graph Convolutional Networks
开放知识图谱
14+阅读 · 2020年4月8日
【NeurIPS2019】图变换网络:Graph Transformer Network
注意力机制可解释吗?这篇ACL 2019论文说……
机器之心
11+阅读 · 2019年6月16日
NAACL 2019 | 一种考虑缓和KL消失的简单VAE训练方法
PaperWeekly
20+阅读 · 2019年4月24日
论文浅尝 | Know-Evolve: Deep Temporal Reasoning for Dynamic KG
开放知识图谱
36+阅读 · 2018年3月30日
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
18+阅读 · 2024年12月27日
Arxiv
175+阅读 · 2023年4月20日
A Survey of Large Language Models
Arxiv
499+阅读 · 2023年3月31日
Arxiv
83+阅读 · 2023年3月26日
Arxiv
181+阅读 · 2023年3月24日
VIP会员
相关VIP内容
【ICML2023】SEGA:结构熵引导的图对比学习锚视图
专知会员服务
24+阅读 · 2023年5月10日
【ICML2022】知识图谱上逻辑查询的神经符号模型
专知会员服务
28+阅读 · 2022年5月25日
【AAAI2022】注意力机制的快速蒙特卡罗近似
专知会员服务
20+阅读 · 2022年2月5日
专知会员服务
29+阅读 · 2020年10月2日
相关基金
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员