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:
- 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.
- 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.
- 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.
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), andHQS(summarization). - Legal: Benchmarked using
MultiLegalPile(generation),CaseHOLD(QA), andBillSum(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 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