arXiv:2512.20635cs.LG2025-12被引 1

通过智能路由与剪枝,让BERT模型变小48%仍保持93%准确率。

SHRP: Specialized Head Routing and Pruning for Efficient Encoder Compression

  • 将注意力头视为独立专家,用轻量共享网络整合输出。
  • 在GLUE上压缩48%参数,准确率损失仅7%,极端压缩下仍保84%准确率。
  • 适合追求低延迟、高吞吐的线上大模型部署场景。

Transformer编码器广泛应用于文本分类、语义检索和内容排序等自然语言理解任务,但其高推理延迟和内存消耗制约了实时服务与可扩展性。这主要源于架构冗余,尤其是注意力模块的参数冗余。注意力头之间相对独立,适合结构化压缩。本文提出SHRP(Specialized Head Routing and Pruning)框架,自动识别并移除冗余注意力头,同时保留模型大部分精度与兼容性。SHRP引入专家注意力机制,将每个注意力头视为独立专家,并通过轻量共享扩展前馈网络融合输出。该框架采用统一的Top-1使用驱动机制,联合实现训练时动态路由与部署时确定性剪枝。在BERT-base模型上进行GLUE基准测试,SHRP在减少48%参数的同时达到原模型93%的准确率;在极端压缩场景下(11/12层被剪),模型仍保持84%准确率,计算量降至原模型11.5%的FLOPs,吞吐提升4.2倍,验证了其在大规模、低延迟网络部署中的实用性。

原文摘要 · Abstract (English)

Transformer encoders are widely deployed in large-scale web services for natural language understanding tasks such as text classification, semantic retrieval, and content ranking. However, their high inference latency and memory consumption pose significant challenges for real-time serving and scalability. These limitations stem largely from architectural redundancy, particularly in the attention module. The inherent parameter redundancy of the attention mechanism, coupled with the fact that its attention heads operate with a degree of independence, makes it particularly amenable to structured model compression. In this paper, we propose SHRP (Specialized Head Routing and Pruning), a novel structured pruning framework that automatically identifies and removes redundant attention heads while preserving most of the model's accuracy and compatibility. SHRP introduces Expert Attention, a modular design that treats each attention head as an independent expert, followed by a lightweight shared expander feed-forward network that refines their outputs. The framework employs a unified Top-1 usage-driven mechanism to jointly perform dynamic routing during training and deterministic pruning at deployment. Experimental results on the GLUE benchmark using a BERT-base encoder show that SHRP achieves 93% of the original model accuracy while reducing parameters by 48 percent. Under an extreme compression scenario where 11/12 of the layers are pruned, the model still maintains 84% accuracy and delivers a 4.2x throughput gain while reducing computation to as low as 11.5 percent of the original FLOPs, demonstrating its practical utility for large-scale and latency-sensitive web deployments.

模型压缩注意力剪枝BERT优化高效推理

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