通过自动分割和块蒸馏实现块注意力的泛化
Towards Generalization of Block Attention via Automatic Segmentation and Block Distillation
AI总结:
提出基于语义分割数据集训练的轻量级分割器和块蒸馏框架,解决块注意力在长上下文中的文本分割和微调效率问题,实现接近全注意力的性能。
摘要:
块注意力将输入作为独立的块处理,块之间不能相互关注,在检索增强生成(RAG)等长上下文场景中具有显著提升KV缓存重用的潜力。然而,其广泛应用受到两个关键挑战的阻碍:将输入文本分割成有意义且自包含的块的困难,以及现有块微调方法效率低下且可能降低性能的风险。为解决这些问题,我们首先构建了SemanticSeg,一个大规模且多样化的语义分割数据集,包含超过30k个实例,涵盖16个类别——包括书籍、代码、网页文本和对话,文本长度从2k到32k。利用该数据集,我们训练了一个轻量级分割器,能够自动将文本分割成符合人类直觉的块,且粒度可控。其次,我们提出了块蒸馏,一种比块微调更高效的训练框架,它使用冻结的全注意力教师模型来指导块注意力学生模型。该框架集成了三个新颖的组件:块汇合令牌以减轻块边界处的信息丢失,块丢弃以利用来自所有块的训练信号,以及令牌级损失加权以聚焦于对块注意力敏感的令牌的学习。跨多个模型和基准的实验表明,我们的分割器优于启发式和统计基线,且块蒸馏在块注意力下实现了接近全注意力的性能,为部署块注意力建立了一条实用且可扩展的路径。
英文摘要:
Block attention, which processes the input as separate blocks that cannot attend to one another, offers significant potential to improve KV cache reuse in long-context scenarios such as Retrieval-Augmented Generation (RAG). However, its broader application is hindered by two key challenges: the difficulty of segmenting input text into meaningful, self-contained blocks, and the inefficiency of existing block fine-tuning methods that risk degrading performance. To address these, we first construct SemanticSeg, a large and diverse semantic segmentation dataset containing over 30k instances across 16 categories-including books, code, web text, and conversations with text lengths ranging from 2k to 32k. Using this dataset, we train a lightweight segmenter to automatically partition text into human-instinct-aligned blocks with controllable granularity. Second, we propose block distillation, a training framework that is more efficient than block fine-tuning, which uses a frozen full-attention teacher model to guide the block-attention student. This framework integrates three novel components: block sink tokens to mitigate information loss at block boundaries, block dropout to leverage training signals from all blocks, and token-level loss weighting to focus learning on block-attention-sensitive tokens. Experiments across multiple models and benchmarks demonstrate that our segmenter outperforms heuristic and statistical baselines, and block distillation achieves near-full-attention performance under block attention, establishing a practical and scalable pathway for deploying block attention.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。