Reading + AI

Streamlining Redundant Layers to Compress Large Language Models

Xiaodong Chen, Yuxuan Hu, Jing Zhang, Yanling Wang, Cuiping Li, Hong Chen

arXiv:2403.19135v5 · This workspace stays on this version. Check arXiv for newer versions

Affiliations and author notes
  • Renmin University of China, China
  • chenxiaodong@ruc.edu.cn
  • huyuxuan1999@ruc.edu.cn
  • zhang-jing@ruc.edu.cn
  • Zhongguancun Laboratory, China
  • licuiping@ruc.edu.cn
  • chong@ruc.edu.cn
  • wangyl@zgclab.edu.cn
Some source details need review 1 to check

Original formulas, table values and figures are preserved. Comparison can miss differences; use the original PDF to check details.

Reading view checked: 102 math expressions, 2 rendering failures; 38 of 38 images available.

Compared 114 of 114 source passages against 21 of 21 PDF pages.

  • Some formulas could not be rendered; their original TeX is shown. Check the original PDF. (2)

38 of 38 figure, table and graphic images captured. Open original PDF

Abstract

This paper introduces LLM-Streamline, a pioneer work on layer pruning for large language models (LLMs). It is based on the observation that different layers have varying impacts on hidden states, enabling the identification of less important layers to be pruned. LLM-Streamline comprises two parts: layer pruning, which removes consecutive layers with the lowest importance based on target sparsity, and layer replacement, a novel module that trains a lightweight network to replace the pruned layers to mitigate performance loss. Additionally, a new metric called stability is proposed to address the limitations of the widely used accuracy metric in evaluating model compression. Experiments show that LLM-Streamline outperforms both previous and concurrent state-of-the-art pruning methods in terms of both performance and training efficiency. Our code is available at this repository.

Figure 1
Figure 1: The left side of the figure illustrates the LLM-Streamline workflow, which includes layer pruning to remove consecutive layers and layer replacement where a lightweight network is trained to replace the pruned layers. The right side of the figure presents the comparison results of LLM-Streamline with the state-of-the-art (SOTA) pruning methods on 12 classification benchmarks (details in Section 4.2) after pruning about 25% of the parameters on Llama2-7B. LLM-Streamline achieves 11.2% higher relative accuracy than these methods, where the relative accuracy represents the percentage of the original model’s accuracy retained by the pruning method.

Large language models (LLMs) built on the Transformer architecture (Vaswani et al., 2017) have gained widespread attention and are applied across diverse domains and tasks. However, as LLMs increase in size, their hardware requirements escalate substantially, thereby constraining their applicability and impeding their deployment in real-world scenarios. To reduce the hardware requirements for deploying LLMs, research efforts have been devoted to developing compact models that maintain high performance through model compression (Zhu et al., 2023; Wang et al., 2024). Currently, model compression techniques are widely categorized into knowledge distillation (Hinton et al., 2015; Gou et al., 2021; Li et al., 2022; Huang et al., 2022; Ho et al., 2022), quantization (Liu et al., 2021; Gholami et al., 2022; Dettmers et al., 2022), and pruning (Louizos et al., 2017; Chen et al., 2023; Frantar & Alistarh, 2023; Das et al., 2023; Sun et al., 2023; Xia et al., 2023). Knowledge distillation achieves compression by transferring the capabilities of a larger teacher model to a smaller student model. Quantization compresses the model by quantizing the weights to lower precision. Alternatively, pruning compresses the model by eliminating unimportant parameters and modules.

This work focuses on the popular pruning methods. Previous approaches for LLM primarily prune dense matrices (Ashkboos et al., 2024), attention heads (Michel et al., 2019; Voita et al., 2019), filters (McCarley et al., 2019; Prasanna et al., 2020), or prune parameters to reduce an LLM’s hidden dimension (Xia et al., 2023; van der Ouderaa et al., 2023; Hu et al., 2024). Despite their effectiveness, these methods often result in structural irregularities, making it inflexible to store and deploy the pruned models. In contrast, layer pruning method simply reduces the depth of LLMs. As the layers of LLMs are stored in data structures like nn.ModuleList, layer pruning only requires removing elements from this list, making it more flexible for application. Therefore, exploring an effective layer-wise pruning method is crucial.

Figure 2
Figure 2: The cosine similarity between the input and output hidden states of each layer in OPT-1.3B, OPT-2.7B, OPT-6.7B, and Llama2-7B.

The core idea of layer pruning is to identify and remove less important layers in an LLM. Specifically, the effect of each layer can be viewed as a transformation of the hidden states. If the input and output hidden states of a particular layer are highly similar, such as exhibiting high cosine similarity, we can say that the layer has a small impact on adjusting the hidden states. As illustrated in Fig. 2, our pilot study shows that certain contiguous layers indeed have smaller impact on the hidden states, indicating they are less important and suitable for pruning. Some concurrent works (Song et al., 2024; Kim et al., 2024; Yang et al., 2024; Men et al., 2024; Gromov et al., 2024) also explore layer pruning. These studies either prune unimportant layers directly without further training (Song et al., 2024; Men et al., 2024) or fine-tune the pruned model to enhance performance (Kim et al., 2024; Yang et al., 2024; Gromov et al., 2024). Directly removing layers can lead to more performance degradation. While parameter-efficient fine-tuning techniques like LoRA (Hu et al., 2021) are used to train the pruned LLM, fine-tuning the model to make the original non-contiguous layers compensate for the performance degradation is not an easy task (details in Section 2.3).

In this work, we propose a layer pruning method called LLM-Streamline, which exhibits advantages in both performance and training efficiency while requiring less training data. LLM-Streamline comprises two components: layer pruning and layer replacement. According to a certain target sparsity, the first step removes consecutive layers with the lowest importance from the original LLM. Subsequently, we train a lightweight network to replace the pruned layers, aiming to recover the performance degradation caused by pruning. We can employ various architectures for this lightweight network, including a feed-forward neural network (FFN), a SwiGLU-based feed-forward neural network (SwiGLU), and a Transformer layer.

Additionally, we find that existing accuracy metrics for evaluating model compression methods have limitations. Specifically, in natural language understanding tasks that involve multiple-choice classification, a compressed model may guess correct answers for samples on which the original model was uncertain, resulting in an overestimation of the compression performance. To address this issue, we propose a new metric named stability, which measures the consistency of predictions before and after pruning, considering the prediction confidence of the original model.

Overall, this paper makes the following contributions:

  • •

    We propose LLM-Streamline, a layer-wise pruning algorithm that demonstrates superior effectiveness and efficiency compared to concurrent methods. To mitigate the potential performance degradation caused by pruning, we propose to use a lightweight network to approximate the functionality of the pruned layers.

  • •

    We propose a new metric called stability, which considers both the prediction confidence of the original model and the consistency of predictions before and after pruning. Stability provides a more accurate reflection of the pruned model’s performance in classification tasks compared to the widely used accuracy metric.

  • •

    We conduct experiments on 12 well-known classification benchmarks and 3 generation benchmarks. Our results show that for an LLM with 7B or 13B parameters and a 25% pruning rate, we can maintain 93% performance in classification tasks and 77% in generation tasks without requiring a lot of training data, outperforming existing SOTA pruning methods.

The workflow of the LLM-Streamline framework, shown in Fig. 1 (a), comprises two main steps: layer pruning and layer replacement. First, we prune redundant layers from the LLMs. Then, we train a lightweight network to replace the pruned layers to restore the model’s performance.

LLMs primarily utilize a Transformer architecture, consisting of a series of Transformer decoder layers. These layers adopt a residual structure, so the effect of each Transformer layer can be viewed as a transformation of the input hidden states. Assuming that the parameters of the ℓ\ell-th layer ff are denoted as θ(ℓ)\theta^{(\ell)}, and its input hidden states are represented by x(ℓ)\bm{x}^{(\ell)}, the layer ff can be expressed as

x(ℓ+1)=x(ℓ)+f(x(ℓ),θ(ℓ)).\displaystyle\bm{x}^{(\ell+1)}=\bm{x}^{(\ell)}+f(\bm{x}^{(\ell)},\theta^{(\ell)}).
(1)

In Eq. 1, the ℓ\ell-th layer ff contributes a transformation f(x(ℓ),θ(ℓ))f(\bm{x}^{(\ell)},\theta^{(\ell)}) to the input x(ℓ)\bm{x}^{(\ell)}. Therefore, we assess the importance of each layer in LLMs by evaluating its impact on the input hidden states. We use the cosine similarity cos⁡(⋅,⋅)\cos{(\cdot,\cdot)} between input x(ℓ)\bm{x}^{(\ell)} and output x(ℓ+1)\bm{x}^{(\ell+1)} as a metric. Essentially, a higher cosine similarity between the input and output of a layer indicates lower importance, and vice versa. This interpretation arises from the observation that a high cosine similarity suggests the layer’s transformation is minimal, making it more amenable to pruning.

To measure the importance of different layers in LLMs, we randomly select samples from the pre-training data (details in Section 4.1). We then record the hidden states generated by the LLMs for these samples and compute the cosine similarity between the input and output hidden states of each layer. The computation of cosine similarity can be formalized as follows,

cos⁡(x(ℓ),x(ℓ+1))=E(xi(ℓ),xi(ℓ+1))∈D(1L∑j=1Lxi,j(ℓ)⋅xi,j(ℓ+1)∥xi,j(ℓ)∥⋅∥xi,j(ℓ+1)∥),\displaystyle\cos{(\bm{x}^{(\ell)},\bm{x}^{(\ell+1)})}=\mathbb{E}_{(\bm{x}^{(\ell)}_{i},\bm{x}^{(\ell+1)}_{i})\in\mathcal{D}}\left(\frac{1}{L}\sum_{j=1}^{L}\frac{\bm{x}^{(\ell)}_{i,j}\cdot\bm{x}^{(\ell+1)}_{i,j}}{\|\bm{x}^{(\ell)}_{i,j}\|\cdot\|\bm{x}^{(\ell+1)}_{i,j}\|}\right),
(2)

