arXiv:2506.17671cs.CLcs.AI2025-06被引 1

让大模型变高效:用线性注意力和内存门控提升长文本处理能力

TPTT: Transforming Pretrained Transformers into Titans

  • 引入线性注意力与内存门控,无需重训练即可增强预训练模型
  • 10亿参数模型在MMLU上准确率提升20%,推理效率显著改善
  • 适合需要长上下文处理的轻量级部署场景,如边缘计算

基于Transformer的大语言模型在自然语言处理任务中表现优异,但其自注意力层的二次方计算与内存开销,给长文本推理和资源受限环境下的部署带来挑战。本文提出TPTT(Transforming Pretrained Transformers into Titans)框架,通过引入线性化注意力(LiZA)和基于内存门控的MaG机制,在不进行全量微调的前提下增强预训练模型。TPTT支持参数高效微调(LoRA),并与Hugging Face Transformers等主流工具链兼容。我们在包括Llama-1B、OlMoE-1B-7B、Qwen2.5-1.5B、Gemma3-270m、OpenELM-1.3B和Mistral-7B在内的多个不同规模模型上进行了评估。针对约10亿参数模型,主要在MMLU基准测试中,实验表明其在效率和精度方面均有潜力提升。例如,Titans-Llama-1B在单次提示评估中,精确匹配分数最高提升20%。此外,研究发现可通过DeltaProduct机制将原本二次复杂度的注意力模型完全转换为纯线性注意力模型。所有训练均在有限算力条件下完成。初步结果表明,TPTT有望以低开销适配预训练大模型用于长上下文任务。未来需在更大模型及更广基准上进一步验证框架的普适性与鲁棒性。代码已开源:https://github.com/fabienfrfr/tptt,Python包可安装:https://pypi.org/project/tptt/

原文摘要 · Abstract (English)

Transformer-based large language models (LLMs) have achieved strong performance across many natural language processing tasks. Nonetheless, their quadratic computational and memory requirements, particularly in self-attention layers, pose challenges for efficient inference on long contexts and for deployment in resource-limited environments. We present TPTT (Transforming Pretrained Transformers into Titans), a framework designed to augment pretrained Transformers with linearized attention (LiZA) and internal memory gating via Memory as Gate (MaG), applied without full retraining. TPTT supports parameter-efficient fine-tuning (LoRA) and integrates with standard toolkits such as Hugging Face Transformers. We evaluated TPTT on several pretrained models, including Llama-1B, OlMoE-1B-7B, Qwen2.5-1.5B, Gemma3-270m, OpenELM-1.3B, and Mistral-7B, in order to assess applicability across architectures of different scales. Experiments on models with approximately 1 billion parameters, evaluated primarily on the MMLU benchmark, suggest potential improvements in both efficiency and accuracy compared to baseline models. For example, Titans-Llama-1B exhibited up to a 20\% relative increase in Exact Match scores in one-shot evaluation. An additional finding is that it is possible to convert a quadratic-attention model into a purely linear-attention model using the DeltaProduct mechanism. All training runs were carried out with modest computational resources. These preliminary findings indicate that TPTT may help adapt pretrained LLMs for long-context tasks with limited overhead. Further studies on larger models and a broader set of benchmarks will be necessary to evaluate the generality and robustness of the framework. Code is available at https://github.com/fabienfrfr/tptt . Python package at https://pypi.org/project/tptt/ .

大模型优化线性注意力长文本处理轻量化部署

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。