Large language models (LLMs) have shown remarkable capabilities in language understanding and generation. However, such impressive capability typically comes with a substantial model size, which presents significant challenges in both the deployment, inference, and training stages. With LLM being a general-purpose task solver, we explore its compression in a task-agnostic manner, which aims to preserve the multi-task solving and language generation ability of the original LLM. One challenge to achieving this is the enormous size of the training corpus of LLM, which makes both data transfer and model post-training over-burdensome. Thus, we tackle the compression of LLMs within the bound of two constraints: being task-agnostic and minimizing the reliance on the original training dataset. Our method, named LLM-Pruner, adopts structural pruning that selectively removes non-critical coupled structures based on gradient information, maximally preserving the majority of the LLM's functionality. To this end, the performance of pruned models can be efficiently recovered through tuning techniques, LoRA, in merely 3 hours, requiring only 50K data. We validate the LLM-Pruner on three LLMs, including LLaMA, Vicuna, and ChatGLM, and demonstrate that the compressed models still exhibit satisfactory capabilities in zero-shot classification and generation. The code is available at: https://github.com/horseee/LLM-Pruner
翻译:大型语言模型(LLMs)在语言理解与生成方面展现出卓越能力。然而,这种惊人能力通常伴随着庞大的模型规模,在部署、推理和训练阶段均带来重大挑战。鉴于LLM作为通用任务求解器的特性,我们探索其任务无关的压缩方法,旨在保留原始LLM的多任务求解与语言生成能力。实现这一目标的关键挑战在于LLM训练语料库的巨大规模,这使得数据传输和模型后训练均过于繁重。因此,我们在两个约束条件下开展LLM压缩研究:任务无关性及最小化对原始训练数据集的依赖。我们提出的方法名为LLM-Pruner,采用结构化剪枝技术,基于梯度信息选择性移除非关键耦合结构,最大程度保留LLM的核心功能。通过仅需5万条数据和3小时微调技术LoRA即可高效恢复剪枝模型性能。我们在LLaMA、Vicuna和ChatGLM三种LLM上验证了LLM-Pruner,证明压缩模型在零样本分类与生成任务中仍具备令人满意的能力。代码访问地址:https://github.com/horseee/LLM-Pruner