where D\mathcal{D} denotes the recorded hidden states from different samples, xi(ℓ)\bm{x}^{(\ell)}_{i}, xi(ℓ+1)∈Rd×L\bm{x}^{(\ell+1)}_{i}\in R^{d\times L} denotes the input and output hidden states of the ii-th sample respectively, dd denotes the hidden size and LL denotes the sequence length of each sample.

To mitigate the effects of model size and model structure, we conduct experiments on four models OPT-1.3B, OPT-2.7B, OPT-6.7B (Zhang et al., 2022), and Llama2-7B (Touvron et al., 2023). The results, illustrated in Fig. 2, show that there is high cosine similarity between the input and output of several consecutive layers in all models, indicating a low level of importance.

Discussion I: Why not use other similarity to measure the importance of layers? In deep learning, cosine similarity is widely employed to measure the similarity between two vectors (Chen et al., 2020; Chen & He, 2021; Reimers, 2019). Alongside it, dot product and Euclidean distance are also utilized, but they additionally consider vector magnitude. Current research suggests that the hidden states of Transformers with the Pre-Norm architecture tend to grow as the depth of layers increases (Liu et al., 2023). This trend leads to a bias where deeper layers in the model have higher dot product similarity, while earlier layers have smaller Euclidean distances. Consequently, we opt for cosine similarity, which is agnostic to the magnitude of the vectors.

Discussion II: Why not use perplexity as the metric to measure the importance of layers? Some concurrent layer pruning work uses perplexity as the metric to measure the importance of layers (Song et al., 2024; Kim et al., 2024). Specifically, they remove each layer one at a time, measuring the change in perplexity of the model on the pre-training data, and eliminate the layer that causes the least change. This process is repeated multiple times to remove several layers. However, we think perplexity is a highly data-sensitive metric, which results in different layers being removed when pruning with different pre-training data. This also results in a situation where, although the perplexity of the pruned model on the pre-training data used for pruning is low, it performs poorly on other datasets. In contrast, the cosine similarity is highly stable and always leads to the same pruned layers on different pre-training data. We conduct detailed experiments in the Appendix A to demonstrate that perplexity is a highly data-sensitive metric and performs poorly on downstream tasks.

As Fig. 2 shows, the less important layers are often contiguous. Hence, given number of pruned layers nn determined by a target sparsity, we remove nn contiguous layers by finding the initial layer ℓ∗(n)\ell^{*}(n) corresponding to the highest cosine similarity for pruning:

ℓ∗(n)=arg⁡max⁡ℓ cos⁡(x(ℓ),x(ℓ+n)),\displaystyle\ell^{*}(n)=\underset{\ell}{\arg\max}\,\cos(\bm{x}^{({\ell})},\bm{x}^{({\ell+n})}),
(3)

where we randomly select samples from the pre-training data to compute the cosine similarity between x(ℓ)\bm{x}^{(\ell)} and x(ℓ+n)\bm{x}^{(\ell+n)}, as outlined in Eq. 2.

After the layer pruning process, we aim to replace the pruned layer with a lightweight network that has much fewer parameters. The rationale is that these layers contribute only minor transformations to the input. Therefore, we hypothesize that the cumulative effect of these layers can be approximated by a lightweight network. Specifically, after identifying the initial layer ℓ∗(n)\ell^{*}(n) for pruning, we use (x(ℓ∗),x(ℓ∗+n))(\bm{x}^{(\ell^{*})},\bm{x}^{(\ell^{*}+n)}) as the training data to train the lightweight network using mean squared error (MSE) loss, which can be formalized as follows:

minh  E(xi(ℓ∗),xi(ℓ∗+n))∈DMSE(h(xi(ℓ∗)),xi(ℓ∗+n)),\displaystyle\underset{h}{\text{min}}\;\mathbb{E}_{(\bm{x}^{(\ell^{*})}_{i},\bm{x}^{(\ell^{*}+n)}_{i})\in\mathcal{D}}{\rm MSE}(h(\bm{x}^{(\ell^{*})}_{i}),\bm{x}^{(\ell^{*}+n)}_{i}),
(4)

where hh denotes the lightweight network, D\mathcal{D} denotes the recorded hidden states of samples.

Discussion: Layer Replacement or Fine-Tuning Pruned LLMs? Here, we discuss why opt for layer replacement, instead of using common Parameter-Efficient Fine-Tuning (PEFT) methods such as LoRA  (Hu et al., 2021) and QLoRA  (Dettmers et al., 2023) after layer pruning.

First, from the perspective of resource overhead, layer replacement is more adaptable to hardware resource constraints compared to other methods. Fine-tuning the model using the PEFT methods requires storing the model’s weights, activation values, and the optimizer state of the PEFT module in the GPU during training. In contrast, layer replacement involves two stages: dataset construction and model training. The first stage only requires storing the model’s weight and the forward computation overhead, and the second stage only requires storing of the lightweight network’s weight, activation values of lightweight network, and the optimizer state of lightweight network. Therefore, layer replacement can also be implemented under conditions of hardware resource constraints.

Second, layer replacement uses a lightweight network to replace the pruned layer, and distills the knowledge of the pruned layer into the lightweight network using the MSE loss function. Unlike layer replacement, we speculate that training the model after pruning with LoRA is a process of redistributing the function of the pruned layers across the remaining layers. Therefore, substituting the pruned layers with a lightweight network could be a less challenging training task than redistributing the function of the pruned layers across the remaining layers. In the experiments of Section 4.7, we demonstrate that layer replacement has better performance compared to LoRA.

Table 1
Dataset#TP\#{\rm TP}#FN\#{\rm FN}#FP\#{\rm FP}#TN\#{\rm TN}
C3543257210815
CHID269563177993
Race-M38095129832
Race-H9383053531902
Table 1
ModelTP{\rm TP}FN{\rm FN}FP{\rm FP}TN{\rm TN}
Llama2-7B1.120.870.941.02
w/ pruning1.130.840.880.92
Table 1: (a) Number of samples in TP,FN,FP{\rm TP},{\rm FN},{\rm FP}, and TN{\rm TN}. (b) The PPL standard deviation results (×10−3\times 10^{-3}) for Llama2-7B and its pruned version on Race-H.
View original tableOriginal Table 1

Accuracy is the most commonly used metric for evaluating LLMs in classification tasks. However, accuracy may overestimate the performance of the model after compression, since it does not take into account the consistency of the model’s answers before and after compression. In this section, we analyze such limitation and propose a novel metric for evaluating compressed models.

When evaluating the natural language understanding capabilities of LLMs, most existing benchmarks frame the task as a classification task. A classification task with kk choices and comprising NN samples is denoted as T={(xi,ci,1,ci,2,...,ci,k,yi)}i=1N\mathcal{T}=\{\left(x_{i},c_{i,1},c_{i,2},...,c_{i,k},y_{i}\right)\}_{i=1}^{N}, where xix_{i} represents the question in the ii-th sample, ci,jc_{i,j} represents the jj-th choices, and yiy_{i} represents the correct choice. The input to the classification task consists of a question accompanied by multiple choices, and the LLM is required to select the correct answer from these choices. Typically, each choice is concatenated with the question to form multiple sentences, and the perplexity (PPL) of each sentence is computed. The choice corresponding to the sentence with the lowest PPL is selected as the answer.

Typically, model pruning results in decreased model performance. However, when we evaluate the model pruned by the method described in Sec 2.2, we unexpectedly observe the accuracy of the pruned model has been improved on some classification tasks. We define M\mathcal{M} to denote the original LLM, Mˉ\bar{\mathcal{M}} to denote the compressed LLM, and y^(M)\hat{y}(\mathcal{M}) to denote the choice predicted by the model M\mathcal{M}. To further investigate this phenomenon, we analyze the experimental results using the confusion matrix  (Li et al., 2024). Specifically, we count the number of samples and average standard deviation (std) for the PPL of the samples for each term of the confusion matrix. The calculation of the std for the PPL of the ii-th sample is defined as follows:

PPLi,j=PPL(M(xi,ci,j)),PPLi=∑j=1kPPLi,jk,stdi=∑j=1k(PPLi,j−PPLi)2k−1,\displaystyle\mathrm{PPL}_{i,j}=\mathrm{PPL}(\mathcal{M}(x_{i},c_{i,j})),{\mathrm{PPL}}_{i}=\frac{\sum_{j=1}^{k}\mathrm{PPL}_{i,j}}{k},\mathrm{std}_{i}=\sqrt{\frac{\sum_{j=1}^{k}(\mathrm{PPL}_{i,j}-{\mathrm{PPL}}_{i})^{2}}{k-1}},
(5)

where PPLi,j{\rm PPL}_{i,j} denotes the PPL for the sentence created by question xix_{i} and choice ci,jc_{i,j} of the model before pruning, stdi{\rm std}_{i} denotes the std for PPL of the ii-th sample. A higher stdi\mathrm{std}_{i} value indicates the LLM exhibits greater confidence in answering the question xix_{i}.

Each term of the confusion matrix is defined as follows,

  • •

    TP[y^i(M)=yi∧y^i(Mˉ)=yi]{\rm TP}\left[\hat{y}_{i}({\mathcal{M}})=y_{i}\wedge\hat{y}_{i}(\bar{\mathcal{M}})=y_{i}\right] is a set of samples where the model answers correctly both before and after pruning.

  • •

    FN[y^i(M)=yi∧y^i(Mˉ)≠yi]{\rm FN}\left[\hat{y}_{i}({\mathcal{M}})=y_{i}\wedge\hat{y}_{i}(\bar{\mathcal{M}})\neq y_{i}\right] is a set of samples where the model answers correctly before pruning but incorrectly after pruning.

  • •

    FP[y^i(M)≠yi∧y^i(Mˉ)=yi]{\rm FP}\left[\hat{y}_{i}({\mathcal{M}})\neq y_{i}\wedge\hat{y}_{i}(\bar{\mathcal{M}})=y_{i}\right] is a set of samples where the model answers incorrectly before pruning but correctly after pruning.

  • •

    TN[y^i(M)≠yi∧y^i(Mˉ)≠yi]{\rm TN}\left[\hat{y}_{i}({\mathcal{M}})\neq y_{i}\wedge\hat{y}_{i}(\bar{\mathcal{M}})\neq y_{i}\right] is a set of samples where the model answers incorrectly both before and after pruning.

