Pruning as a Domain-specific LLM Extractor

Nan Zhang, Yanchi Liu, Xujiang Zhao, Wei Cheng, Runxue Bao, Rui Zhang, Prasenjit Mitra, Haifeng Chen

Abstract

Large Language Models (LLMs) have exhibited remarkable proficiency across a wide array of NLP tasks. However, the escalation in model size also engenders substantial deployment costs. While few efforts have explored model pruning techniques to reduce the size of LLMs, they mainly center on general or task-specific weights. This leads to suboptimal performance due to lacking specificity on the target domain or generality on different tasks when applied to domain-specific challenges. This work introduces an innovative unstructured dual-pruning methodology, D-Pruner, for domain-specific compression on LLM. It extracts a compressed, domain-specific, and task-agnostic LLM by identifying LLM weights that are pivotal for general capabilities, like linguistic capability and multi-task solving, and domain-specific knowledge. Our comprehensive experiments across various tasks in healthcare and legal domains show the effectiveness of D-Pruner in domain-specific compression.

Introduction

The deployment of Large Language Models (LLMs) is increasingly constrained by their massive parameter counts and associated computational costs. While model pruning offers a path toward efficiency, existing techniques often struggle with a "generality vs. specificity" trade-off. Standard post-training pruning methods often prioritize general linguistic capabilities but fail to capture the nuances of specialized domains. Conversely, task-specific pruning methods can compromise the model's general reasoning abilities and natural language flow.

To address this, we propose D-PRUNER, a novel unstructured dual-pruning strategy. D-PRUNER treats pruning as an "extraction" process, aiming to isolate a specialized sub-network that maintains core reasoning abilities while mastering domain-specific knowledge.

Methodology: The Dual-Pruning Approach

D-PRUNER identifies and preserves weights critical for both general capabilities and domain-specific expertise. The methodology follows a three-stage workflow:

  1. General Weight Assessment: Using an open-domain calibration dataset (e.g., C4), the model identifies weights essential for general language understanding via a Taylor expansion of the loss function.
  2. Regularized Loss Update: During domain adaptation, the training loss is updated with a regularization term that penalizes the removal of the "general-purpose" weights identified in the first stage.
  3. Dual-Pruning Importance Scoring: A final importance score is calculated using a small domain-specific calibration set. This is efficiently approximated using the empirical Fisher information matrix, avoiding the high cost of full-model retraining.
Conceptual comparison of D-PRUNER's dual-pruning strategy against standard post-training and task-specific pruning.

This approach ensures the resulting model is task-agnostic within its domain, capable of handling diverse tasks such as QA, summarization, and inference within a specialized field.

Experimental Setup

We evaluated D-PRUNER across two knowledge-intensive domains:

  • Healthcare: Benchmarked using InternalMed_Harrison (generation), MedNLI (inference), PubMedQA (QA), and HQS (summarization).
  • Legal: Benchmarked using MultiLegalPile (generation), CaseHOLD (QA), and BillSum (summarization).

Calibration was performed using the C4 dataset for general capabilities and small subsets of the domain-specific datasets for specialized knowledge.

Results and Discussion

Our experiments demonstrate that D-PRUNER effectively extracts high-performing domain-specific models at 50% sparsity.

Performance comparison of D-PRUNER against dense and pruned baselines across Healthcare and Legal domains for LLaMA2-7B and 13B.

Performance at 50% Sparsity

D-PRUNER models consistently matched or exceeded the performance of full-sized dense LLaMA2-7B and 13B models. Notably, on the PubMedQA task, D-PRUNER (7B) achieved a score of 45.38, significantly outperforming SparseGPT’s 36.22. The method also showed exceptional strength in summarization tasks, frequently surpassing the original dense model's ROUGE scores.

The "Extractor" Philosophy

The success of D-PRUNER supports the philosophy that specialized sub-networks are latent within foundation models. Analysis of mask similarity suggests that self-attention modules are primary drivers of domain specificity, while MLP modules tend to store more domain-shared, general knowledge. Furthermore, the observation that pruned models can outperform dense ones suggests that removing weights irrelevant to the target domain can reduce noise and improve focus.

Limitations and Future Work

While effective, D-PRUNER requires full-parameter gradients to calculate importance, leading to higher memory overhead during the pruning phase compared to one-shot methods. Additionally, while D-PRUNER excels in task-specific accuracy, methods like SparseGPT may maintain slightly better general linguistic perplexity. Future research will explore combining dual-pruning with quantization for more extreme compression and extending the pipeline to diverse architectures beyond LLaMA.

Summary updated

BibTeX
@inproceedings{zhang2024pruning,
  author = {Nan Zhang and Yanchi Liu and Xujiang Zhao and Wei Cheng and Runxue Bao and Rui Zhang and Prasenjit Mitra and Haifeng Chen},
  title = {{Pruning as a Domain-specific LLM Extractor}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2024},
  url = {https://openreview.net/forum?id=saYhULa3Do},
}
Figure