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

SinkLoRA:提升长上下文大语言模型的效率与对话能力

SinkLoRA: Enhanced Efficiency and Chat Capabilities for Long-Context Large Language Models

Cranberry-Lemon University(蔓越莓柠檬大学);Department of Computer Science(计算机科学系)

Hengyu Zhang

AI总结:

SinkLoRA通过SF-Attn分割重组算法和H₂O缓存压缩,解决了LongLoRA长上下文扩展效率低的问题,将困惑度改善提升至全注意力的92%,并增强了对话能力。

摘要:

将Transformer模型的功能扩展到更长的序列长度已成为一项关键挑战。这种扩展不仅对改进语言翻译和长上下文处理等任务至关重要,而且对实现聊天机器人、代码生成和多媒体内容创作等新应用也必不可少。主要障碍在于自注意力机制,其计算时间和内存需求随序列长度呈二次方增长。LongLoRA提出了移位稀疏注意力(S²-Attn),有效地实现了上下文扩展,并在与使用普通注意力进行微调性能相似的情况下带来了可观的计算节省。然而,LongLoRA的效率仍不如普通注意力,其困惑度改善仅达到全注意力的39%。这种低效源于在不同注意力头模式中应用的循环移位,导致注意力头结构混乱或token组之间不必要的信息交换。为解决这些问题,我们提出了SinkLoRA,它具有更好的工作划分。具体而言,(1)我们开发了SF-Attn,采用分割与重组算法,将循环移位的注意力头组按比例恢复到未移位状态,并结合“汇聚注意力token”的全局注意力,在微调后实现了全注意力92%的困惑度改善;(2)应用了最先进的KV缓存压缩算法H₂O来加速推理。此外,我们使用自行收集的LongAlpaca-plus数据集对SinkLoRA进行了监督微调。我们所有的代码、模型、数据集和演示均可在https://github.com/Dexter-GT-86/SinkLoRA获取。

英文摘要:

Extending the functionality of the Transformer model to accommodate longer sequence lengths has become a critical challenge. This extension is crucial not only for improving tasks such as language translation and long-context processing but also for enabling novel applications like chatbots, code generation, and multimedia content creation. The primary obstacle is the self-attention mechanism, which scales quadratically with sequence length in terms of computation time and memory requirements. LongLoRA proposed shifted sparse attention (S\(^2\)-Attn), effectively enabling context extension and leading to non-trivial computation savings with similar performance to fine-tuning with vanilla attention. However, LongLoRA is still not as efficient as vanilla attention, reaching only 39\% of the perplexity improvement compared to full attention. This inefficiency is due to the cyclic shift applied within different attention head patterns, causing either chaos in the attention head structure or unnecessary information exchange between token groups. To address these issues, We propose \textbf{SinkLoRA}, which features better work partitioning. Specifically, (1) we developed SF-Attn with a segmentation and reassembly algorithm to proportionally return cyclically shifted groups of attention heads to their un-shifted state together with global attention of "sink attention tokens", achieving 92\% of the perplexity improvement compared to full attention after fine tuning, and (2) applied a SOTA KV cache compression algorithm H$_2$O to accelerate inference. Furthermore, We conducted supervised fine-tuning with SinkLoRA using a self collected LongAlpaca-plus dataset. All our code, models, datasets, and demos are available at \url{https://github.com/Dexter-GT-86/SinkLoRA}.

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

↑