通过层合并压缩Transformer深度,保留更多知识且加速推理
FlattenGPT: Depth Compression for Transformer with Layer Flattening
- 将相邻两层合并为一层,实现深度压缩并更好检测冗余
- 在多种模型上保持90%-96%零样本性能,压缩率达20%
- 适合需要高效推理的大型语言模型部署场景
近期研究发现Transformer块间存在冗余,促使深度压缩成为模型剪枝的新方向。然而,现有整块剪枝方法易丢失关键特征,导致性能显著下降。通道剪枝虽能较好保留性能,却无法减少模型深度,且各层剪枝比例不一致。为此,本文提出FlattenGPT,一种新型深度冗余检测与压缩方法。通过将相邻两层扁平化合并为一层,既压缩了网络深度,又增强了参数冗余检测与移除效果。该方法可完整保留各层学习到的知识,且与原始Transformer架构保持一致。大量实验表明,FlattenGPT在保持性能的同时提升模型效率,在不同模型类型和参数规模下均优于现有剪枝方法。在LLaMA-2/3与Qwen-1.5模型上,压缩比达20%时仍保持90%-96%的零样本准确率,并显著加速大模型推理,展现出良好的应用前景。
原文摘要 · Abstract (English)
Recent works have indicated redundancy across transformer blocks, prompting the research of depth compression to prune less crucial blocks. However, current ways of entire-block pruning suffer from risks of discarding meaningful cues learned in those blocks, leading to substantial performance degradation. As another line of model compression, channel pruning can better preserve performance, while it cannot reduce model depth and is challenged by inconsistent pruning ratios for individual layers. To pursue better model compression and acceleration, this paper proposes \textbf{FlattenGPT}, a novel way to detect and reduce depth-wise redundancies. By flatting two adjacent blocks into one, it compresses the network depth, meanwhile enables more effective parameter redundancy detection and removal. FlattenGPT allows to preserve the knowledge learned in all blocks, and remains consistent with the original transformer architecture. Extensive experiments demonstrate that FlattenGPT enhances model efficiency with a decent trade-off to performance. It outperforms existing pruning methods in both zero-shot accuracies and WikiText-2 perplexity across various model types and parameter sizes. On LLaMA-2/3 and Qwen-1.5 models, FlattenGPT retains 90-96\% of zero-shot performance with a compression ratio of 20\%. It also outperforms other pruning methods in accelerating LLM inference, making it promising for enhancing the efficiency of transformers.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。