Table 1 presents the counts of samples in TP, FN, FP, TN in sevaral datasets, and also the PPL standard deviation in Race-H dataset. We can observe that the std for TP{\rm TP} and TN{\rm TN} is significantly higher than that for FN{\rm FN} and FP{\rm FP}. This indicates that the model is more uncertain about the FN{\rm FN} and FP{\rm FP} samples. In addition, the samples in FP{\rm FP} constitute a considerable proportion of the total samples, implying that the model may guess the correct answer for a significant portion after pruning. This phenomenon suggests that the accuracy metric may overestimate the performance of the compressed model.

We propose a novel metric stability to evaluate the performance of LLMs after pruning, i.e.,

Stability(M,Mˉ)=∑i=1N(exp⁡(stdi)⋅1[i∈TP∪TN])∑i=1Nexp⁡(stdj),\displaystyle\mathrm{Stability}(\mathcal{M},\bar{\mathcal{M}})=\frac{\sum_{i=1}^{N}\left(\exp{(\mathrm{std}_{i})}\cdot\mathbbm{1}_{\left[i\in{\rm TP}\cup{\rm TN}\right]}\right)}{\sum_{i=1}^{N}\exp{(\mathrm{std}_{j}})},
(6)

where the identifier 1[i∈TP∪TN]\mathbbm{1}_{\left[i\in{\rm TP}\cup{\rm TN}\right]} is used to indicate whether the ii-th sample belongs to TP{\rm TP} and TN{\rm TN}. We use stdi{\rm std}_{i} as the weight of the ii-th sample. Because the std{\rm std} of different samples varies significantly, to mitigate the influence of samples with excessively large standard deviations, we apply the exp⁡\exp function to moderate the weight differences among samples. Different from accuracy, stability focuses on the model’s confidence in its answers and the consistency between the model before and after pruning on a task, aligning more closely with the goal of model pruning, i.e., ensuring the pruned model remains as similar as possible to the original model.

In this section, we first compare our proposed method, LLM-Streamline, with several popular pruning methods to demonstrate its effectiveness (4.4). Next, we analyze the impact of different sizes and structures of lightweight networks on model performance (4.5) and evaluate performance under various pruning ratios (4.6). Finally, we compare our layer replacement approach with the well-known PEFT method, LoRA (Hu et al., 2021) (4.7), showing that layer replacement offers superior performance and reduced memory overhead.

We conduct experiments on popular open-source LLMs, including Llama2-7B and Llama2-13B (Touvron et al., 2023). Following previous work (Men et al., 2024; Yang et al., 2024), we perform experiments with a 25% pruning rate and extract data from pre-training dataset SlimPajama which contains data from different domains for layer pruning and layer replacement. Sheared LLaMa  (Xia et al., 2023) finds that the performance degradation of pruned models varies across different domains, and proposes determining the distribution of data from different domains based on the degree of performance degradation. Therefore, we randomly sample the data based on the distribution used by Sheared LLaMa  (Xia et al., 2023), finally constructing the dataset containing 30,000 pieces of data. We randomly select 500 samples from this dataset and input them into LLMs, generating Fig. 2, and use these 500 data samples for layer pruning. All 30,000 pieces of data are used to train the lightweight network. We utilize two types of lightweight networks: a Feed-Forward Neural Network (FFN), referred to as Ours (FFN), and a Transformer Layer, referred to as Ours (Layer). The FFN is randomly initialized, while the Transformer Layer inherits the parameters from the first pruned layer. Additionally, we explore a purely pruning approach without incorporating any lightweight network, denoted as Ours (None). Further experimental details are available in the Appendix C.1.

We use 12 natural language understanding benchmarks for evaluation: CMNLI  (Xu et al., 2020), HellaSwag(HeSw)  (Zellers et al., 2019), PIQA  (Bisk et al., 2020),CHID  (Zheng et al., 2019), WSC  (Levesque et al., 2012),CommonSenseQA(CoQA)  (Talmor et al., 2018), BoolQ  (Clark et al., 2019),MMLU  (Hendrycks et al., 2020), CMMLU  (Li et al., 2023),Race-High/Middle  (Lai et al., 2017), C3  (Sun et al., 2020). The tasks in these benchmarks are formalized as classification tasks, so we refer to these benchmarks as classification benchmarks. For these benchmarks, we use both accuracy and stability as metrics for evaluating the models. Additionally, we include 3 benchmarks: XSum  (Narayan et al., 2018), GSM8K  (Cobbe et al., 2021) and StrategyQA  (Geva et al., 2021), to demonstrate the LLM’s performance on generation tasks after pruning. We refer to these tasks as generation benchmarks. Following the evaluation framework of OpenCompass (Contributors, 2023), we use accuracy to evaluate StrategyQA and GSM8K, and use ROUGE1 to evaluate Xsum.

We compare several pruning methods that prune the attention heads, the filters of the FFN layer, and the hidden dimension, as well as the concurrent layer-pruning methods LaCo. In addition, ShortGPT and UIDL (Men et al., 2024; Gromov et al., 2024) can be considered as a variant of our approach, i.e., Ours (None). We also discuss layer pruning methods which use perplexity as the metric, such as SLEB (Song et al., 2024), in Appendix A.

LLM-Pruner (Ma et al., 2023) prunes attention heads, FFN layer filters, and hidden dimensions by using gradients and activations to estimate the importance of these modules.

SliceGPT (Ashkboos et al., 2024) prunes hidden dimensions. It inserts dimensionality reduction matrices into the model and employs Principal Component Analysis (PCA) to initialize and compress the matrices, and then merge them with the original weight matrix to reduce the model’s size.

LaCo (Yang et al., 2024) prunes layers by dividing the layers into groups, each consisting of multiple consecutive layers, and compresses them separately, whereas our method simply compresses a piece of consecutive layers. LaCo merges consecutive layers by averaging their parameters whereas we train an additional lightweight network to replace these layers.

Table 2
LLMMethodRatioBenchmarksAverageRP
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Llama2-7BDense0.00%43.833.041.670.837.566.771.378.133.135.546.831.849.2100.0
LLMPruner24.8%29.733.428.458.740.448.554.672.022.922.025.325.038.478.0
SliceGPT25.4%31.531.618.559.943.349.647.568.327.029.428.824.838.478.0
LaCo*27.0%39.734.436.164.140.445.755.769.823.622.626.525.240.381.9
Ours (None)24.0%40.234.421.567.340.451.759.769.035.234.744.628.944.089.4
Ours (FFN)25.0%40.733.022.865.938.560.661.271.238.038.747.031.745.893.1
Ours (Layer)24.0%43.333.024.167.536.559.261.171.534.837.045.529.445.291.9
Llama2-13BDense0.00%47.533.047.271.551.066.874.879.860.058.155.838.757.0100.0
LLMPruner24.4%29.533.029.558.047.143.754.772.721.922.525.224.938.667.7
SliceGPT23.6%38.630.518.337.842.338.345.661.924.025.030.625.634.961.2
LaCo*24.6%44.932.940.164.052.952.764.474.356.654.545.932.651.390.0
Ours (None)24.6%47.033.036.562.364.458.866.673.560.258.354.838.454.595.6
Ours (FFN)25.4%45.833.037.167.437.564.467.974.058.658.255.738.653.293.3
Ours (Layer)24.6%45.733.038.066.236.563.869.175.158.057.455.139.253.193.2
Table 2: Accuracy of pruning methods on classification benchmarks. “*” indicates that we refer to the results in the original paper. Retained performance (RP) represents the percentage of the original model’s performance retained by the pruning method.
View original tableOriginal Table 2
Table 3
LLMMethodRatioBenchmarksAverage
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Llama2-7BLLMPruner24.8%72.894.074.170.887.571.079.986.852.455.253.365.972.0
SliceGPT25.4%53.235.453.377.180.875.371.678.790.785.360.356.768.2
Ours (None)24.0%76.638.765.381.487.574.780.781.073.767.980.170.873.2
Ours (FFN)25.0%79.810064.183.193.380.784.784.685.179.087.582.583.7
Ours (Layer)24.0%79.810064.486.395.281.785.385.681.879.082.471.082.7
Llama2-13BLLMPruner24.4%71.610069.270.565.469.577.886.742.335.648.152.365.8
SliceGPT23.6%62.239.551.427.168.365.564.975.645.343.452.752.954.1
Ours (None)24.6%84.299.971.877.446.282.285.786.583.383.689.183.881.1
Ours (FFN)25.4%85.710072.579.859.689.289.489.784.883.393.690.784.9
Ours (Layer)24.6%87.410074.181.358.689.090.590.584.283.092.585.584.7
Table 3: Stability of pruning methods on classification benchmarks. The stability of the original model is 1.0, because stability is measured by comparing the prediction results of the original model.
View original tableOriginal Table 3
Table 4
LLMMethodRatioBenchmarksAverageRP
XsumGSM8KStrategyQA
Llama2-7BDense0.00%19.416.560.232.0100.0
LLMPruner24.8%16.40.6144.220.463.8
SliceGPT25.4%12.43.3445.720.564.1
LaCo*27.1%15.6----
Ours (None)24.0%14.81.9741.819.560.9
Ours (FFN)25.0%18.62.1646.522.470.0
Ours (Layer)24.0%20.21.8252.124.777.2
Llama2-13BDense0.00%23.729.058.136.9100.0
LLMPruner24.4%17.51.943.721.056.9
SliceGPT23.6%5.01.938.315.140.9
LaCo*24.6%14.5----
Ours (None)24.6%17.72.3546.022.059.6
Ours (FFN)25.4%21.44.1059.628.477.0
Ours (Layer)24.6%21.84.7057.327.975.6
Table 4: Evaluations on generation benchmarks. “*” indicates that we refer to the results in the original paper.
View original tableOriginal Table 4
Table 5
Layer-RandomLayer-FirstLayer-LastLayer-AvgFFN†FFNSwiGLU†SwiGLU
Accuracy45.145.245.644.446.045.843.844.2
Stability81.282.781.979.280.783.782.683.3
Table 5: Comparison of different lightweight networks on classification benchmarks in terms of average accuracy and stability metrics, where “†{\dagger}” indicates that the intermediate size of the added lightweight network is half that of the default LLM’s intermediate size.
View original tableOriginal Table 5

We present accuracy and stability for different methods on the classification benchmarks in Table 2 and Table 3, respectively, and Table 4 for the generative benchmarks. The results demonstrate that our proposed LLM-Streamline consistently outperforms the baseline methods. Specifically, in classification tasks, LLM-Streamline surpasses LLM-Pruner by 7% in accuracy and 12% in stability on Llama2-7B, and by 16% in accuracy and 19% in stability on Llama2-13B. LLM-Streamline also surpasses LaCo by 5% in accuracy on Llama2-7B. For generation tasks, LLM-Streamline retains nearly 77% of Llama2-7B and Llama2-13B’s capabilities, significantly outperforming other pruning methods. We find that almost all of the pruning methods fail on the GSM8K dataset. However, sufficient training can gradually restore the model’s performance on math tasks, and the specific experimental results are shown in Table 28 of Appendix E.8.

Additionally, comparing the average stability (Average) in Table 3 with the retrained performance (RP) in Table 2 reveals that stability is often much lower than accuracy. We also observe that accuracy on Race-M and Race-H even increases after model pruning. Furthermore, we find that without using any lightweight network, Llama2-13B achieves the highest accuracy on classification benchmarks, but its stability on classification benchmarks and performance on generation benchmarks are lower. These results indicate that pruned models tend to make correct guesses on some classification questions that they are uncertain, highlighting the limitations of accuracy as a sole measure of pruning method performance. We also conduct experiments on OPT-1.3B, OPT-2.7B, OPT-6.7B, Baichuan-7B, Baichuan-13B, Baichuan2-7B, Baichuan2-13B (yang2023baichuan), Llama3.1-8B, Llama3.1-70B (dubey2024llama) and Mixtral-8x7B-v0.1 (jiang2024mixtral). Details can be found in Appendix E.1, Appendix E.2, Appendix E.3, Appendix E.4, Appendix E.5 and Appendix E.6. In addition, we compare the performance of LLM-Streamline with other methods at a higher pruning ratio of approximately 50%, and the results can be found in Appendix E.7.

While FFN achieves the best result, Transformer layer still has performance potential. We perform experiments with Llama2-7B using various lightweight network, including Feed-Forward Neural Networks (FFN), SwiGLU-based Feed-Forward Neural Networks (SwiGLU), and Transformer layers. We also explore various initialization methods for the Transformer Layer, including random initialization (Layer-Random), inheritance of the first pruned layer (Layer-First), inheritance of the last pruned layer (Layer-Last), and averaging the pruned layers (Layer-Avg). The average accuracy and stability metrics across all the classification benchmarks are presented in Table 5, with detailed results on each benchmark available in Appendix E.9. The results show that FFN achieves the best results. Meanwhile, for the Transformer Layer, inheriting the pruned first layer yields the best results. In contrast, the performance of Layer-Avg, inspired by LaCo, shows that averaging weights does not achieve the same effectiveness as the pruned first layer. In addition, we plot the validation loss curves for different lightweight networks, as shown in Fig. 3. We can observe that FFN and SwiGLU have already converged by the 10th epoch, whereas the loss of Transformer Layer is still decreasing. This indicates that the Transformer layer still has potential, and further training could yield better results, but this would require more computing resources.

The performance of the pruned model is linearly correlated with the number of parameters at modest pruning ratios. To verify the model’s performance at various modest pruning ratios, we evaluate our method not only at the approximately 25% pruning ratio but also at ratios of around 2%, 11%, and 20% on Llama2-7B. The average stability and accuracy metrics across all the classification benchmarks are shown in Fig. 4, with details on each benchmark presented in Appendix E.10. By comparing the performance of the original Llama2-7B, TinyLlama-1.1B, OpenLlama-3B-v2, and Llama2-7B pruned at various ratios, we observe a linear correlation between the performance of both the pruned models and the pre-trained original models relative to the number of parameters. This suggests that the performance of models pruned using our method is comparable to that of pre-trained models with the same number of parameters.

Layer Replacement outperforms LoRA in both performance and GPU memory consumption. We compare the performance of layer replacement with LoRA. Since layer replacement is trained based on hidden states with a different training objective than LoRA, we additionally train one epoch using the language model loss for layer replacement when comparing it with LoRA. The training details can be found in the Appendix C.2. For layer replacement, we freeze the original model’s weights and train only the lightweight network. In the case of LoRA, we set the rank to 128 to align the number of parameters trained with those of the lightweight networks. We randomly extract 30,000 samples from SlimPajama-6B for layer replacement training and also test with the entire dataset to evaluate the limited impact of extensive data on performance (details in Appendix E.8). For LoRA, we use 300,000 samples from SlimPajama-6B. Table 6 presents the average accuracy and stability across all classification benchmarks, with detailed results available in Appendix E.11. The findings indicate that layer replacement surpasses LoRA in both accuracy and stability, while also requiring significantly less GPU memory and training data.

Figure 3
Figure 3: Validation loss curves during training of (a) FFN and SwiGLU; (b) Transformer layer.
Figure 4
Figure 4: (a) Stability of the pruned Llama2-7B at different pruning ratios. (b) Accuracy of the pruned Llama2-7B at different pruning ratios, compared to the original Llama2-7B, OpenLlama-3B-v2, and TinyLlama-1.1B. Metrics are averaged across classification benchmarks.
Table 6
Layer-FirstLayer-LastLayer-AvgFFN†FFNSwiGLU†SwiGLULoRA
Accuracy46.746.846.245.846.344.445.544.5
Stability85.785.683.983.485.284.784.782.1
GPU Memory (G)27.827.827.825.627.025.326.456.4
Table 6: Comparison of layer replacement and LoRA on classification benchmarks in terms of average accuracy metrics across all benchmarks, where “†{\dagger}” indicates that the intermediate size of the added lightweight network is half that of the default LLM’s intermediate size.
View original tableOriginal Table 6
Table 7
MethodMetricNeed TrainingTraining DataData SizeTraining ModuleTrainig Method
SLEBPerplexityNoNoneNoneNoneNone
ShortGPTCosine SimilarityNoNoneNoneNoneNone
UIDLCosine SimilarityYesC4164MLoRA-AdapterQLoRA
LaCOCosine SimilarityYesUnpublished1BFull ParametersFine-tuning
Shortened LlamaTaylor PerplexityYesSlimPajama Alpaca627B 50kFull Parameters LoRA-AdapterFine-tuning LoRA
LLM-StreamlineCosine SimilarityYesSlimPajama30kLightweight NetworkTraining Lightweight Network
Table 7: Comparison of concurrent layer pruning methods, with the metric indicating the importance of layers. Shortened Llama consists of two training stages: initial continual pre-training on the SlimPajama dataset, followed by LoRA fine-tuning on the Alpaca dataset.
View original tableOriginal Table 7

Previous pruning methods for LLMs primarily focus on pruning dense matrices (Ashkboos et al., 2024), attention heads (Michel et al., 2019; Voita et al., 2019), filters (McCarley et al., 2019; Prasanna et al., 2020), or hidden dimension (Xia et al., 2023; van der Ouderaa et al., 2023). These approaches often lead to structural irregularities, making pruned models less flexible for deployment. In contrast, layer pruning, which only alters the model’s depth, is easier to deploy. Concurrent works in layer pruning alongside LLM-Streamline include LaCo (Yang et al., 2024), ShortGPT (Men et al., 2024), UIDL (Gromov et al., 2024), SLEB (Song et al., 2024), and Shortened Llama (Kim et al., 2024).

LaCo (Yang et al., 2024) divides layers into groups of consecutive layers and compresses them by replacing the consecutive layers with averaged parameter weights. ShortGPT (Men et al., 2024) uses a BI score, equivalent to cosine similarity, to assess layer importance and remove less important layers. Similarly, UIDL (Gromov et al., 2024) uses angular distance, also equivalent to cosine similarity, to determine and remove less important layers, and employs QLoRA to enhance performance. SLEB (Song et al., 2024) calculates layer importance using perplexity and discards those deemed insignificant. Shortened Llama (Kim et al., 2024) explores various layer selection metrics and examines the effectiveness of using continual pre-training and LoRA after pruning. The differences between these layer pruning methods and LLM-Streamline are summarized in Table 7.

Unlike traditional layer pruning methods, LLM-Streamline fundamentally differs by retraining a lightweight model to replace the pruned layers, rather than removing them directly with or without training the pruned model. LLM-Streamline reduces both computation time and resource consumption compared to layer pruning methods (Shortened Llama, LaCo, UIDL) that necessitate retraining. Additionally, LLM-Streamline better preserves the performance of the original LLM compared to concurrent layer pruning methods.

In this paper, we propose LLM-Streamline, a layer pruning-and-replacement algorithm for LLMs. We also identify shortcomings in the existing accuracy metric and propose a new metric called stability for evaluating model compression. Extensive experiments show that this layer replacement method using a lightweight network outperforms previous state-of-the-art pruning methods and demonstrates superior effectiveness and efficiency compared to concurrent layer pruning methods.

References

  1. Ashkboos et al. (2024) Saleh Ashkboos, Maximilian L Croci, Marcelo Gennari do Nascimento, Torsten Hoefler, and James Hensman. Slicegpt: Compress large language models by deleting rows and columns. arXiv preprint arXiv:2401.15024, 2024.
  2. Bisk et al. (2020) Yonatan Bisk, Rowan Zellers, Jianfeng Gao, Yejin Choi, et al. Piqa: Reasoning about physical commonsense in natural language. In Proceedings of the AAAI conference on artificial intelligence, volume 34, pp. 7432–7439, 2020.
  3. Chen et al. (2023) Tianyi Chen, Tianyu Ding, Badal Yadav, Ilya Zharkov, and Luming Liang. Lorashear: Efficient large language model structured pruning and knowledge recovery. arXiv preprint arXiv:2310.18356, 2023.
  4. Chen et al. (2020) Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pp. 1597–1607. PMLR, 2020.
  5. Chen & He (2021) Xinlei Chen and Kaiming He. Exploring simple siamese representation learning. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 15750–15758, 2021.
  6. Clark et al. (2019) Christopher Clark, Kenton Lee, Ming-Wei Chang, Tom Kwiatkowski, Michael Collins, and Kristina Toutanova. Boolq: Exploring the surprising difficulty of natural yes/no questions. arXiv preprint arXiv:1905.10044, 2019.
  7. Cobbe et al. (2021) Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, et al. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021.
  8. Contributors (2023) OpenCompass Contributors. Opencompass: A universal evaluation platform for foundation models. GitHub repository, 2023.
  9. Das et al. (2023) Rocktim Jyoti Das, Liqun Ma, and Zhiqiang Shen. Beyond size: How gradients shape pruning decisions in large language models. arXiv preprint arXiv:2311.04902, 2023.
  10. Dettmers et al. (2022) Tim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer. Gpt3. int8 (): 8-bit matrix multiplication for transformers at scale. Advances in Neural Information Processing Systems, 35:30318–30332, 2022.
  11. Dettmers et al. (2023) Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, and Luke Zettlemoyer. Qlora: Efficient finetuning of quantized llms, 2023.
  12. Frantar & Alistarh (2023) Elias Frantar and Dan Alistarh. Sparsegpt: Massive language models can be accurately pruned in one-shot. In International Conference on Machine Learning, pp. 10323–10337. PMLR, 2023.
  13. Geva et al. (2021) Mor Geva, Daniel Khashabi, Elad Segal, Tushar Khot, Dan Roth, and Jonathan Berant. Did aristotle use a laptop? a question answering benchmark with implicit reasoning strategies. Transactions of the Association for Computational Linguistics, 9:346–361, 2021.
  14. Gholami et al. (2022) Amir Gholami, Sehoon Kim, Zhen Dong, Zhewei Yao, Michael W Mahoney, and Kurt Keutzer. A survey of quantization methods for efficient neural network inference. In Low-Power Computer Vision, pp. 291–326. Chapman and Hall/CRC, 2022.
  15. Gou et al. (2021) Jianping Gou, Baosheng Yu, Stephen J Maybank, and Dacheng Tao. Knowledge distillation: A survey. International Journal of Computer Vision, 129(6):1789–1819, 2021.
  16. Gromov et al. (2024) Andrey Gromov, Kushal Tirumala, Hassan Shapourian, Paolo Glorioso, and Daniel A Roberts. The unreasonable ineffectiveness of the deeper layers. arXiv preprint arXiv:2403.17887, 2024.
  17. Hendrycks et al. (2020) Dan Hendrycks, Collin Burns, Steven Basart, Andy Zou, Mantas Mazeika, Dawn Song, and Jacob Steinhardt. Measuring massive multitask language understanding. arXiv preprint arXiv:2009.03300, 2020.
  18. Hinton et al. (2015) Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.
  19. Ho et al. (2022) Namgyu Ho, Laura Schmid, and Se-Young Yun. Large language models are reasoning teachers. arXiv preprint arXiv:2212.10071, 2022.
  20. Hu et al. (2021) Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models, 2021.
  21. Hu et al. (2024) Yuxuan Hu, Jing Zhang, Zhe Zhao, Chen Zhao, Xiaodong Chen, Cuiping Li, and Hong Chen. $\rm sp^{3}$: Enhancing structured pruning via pca projection, 2024. URL https://arxiv.org/abs/2308.16475.Source
  22. Huang et al. (2022) Yukun Huang, Yanda Chen, Zhou Yu, and Kathleen McKeown. In-context learning distillation: Transferring few-shot learning ability of pre-trained language models. arXiv preprint arXiv:2212.10670, 2022.
  23. Kim et al. (2024) Bo-Kyeong Kim, Geonmin Kim, Tae-Ho Kim, Thibault Castells, Shinkook Choi, Junho Shin, and Hyoung-Kyu Song. Shortened llama: A simple depth pruning for large language models. arXiv preprint arXiv:2402.02834, 2024.
  24. Lai et al. (2017) Guokun Lai, Qizhe Xie, Hanxiao Liu, Yiming Yang, and Eduard Hovy. Race: Large-scale reading comprehension dataset from examinations. arXiv preprint arXiv:1704.04683, 2017.
  25. Levesque et al. (2012) Hector Levesque, Ernest Davis, and Leora Morgenstern. The winograd schema challenge. In Thirteenth international conference on the principles of knowledge representation and reasoning, 2012.
  26. Li et al. (2023) Haonan Li, Yixuan Zhang, Fajri Koto, Yifei Yang, Hai Zhao, Yeyun Gong, Nan Duan, and Timothy Baldwin. Cmmlu: Measuring massive multitask language understanding in chinese. arXiv preprint arXiv:2306.09212, 2023.
  27. Li et al. (2022) Shiyang Li, Jianshu Chen, Yelong Shen, Zhiyu Chen, Xinlu Zhang, Zekun Li, Hong Wang, Jing Qian, Baolin Peng, Yi Mao, et al. Explanations from large language models make small reasoners better. arXiv preprint arXiv:2210.06726, 2022.
  28. Li et al. (2024) Shiyao Li, Xuefei Ning, Luning Wang, Tengxuan Liu, Xiangsheng Shi, Shengen Yan, Guohao Dai, Huazhong Yang, and Yu Wang. Evaluating quantized large language models, 2024.
  29. Liu et al. (2021) Zhenhua Liu, Yunhe Wang, Kai Han, Wei Zhang, Siwei Ma, and Wen Gao. Post-training quantization for vision transformer. Advances in Neural Information Processing Systems, 34:28092–28103, 2021.
  30. Liu et al. (2023) Zichang Liu, Jue Wang, Tri Dao, Tianyi Zhou, Binhang Yuan, Zhao Song, Anshumali Shrivastava, Ce Zhang, Yuandong Tian, Christopher Re, et al. Deja vu: Contextual sparsity for efficient llms at inference time. In International Conference on Machine Learning, pp. 22137–22176. PMLR, 2023.
  31. Louizos et al. (2017) Christos Louizos, Max Welling, and Diederik P Kingma. Learning sparse neural networks through $l\_0$ regularization. arXiv preprint arXiv:1712.01312, 2017.
  32. Ma et al. (2023) Xinyin Ma, Gongfan Fang, and Xinchao Wang. Llm-pruner: On the structural pruning of large language models. Advances in neural information processing systems, 36:21702–21720, 2023.
  33. McCarley et al. (2019) JS McCarley, Rishav Chakravarti, and Avirup Sil. Structured pruning of a bert-based question answering model. arXiv preprint arXiv:1910.06360, 2019.
  34. Men et al. (2024) Xin Men, Mingyu Xu, Qingyu Zhang, Bingning Wang, Hongyu Lin, Yaojie Lu, Xianpei Han, and Weipeng Chen. Shortgpt: Layers in large language models are more redundant than you expect. arXiv preprint arXiv:2403.03853, 2024.
  35. Michel et al. (2019) Paul Michel, Omer Levy, and Graham Neubig. Are sixteen heads really better than one? Advances in neural information processing systems, 32, 2019.
  36. Narayan et al. (2018) Shashi Narayan, Shay B Cohen, and Mirella Lapata. Don’t give me the details, just the summary! topic-aware convolutional neural networks for extreme summarization. arXiv preprint arXiv:1808.08745, 2018.
  37. Prasanna et al. (2020) Sai Prasanna, Anna Rogers, and Anna Rumshisky. When bert plays the lottery, all tickets are winning. arXiv preprint arXiv:2005.00561, 2020.
  38. Reimers (2019) N Reimers. Sentence-bert: Sentence embeddings using siamese bert-networks. arXiv preprint arXiv:1908.10084, 2019.
  39. Song et al. (2024) Jiwon Song, Kyungseok Oh, Taesu Kim, Hyungjun Kim, Yulhwa Kim, and Jae-Joon Kim. Sleb: Streamlining llms through redundancy verification and elimination of transformer blocks, 2024. URL https://arxiv.org/abs/2402.09025.Source
  40. Sun et al. (2020) Kai Sun, Dian Yu, Dong Yu, and Claire Cardie. Investigating prior knowledge for challenging chinese machine reading comprehension. Transactions of the Association for Computational Linguistics, 8:141–155, 2020.
  41. Sun et al. (2023) Mingjie Sun, Zhuang Liu, Anna Bair, and J Zico Kolter. A simple and effective pruning approach for large language models. arXiv preprint arXiv:2306.11695, 2023.
  42. Talmor et al. (2018) Alon Talmor, Jonathan Herzig, Nicholas Lourie, and Jonathan Berant. Commonsenseqa: A question answering challenge targeting commonsense knowledge. arXiv preprint arXiv:1811.00937, 2018.
  43. Touvron et al. (2023) Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288, 2023.
  44. van der Ouderaa et al. (2023) Tycho FA van der Ouderaa, Markus Nagel, Mart Van Baalen, Yuki M Asano, and Tijmen Blankevoort. The llm surgeon. arXiv preprint arXiv:2312.17244, 2023.
  45. Vaswani et al. (2017) Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
  46. Voita et al. (2019) Elena Voita, David Talbot, Fedor Moiseev, Rico Sennrich, and Ivan Titov. Analyzing multi-head self-attention: Specialized heads do the heavy lifting, the rest can be pruned, 2019.
  47. Wang et al. (2024) Wenxiao Wang, Wei Chen, Yicong Luo, Yongliu Long, Zhengkai Lin, Liye Zhang, Binbin Lin, Deng Cai, and Xiaofei He. Model compression and efficient inference for large language models: A survey, 2024.
  48. Xia et al. (2023) Mengzhou Xia, Tianyu Gao, Zhiyuan Zeng, and Danqi Chen. Sheared llama: Accelerating language model pre-training via structured pruning. arXiv preprint arXiv:2310.06694, 2023.
  49. Xu et al. (2020) Liang Xu, Hai Hu, Xuanwei Zhang, Lu Li, Chenjie Cao, Yudong Li, Yechen Xu, Kai Sun, Dian Yu, Cong Yu, et al. Clue: A chinese language understanding evaluation benchmark. arXiv preprint arXiv:2004.05986, 2020.
  50. Yang et al. (2024) Yifei Yang, Zouying Cao, and Hai Zhao. Laco: Large language model pruning via layer collapse. arXiv preprint arXiv:2402.11187, 2024.
  51. Zellers et al. (2019) Rowan Zellers, Ari Holtzman, Yonatan Bisk, Ali Farhadi, and Yejin Choi. Hellaswag: Can a machine really finish your sentence? arXiv preprint arXiv:1905.07830, 2019.
  52. Zhang et al. (2022) Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, et al. Opt: Open pre-trained transformer language models. arXiv preprint arXiv:2205.01068, 2022.
  53. Zheng et al. (2019) Chujie Zheng, Minlie Huang, and Aixin Sun. Chid: A large-scale chinese idiom dataset for cloze test. arXiv preprint arXiv:1906.01265, 2019.
  54. Zhu et al. (2023) Xunyu Zhu, Jian Li, Yong Liu, Can Ma, and Weiping Wang. A survey on model compression for large language models, 2023.

To demonstrate the sensitivity of perplexity, referencing the SLEB (Song et al., 2024), we prune the Llama2-7B model with different pre-training datasets, including SlimPajama, C4 and wikitext. The experimental results are presented in Table 8. When pruning with cosine similarity, the layers pruned are consistent across different datasets, whereas when pruning with perplexity, the layers vary, indicating the sensitivity of perplexity. In addition, we evaluate the model after pruning with the SlimPajama dataset, and the experimental results are shown in Table 9. This indicates that the model pruned with perplexity shows lower perplexity on the dataset used for pruning, but performs worse on downstream tasks.

Table 8
LLMDatasetPruned Layers
PerplexityCosine Similarity
Llama2-7BSlimPajama9,10,11,12,21,23,25,2722,23,24,25,26,27,28,29
wikitext9,10,11,12,21,23,24,2722,23,24,25,26,27,28,29
C48,9,11,12,22,23,24,2522,23,24,25,26,27,28,29
Table 8: Pruned layers using perplexity and cosine similarity for pruning.
View original tableOriginal Table 8
Table 9
LLMMetricPerplexity*BenchmarksAverageRP
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLUXsumGSM8kStrategyQA
Llama2-7BDense6.2343.833.041.670.837.566.771.378.133.135.546.831.819.416.560.245.7100.0
Cosine Similarity19.740.234.421.567.340.451.759.769.035.534.744.628.914.81.9741.839.185.6
Perplexity12.137.633.034.261.736.547.356.571.422.121.625.924.817.11.7433.235.076.6
Table 9: Detailed results of accuracy of using perplexity and cosine similarity for pruning. “Perplexity*” refers to the Perplexity of the pruned model on SlimPajama. Using perplexity as the metric can be considered as SLEB, while using cosine similarity as the metric can be considered as a variant of our approach, i.e., Ours (None)(details in Section 4.1).
View original tableOriginal Table 9

We extract the training data from different domains based on the data distribution strategy proposed in Sheared-LLaMa  (Xia et al., 2023). The detailed data distribution is shown in Table 10.

Table 10
CCGitHubBookStackExchangeWikiArXivC4
SlimPajama-6B54.1%4.2%3.7%2.8%3.1%3.4%28.7%
Ours36.1%0.8%9.1%1.0%3.1%0.7%49.2%
Table 10: The proportion of different domains randomly selected from the SlimPajama-6B dataset.
View original tableOriginal Table 10

For both the FFN structure and the SwiGLU structure, the learning rate is set to 1e-3 and the weight decay is 1e-4. For the Transformer layer, the learning rate is set to 1e-5 and the weight decay is 1e-3. The model is trained using a batch size of 32 over 20 epochs. On a single A800 GPU, the training duration for the lightweight network is approximate 5 hours (for the Transformer layer).

For layer replacement, in order to have a fairer comparison with LoRA, we conduct one epoch of post-training with a learning rate of 5e-5, a weight decay of 1e-3, and a batch size of 32. This process takes less than an hour on a single A800 GPU. For LoRA, the model is trained one epochs with a learning rate of 1e-4, a weight decay of 1e-3, and a batch size of 32. Since the amount of training data used is ten times that of layer replacement, it take approximately 10 hours to complete the training on a single A800 GPU.

As shown in the Table 11, we evaluate the inference speed of various pruning methods at similar pruning ratio when generating sequences of length 128. The results indicate that the acceleration effect of LLM-Streamline is slightly inferior to that of SliceGPT and LLM-Pruner.

Table 11
Llama2-7BDenseLLM-PrunerSliceGPTOurs(None)Ours(FFN)Ours(Layer)
Pruning Ratio (%)0.0024.825.424.025.024.0
Inference Speed (tokens/s)19.8725.9127.2025.6825.8825.68
Table 11: The inference speed of models pruned using different methods.
View original tableOriginal Table 11

We conduct experiments on OPT-6.7B. The experimental results are shown in Table 12, Table 13 and Table 14. The results indicate that our proposed LLM-Streamline is superior to the previous SOTA method.

Table 12
LLMMethodRatioBenchmarksAverageRP
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
OPT-6.7BDense0.00%38.732.921.664.641.454.863.375.425.125.424.725.541.1100
SliceGPT25.6%40.031.219.537.936.538.245.665.825.826.025.824.834.884.7
Ours (None)24.0%27.632.512.744.836.520.626.552.122.122.423.625.228.970.3
Ours (FFN)25.0%37.632.118.763.737.541.855.973.222.722.224.424.937.992.2
Ours (Layer)24.0%36.432.018.962.438.545.154.374.023.624.224.325.238.292.9
Table 12: Accuracy of different pruning methods on classification benchmarks by pruning OPT-6.7B.
View original tableOriginal Table 12
Table 13
LLMMethodRatioBenchmarksAverage
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
OPT-6.7BSliceGPT25.6%66.439.873.130.179.475.273.782.572.569.168.967.266.5
Ours (None)24.0%56.262.571.441.587.548.650.557.163.462.262.362.760.5
Ours (FFN)25.0%74.136.177.474.290.482.488.492.068.363.974.765.073.9
Ours (Layer)24.0%72.135.576.172.191.483.687.091.672.971.278.170.175.1
Table 13: Stability of different pruning methods on classification benchmarks by pruning OPT-6.7B.
View original tableOriginal Table 13
Table 14
LLMMethodRatioBenchmarksAverageRP
XsumGSM8KStrategyQA
OPT-6.7BDense0.00%13.42.254.323.3100.0
SliceGPT25.6%14.92.540.819.483.3
Ours (None)24.0%4.9001.66.87
Ours (FFN)25.0%14.80.843.619.784.5
Ours (Layer)24.0%18.42.544.421.893.6
Table 14: Accuracy of different pruning methods on generation benchmarks by pruning OPT-6.7B.
View original tableOriginal Table 14

We conduct experiments on Baichuan-7B and Baichuan-13B. The experimental results are shown in Table 15, Table 16 and Table 17. The results indicate that our proposed LLM-Streamline is superior to the previous SOTA method.

Table 15
LLMMethodRatioBenchmarksAverageRP
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Baichuan-7BDense0.00%55.835.391.361.439.458.465.377.629.530.443.743.852.7100
LLMPruner24.2%43.733.965.940.536.548.252.268.122.622.024.225.340.276.3
Ours (None)24.2%33.232.725.860.836.536.034.658.722.121.525.738.835.567.4
Ours (FFN)25.1%53.136.369.453.136.548.753.269.423.224.537.739.145.486.1
Ours (Layer)24.2%55.036.077.448.136.549.854.369.022.923.839.841.146.187.5
Baichuan-13BDense0.00%61.536.491.565.849.064.269.178.248.146.054.855.360.0100
Ours (None)24.7%48.834.850.262.240.446.456.768.230.627.752.955.147.879.7
Ours (FFN)25.5%58.335.177.564.136.557.758.269.426.528.853.154.351.686.0
Ours (Layer)24.7%59.136.183.762.036.558.259.471.827.825.052.356.152.387.2
Table 15: Accuracy of different pruning methods on classification benchmarks by pruning Baichuan-7B and Baichuan-13B.
View original tableOriginal Table 15
Table 16
LLMMethodRatioBenchmarksAverage
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Baichuan-7BLLMPruner24.2%70.240.071.424.991.475.375.982.468.866.854.753.664.6
Ours (None)24.2%55.545.131.376.893.364.750.161.068.965.974.060.862.3
Ours (FFN)25.1%84.177.875.665.493.376.583.184.377.170.374.274.678.0
Ours (Layer)24.2%86.379.382.340.793.377.681.383.575.871.075.975.676.9
Baichuan-13BOurs (None)24.7%67.275.854.166.651.074.974.678.552.355.282.789.368.5
Ours (FFN)25.5%85.787.382.181.343.381.281.779.846.661.184.383.774.8
Ours (Layer)24.7%88.692.789.372.943.383.586.188.249.252.183.490.476.6
Table 16: Stability of different pruning methods on classification benchmarks by pruning Baichuan-7B and Baichuan-13B.
View original tableOriginal Table 16
Table 17
LLMMethodRatioBenchmarksAverageRP
XsumGSM8KStrategyQA
Baichuan-7BDense0.00%19.19.8455.528.1100
LLMPruner24.2%12.61.7440.418.264.8
Ours (None)24.2%0.3000.10
Ours (FFN)25.1%19.32.1141.120.874.0
Ours (Layer)24.2%18.21.3638.719.469.0
Baichuan-13BDense0.00%24.627.161.137.6100
Ours (None)24.7%2.11.212.35.213.8
Ours (FFN)25.5%23.12.147.324.264.4
Ours (Layer)24.7%22.22.443.222.660.1
Table 17: Accuracy of different pruning methods on generation benchmarks by pruning Baichuan-7B and Baichuan-13B.
View original tableOriginal Table 17

We conduct experiments on Baichuan2-7B and Baichuan2-13B. The experimental results are shown in Table 18, Table 19 and Table 20. The results indicate that our proposed LLM-Streamline is superior to the concurrent SOTA method, LaCo.

Table 18
LLMMethodRatioBenchmarksAverageRP
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Baichuan2-7BDense0.00%64.433.485.563.142.363.167.676.151.152.554.757.159.2100
LLMPruner24.2%39.933.970.650.042.338.752.770.422.322.824.924.941.169.4
LaCo*24.2%50.933.076.256.242.347.352.368.527.729.031.531.245.576.9
Ours (None)24.2%45.733.058.062.636.541.946.362.425.627.443.046.544.174.5
Ours (FFN)25.1%58.233.074.161.236.547.654.368.029.130.552.156.750.184.6
Ours (Layer)24.2%60.434.972.262.736.548.852.567.035.536.854.056.351.587.0
Baichuan2-13BDense0.00%65.633.286.766.842.365.671.178.168.967.259.661.363.9100
LaCo*24.7%61.133.076.762.444.255.560.768.957.856.951.453.756.989.0
Ours (None)24.7%59.134.481.961.836.553.961.971.063.060.450.357.957.790.3
Ours (FFN)25.5%63.033.081.760.136.554.762.170.571.168.257.158.259.793.4
Ours (Layer)24.7%63.533.084.162.038.556.963.072.070.266.359.160.260.795.0
Table 18: Accuracy of different pruning methods on classification benchmarks by pruning Baichuan2-7B and Baichuan2-13B. “*” indicates that we refer to the results in the original paper.
View original tableOriginal Table 18
Table 19
LLMMethodRatioBenchmarksAverage
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Baichuan2-7BLLMPruner24.2%62.250.675.155.563.566.080.387.054.251.750.046.961.9
Ours (None)24.2%68.598.163.869.184.661.367.372.050.648.069.374.568.9
Ours (FFN)25.1%81.198.177.168.284.666.578.177.361.257.787.389.277.2
Ours (Layer)24.2%83.392.874.967.684.668.077.280.964.162.989.288.677.8
Baichuan2-13BOurs (None)24.7%85.088.786.585.182.779.582.285.184.683.074.285.683.5
Ours (FFN)25.5%86.499.087.284.782.777.683.285.783.281.190.291.786.1
Ours (Layer)24.7%87.999.089.087.184.780.284.986.989.487.091.792.588.4
Table 19: Stability of different pruning methods on classification benchmarks by pruning Baichuan2-7B and Baichuan2-13B.
View original tableOriginal Table 19
Table 20
LLMMethodRatioBenchmarksAverageRP
XsumGSM8KStrategyQA
Baichuan2-7BDense0.00%21.024.860.035.3100
LLMPruner24.2%14.51.410.88.925.2
LaCo*24.2%12.0----
Ours (None)24.2%12.11.730.714.841.9
Ours (FFN)25.1%15.92.737.118.652.7
Ours (Layer)24.2%16.82.334.818.051.0
Baichuan2-13BDense0.00%25.353.265.948.1100
LaCo*24.7%12.3----
Ours (None)24.7%17.23.337.219.239.9
Ours (FFN)25.5%21.33.148.824.450.7
Ours (Layer)24.7%20.95.551.325.953.8
Table 20: Accuracy of different pruning methods on generation benchmarks by pruning Baichuan2-7B and Baichuan2-13B. “*” indicates that we refer to the results in the original paper.
View original tableOriginal Table 20

We conduct experiments on Llama3.1-8B and Llama3.1-70B. The experimental results are shown in Table 21 and Table 22. The results indicate that our proposed LLM-Streamline is superior to the previous SOTA method.

Table 21
LLMMethodRatioBenchmarksAverageRP
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Llama3.1-8BDense0.00%65.333.073.868.236.569.874.781.171.664.566.852.563.2100
SliceGPT23.9%38.432.121.337.838.538.039.958.721.923.325.825.233.452.8
Ours (None)24.4%42.333.719.352.336.530.728.458.936.633.339.134.436.958.4
Ours (Layer)24.4%55.934.554.567.636.562.562.674.564.855.964.951.557.190.6
Llama3.1-70BDense0.00%74.833.081.676.537.573.079.983.986.880.579.368.871.3100
SliceGPT29.1%40.431.918.937.837.541.045.361.024.124.837.530.535.950.4
Ours (None)30.3%66.137.558.169.046.261.868.475.781.773.270.462.064.290.0
Ours (Layer)30.3%68.934.770.072.542.368.974.479.386.881.578.668.268.896.5
Table 21: Accuracy of different pruning methods on classification benchmarks by pruning Llama3.1-8B and Llama3.1-70B.
View original tableOriginal Table 21
Table 22
LLMMethodRatioBenchmarksAverage
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Llama3.1-8BSliceGPT23.9%63.237.038.535.698.160.759.371.239.046.142.147.453.2
Ours (None)24.4%59.947.039.057.010049.843.464.753.454.557.861.453.7
Ours (Layer)24.4%78.549.759.975.010080.384.886.587.386.190.889.180.7
Llama3.1-70BSliceGPT29.1%55.645.432.136.198.158.859.672.032.939.648.745.949.3
Ours (None)30.3%77.643.664.573.091.476.884.685.092.489.384.181.478.6
Ours (Layer)30.3%86.795.776.177.795.289.592.693.497.296.395.994.690.9
Table 22: Stability of different pruning methods on classification benchmarks by pruning Llama3.1-8B and Llama3.1-70B.
View original tableOriginal Table 22

We conduct experiments on Mixture of Experts(MoE) model Mixtral-8x7B-v0.1. The experimental results are shown in Table 23 and Table 24.

Table 23
LLMMethodRatioBenchmarksAverageRP
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Mixtral-8x7B-v0.1Dense0.00%54.133.048.668.456.768.276.281.772.470.971.352.862.9100.0
Ours (None)24.9%39.033.026.962.839.445.655.470.241.343.367.739.247.074.7
Ours (Layer)24.9%51.234.441.566.356.762.068.377.954.555.769.950.257.491.3
Table 23: Accuracy of LLM-Streamline on classification benchmarks by pruning Mixtral-8x7B-v0.1.
View original tableOriginal Table 23
Table 24
LLMMethodRatioBenchmarksAverage
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Mixtral-8x7B-v0.1Ours (None)24.9%66.998.962.476.438.569.372.480.657.060.379.164.468.9
Ours (Layer)24.9%83.687.676.281.310086.890.490.867.869.085.380.483.3
Table 24: Stability of LLM-Streamline on classification benchmarks by pruning Mixtral-8x7B-v0.1.
View original tableOriginal Table 24

We also conduct experiments on small models (OPT-1.3B and OPT-2.7B). The experimental results are shown in Table 25. The results indicate that our proposed LLM-Streamline is superior to the previous SOTA method, across different pruning rates.

Table 25
LLMMethodRatioBenchmarksAverageRP
PIQAWinoGrandeHellaSwagARC-easyARC-challengeOpenBookQA
OPT-1.3BDense0.00%72.459.353.751.029.523.448.2100.0
SliceGPT18.1%67.653.635.751.123.120.241.986.9
Ours(None)19.4%57.251.729.132.522.713.234.471.4
Ours(FFN)18.1%68.858.439.154.323.323.344.592.3
Dense0.00%72.459.353.751.029.523.448.2100.0
SliceGPT25.8%65.552.834.248.824.417.040.584.0
Ours(None)27.1%52.251.125.726.620.514.031.765.8
Ours(FFN)25.8%66.456.036.851.622.221.042.387.8
Dense0.00%72.459.353.751.029.523.448.2100.0
SliceGPT33.6%62.452.632.245.423.116.638.780.3
Ours(None)34.8%50.551.525.826.220.314.631.565.4
Ours(FFN)33.6%62.952.133.948.320.820.639.882.6
OPT-2.7BDense0.00%73.861.045.960.926.825.048.9100.0
SliceGPT16.8%69.656.340.456.227.520.245.092.0
Ours(None)17.8%61.254.133.841.224.115.838.478.5
Ours(FFN)16.8%70.760.442.957.825.324.446.995.9
Dense0.00%73.861.045.960.926.825.048.9100.0
SliceGPT25.7%69.155.037.953.926.718.243.589.0
Ours(None)26.7%59.753.433.538.124.315.437.476.5
Ours(FFN)25.7%67.059.540.354.624.722.244.791.4
Dense0.00%73.861.045.960.926.825.048.9100.0
SliceGPT34.6%64.854.135.650.026.518.041.584.9
Ours(None)35.6%56.652.931.537.624.114.936.374.2
Ours(FFN)34.6%65.355.336.351.424.521.042.386.5
Table 25: Accuracy of different pruning methods by pruning OPT-1.3B and OPT-2.7B.
View original tableOriginal Table 25

We conduct experiments on Llama2-7B at a higher pruning ratio of approximately 50%. The experimental results are shown in Table 26 and Table 27. The results indicate that our proposed LLM-Streamline is superior to the previous SOTA method.

Table 26
LLMMethodRatioBenchmarksAverageRP
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Llama2-7BDense0.00%43.833.041.670.837.566.771.378.133.135.546.831.849.2100.0
LLMPruner49.2%26.433.217.343.538.525.432.759.222.321.723.424.830.763.4
SliceGPT48.3%26.532.115.438.142.328.130.953.623.623.125.225.330.461.8
Ours (None)48.0%33.134.017.355.436.531.034.356.326.827.234.927.934.670.3
Ours (Layer)48.0%39.733.027.762.136.544.345.263.624.624.333.228.138.578.3
Table 26: Accuracy of different pruning methods on classification benchmarks by pruning Llama2-7B at a higher pruning ratio of approximately 50%.
View original tableOriginal Table 26
Table 27
LLMMethodRatioBenchmarksAverage
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Llama2-7BLLMPruner49.2%63.696.260.833.887.551.555.570.947.848.156.958.160.9
SliceGPT48.3%48.034.954.719.083.757.752.763.471.261.552.258.154.8
Ours (None)48.0%73.263.062.265.295.252.252.562.648.252.561.458.862.3
Ours (Layer)48.0%80.810067.779.595.265.366.176.058.757.363.859.472.5
Table 27: Stability of different pruning methods on classification benchmarks by pruning Llama2-7B at a higher pruning ratio of approximately 50%.
View original tableOriginal Table 27

Following the method outlined in Section 4.7, We conduct experiments using the entire SlimPajama-6B for post-training, and the results are presented in Table 28. As shown, using the entire dataset resulted in a slight improvement, but at a significant computational cost, requiring 100 times the computational time.

Table 28
LLMMethodTraining data sizeBenchmarksAverageRP
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLUXsumGSM8kStrategyQA
Llama2-7BDense-43.833.041.670.837.566.771.378.133.135.546.831.819.416.560.245.7100.0
Layer-First30k43.933.029.870.836.559.664.373.436.637.444.930.019.72.0554.842.593.0
Layer-First5.49M43.533.033.268.846.261.166.576.031.829.947.331.818.210.658.643.895.8
Table 28: Detailed accuracy results with different training data volumes.
View original tableOriginal Table 28

The detailed results of accuracy and stability of different lightweight networks on different classification benchmarks are shown in Table 29 and Table 30. We can observe that FFN achieves the best results. Meanwhile, for the Transformer Layer, inheritance of the pruned first layer yields the best results.

Table 29
LLMMethodRatioBenchmarksAverageRP
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Llama2-7BDense0.00%43.833.041.670.837.566.771.378.133.135.546.831.849.2100.0
Layer-Random24.0%42.533.027.065.936.558.058.870.235.036.046.331.445.191.7
Layer-First24.0%43.333.024.167.536.559.261.171.534.837.045.529.445.291.9
Layer-Last24.0%43.533.029.064.541.456.861.571.634.535.046.030.845.692.7
Layer-Avg24.0%42.133.026.766.336.557.759.469.934.334.543.328.544.490.2
FFN†26.0%40.633.024.267.536.558.459.571.441.941.446.330.846.093.5
FFN25.0%40.733.022.865.938.560.661.271.238.038.747.031.745.893.1
SwiGLU†26.0%41.933.024.368.536.555.857.969.629.933.343.431.643.889.0
SwiGLU25.0%40.933.022.167.036.556.959.170.033.835.045.630.844.289.8
Table 29: Detailed accuracy results of different lightweight networks on different classification benchmarks, where “†{\dagger}” indicates that the intermediate size of the added lightweight network is half that of the default LLM’s intermediate size.
View original tableOriginal Table 29
Table 30
LLMMethodRatioBenchmarksAverage
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Llama2-7BLayer-Random24.0%79.910068.283.895.277.482.083.269.971.985.177.481.2
Layer-First24.0%79.810064.486.395.281.785.385.681.879.082.471.082.7
Layer-Last24.0%81.010073.584.982.781.385.885.482.376.383.066.981.9
Layer-Avg24.0%80.710068.584.495.278.982.882.573.070.774.658.879.2
FFN†{\dagger}26.0%79.910065.482.195.278.780.781.774.770.384.974.680.7
FFN25.0%79.810064.183.193.380.784.784.685.179.087.582.583.7
SwiGLU†26.0%78.510064.578.995.275.480.982.189.387.180.778.482.6
SwiGLU25.0%78.910063.584.495.277.082.282.385.782.487.979.783.3
Table 30: Detailed stability results of different lightweight networks on different classification benchmarks, where “†{\dagger}” indicates that the intermediate size of the added lightweight network is half that of the default LLM’s intermediate size.
View original tableOriginal Table 30

The detailed results of accuracy and stability on LLMs under different pruning ratios on different classification benchmarks are shown in Table 31 and Table 32. The experiment results show that the performance of the pruned model is linearly correlated with the number of parameters, demonstrating the effectiveness of our method.

Table 31
LLMMethodRatioBenchmarksAverageRP
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Llama2-7BDense0.00%43.833.041.670.837.566.771.378.133.135.546.831.849.2100.0
FFN†{\dagger}2.0%43.633.041.071.536.565.470.777.536.138.146.331.649.3100.0
FFN†{\dagger}11.0%42.133.035.169.037.563.467.875.635.237.046.529.947.797.0
FFN†{\dagger}20.0%42.333.029.070.236.562.763.872.337.837.745.728.846.794.9
FFN†{\dagger}26.0%40.633.024.267.536.558.459.571.441.941.446.330.846.093.5
TinyLlama-1.1BDense0.00%38.334.630.456.447.148.854.571.324.125.825.825.040.2100.0
OpenLlama-3B-v2Dense0.00%43.033.031.160.637.558.765.377.025.126.927.025.342.5100.0
Table 31: Detailed accuracy results of different pruning ratios on different classification benchmarks, where “†{\dagger}” indicates that the intermediate size of the added lightweight network is half that of the default LLM’s intermediate size.
View original tableOriginal Table 31
Table 32
LLMMethodRatioBenchmarksAverage
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Llama2-7BFFN†{\dagger}2.0%95.810093.286.595.296.297.897.193.089.595.589.794.1
FFN†{\dagger}11.0%90.410082.591.494.290.293.492.789.682.784.672.088.6
FFN†{\dagger}20.0%81.610071.986.095.284.487.387.985.278.678.167.783.7
FFN†{\dagger}26.0%79.910065.482.195.278.780.781.774.770.384.974.680.7
Table 32: Detailed stability results of different pruning ratios on different classification benchmarks, where “†{\dagger}” indicates that the intermediate size of the added lightweight network is half that of the default LLM’s intermediate size.
View original tableOriginal Table 32

The detailed results of accuracy and stability of different layer replacement strategies and LoRA on different benchmarks are shown in Table 33 and Table 34. The results show that layer replacement outperforms LoRA in both accuracy and stability.

Table 33
LLMMethodRatioBenchmarksAverageRP
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Llama2-7BDense0.00%43.833.041.670.837.566.771.378.133.135.546.831.849.2100.0
Layer-First24.0%43.933.029.870.836.559.664.373.436.637.444.930.046.794.9
Layer-Last24.0%44.933.029.469.236.558.963.574.137.837.846.530.446.895.1
Layer-Avg24.0%43.933.030.167.536.558.362.572.336.636.146.231.946.293.9
FFN†{\dagger}26.0%41.633.025.862.636.558.962.172.341.940.244.430.545.893.1
FFN25.0%43.833.027.068.736.560.763.572.437.435.445.331.546.394.1
SwiGLU†26.0%44.033.027.961.236.557.261.771.230.332.945.031.944.490.2
SwiGLU25.0%43.233.027.167.036.558.262.171.235.135.745.830.845.592.5
LoRA24.0%43.233.027.663.536.557.762.471.730.732.943.530.844.590.4
Table 33: Detailed accuracy results of layer replacement and LoRA on different classification benchmarks, where “†{\dagger}” indicates that the intermediate size of the added lightweight network is half that of the default LLM’s intermediate size.
View original tableOriginal Table 33
Table 34
LLMMethodRatioBenchmarksAverage
C3CMNLICHIDBoolQWSCCoQAHeSWPIQARace-MRace-HMMLUCMMLU
Llama2-7BLayer-First24.0%82.710074.384.795.285.789.188.684.182.284.577.285.7
Layer-Last24.0%83.210073.887.995.289.585.888.784.782.183.172.985.6
Layer-Avg24.0%81.010072.367.095.284.187.486.687.382.290.573.783.9
FFN†{\dagger}26.0%82.010071.475.495.282.986.687.279.075.385.181.083.4
FFN25.0%80.610072.083.595.285.487.787.284.581.085.479.385.2
SwiGLU†26.0%80.010071.463.195.280.586.185.190.487.789.287.784.7
SwiGLU25.0%81.610072.967.395.281.886.585.387.784.890.083.384.7
LoRA24.0%81.910073.459.195.281.684.885.385.281.382.175.382.1
Table 34: Detailed stability results of layer replacement and LoRA on different classification benchmarks, where “†{\dagger}” indicates that the intermediate size of the added lightweight network is half that of the default LLM’s intermediate size.
View original tableOriginal Table 34

Our method achieves SOTA results compared to existing pruning methods, but its performance still falls short of other commonly used model compression methods, e.g., quantization. Therefore, we plan to enhance the performance of our pruning method and explore combining it with other compression and inference acceleration techniques to make it more practical.