Datasets:
Add files using upload-large-folder tool
Browse files- parse/test/IEduRUO55F/IEduRUO55F.md +0 -0
- parse/test/IEduRUO55F/IEduRUO55F_content_list.json +0 -0
- parse/test/IEduRUO55F/IEduRUO55F_middle.json +0 -0
- parse/test/LzPWWPAdY4/LzPWWPAdY4.md +421 -0
- parse/test/LzPWWPAdY4/LzPWWPAdY4_content_list.json +943 -0
- parse/test/LzPWWPAdY4/LzPWWPAdY4_middle.json +0 -0
- parse/test/LzPWWPAdY4/LzPWWPAdY4_model.json +0 -0
- parse/test/Th6NyL07na/Th6NyL07na.md +393 -0
- parse/test/Th6NyL07na/Th6NyL07na_content_list.json +0 -0
- parse/test/Th6NyL07na/Th6NyL07na_middle.json +0 -0
- parse/test/Th6NyL07na/Th6NyL07na_model.json +0 -0
- parse/test/rlloVZoKrX/rlloVZoKrX.md +0 -0
- parse/test/rlloVZoKrX/rlloVZoKrX_content_list.json +0 -0
- parse/test/rlloVZoKrX/rlloVZoKrX_middle.json +0 -0
- parse/test/rlloVZoKrX/rlloVZoKrX_model.json +0 -0
- parse/test/t0L4xG4aGC/t0L4xG4aGC.md +280 -0
- parse/test/tzW948kU6x/tzW948kU6x.md +0 -0
- parse/test/tzW948kU6x/tzW948kU6x_content_list.json +0 -0
- parse/test/tzW948kU6x/tzW948kU6x_middle.json +0 -0
- parse/test/tzW948kU6x/tzW948kU6x_model.json +0 -0
parse/test/IEduRUO55F/IEduRUO55F.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/IEduRUO55F/IEduRUO55F_content_list.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/IEduRUO55F/IEduRUO55F_middle.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/LzPWWPAdY4/LzPWWPAdY4.md
ADDED
|
@@ -0,0 +1,421 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LOFTQ: LORA-FINE-TUNING-AWARE QUANTIZA-TION FOR LARGE LANGUAGE MODELS
|
| 2 |
+
|
| 3 |
+
Yixiao Li1 ∗ Yifan Yu1 ∗ Chen Liang1
|
| 4 |
+
|
| 5 |
+
Pengcheng He2
|
| 6 |
+
|
| 7 |
+
Nikos Karampatziakis2
|
| 8 |
+
|
| 9 |
+
Weizhu Chen2
|
| 10 |
+
|
| 11 |
+
Tuo Zhao1
|
| 12 |
+
|
| 13 |
+
# ABSTRACT
|
| 14 |
+
|
| 15 |
+
Quantization is an indispensable technique for serving Large Language Models (LLMs) and has recently found its way into LoRA fine-tuning (Dettmers et al., 2023). In this work we focus on the scenario where quantization and LoRA finetuning are applied together on a pre-trained model. In such cases it is common to observe a consistent gap in the performance on downstream tasks between full fine-tuning and quantization plus LoRA fine-tuning approach. In response, we propose LoftQ (LoRA-Fine-Tuning-aware Quantization), a novel quantization framework that simultaneously quantizes an LLM and finds a proper lowrank initialization for LoRA fine-tuning. Such an initialization alleviates the discrepancy between the quantized and full-precision model and significantly improves generalization in downstream tasks. We evaluate our method on natural language understanding, question answering, summarization, and natural language generation tasks. Experiments show that our method is highly effective and outperforms existing quantization methods, especially in the challenging 2-bit and 2/4-bit mixed precision regimes. The code is available on https://github.com/yxli2123/LoftQ.1 2
|
| 16 |
+
|
| 17 |
+
# 1 INTRODUCTION
|
| 18 |
+
|
| 19 |
+
The advent of Pre-trained Language Models (PLMs) has marked a transformative shift in the field of Natural Language Processing (NLP), offering versatile solutions across various applications (He et al., 2021b; Lewis et al., 2019; Touvron et al., 2023). They have showcased unparalleled proficiency in executing a variety of language tasks, including Natural Language Understanding (NLU) and Natural Language Generation (NLG). These models typically have millions or even billions of parameters, necessitating substantial computational and memory requirements. However, the extensive computational and memory demands of these models pose significant challenges, especially for deployments where resources are often constrained and need to be shared among many users.
|
| 20 |
+
|
| 21 |
+
To mitigate the extensive storage requirements of pre-trained models, quantization serves as a pivotal compression technique (Zafrir et al., 2019; Shen et al., 2020; Bai et al., 2022; Dettmers et al., 2022), converting high-precision numerical values into a discrete set of values. Typically, model parameters, originally stored in a 16-bit float format, are transformed into a 4-bit integer format through quantization, resulting in a substantial $7 5 \%$ reduction in storage overhead. Additionally, to facilitate the adaptation of quantized pre-trained models to downstream tasks efficiently, Low-Rank Adaptation (LoRA) is a viable approach (Hu et al., 2021). This technique is a parameter-efficient fine-tuning method traditionally applied to high-precision pre-trained models. It is based on the hypothesis that the differences between fully fine-tuned weights and pre-trained weights exhibit low-rank properties. This allows these differences to be represented using low-rank matrices. As a result, the original pre-trained weights remain unaltered, with adaptations confined solely to these low-rank matrices, enabling effective task adaptation.
|
| 22 |
+
|
| 23 |
+
When quantizing pre-trained models, practitioners often concentrate primarily on the quantization technique, inadvertently neglecting the importance of subsequent LoRA fine-tuning (Dettmers et al., 2023; Diao et al., 2023). For example, QLoRA inherits the fixup initialization (Zhang et al., 2019) used in LoRA, which (Dettmers et al., 2023) attaches zero initialized low-rank adapters (see Section 2.3) to the quantized pre-trained model. The inevitable discrepancy introduced by quantization during the approximation of the original high-precision numbers, a scenario particularly pronounced in low-bit situations such as the 2-bit regime, can adversely impact the initialization of LoRA finetuning. As illustrated in Figure 1a, the quantized pre-trained model obtained by QLoRA exhibits severe degradation below the 3-bit level. This deviation in initialization often results in an inferior fine-tuning performance. As illustrated in Figure 1b, the fine-tuning performance drops as the quantization bit decreases when applying QLoRA. Moreover, it is noteworthy that QLoRA fails below the 3-bit level.
|
| 24 |
+
|
| 25 |
+
In this paper, we introduce a novel quantization framework, called LoRA-Fine-Tuning-aware Quantization (LoftQ). It is designed specifically for pre-trained models that require quantization and LoRA fine-tuning. This framework actively integrates low-rank approximation, working in tandem with quantization to jointly approximate the original high-precision pre-trained weights. This synergy significantly enhances alignment with the original pre-trained weights as illustrated in Figure 2. Consequently, our method provides an advantageous initialization point for subsequent LoRA fine-tuning, leading to improvements in downstream tasks.
|
| 26 |
+
|
| 27 |
+

|
| 28 |
+
Figure 1: QLoRA performance with different bits. Left: QLoRA initialization of LLAMA-2-13b on WikiText-2. Right: Apply QLoRA to LLAMA-2-13b on WikiText-2 language modeling task. Smaller perplexity indicates better performance.
|
| 29 |
+
|
| 30 |
+
We evaluate our quantization framework by conducting extensive experiments on downstream tasks, such as NLU, question answering, summarization, and NLG. Experiments show that LoftQ consistently outperforms QLoRA across all precision levels. For instance, with 4-bit quantization, we achieve a 1.1 and 0.8 gain in Rouge-1 for XSum (Narayan et al., 2018) and CNN/DailyMail (Hermann et al., 2015), respectively. LoftQ excels particularly in low-bit scenarios and works effectively with different quantization methods. For example, we achieve over an $8 \%$ gain on MNLI (Wang et al., 2019) and more than $10 \%$ on SQuADv1.1 (Rajpurkar et al., 2016) with both 2-bit NormalFloat and the 2-bit uniform quantization. We have not seen our approach performs worse than QLoRA.
|
| 31 |
+
|
| 32 |
+
# 2 BACKGROUND
|
| 33 |
+
|
| 34 |
+
# 2.1 TRANSFORMER MODELS
|
| 35 |
+
|
| 36 |
+
A transformer model contains a sequence of layers, where each layer consists of two sub-layers: a multi-head self-attention (MHA) and a fully connected feed forward network (FFN) (Vaswani et al., 2017). Given the input $\ b { X } \in \mathbb { R } ^ { n \times d }$ , where $n$ is the sequence length and $d$ is the hidden dimension of the model, MHA computes the $h$ attention heads in parallel:
|
| 37 |
+
|
| 38 |
+
$$
|
| 39 |
+
\mathrm { M H A } ( X ) = \mathrm { C o n c a t } ( \mathrm { h e a d } _ { 1 } , . . . , \mathrm { h e a d } _ { h } ) W _ { o } ,
|
| 40 |
+
$$
|
| 41 |
+
|
| 42 |
+
$$
|
| 43 |
+
\mathrm { h e a d } _ { i } = \mathrm { S o f t m a x } ( X W _ { q _ { i } } ( X W _ { k _ { i } } ) ^ { \top } / \sqrt { d _ { h } } ) X W _ { v _ { i } } \mathrm { f o r } i = 1 , . . . , h ,
|
| 44 |
+
$$
|
| 45 |
+
|
| 46 |
+
where $W _ { q _ { i } } , W _ { k _ { i } } , W _ { v _ { i } } \in \mathbb { R } ^ { d \times d _ { h } }$ are query, key, and value matrices, $W _ { o } \in \mathbb { R } ^ { d \times d }$ is the output matrix, and $d _ { h } = d / h$ . FFN comprises two linear transformations and an activation function, and is defined as $\mathrm { F F N } ( X ) = \sigma ( X W _ { f _ { 1 } } \bar { + } b _ { 1 } ) W _ { f _ { 2 } } + b _ { 2 }$ , where $W _ { f _ { 1 } } \in \mathbb { R } ^ { d \times d _ { m } }$ , $W _ { f _ { 2 } } \in \mathbb { R } ^ { d _ { m } \times d }$ , and $\sigma ( \cdot )$ is the activation function. A residual connection is used and followed by layer normalization.
|
| 47 |
+
|
| 48 |
+

|
| 49 |
+
Figure 2: Initialization discrepancy between the LoRA initialization and the original pre-trained weight matrix, described by the spectral norm and Frobenius norm of the difference. The weight matrix in the above figures is randomly selected in BART-large. The initialization is obtained by QLoRA and LoftQ, with Uniform and NormalFloat quantization methods applied at both 2-bit and 4-bit levels. LoftQ successfully mitigates the discrepancy, especially at the 2-bit level.
|
| 50 |
+
|
| 51 |
+
# 2.2 QUANTIZATION
|
| 52 |
+
|
| 53 |
+
Quantization. Given a high-precision number, e.g., such as 32-bit floating point number, $X ^ { \mathrm { H P } } \in \mathbb { R }$ , $N$ -bit quantization encodes it to an integer $X ^ { \mathrm { I N T } } \in \{ 0 , 1 , . . . , 2 ^ { N } - 1 \}$ . This process can be expressed as
|
| 54 |
+
|
| 55 |
+
$$
|
| 56 |
+
X ^ { \mathrm { I N T } } = \mathrm { r o u n d } \left( ( 2 ^ { N } - 1 ) F \left( X ^ { \mathrm { H P } } \right) \right) ,
|
| 57 |
+
$$
|
| 58 |
+
|
| 59 |
+
where $F ( \cdot ) \colon \mathbb { R } \mapsto [ 0 , 1 ]$ is a normalization function. Uniform quantization assumes $F ( X ) = ( X -$ $X _ { \mathrm { m i n } } ) / ( X _ { \mathrm { m a x } } - X _ { \mathrm { m i n } } )$ . Dettmers et al. (2023) proposes 4-bit NormalFloat Quantization (NF4). It assumes $X \sim { \mathcal { N } } ( 0 , \sigma ^ { 2 } )$ and hence $F ( X ) = \Phi ( X / \sigma )$ , where $\Phi ( \cdot )$ is the cumulative distribution function of the standard normal distribution.
|
| 60 |
+
|
| 61 |
+
Dequantization. A lookup table $\tau$ , where
|
| 62 |
+
|
| 63 |
+
$$
|
| 64 |
+
\mathcal { T } [ i ] = F ^ { - 1 } \left( \frac { i } { 2 ^ { N } - 1 } \right) , i = 0 , 1 , . . . , 2 ^ { N } - 1 ,
|
| 65 |
+
$$
|
| 66 |
+
|
| 67 |
+
is used to decode the integer $X ^ { \mathrm { I N T } }$ to its simulated high-precision counterpart $X ^ { \mathbf { D } } \in \mathbb { R }$ . Therefore, the dequantization can be expressed as
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
X ^ { \mathrm { D } } = { \mathcal { T } } [ X ^ { \mathrm { I N T } } ] .
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
Simulated Quantization for Matrices. While it is possible to perform multiplication directly between quantized representations, it is common to apply simulated quantization for matrices (Bai et al., 2020; Shen et al., 2020). There, quantized weight matrices are stored as encoded integers in memory, and are temporarily dequantized to simulated high-precision matrices by the lookup table when engaged in multiplication operations. In simulated quantization, it is only necessary to analyze the map from aend-to-end process by $q _ { N } \big ( \cdot \big ) \colon \mathbb { R } ^ { m \times n } \mapsto \mathbb { R } _ { N } ^ { m \times n }$ a simu, where $\mathbb { R } _ { N } : \{ \bar { T } [ i ] \in \mathbb { R } | 0 \le i < 2 ^ { N } \}$ We denote this.
|
| 74 |
+
|
| 75 |
+
# 2.3 LOW-RANK ADAPTATION
|
| 76 |
+
|
| 77 |
+
LoRA (Hu et al., 2021) updates two small weight matrices $A$ and $B$ that are attached to a frozen pre-trained weight matrix $W$ . Hence, a linear transformation, $Y = X W$ , is reformulated as
|
| 78 |
+
|
| 79 |
+
$$
|
| 80 |
+
\boldsymbol { Y } = \boldsymbol { X } \boldsymbol { W } + \boldsymbol { X } \boldsymbol { A } \boldsymbol { B } ^ { \intercal } ,
|
| 81 |
+
$$
|
| 82 |
+
|
| 83 |
+
where $\begin{array} { r } { X \in \mathbb { R } ^ { n \times d _ { 1 } } , W \in \mathbb { R } ^ { d _ { 1 } \times d _ { 2 } } , A \in \mathbb { R } ^ { d _ { 1 } \times r } , B \in \mathbb { R } ^ { d _ { 2 } \times r } , } \end{array}$ , and $r \ll \operatorname* { m i n } \{ d _ { 1 } , d _ { 2 } \}$ . Initially,
|
| 84 |
+
|
| 85 |
+
$$
|
| 86 |
+
A \sim \mathcal { N } ( 0 , \sigma ^ { 2 } ) , B = 0 ,
|
| 87 |
+
$$
|
| 88 |
+
|
| 89 |
+
so as to align to the pre-trained weights. During the fine-tuning, $W$ is fixed while $A$ and $B$ are updated by some SGD-type optimization method.
|
| 90 |
+
|
| 91 |
+
It is worth noting that if low-rank adapters $A$ and $B$ are attached to a quantized backbone $Q =$ $q _ { N } ( W )$ and are initialized by (5), the starting weight $Q + A B ^ { \top }$ is no longer equal to the pre-trained weight $W$ due to the discrepancy introduced by the quantization.
|
| 92 |
+
|
| 93 |
+
# 3 METHOD
|
| 94 |
+
|
| 95 |
+
We propose LoRA-Fine-Tuning-aware Quantization (LoftQ), a quantization framework for LLMs. It alternatively applies quantization and low-rank approximation to approximate original pre-trained weights. This quantization framework provides a promising initialization for LoRA fine-tuning, which alleviates the quantization discrepancy in QLoRA and improves generalization in downstream tasks significantly.
|
| 96 |
+
|
| 97 |
+
# 3.1 LORA-AWARE QUANTIZATION
|
| 98 |
+
|
| 99 |
+
We use an $N$ -bit quantized weight $Q \in \mathbb { R } _ { N } ^ { d _ { 1 } \times d _ { 2 } }$ and low-rank approximations $A \in \mathbb { R } ^ { d _ { 1 } \times r } , B \in$ $\mathbb { R } ^ { d _ { 2 } \times r }$ to approximate the original high-precision pre-trained weight $W \in \mathbb { R } ^ { d _ { 1 } \times d _ { 2 } }$ as the initialization of LoRA fine-tuning. Specifically, before fine-tuning, we initialize the network by minimizing the following objective:
|
| 100 |
+
|
| 101 |
+
$$
|
| 102 |
+
\operatorname* { m i n } _ { Q , A , B } \left\| \boldsymbol W - \boldsymbol Q - \boldsymbol A \boldsymbol B ^ { \intercal } \right\| _ { F } ,
|
| 103 |
+
$$
|
| 104 |
+
|
| 105 |
+
where $\left\| \cdot \right\| _ { F }$ denotes the Frobenious norm. This objective in (6) takes LoRA fine-tuning into consideration by jointly optimizing the initial values of the quantized backbone $Q$ and low-rank adapters $A , B$ . Contrarily, practitioners typically convert the pre-trained weight $W$ into a quantized weight $Q$ outright, neglecting the subsequent LoRA fine-tuning process. This oversight leads to notable performance degradation in downstream tasks arising from the quantization discrepancy.
|
| 106 |
+
|
| 107 |
+
# 3.2 ALTERNATING OPTIMIZATION
|
| 108 |
+
|
| 109 |
+
We solve the minimization problem in (6) by alternating between quantization and singular value decomposition (SVD). To begin with, we set $A _ { 0 }$ , and $B _ { 0 }$ equal to 0.
|
| 110 |
+
|
| 111 |
+
Quantization. At the $t$ -th step, we quantize the difference between the original pre-trained weight matrix $W$ and the low-rank approximation $A _ { t - 1 } B _ { t - 1 } ^ { \top }$ from the previous step to obtain the quantized weight matrix $Q _ { t }$ by
|
| 112 |
+
|
| 113 |
+
$$
|
| 114 |
+
Q _ { t } = q _ { N } ( W - A _ { t - 1 } B _ { t - 1 } ^ { \top } ) ,
|
| 115 |
+
$$
|
| 116 |
+
|
| 117 |
+
where $q _ { N } ( \cdot )$ maps a high-precision weight matrix to a quantized matrix.
|
| 118 |
+
|
| 119 |
+
We remark that our algorithm is compatible with different quantization functions $q _ { N } ( \cdot )$ . We apply NF4 and the uniform quantization in Section 4 as examples. We also remark that $Q _ { t }$ is not an exact solution of the minimization in (6), given the fixed $A _ { t - 1 } B _ { t - 1 } ^ { \top }$ , but it is an efficient approximation.
|
| 120 |
+
|
| 121 |
+
SVD. After obtaining the $t$ -th quantized weight $Q _ { t }$ , SVD is applied to the residual of the quantization denoted by $R _ { t } = W - Q _ { t }$ by
|
| 122 |
+
|
| 123 |
+
$$
|
| 124 |
+
R _ { t } = \sum _ { i = 1 } ^ { d } { \sigma _ { t , i } u _ { t , i } v _ { t , i } ^ { \top } } ,
|
| 125 |
+
$$
|
| 126 |
+
|
| 127 |
+
where $d = \operatorname* { m i n } \{ d _ { 1 } , d _ { 2 } \}$ , $\sigma _ { t , 1 } \geq \sigma _ { t , 2 } \geq \ldots \geq \sigma _ { t , d }$ are the singular values of $R _ { t } , u _ { t , i }$ ’s and $v _ { t , i }$ ’s are the associated left and right singular vectors of $R _ { t }$ . We then obtain a rank- $r$ approximation of $R _ { t }$ by $A _ { t } B _ { t } ^ { \top }$ , where
|
| 128 |
+
|
| 129 |
+
$$
|
| 130 |
+
\begin{array} { r l } & { A _ { t } = [ \sqrt { \sigma _ { t , 1 } } u _ { t , 1 } , . . . , \sqrt { \sigma _ { t , r } } u _ { t , r } ] , } \\ & { B _ { t } = [ \sqrt { \sigma _ { t , 1 } } v _ { t , 1 } , . . . , \sqrt { \sigma _ { t , r } } v _ { t , r } ] . } \end{array}
|
| 131 |
+
$$
|
| 132 |
+
|
| 133 |
+
We summarize our method in Algorithm 1. It is worth noting that $T = 1$ is a special case where $Q _ { 1 }$ is the exact quantized weight obtained by QLoRA, and low-rank approximations $A _ { 1 } , B _ { 1 }$ are obtained by the SVD of the quantization residual $W - Q _ { 1 }$ . $T = 1$ is sufficient to mitigate the quantization discrepancy, and alternating optimization helps to find a closer initialization to the pre-trained weight $W$ , which further improves the performance (see Section 3).
|
| 134 |
+
|
| 135 |
+
We remark that the computational cost of LoftQ is negligible because it is applied to individual weight matrices and can be executed in parallel. We also remark one can apply LoftQ only once to a pre-trained model and reuse the initialization obtained by LoftQ for different downstream tasks.
|
| 136 |
+
|
| 137 |
+
# 3.3 APPLYING TO LORA FINE-TUNING
|
| 138 |
+
|
| 139 |
+
We store the $Q _ { T } \in \mathbb { R } _ { N } ^ { d _ { 1 } \times d _ { 2 } }$ obtained by LoftQ using an integer matrix $M$ by (1) and a lookup table $\tau$ by (2). We initialize the backbone with the integer matrix $M$ and initialize the low-rank adapters with $A _ { T } , B _ { T }$ obtained by LoftQ.
|
| 140 |
+
|
| 141 |
+
# Algorithm 1 LoftQ
|
| 142 |
+
|
| 143 |
+
input Pre-trained weight $W$ , target rank $r$ , $N$ -bit quantization function $q _ { N } ( \cdot )$ , alternating step $T$
|
| 144 |
+
1: Initialize $A _ { 0 } 0 , B _ { 0 } 0$
|
| 145 |
+
2: for $\mathbf { t } = 1$ to $T$ do
|
| 146 |
+
3: Obtain quantized weight $Q _ { t } q _ { N } ( W - A _ { t - 1 } B _ { t - 1 } ^ { \top } )$
|
| 147 |
+
4: Obtain low-rank approximation $A _ { t } , B _ { t } \gets \operatorname { S V D } ( W - Q _ { t } )$ by (9)
|
| 148 |
+
|
| 149 |
+
5: end for output $Q _ { T } , A _ { T } , B _ { T }$
|
| 150 |
+
|
| 151 |
+
During LoRA fine-tuning, we freeze the integer weight $M$ and optimize the low-rank adapters with an efficient optimization algorithm, e.g., AdamW (Loshchilov & Hutter, 2017). In forward propagation, the integer weight $M$ is temporarily dequantized to the simulated high-precision weight $Q _ { T }$ by its lookup table, as described in (3). In back propagation, gradients and optimizer state are only related to low-rank adapters $A , B$ , which reduces considerable training cost.
|
| 152 |
+
|
| 153 |
+
# 4 EXPERIMENTS
|
| 154 |
+
|
| 155 |
+
We evaluate our method on NLU and NLG tasks. We apply LoftQ for quantizing DeBERTaV3-base (He et al., 2021b), BART-large (Lewis et al., 2019), and LLAMA-2 series (Touvron et al., 2023).
|
| 156 |
+
|
| 157 |
+
Implementation Details. Following the prior works of LoRA variants (Zhang et al., 2023; He et al., 2021a), we freeze all the backbone weight matrices and add low-rank adapters to weight matrices in MHA and FFN of all layers. We quantize the weight matrices that are attached by lowrank adapters. All the quantized models and adapters used in this paper are available on https: //huggingface.co/LoftQ. Our implementation is based on publicly available Huggingface Transformers code-base (Paszke et al., 2019). All the experiments are conducted on NVIDIA A100 GPUs.
|
| 158 |
+
|
| 159 |
+
Quantization Methods. We apply two quantization methods to demonstrate LoftQ is compatible with different quantization functions:
|
| 160 |
+
|
| 161 |
+
• Uniform quantization is a classic quantization method. It uniformly divides a continuous interval into $2 ^ { N }$ categories and stores a local maximum absolute value for dequantization. • NF4 and its 2-bit variant NF2 are quantization methods used in QLoRA (Dettmers et al., 2023). They assume that the high-precision values are drawn from a Gaussian distribution and map these values to discrete slots that have equal probability.
|
| 162 |
+
|
| 163 |
+
We perform 2-bit and 4-bit quantization on all models, achieving compression ratios of $2 5 - 3 0 \%$ and $1 5 - 2 0 \%$ at the 4-bit and 2-bit levels, respectively. The compression ratios and trainable parameter ratios for all models are detailed in the Appendix A.
|
| 164 |
+
|
| 165 |
+
Baselines. We compare LoftQ with the following baseline methods:
|
| 166 |
+
|
| 167 |
+
• Full fine-tuning is the most common approach for adapting a pre-trained model to downstream tasks. The model is initialized with pre-trained weights and all parameters are updated through an SGD-type optimization method.
|
| 168 |
+
• Full precision LoRA (LoRA) is a lightweight method for task adaptation, where it stores the backbone using 16-bit numbers and optimizes the low-rank adaptors only. The adaptors are applied to the same matrices as in LoftQ.
|
| 169 |
+
• QLoRA is similar to LoRA except the backbone is quantized into low-bit regime. The lowrank adapters are initialized using (5) and are applied to the same matrices as in LoftQ.
|
| 170 |
+
|
| 171 |
+
# 4.1 ENCODER-ONLY MODEL: DEBERTAV3
|
| 172 |
+
|
| 173 |
+
Models and Datasets. We quantize the DeBERTaV3-base (He et al., 2021b) with LoftQ, then finetune and evaluate the model on the General Language Understanding Evaluation (GLUE) benchmark (Wang et al., 2019), SQuADv1.1 (Rajpurkar et al., 2016), and ANLI (Nie et al., 2019). The specific tasks of GLUE are given in Appendix C. Following previous works (Zhang et al., 2023), we exclude WNLI in the experiments.
|
| 174 |
+
|
| 175 |
+
Implementation Details. We select the learning rates from $\{ 1 \times 1 0 ^ { - 5 } , 5 \times 1 0 ^ { - 5 } , 1 \times 1 0 ^ { - 4 } 5 \times 1 0 ^ { - 4 } \}$ . We quantize the entire backbone. Given that GLUE, SQuADv1.1, and ANLI are relatively easy NLU tasks, we also quantize the embedding layer for higher compression efficiency. We apply the NormalFloat and the uniform quantization for LoftQ and QLoRA at both 2-bit and 4-bit levels. We use rank 16 and 32 for low-rank adapters. More implementation details, such as the training epochs and batch sizes, are presented in Appendix D.2.
|
| 176 |
+
|
| 177 |
+
Main Results. Table 1 and Table 2 summarize the results for 2-bit quantization on the GLUE, SQuADv1.1, and ANLI datasets, by NF2 and the uniform quantization, respectively. Our method consistently outperforms QLoRA on all settings with respect to different ranks, quantization methods, and datasets. When using the uniform quantization (Table 2), our method achieves $8 8 . 0 \%$ accuracy on MNLI-m, surpassing the QLoRA baseline by $8 \%$ . For tasks like SST and SQuADv1.1, our method even approaches the full fine-tuning performance at 2-bit level. The 4-bit quantization experiment results are presented in Appendix D.1 as both LoftQ and QLoRA achieve performance close to full fine-tuning.
|
| 178 |
+
|
| 179 |
+
Table 1: Results with 2-bit LoftQ of DeBERTaV3-base models on GLUE development set, SQuADv1.1 development set, ANLI test set using NF2 quantization. We report the median over four seeds. N.A. indicates the model does not converge. The best results on each dataset are shown in bold.
|
| 180 |
+
|
| 181 |
+
<table><tr><td>Rank</td><td>Method</td><td>MNLI m/mm</td><td>QNLI Acc</td><td>RTE Acc</td><td>SST Acc</td><td>MRPC Acc</td><td>CoLA Matt</td><td>QQP Acc</td><td>STSB P/S Corr</td><td>SQuAD EM/F1</td><td>ANLI Acc</td></tr><tr><td></td><td>Full FT</td><td>90.5/90.6</td><td>94.0</td><td>82.0</td><td>95.3</td><td>89.5/93.3</td><td>69.2</td><td>92.4/89.8</td><td>91.6/91.1</td><td>88.5/92.8</td><td>59.8</td></tr><tr><td>16</td><td>LoRA</td><td>90.4/90.5</td><td>94.6</td><td>85.1</td><td>95.1</td><td>89.9/93.6</td><td>69.9</td><td>92.0/89.4</td><td>91.7/91.1</td><td>87.3/93.1</td><td>60.2</td></tr><tr><td>16</td><td>QLoRA</td><td>75.4775.6</td><td>824</td><td>55</td><td>86.5</td><td>73.8/82.8</td><td>N</td><td>86.3/82.3</td><td>83.0/82.8</td><td>61.5/71.2</td><td>N</td></tr><tr><td>32</td><td>LoRA</td><td>78.5/78.7</td><td>804</td><td>567</td><td>869</td><td>73.8/82.7</td><td>N</td><td>87.182.7</td><td>83.6/83.3</td><td>64.6773.8</td><td></td></tr></table>
|
| 182 |
+
|
| 183 |
+
Table 2: Results with 2-bit LoftQ of DeBERTaV3-base models on GLUE development set, SQuADv1.1 development set using Uniform quantization . We report the median over four seeds. N.A. indicates the model does not converge. The best results on each task are shown in bold.
|
| 184 |
+
|
| 185 |
+
<table><tr><td>Rank</td><td>Method</td><td>MNLI m/mm</td><td>QNLI Acc</td><td>RTE Acc</td><td>SST Acc</td><td>MRPC Acc</td><td>CoLA Matt</td><td>QQP Acc</td><td>STSB P/S Corr</td><td>SQuAD Em/F1</td></tr><tr><td></td><td>Full FT</td><td>90.5/90.6</td><td>94.0</td><td>82.0</td><td>95.3</td><td>89.5/93.3</td><td>69.2</td><td>92.4/89.8</td><td>91.6/91.1</td><td>88.5/92.8</td></tr><tr><td>16</td><td>LoRA</td><td>90.4/90.5</td><td>94.6</td><td>85.1</td><td>95.1</td><td>89.9/93.6</td><td>69.9</td><td>92.0/89.4</td><td>91.7/91.1</td><td>87.3/93.1</td></tr><tr><td>16</td><td>QLoRA</td><td>76.5/76.3</td><td>88</td><td>567</td><td>86</td><td>75.7784.7</td><td></td><td>87.182.6</td><td>83.5/83.4</td><td>89.5/776</td></tr><tr><td>32</td><td>LoRA</td><td>79.9779.5</td><td>87</td><td>578</td><td>8.9</td><td>76.5/84.2</td><td>N</td><td>8.6/84.7</td><td>84.1/84.0</td><td>71.6/80.2</td></tr></table>
|
| 186 |
+
|
| 187 |
+
Our method is also more stable compared to QLoRA in the low-bit regime. For instance, while QLoRA fails to converge on CoLA for both quantization methods and ranks, LoftQ converges in all cases and achieves a score of 60.5 using uniform quantization at rank 32. LoftQ stands out in its ability to consistently attain robust and improved performance by effectively preserving the starting point of pre-trained weights.
|
| 188 |
+
|
| 189 |
+
# 4.2 ENCODER-DECODER MODEL: BART
|
| 190 |
+
|
| 191 |
+
Models and Datasets. We quantize BART-large model (Lewis et al., 2020) with LoftQ, then finetune and evaluate the model on two commonly used summarization datasets: XSum (Narayan et al., 2018) and CNN/DailyMail(Hermann et al., 2015).
|
| 192 |
+
|
| 193 |
+
Implementation Details. We apply LoftQ to weight matrices in MHA and FFN of both encoder and decoder layers. We report ROUGE 1/2/L scores, which are the metrics for summarization tasks (Lin, 2004). We conduct quantization experiments in both 2-bit and 4-bit scenarios. We experiment with both NormalFloat and the uniform quantization in both 2-bit and 4-bit scenarios. In each precision, we choose rank equal to 8 and 16 for a fair comparison with the full precision LoRA baseline (Zhang et al., 2023). Please see Appendix E for detailed configurations.
|
| 194 |
+
|
| 195 |
+
Main Results. Table 3 summarizes our 4-bit quantization experiment results on the XSum and CNN/DailyMail test sets. Our method consistently outperforms QLoRA at both ranks on both datasets. It even surpasses full precision LoRA at both ranks on Xsum. We will discuss this unexpected results in Section 5. The 2-bit quantization results are shown in Table 4. Our observation is consistent with the NLU experiments, that LoftQ demonstrates the convergence to reasonable results, while QLoRA does not converge. This indicates our method is robuster by narrowing the initialization gap.
|
| 196 |
+
|
| 197 |
+
Table 3: Results with 4-bit LoftQ of BART-large on XSum and CNN/DailyMail. We report ROUGE1/2/L. Lead-3 means choosing the first 3 sentences as the summary. N.A. indicates the model does not converge. Full FT: full fine-tuning. We report the median over five seeds.
|
| 198 |
+
|
| 199 |
+
<table><tr><td>Quantization</td><td>Rank</td><td>Method</td><td>XSum</td><td>CNN/DailyMail</td></tr><tr><td rowspan="2">Full Precision</td><td></td><td>Lead-3 Full FT</td><td>16.30/1.60/11.95 45.14/22.27/37.25</td><td>40.42/17.62/36.67 44.16/21.28/40.90</td></tr><tr><td>8</td><td>LoRA</td><td>43.40/20.20/35.20</td><td>44.72/21.58/41.84</td></tr><tr><td rowspan="3">NF4</td><td>16 8</td><td>LoRA QLoRA</td><td>43.95/20.72/35.68 42.91/19.72/34.82</td><td>45.03/21.84/42.15 43.10/20.22/40.06</td></tr><tr><td></td><td>LoftQ</td><td>44.08/20.72/35.89</td><td>43.81/20.95/40.84</td></tr><tr><td>16</td><td>QLoRA</td><td>43.29/20.0/35.15</td><td>43.42/20.67/40.4</td></tr><tr><td rowspan="3">Uniform</td><td>8</td><td></td><td></td><td></td></tr><tr><td></td><td>QLoRA</td><td>41.84/18.71/3374</td><td>43.73/20.91/40.77</td></tr><tr><td>16</td><td>QLoRA</td><td>4.45/19.36/34.38</td><td>4300/20.19/40.02</td></tr></table>
|
| 200 |
+
|
| 201 |
+
Table 4: Results with 2-bit LoftQ of BART-large on XSum and CNN/DailyMail using NF2 quantization. N.A. indicates the model does not converge. We report ROUGE-1/2/L, the higher the better. We report the median over five seeds.
|
| 202 |
+
|
| 203 |
+
<table><tr><td>Rank</td><td>Method</td><td>XSum</td><td>CNN/DailyMail</td></tr><tr><td>8</td><td>QLoRA LoftQ</td><td>N.A. 39.63/16.65/31.62</td><td>N.A. 42.24/19.44/29.04</td></tr><tr><td>16</td><td>QLoRA</td><td>40.81/17.85/32.80</td><td>42.52/19.81/39.51</td></tr></table>
|
| 204 |
+
|
| 205 |
+
# 4.3 DECODER-ONLY MODEL: LLAMA-2
|
| 206 |
+
|
| 207 |
+
Models and Datasets. We quantize LLAMA-2-7b and LLAMA-2-13b (Touvron et al., 2023) with LoftQ. We then fine-tune and evaluate the models on two NLG datasets: GSM8K (Cobbe et al., 2021) and WikiText-2 (Merity et al., 2016). Please see Appendix F for more details about the datasets.
|
| 208 |
+
|
| 209 |
+
Implementation Details. Similarly, we apply LoftQ to weight matrices in MHA and FFN of all layers. In WikiText-2 evaluation, we report perplexity. In case of overfitting, we apply weight decay to low-rank adapters for all settings. In GSM8K evaluation, we extract numerical answers in the generated solutions and then calculate the accuracy using those numerical answers. We conduct experiments with both NF2 and NF4. Please see Appendix F for detailed configurations.
|
| 210 |
+
|
| 211 |
+
Main Results. Table 5 presents a summary of our experiments on LLAMA-2-7b and LLAMA-2- 13b using 2-bit, 4-bit, and mixed-precision NormalFloat quantization methods on WikiText-2 and GSM8K datasets. In WikiText-2, our method consistently outperforms QLoRA across all quantization precision settings on both models. When dealing with the challenging 2-bit precision, where QLoRA fails to converge, LoftQ manages to achieve a perplexity of 7.85. In GSM8K, our method achieves better or on par performance compared to QLoRA across different model sizes and quantization precision levels. For example, our method achieves $2 6 . 5 \%$ accuracy using 2-bit precision of LLAMA-2-7b, where QLoRA does not converge.
|
| 212 |
+
|
| 213 |
+
To provide a customized trade-off between the performance and precision, we also explore mixedprecision (equivalent to 3 bits) quantization where matrices in the first half layers are quantized using 4 bits, and the rest matrices remain 2 bits. We witness a remarkable $4 . 1 \%$ accuracy boost on the GSM8K dataset using LLAMA-2-7b and a $4 . 7 \%$ boost using LLAMA-2-13b. This result underscores the potential of LoftQ for complex mixed-precision quantization scenarios.
|
| 214 |
+
|
| 215 |
+
Table 5: Results of LoftQ using NormalFloat for LLAMA-2 series on WikiText-2 and GSM8K. 3/2.5/2.25-bit indicates mixed-precision quantization: 4-bit precision for the first 16/8/4 layers and 2-bit precision for the rest of layers. We report the perplexity (the smaller the better) for WikiText-2 and accuracy for GSM8K. The rank of low-rank adapters is 64. N.A. indicates the model does not converge. We report the median over five random seeds.
|
| 216 |
+
|
| 217 |
+
<table><tr><td rowspan="2">Method</td><td rowspan="2">Bit</td><td colspan="2">wikiLLAMA-2-7M8K↑</td><td colspan="2">wikiLLAMA-2-13M8K↑</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>LoRA</td><td>16</td><td>5.08</td><td>38.5</td><td>5.12</td><td>48.8</td></tr><tr><td rowspan="2">QLoRA LoftQ</td><td>4</td><td>5.70</td><td>38.2</td><td>5.22</td><td>48.8</td></tr><tr><td>4</td><td>5.24</td><td>38.0</td><td>5.16</td><td>49.1</td></tr><tr><td rowspan="2">QLoRA LoftQ</td><td>3</td><td>5.73</td><td>32.1</td><td>5.22</td><td>40.7</td></tr><tr><td>3</td><td>5.63</td><td>36.2</td><td>5.13</td><td>45.4</td></tr><tr><td rowspan="2">QLoRA LoftQ</td><td>2.5</td><td>N.A.</td><td>N.A.</td><td>19.39</td><td>N.A.</td></tr><tr><td>2.5</td><td>5.78</td><td>31.1</td><td>5.22</td><td>41.1</td></tr><tr><td rowspan="2">QLoRA LoftQ</td><td>2.25</td><td>N.A.</td><td>N.A.</td><td>N.A.</td><td>N.A.</td></tr><tr><td>2.25</td><td>6.13</td><td>27.5</td><td>5.45</td><td>38.1</td></tr><tr><td rowspan="2">QLoRA LoftQ</td><td>2</td><td>N.A</td><td>N.A.</td><td>N.A.</td><td></td></tr><tr><td>2</td><td>7.85</td><td>26.5</td><td>7.69</td><td>N.A. 33.4</td></tr></table>
|
| 218 |
+
|
| 219 |
+
# 4.4 ANALYSIS
|
| 220 |
+
|
| 221 |
+
Effectiveness of Alternating Optimization. We conduct experiments with different alternating step $T$ to verify the effectiveness of the alternating optimization and to find the best value $T$ as a hyperparameter for different models. Across all tasks and models, we observed that alternating optimization yields substantial improvements even with a minimal alternating step. This suggests that it rapidly narrows the discrepancy between quantized weights and pre-trained weights, making our method easy to apply. For example, LoftQ achieves 21.14 Rouge-2 score on XSum using only 1 step. Interestingly, we noticed that increasing the alternating step beyond a certain point tends to result in diminishing returns. We suspect this phenomenon occurs because, as the gap becomes smaller, it becomes more challenging for alternating optimization to consistently minimize the gap at each step. This challenge emerges because of the inherent errors introduced by the quantization method. Nevertheless, results from Figure 3 indicate our method is not sensitive to the alternating step $T$ and is able to consistently enhance downstream fine-tuning performance.
|
| 222 |
+
|
| 223 |
+

|
| 224 |
+
Figure 3: Comparison of different alternating step $T$ used in LoftQ. $T = 0$ indicates we use QLoRA method that initializes low-rank adapters by (5). $T = 1 , 5 , 1 0$ indicates we use different $T$ for LoftQ described in Algorithm 1. Left: Uniform 2-bit DeBERTaV3-base. Middle: NF2 2-bit LLAMA-2- 13b. Right: NF4 BART-large.
|
| 225 |
+
|
| 226 |
+
# 5 DISCUSSION
|
| 227 |
+
|
| 228 |
+
Start with quantization or SVD in the alternating optimization? An alternative algorithm to the alternating optimization is that we first obtain the low-rank approximation $A _ { t } , B _ { t }$ and then obtain the quantized weight $Q _ { t }$ by switching Line 3 and Line 4 in Algorithm 1. We note this is a valid alternative method as both still jointly minimize the objective in (6). Table 6 summarizes the performance of this alternative method. It is noteworthy that the alternative method still outperforms QLoRA significantly, even though it is worse than the primary version. This observation underscores the potential for performance improvement by achieving a closer approximation of pre-trained weights within the low-precision regime.
|
| 229 |
+
|
| 230 |
+
LoftQ better than Full-precision LoRA? We find LoftQ outperforms full precision LoRA in XSum and GSM8K (see Table 3 and Table 5). Beside the overfitting caused by lack of regularization, anonther possible explanation for this unexpected phenomenon is that the initial low-rank adapters obtained by LoftQ are non-zero while they are all zero in full precision LoRA as described in (5). Such zero initialization could make the fine-tuning unstable, and therefore it performs worse than LoftQ. We leave the study of the robustness of LoftQ as future work.
|
| 231 |
+
|
| 232 |
+
Table 6: Results of 2-bit uniformly quantized DeBERTaV3-base on part of GLUE. LoftQ(SVD First) indicates the alternative LoftQ that swiches Line 3 and Line 4 in Algorithm 1. We report the median over four random seeds. The best results on each task are shown in bold.
|
| 233 |
+
|
| 234 |
+
<table><tr><td>Method</td><td>Rank</td><td>MNLI</td><td>QNLI</td><td>SST2</td></tr><tr><td>Full FT</td><td></td><td>90.5/90.6</td><td>94.0</td><td>95.3</td></tr><tr><td>QLoRA</td><td>32</td><td>79.9/79.5</td><td>83.8</td><td>86.6</td></tr><tr><td>LoftQ(SVD First)</td><td>32</td><td>87.8/87.7</td><td>84.9</td><td>89.7</td></tr><tr><td>LoftQ(Quantiztion First)</td><td>32</td><td>88.0/88.1</td><td>92.2</td><td>94.7</td></tr></table>
|
| 235 |
+
|
| 236 |
+
# 6 RELATED WORK
|
| 237 |
+
|
| 238 |
+
Quantization-Aware Training (QAT) is often used to obtain quantized models that are adapted in downstream tasks (Peri et al., 2020; Liu et al., 2023). It involves quantization and full model fine-tuning at the same time. However, QAT requires massive training cost, such as the gradient and optimization state. Moreover, it is difficult to compute the gradient of quantized weights. Our method, with the help of LoRA, sidesteps the aforementioned issues, providing a light approach for downstream task adaptation.
|
| 239 |
+
|
| 240 |
+
Post-Training Quantization (PTQ) is a category of popular quantization frameworks (Frantar et al., 2022; Xiao et al., 2023), which can also be used for task adaptation. It calibrates the high-precision model with a small subset of the training dataset. Therefore, the subsequent quantization is guided by the training dataset, providing task-specific quantized models. Besides, it does not involve any gradient backpropagation, so it is cost-efficient. However, it usually results in lower accuracy compared to QAT.
|
| 241 |
+
|
| 242 |
+
# 7 CONCLUSION
|
| 243 |
+
|
| 244 |
+
We propose LoftQ, a quantization framework for LLMs, which alternatively applies quantization and low-rank approximation to the original high-precision pre-trained weights, to obtain an initialization for the subsequent LoRA fine-tuning. Experiments on natural language understanding, question answering, summarization, and natural language generation show that our framework remarkably surpasses existing methods, e.g., QLoRA, for quantizing encoder-only, encoder-decoder, and decoder-only models. We have not observed our method exhibiting worse performance over QLoRA. Moreover, our quantization framework demonstrates effectiveness and robustness particularly in low-bit quantization regimes, e.g., the 2-bit level.
|
| 245 |
+
|
| 246 |
+
REFERENCES
|
| 247 |
+
Haoli Bai, Wei Zhang, Lu Hou, Lifeng Shang, Jing Jin, Xin Jiang, Qun Liu, Michael Lyu, and Irwin King. Binarybert: Pushing the limit of bert quantization. arXiv preprint arXiv:2012.15701, 2020.
|
| 248 |
+
Haoli Bai, Lu Hou, Lifeng Shang, Xin Jiang, Irwin King, and Michael R Lyu. Towards efficient posttraining quantization of pre-trained language models. Advances in Neural Information Processing Systems, 35:1405–1418, 2022.
|
| 249 |
+
Roy Bar-Haim, Ido Dagan, Bill Dolan, Lisa Ferro, Danilo Giampiccolo, Bernardo Magnini, and Idan Szpektor. The second pascal recognising textual entailment challenge. 2006.
|
| 250 |
+
Luisa Bentivogli, Peter Clark, Ido Dagan, and Danilo Giampiccolo. The fifth pascal recognizing textual entailment challenge. In TAC, 2009.
|
| 251 |
+
Daniel Cer, Mona Diab, Eneko Agirre, Inigo Lopez-Gazpio, and Lucia Specia. SemEval-2017 task ˜ 1: Semantic textual similarity multilingual and crosslingual focused evaluation. In Proceedings of the 11th International Workshop on Semantic Evaluation (SemEval-2017), pp. 1–14, Vancouver, Canada, August 2017. Association for Computational Linguistics. doi: 10.18653/v1/S17-2001.
|
| 252 |
+
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.
|
| 253 |
+
Ido Dagan, Oren Glickman, and Bernardo Magnini. The pascal recognising textual entailment challenge. In Machine Learning Challenges Workshop, 2007.
|
| 254 |
+
Tim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer. Llm. int8 (): 8-bit matrix multiplication for transformers at scale. arXiv preprint arXiv:2208.07339, 2022.
|
| 255 |
+
Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, and Luke Zettlemoyer. Qlora: Efficient finetuning of quantized llms. arXiv preprint arXiv:2305.14314, 2023.
|
| 256 |
+
Shizhe Diao, Rui Pan, Hanze Dong, Ka Shun Shum, Jipeng Zhang, Wei Xiong, and Tong Zhang. Lmflow: An extensible toolkit for finetuning and inference of large foundation models. arXiv preprint arXiv:2306.12420, 2023.
|
| 257 |
+
William B. Dolan and Chris Brockett. Automatically constructing a corpus of sentential paraphrases. In Proceedings of the Third International Workshop on Paraphrasing (IWP2005), 2005.
|
| 258 |
+
Elias Frantar, Saleh Ashkboos, Torsten Hoefler, and Dan Alistarh. Gptq: Accurate post-training quantization for generative pre-trained transformers. arXiv preprint arXiv:2210.17323, 2022.
|
| 259 |
+
Danilo Giampiccolo, Bernardo Magnini, Ido Dagan, and Bill Dolan. The third PASCAL recognizing textual entailment challenge. In Proceedings of the ACL-PASCAL Workshop on Textual Entailment and Paraphrasing, pp. 1–9, Prague, June 2007. Association for Computational Linguistics.
|
| 260 |
+
Junxian He, Chunting Zhou, Xuezhe Ma, Taylor Berg-Kirkpatrick, and Graham Neubig. Towards a unified view of parameter-efficient transfer learning. arXiv preprint arXiv:2110.04366, 2021a.
|
| 261 |
+
Pengcheng He, Jianfeng Gao, and Weizhu Chen. Debertav3: Improving deberta using electra-style pre-training with gradient-disentangled embedding sharing. arXiv preprint arXiv:2111.09543, 2021b.
|
| 262 |
+
Karl Moritz Hermann, Tomas Kocisky, Edward Grefenstette, Lasse Espeholt, Will Kay, Mustafa Suleyman, and Phil Blunsom. Teaching machines to read and comprehend. Advances in neural information processing systems, 28, 2015.
|
| 263 |
+
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. arXiv preprint arXiv:2106.09685, 2021.
|
| 264 |
+
Hector Levesque, Ernest Davis, and Leora Morgenstern. The winograd schema challenge. In Thirteenth international conference on the principles of knowledge representation and reasoning, 2012.
|
| 265 |
+
|
| 266 |
+
Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Ves Stoyanov, and Luke Zettlemoyer. Bart: Denoising sequence-to-sequence pretraining for natural language generation, translation, and comprehension. arXiv preprint arXiv:1910.13461, 2019.
|
| 267 |
+
|
| 268 |
+
Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Veselin Stoyanov, and Luke Zettlemoyer. BART: Denoising sequence-to-sequence pretraining for natural language generation, translation, and comprehension. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 7871–7880, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.703.
|
| 269 |
+
Yixiao Li, Yifan Yu, Qingru Zhang, Chen Liang, Pengcheng He, Weizhu Chen, and Tuo Zhao. Losparse: Structured compression of large language models based on low-rank and sparse approximation. arXiv preprint arXiv:2306.11222, 2023.
|
| 270 |
+
Chin-Yew Lin. ROUGE: A package for automatic evaluation of summaries. In Text Summarization Branches Out, pp. 74–81, Barcelona, Spain, July 2004. Association for Computational Linguistics.
|
| 271 |
+
Zechun Liu, Barlas Oguz, Changsheng Zhao, Ernie Chang, Pierre Stock, Yashar Mehdad, Yangyang Shi, Raghuraman Krishnamoorthi, and Vikas Chandra. Llm-qat: Data-free quantization aware training for large language models. arXiv preprint arXiv:2305.17888, 2023.
|
| 272 |
+
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
|
| 273 |
+
Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models, 2016.
|
| 274 |
+
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, abs/1808.08745, 2018.
|
| 275 |
+
Yixin Nie, Adina Williams, Emily Dinan, Mohit Bansal, Jason Weston, and Douwe Kiela. Adversarial nli: A new benchmark for natural language understanding. ArXiv, abs/1910.14599, 2019. URL https://api.semanticscholar.org/CorpusID:207756753.
|
| 276 |
+
Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, high-performance deep learning library. In Advances in Neural Information Processing Systems 32, pp. 8024–8035. Curran Associates, Inc., 2019.
|
| 277 |
+
Dheeraj Peri, Jhalak Patel, and Josh Park. Deploying quantization-aware trained networks using tensorrt. In GPU Technology Conference, 2020.
|
| 278 |
+
Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: $1 0 0 { , } 0 0 0 { + }$ questions for machine comprehension of text. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pp. 2383–2392, Austin, Texas, November 2016. Association for Computational Linguistics. doi: 10.18653/v1/D16-1264.
|
| 279 |
+
Sheng Shen, Zhen Dong, Jiayu Ye, Linjian Ma, Zhewei Yao, Amir Gholami, Michael W Mahoney, and Kurt Keutzer. Q-bert: Hessian based ultra low precision quantization of bert. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 8815–8821, 2020.
|
| 280 |
+
Richard Socher, Alex Perelygin, Jean Wu, Jason Chuang, Christopher D. Manning, Andrew $\mathrm { N g }$ , and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, pp. 1631–1642, Seattle, Washington, USA, October 2013. Association for Computational Linguistics.
|
| 281 |
+
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.
|
| 282 |
+
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.
|
| 283 |
+
Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In International Conference on Learning Representations, 2019.
|
| 284 |
+
Alex Warstadt, Amanpreet Singh, and Samuel R. Bowman. Neural network acceptability judgments. Transactions of the Association for Computational Linguistics, 7:625–641, 2019. doi: 10.1162/ tacl a 00290.
|
| 285 |
+
Adina Williams, Nikita Nangia, and Samuel Bowman. A broad-coverage challenge corpus for sentence understanding through inference. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 1112–1122, New Orleans, Louisiana, June 2018. Association for Computational Linguistics. doi: 10.18653/v1/N18-1101.
|
| 286 |
+
Guangxuan Xiao, Ji Lin, Mickael Seznec, Hao Wu, Julien Demouth, and Song Han. Smoothquant: Accurate and efficient post-training quantization for large language models. In International Conference on Machine Learning, pp. 38087–38099. PMLR, 2023.
|
| 287 |
+
Ofir Zafrir, Guy Boudoukh, Peter Izsak, and Moshe Wasserblat. Q8bert: Quantized 8bit bert. In 2019 Fifth Workshop on Energy Efficient Machine Learning and Cognitive Computing-NeurIPS Edition (EMC2-NIPS), pp. 36–39. IEEE, 2019.
|
| 288 |
+
Hongyi Zhang, Yann N Dauphin, and Tengyu Ma. Fixup initialization: Residual learning without normalization. arXiv preprint arXiv:1901.09321, 2019.
|
| 289 |
+
Qingru Zhang, Minshuo Chen, Alexander Bukharin, Pengcheng He, Yu Cheng, Weizhu Chen, and Tuo Zhao. Adaptive budget allocation for parameter-efficient fine-tuning. arXiv preprint arXiv:2303.10512, 2023.
|
| 290 |
+
|
| 291 |
+
# A MODEL COMPRESSION RATIO AND MEMORY FOOTPRINT
|
| 292 |
+
|
| 293 |
+
We report the compression ratio after applying LoftQ in Table 7. It is defined as backbone size + LoRA adapter size compression ration $=$ pre-trained size
|
| 294 |
+
|
| 295 |
+
We also measure the GPU memory cost during training. Given that GPU memory varies by models, tasks, sequence lengths, batch sizes, etc. We report LLAMA-2 on GSM8K as an example in Table 8.
|
| 296 |
+
|
| 297 |
+
Table 7: Compression ratios of backbones.
|
| 298 |
+
|
| 299 |
+
<table><tr><td>Model</td><td>Compression ratio (%)</td><td>Trainable ratio (%)</td><td>Rank</td><td>Bits</td><td>Quantization method</td></tr><tr><td>DeBERTaV3-base</td><td>15.6</td><td>3.1</td><td>16</td><td></td><td>Uniform</td></tr><tr><td>DeBERTaV3-base</td><td>18.8</td><td>6.3</td><td>32</td><td></td><td>Uniform</td></tr><tr><td>DeBERTaV3-base</td><td>17.2</td><td>3.1</td><td>16</td><td>222</td><td>NF2</td></tr><tr><td>DeBERTaV3-base</td><td>20.4</td><td>6.3</td><td>32</td><td>2</td><td>NF2</td></tr><tr><td>BART-large</td><td>15.3</td><td>1.2</td><td>8</td><td>4</td><td>NF2</td></tr><tr><td>BART-large</td><td>16.7</td><td>2.5</td><td>16</td><td>4</td><td>NF2</td></tr><tr><td>BART-large</td><td>27.8</td><td>1.2</td><td>8</td><td>4</td><td>NF4</td></tr><tr><td>BART-large</td><td>29.0</td><td>2.5</td><td>16</td><td>4</td><td>NF4</td></tr><tr><td>BART-large</td><td>26.2</td><td>1.2</td><td>8</td><td>4</td><td>Uniform</td></tr><tr><td>BART-large</td><td>27.5</td><td>2.5</td><td>16</td><td>4</td><td>Uniform</td></tr><tr><td>LLAMA-2-7b</td><td>16.6</td><td>2.4</td><td>64</td><td>2</td><td>Nf2</td></tr><tr><td>LLAMA-2-7b</td><td>29.0</td><td>2.4</td><td>64</td><td>4</td><td>Nf4</td></tr><tr><td>LLAMA-2-13b</td><td>16.0</td><td>1.9</td><td>64</td><td>2</td><td>Nf2</td></tr><tr><td>LLAMA-2-13b</td><td>28.5</td><td>1.9</td><td>64</td><td>4</td><td>Nf4</td></tr></table>
|
| 300 |
+
|
| 301 |
+
Table 8: GPU memory footprint
|
| 302 |
+
|
| 303 |
+
<table><tr><td>Model</td><td>Dataset</td><td> Seq length</td><td>Batch size</td><td>GPU Mem</td></tr><tr><td>LLAMA-2-7b</td><td>GSM8K</td><td>384</td><td>1</td><td>15GB</td></tr><tr><td>LLAMA-2-13b</td><td>GSM8K</td><td>384</td><td>1</td><td>24GB</td></tr></table>
|
| 304 |
+
|
| 305 |
+
# B QUANTIZATION TIME
|
| 306 |
+
|
| 307 |
+
We report the execution time of LoftQ applying to a single weight matrix in Table 9. The time is tested on Intel(R) Xeon(R) CPU E5-2650 v4 $\textcircled { a } 2 . 2 0 \mathrm { G H z }$ .
|
| 308 |
+
|
| 309 |
+
Table 9: Execution time of LoftQ applying to different weight matrices.
|
| 310 |
+
|
| 311 |
+
<table><tr><td>Model</td><td>Size</td><td>Step T</td><td>Quantization method</td><td>Time</td></tr><tr><td>DeBERTaV3-base</td><td>768×768</td><td>5</td><td>Uniform</td><td>1s</td></tr><tr><td>BART-large</td><td>1024×1024</td><td>5</td><td>NF4</td><td>1s</td></tr><tr><td>LLAMA-2-7b</td><td>4096 × 4096</td><td>5</td><td>NF4</td><td>21s</td></tr><tr><td>LLAMA-2-13b</td><td>5120 × 5120</td><td>5</td><td>NF4</td><td>43s</td></tr></table>
|
| 312 |
+
|
| 313 |
+
# C GLUE DATASET STATISTICS
|
| 314 |
+
|
| 315 |
+
We present the dataset statistics of GLUE Wang et al. (2019) in the following table.
|
| 316 |
+
|
| 317 |
+
GLUE includes two single-sentence classification tasks: SST-2 (Socher et al., 2013) and CoLA (Warstadt et al., 2019), and three similarity and paraphrase tasks: MRPC (Dolan & Brockett, 2005), STS-B (Cer et al., 2017), and QQP. GLUE also includes four natural language inference tasks in GLUE: MNLI (Williams et al., 2018), QNLI (Rajpurkar et al., 2016), RTE (Dagan et al., 2007; BarHaim et al., 2006; Giampiccolo et al., 2007; Bentivogli et al., 2009), and WNLI (Levesque et al., 2012).
|
| 318 |
+
|
| 319 |
+
Table 10: Summary of the GLUE benchmark.
|
| 320 |
+
|
| 321 |
+
<table><tr><td>Corpus</td><td>Task</td><td>#Train</td><td>#Dev</td><td>#Test</td><td>#Label</td><td>Metrics</td></tr><tr><td colspan="7">Single-Sentence Classification (GLUE)</td></tr><tr><td>CoLA</td><td> Acceptability</td><td>8.5k</td><td>1k</td><td>1k</td><td>2</td><td>Matthews corr</td></tr><tr><td>SST</td><td>Sentiment</td><td>67k</td><td>872</td><td>1.8k</td><td>2</td><td>Accuracy</td></tr><tr><td colspan="7">Pairwise Text Classification (GLUE)</td></tr><tr><td>MNLI</td><td>NLI</td><td>393k</td><td>20k</td><td>20k</td><td>3</td><td>Accuracy</td></tr><tr><td>RTE</td><td>NLI</td><td>2.5k</td><td>276</td><td>3k</td><td>2</td><td>Accuracy</td></tr><tr><td>QQP</td><td>Paraphrase</td><td>364k</td><td>40k</td><td>391k</td><td>2</td><td>Accuracy/F1</td></tr><tr><td>MRPC</td><td>Paraphrase</td><td>3.7k</td><td>408</td><td>1.7k</td><td>2</td><td>Accuracy/F1</td></tr><tr><td>QNLI</td><td>QA/NLI</td><td>108k</td><td>5.7k</td><td>5.7k</td><td>2</td><td>Accuracy</td></tr><tr><td colspan="7">Text Similarity (GLUE)</td></tr><tr><td>STS-B</td><td>Similarity</td><td>7k</td><td>1.5k</td><td>1.4k</td><td>1</td><td>Pearson/Spearman corr</td></tr></table>
|
| 322 |
+
|
| 323 |
+
# D NATURAL LANGUAGE UNDERSTANDING
|
| 324 |
+
|
| 325 |
+
# D.1 GLUE WITH 4-BIT
|
| 326 |
+
|
| 327 |
+
We show the 4-bits results in the Table 11. Both methods can achieve performance close to fullfinetuning.
|
| 328 |
+
|
| 329 |
+
Table 11: Results with 4-bit LoftQ of DeBERTaV3-base models on GLUE development set using NF4 quantization. We report the median over four seeds. Results with N.A. indicate the model does not converge. The best results on each dataset are shown in bold
|
| 330 |
+
|
| 331 |
+
<table><tr><td>Method</td><td>Rank</td><td>MNLI m /mm</td><td>SST-2 Acc</td><td>QNLI Acc</td><td>ANLI Acc</td></tr><tr><td>Full FT</td><td>-</td><td>90.5/90.6</td><td>95.3</td><td>94.0</td><td>59.8</td></tr><tr><td>QLoRA</td><td>32</td><td>89.9/89.9</td><td>95.3</td><td>94.2</td><td>59.4</td></tr><tr><td>LoftQ</td><td>32</td><td>89.9/90.0</td><td>95.3</td><td>94.1</td><td>59.9</td></tr></table>
|
| 332 |
+
|
| 333 |
+
# D.2 TRAINING DETAILS
|
| 334 |
+
|
| 335 |
+
Implementation Details. The implementation of LoftQ is based on publicly available Huggingface (Paszke et al., 2019) code-base 3.
|
| 336 |
+
|
| 337 |
+
Hyper-parameter Details. We select the learning rate of $\{ 1 \times 1 0 ^ { - 5 } , 5 \times 1 0 ^ { - 5 } , 1 \times 1 0 ^ { - 4 } , 5 \times 1 0 ^ { - 4 } \}$ , and use the selected learning rate for both uniform quantization experiments and nf2 quantization experiments. We use batch size of 32 for all GLUE tasks and ANLI. We use batch size of 16 for SQuADv1.1. We use LoftQ of 5 iterations for all GLUE tasks.
|
| 338 |
+
|
| 339 |
+
Table 12 summarizes the detailed hyperparameters for each task used in training DeBERTaV3-base using uniform quantization. Table 13 summarizes the detailed hyperparameters for each task used in training DeBERTaV3-base using nf2 quantization.
|
| 340 |
+
|
| 341 |
+
Table 12: Hyper-parameter setup of LoftQ for GLUE benchmark for training DeBERTaV3-base using Uniform quantization.
|
| 342 |
+
|
| 343 |
+
<table><tr><td>Hyper-parameter</td><td>MNLI</td><td>RTE</td><td>QNLI</td><td>MRPC</td><td>QQP</td><td>SST-2</td><td>CoLA</td><td>STS-B</td><td>SQuADv1.1</td><td>ANLI</td></tr><tr><td># epochs</td><td>5</td><td>20</td><td>10</td><td>60</td><td>10</td><td>10</td><td>60</td><td>60</td><td>10</td><td>12</td></tr><tr><td>Learning rate</td><td>1 ×10-4</td><td>5×10-4</td><td>5×10-5</td><td>1×10-4</td><td>5×10-5</td><td>5×10-5</td><td>5×10-5</td><td>5×10-5</td><td>5×10-5</td><td>5×10-5</td></tr></table>
|
| 344 |
+
|
| 345 |
+
3https://github.com/huggingface/transformers/tree/main/examples/pytorch
|
| 346 |
+
|
| 347 |
+
Table 13: Hyper-parameter setup of LoftQ for GLUE benchmark for training DeBERTaV3-base using NF2 quantization.
|
| 348 |
+
|
| 349 |
+
<table><tr><td>Hyper-parameter</td><td>MNLI</td><td>RTE</td><td>QNLI</td><td>MRPC</td><td>QQP</td><td>SST-2</td><td>CoLA</td><td>STS-B</td><td>SQuADv1.1</td><td>ANLI</td></tr><tr><td># epochs</td><td>5</td><td>20</td><td>10</td><td>60</td><td>10</td><td>10</td><td>60</td><td>60</td><td>10</td><td>12</td></tr><tr><td>Learning rate</td><td>1 ×10-4</td><td>5×10-5</td><td>5×10-5</td><td>1 ×10-4</td><td>5×10-5</td><td>5×10-5</td><td>5×10-5</td><td>1×10-4</td><td>5×10-5</td><td>5×10-5</td></tr></table>
|
| 350 |
+
|
| 351 |
+
# E SUMMARIZATION
|
| 352 |
+
|
| 353 |
+
# E.1 TRAINING DETAILS
|
| 354 |
+
|
| 355 |
+
We choose Adam as the optimizer and try learning rate from $\{ 1 \times 1 0 ^ { - 5 } , 5 \times 1 0 ^ { - 5 } , 7 \times 1 0 ^ { - 5 } , 2 \times$ $1 0 ^ { - 4 } , 3 \times 1 0 ^ { - 4 } , 4 \times 1 0 ^ { - 4 } \dot \}$ . We show the optimal learning rate for different settings in Table 14. We use LoftQ of 1 iteration for all BART-large experiments. Table 14 and Table 15 summarize the learning rate and other hyper-parameters for CNN/DailyMail and XSum.
|
| 356 |
+
|
| 357 |
+
Table 14: Hyper-parameter setup of LoftQ BART-large on CNN/DailyMail
|
| 358 |
+
|
| 359 |
+
<table><tr><td rowspan="2">Hyperparameter</td><td colspan="2">NF4</td><td colspan="2"> 4-bit Uniform</td><td colspan="2">NF2</td></tr><tr><td>rank8</td><td>rank16</td><td>rank8</td><td>rank16</td><td>rank8</td><td>rank16</td></tr><tr><td>Learning rate</td><td>2e-4</td><td>2e-4</td><td>2e-4</td><td>3e-4</td><td>2e-4</td><td>2e-4</td></tr><tr><td>Epoch</td><td>15</td><td>15</td><td>15</td><td>15</td><td>15</td><td>15</td></tr><tr><td>Batch size</td><td>64</td><td>64</td><td>64</td><td>64</td><td>64</td><td>64</td></tr></table>
|
| 360 |
+
|
| 361 |
+
Table 15: Hyper-parameter setup of LoftQ BART-large on XSum
|
| 362 |
+
|
| 363 |
+
<table><tr><td rowspan="2">Hyperparameter</td><td colspan="2">NF4</td><td colspan="2"> 4-bit Uniform</td><td colspan="2">NF2</td></tr><tr><td>rank8</td><td>rank16</td><td>rank8</td><td>rank16</td><td>rank8</td><td>rank16</td></tr><tr><td>Learning rate</td><td>2e-4</td><td>2e-4</td><td>2e-4</td><td>2e-4</td><td>2e-4</td><td>2e-4</td></tr><tr><td>Epoch</td><td>25</td><td>25</td><td>25</td><td>25</td><td>25</td><td>25</td></tr><tr><td>Batch size</td><td>32</td><td>32</td><td>32</td><td>32</td><td>32</td><td>32</td></tr></table>
|
| 364 |
+
|
| 365 |
+
# F NATURAL LANGUAGE GENERATION
|
| 366 |
+
|
| 367 |
+
We set the batch size as 32 for WikiText-2 and 16 for GSM8K. We train 2 epochs on WikiText-2 and 6 epochs on GSM8K. We select learning rate from $\{ 1 \times 1 0 ^ { - 5 } , 5 \times 1 0 ^ { - 5 } , \bar { 7 } \times 1 0 ^ { - 5 } , 1 \times 1 0 ^ { - 4 } , 3 \times$ $1 0 ^ { - 4 } , 4 \times 1 0 ^ { - 4 } \}$ . Specific settings are summarized in Table 16 and Table 17.
|
| 368 |
+
|
| 369 |
+
# G COMPARISON TO PRUNING
|
| 370 |
+
|
| 371 |
+
Pruning is also a widely used compression method. Here we compare LoftQ with the state-of-theart pruning method Li et al. (2023). We show the comparison in Table 18. We can see our method significantly outperforms the pruning methods on DeBERTaV3-base model. We also remark that LoftQ can consistently reduce the memory of both training and storage. In contrast, pruning requires training the entire full-precision matrix, which implies that it can not achieve any memory savings during the training stage.
|
| 372 |
+
|
| 373 |
+
# H EXTENSION TO CONVOLUTIONAL LAYERS
|
| 374 |
+
|
| 375 |
+
Low-rank adapters can also be applied to convolutional layers. Given an input feature map $X ~ \in ~ \mathbb { R } ^ { h \times w \times \dot { c } _ { 1 } }$ and $c _ { 2 }$ 2D convolutional kernels $K _ { i } \in \mathbb { R } ^ { c _ { 1 } \times d \times d } , i \mathrm { ~ = ~ } 1 , 2 , . . . , \dot { c } _ { 2 }$ , the output of the convolutional layer is
|
| 376 |
+
|
| 377 |
+
$$
|
| 378 |
+
Y = { \mathrm { s t a c k } } ( X \otimes K _ { 1 } , . . . , X \otimes K _ { c _ { 2 } } ) ,
|
| 379 |
+
$$
|
| 380 |
+
|
| 381 |
+
where $Y \in \mathbb { R } ^ { h \times w \times c _ { 2 } }$ and $\otimes$ denotes the 2D convolution operation.
|
| 382 |
+
|
| 383 |
+
Table 16: Hyper-parameter setup of LoftQ LLAMA-2-series on GSM8K
|
| 384 |
+
|
| 385 |
+
<table><tr><td>Model</td><td>Hyperparameter</td><td>NF4</td><td>NF2</td><td>Mixed-precision</td></tr><tr><td>LLAMA-2-7b</td><td> learning rate</td><td>3×10-4</td><td>3×10-4</td><td>3×10-4</td></tr><tr><td>LLAMA-2-13b</td><td>learning rate</td><td>1×10-4</td><td>1×10-4</td><td>3×10-4</td></tr></table>
|
| 386 |
+
|
| 387 |
+
Table 17: Hyper-parameter setup of LoftQ LLAMA-2-series on WikiText-2
|
| 388 |
+
|
| 389 |
+
<table><tr><td>Model</td><td> Hyperparameter</td><td>NF4</td><td>NF2</td><td>Mixed-precision</td></tr><tr><td>LLAMA-2-7b</td><td> learning rate</td><td>3×10-4</td><td>3×10-4</td><td>3×10-4</td></tr><tr><td>LLAMA-2-13b</td><td> learning rate</td><td>1×10-4</td><td>1×10-4</td><td>3×10-4</td></tr></table>
|
| 390 |
+
|
| 391 |
+
Table 18: Results of LoftQ using 2-bits uniform quantization compared with LoSparse with DeBERTaV3-base models on some of GLUE development sets. Here Ratio is the proportion of total remaining weights. Results with N.A. indicate the model does not converge.
|
| 392 |
+
|
| 393 |
+
<table><tr><td>Method</td><td>Ratio</td><td>MNLI m/mm</td><td>SST-2 Acc</td><td>QNLI Acc</td></tr><tr><td>Full FT</td><td>100%</td><td>90.5 /90.6</td><td>95.3</td><td>94.0</td></tr><tr><td>LoSparse</td><td>15%</td><td>84.3/82.9</td><td>87.6</td><td>904</td></tr><tr><td>LoftQ</td><td>15.%</td><td>87.3/87.1</td><td>940</td><td>94</td></tr></table>
|
| 394 |
+
|
| 395 |
+
We can reformulate Equation (10) into matrix multiplication as
|
| 396 |
+
|
| 397 |
+
$$
|
| 398 |
+
\boldsymbol { Y } = \boldsymbol { Z } \times \boldsymbol { H } ^ { \intercal } ,
|
| 399 |
+
$$
|
| 400 |
+
|
| 401 |
+
where $Z \in \mathbb { R } ^ { h w \times c _ { 1 } d ^ { 2 } } , H \in \mathbb { R } ^ { c _ { 2 } \times c _ { 1 } d ^ { 2 } }$ , by extending and flattening the input $X$ together with concatenating and flattening kernels. We first extend a vector $x _ { i , j } \in \mathbb { R } ^ { c _ { 1 } }$ by its neighbor vectors within the kernel window:
|
| 402 |
+
|
| 403 |
+
$$
|
| 404 |
+
\begin{array} { r } { x _ { i , j } ^ { ' } = \mathrm { C o n c a t } ( \mathrm { x _ { i - \frac { d } { 2 } , j - \frac { d } { 2 } } } , . . . , \mathrm { x _ { i + \frac { d } { 2 } , j + \frac { d } { 2 } } } ) . } \end{array}
|
| 405 |
+
$$
|
| 406 |
+
|
| 407 |
+
Now, $X$ becomes $X ^ { \prime } \in \mathbb { R } ^ { h \times w \times c _ { 1 } d ^ { 2 } }$ . We then flatten $X ^ { \prime }$ into $Z \in \mathbb { R } ^ { h w \times c _ { 1 } d ^ { 2 } }$ . For kernels, we first concatenate $\{ K _ { 1 } , . . . , K _ { c _ { 2 } } \}$ into $H ^ { \prime } \in \mathbb { R } ^ { c _ { 2 } \times c _ { 1 } \times d \times d }$ . We then flatten $H ^ { \prime }$ into $H$ .
|
| 408 |
+
|
| 409 |
+
Note that $H$ can be approximated by a low-rank matrix
|
| 410 |
+
|
| 411 |
+
$$
|
| 412 |
+
R = U V ^ { \top } ,
|
| 413 |
+
$$
|
| 414 |
+
|
| 415 |
+
where $U \in \mathbb { R } ^ { c _ { 2 } \times r } , V \in \mathbb { R } ^ { c _ { 1 } d ^ { 2 } \times r } , r \ll \operatorname* { m i n } \{ c _ { 2 } , c _ { 1 } d ^ { 2 } \}$ by SVD. Therefore, the original convolution layer can be approximated as
|
| 416 |
+
|
| 417 |
+
$$
|
| 418 |
+
\begin{array} { r l } & { \widehat { \boldsymbol { Y } } = \boldsymbol { Z } \times ( \boldsymbol { U } \boldsymbol { V } ^ { \intercal } ) ^ { \intercal } } \\ & { \quad = ( \boldsymbol { Z } \times \boldsymbol { V } ) \times \boldsymbol { U } ^ { \intercal } } \\ & { \quad = \boldsymbol { M } \times \boldsymbol { U } ^ { \intercal } . } \end{array}
|
| 419 |
+
$$
|
| 420 |
+
|
| 421 |
+
Note that $Z \times V$ can be restored into a convolution operation where we have $r$ kernels $D _ { i } \in$ $\mathbb { R } ^ { c _ { 1 } \times d \times d } , i = 1 , 2 , . . . , r$ and $M \times U ^ { \top }$ can also be restored into a convolution operation where we have $c _ { 2 }$ kernels $U _ { i } \in \mathbb { R } ^ { r \times 1 \times 1 } , i = 1 , 2 , , . . . , c _ { 2 }$ .
|
parse/test/LzPWWPAdY4/LzPWWPAdY4_content_list.json
ADDED
|
@@ -0,0 +1,943 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"type": "text",
|
| 4 |
+
"text": "LOFTQ: LORA-FINE-TUNING-AWARE QUANTIZA-TION FOR LARGE LANGUAGE MODELS",
|
| 5 |
+
"text_level": 1,
|
| 6 |
+
"page_idx": 0
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"type": "text",
|
| 10 |
+
"text": "Yixiao Li1 ∗ Yifan Yu1 ∗ Chen Liang1 ",
|
| 11 |
+
"page_idx": 0
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"type": "text",
|
| 15 |
+
"text": "Pengcheng He2 ",
|
| 16 |
+
"page_idx": 0
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"type": "text",
|
| 20 |
+
"text": "Nikos Karampatziakis2 ",
|
| 21 |
+
"page_idx": 0
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"type": "text",
|
| 25 |
+
"text": "Weizhu Chen2 ",
|
| 26 |
+
"page_idx": 0
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"type": "text",
|
| 30 |
+
"text": "Tuo Zhao1 ",
|
| 31 |
+
"page_idx": 0
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"type": "text",
|
| 35 |
+
"text": "ABSTRACT ",
|
| 36 |
+
"text_level": 1,
|
| 37 |
+
"page_idx": 0
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"type": "text",
|
| 41 |
+
"text": "Quantization is an indispensable technique for serving Large Language Models (LLMs) and has recently found its way into LoRA fine-tuning (Dettmers et al., 2023). In this work we focus on the scenario where quantization and LoRA finetuning are applied together on a pre-trained model. In such cases it is common to observe a consistent gap in the performance on downstream tasks between full fine-tuning and quantization plus LoRA fine-tuning approach. In response, we propose LoftQ (LoRA-Fine-Tuning-aware Quantization), a novel quantization framework that simultaneously quantizes an LLM and finds a proper lowrank initialization for LoRA fine-tuning. Such an initialization alleviates the discrepancy between the quantized and full-precision model and significantly improves generalization in downstream tasks. We evaluate our method on natural language understanding, question answering, summarization, and natural language generation tasks. Experiments show that our method is highly effective and outperforms existing quantization methods, especially in the challenging 2-bit and 2/4-bit mixed precision regimes. The code is available on https://github.com/yxli2123/LoftQ.1 2 ",
|
| 42 |
+
"page_idx": 0
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"type": "text",
|
| 46 |
+
"text": "1 INTRODUCTION ",
|
| 47 |
+
"text_level": 1,
|
| 48 |
+
"page_idx": 0
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"type": "text",
|
| 52 |
+
"text": "The advent of Pre-trained Language Models (PLMs) has marked a transformative shift in the field of Natural Language Processing (NLP), offering versatile solutions across various applications (He et al., 2021b; Lewis et al., 2019; Touvron et al., 2023). They have showcased unparalleled proficiency in executing a variety of language tasks, including Natural Language Understanding (NLU) and Natural Language Generation (NLG). These models typically have millions or even billions of parameters, necessitating substantial computational and memory requirements. However, the extensive computational and memory demands of these models pose significant challenges, especially for deployments where resources are often constrained and need to be shared among many users. ",
|
| 53 |
+
"page_idx": 0
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"type": "text",
|
| 57 |
+
"text": "To mitigate the extensive storage requirements of pre-trained models, quantization serves as a pivotal compression technique (Zafrir et al., 2019; Shen et al., 2020; Bai et al., 2022; Dettmers et al., 2022), converting high-precision numerical values into a discrete set of values. Typically, model parameters, originally stored in a 16-bit float format, are transformed into a 4-bit integer format through quantization, resulting in a substantial $7 5 \\%$ reduction in storage overhead. Additionally, to facilitate the adaptation of quantized pre-trained models to downstream tasks efficiently, Low-Rank Adaptation (LoRA) is a viable approach (Hu et al., 2021). This technique is a parameter-efficient fine-tuning method traditionally applied to high-precision pre-trained models. It is based on the hypothesis that the differences between fully fine-tuned weights and pre-trained weights exhibit low-rank properties. This allows these differences to be represented using low-rank matrices. As a result, the original pre-trained weights remain unaltered, with adaptations confined solely to these low-rank matrices, enabling effective task adaptation. ",
|
| 58 |
+
"page_idx": 0
|
| 59 |
+
},
|
| 60 |
+
{
|
| 61 |
+
"type": "text",
|
| 62 |
+
"text": "When quantizing pre-trained models, practitioners often concentrate primarily on the quantization technique, inadvertently neglecting the importance of subsequent LoRA fine-tuning (Dettmers et al., 2023; Diao et al., 2023). For example, QLoRA inherits the fixup initialization (Zhang et al., 2019) used in LoRA, which (Dettmers et al., 2023) attaches zero initialized low-rank adapters (see Section 2.3) to the quantized pre-trained model. The inevitable discrepancy introduced by quantization during the approximation of the original high-precision numbers, a scenario particularly pronounced in low-bit situations such as the 2-bit regime, can adversely impact the initialization of LoRA finetuning. As illustrated in Figure 1a, the quantized pre-trained model obtained by QLoRA exhibits severe degradation below the 3-bit level. This deviation in initialization often results in an inferior fine-tuning performance. As illustrated in Figure 1b, the fine-tuning performance drops as the quantization bit decreases when applying QLoRA. Moreover, it is noteworthy that QLoRA fails below the 3-bit level. ",
|
| 63 |
+
"page_idx": 1
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"type": "text",
|
| 67 |
+
"text": "In this paper, we introduce a novel quantization framework, called LoRA-Fine-Tuning-aware Quantization (LoftQ). It is designed specifically for pre-trained models that require quantization and LoRA fine-tuning. This framework actively integrates low-rank approximation, working in tandem with quantization to jointly approximate the original high-precision pre-trained weights. This synergy significantly enhances alignment with the original pre-trained weights as illustrated in Figure 2. Consequently, our method provides an advantageous initialization point for subsequent LoRA fine-tuning, leading to improvements in downstream tasks. ",
|
| 68 |
+
"page_idx": 1
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"type": "image",
|
| 72 |
+
"img_path": "images/4588ba2d881aa7db51f5374d09d02b6d2fa419344a2fa2f3b3172084de1fc2c4.jpg",
|
| 73 |
+
"image_caption": [
|
| 74 |
+
"Figure 1: QLoRA performance with different bits. Left: QLoRA initialization of LLAMA-2-13b on WikiText-2. Right: Apply QLoRA to LLAMA-2-13b on WikiText-2 language modeling task. Smaller perplexity indicates better performance. "
|
| 75 |
+
],
|
| 76 |
+
"image_footnote": [],
|
| 77 |
+
"page_idx": 1
|
| 78 |
+
},
|
| 79 |
+
{
|
| 80 |
+
"type": "text",
|
| 81 |
+
"text": "We evaluate our quantization framework by conducting extensive experiments on downstream tasks, such as NLU, question answering, summarization, and NLG. Experiments show that LoftQ consistently outperforms QLoRA across all precision levels. For instance, with 4-bit quantization, we achieve a 1.1 and 0.8 gain in Rouge-1 for XSum (Narayan et al., 2018) and CNN/DailyMail (Hermann et al., 2015), respectively. LoftQ excels particularly in low-bit scenarios and works effectively with different quantization methods. For example, we achieve over an $8 \\%$ gain on MNLI (Wang et al., 2019) and more than $10 \\%$ on SQuADv1.1 (Rajpurkar et al., 2016) with both 2-bit NormalFloat and the 2-bit uniform quantization. We have not seen our approach performs worse than QLoRA. ",
|
| 82 |
+
"page_idx": 1
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"type": "text",
|
| 86 |
+
"text": "2 BACKGROUND ",
|
| 87 |
+
"text_level": 1,
|
| 88 |
+
"page_idx": 1
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
"type": "text",
|
| 92 |
+
"text": "2.1 TRANSFORMER MODELS ",
|
| 93 |
+
"text_level": 1,
|
| 94 |
+
"page_idx": 1
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"type": "text",
|
| 98 |
+
"text": "A transformer model contains a sequence of layers, where each layer consists of two sub-layers: a multi-head self-attention (MHA) and a fully connected feed forward network (FFN) (Vaswani et al., 2017). Given the input $\\ b { X } \\in \\mathbb { R } ^ { n \\times d }$ , where $n$ is the sequence length and $d$ is the hidden dimension of the model, MHA computes the $h$ attention heads in parallel: ",
|
| 99 |
+
"page_idx": 1
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"type": "equation",
|
| 103 |
+
"img_path": "images/20a8be747125a38b2c059d0bdd31082489c69d90572487301c04897ffb7ee947.jpg",
|
| 104 |
+
"text": "$$\n\\mathrm { M H A } ( X ) = \\mathrm { C o n c a t } ( \\mathrm { h e a d } _ { 1 } , . . . , \\mathrm { h e a d } _ { h } ) W _ { o } ,\n$$",
|
| 105 |
+
"text_format": "latex",
|
| 106 |
+
"page_idx": 1
|
| 107 |
+
},
|
| 108 |
+
{
|
| 109 |
+
"type": "equation",
|
| 110 |
+
"img_path": "images/c02434ea0606db37a51a08037bae9316ef8b7b7cb61b1ed80f77476f80b88476.jpg",
|
| 111 |
+
"text": "$$\n\\mathrm { h e a d } _ { i } = \\mathrm { S o f t m a x } ( X W _ { q _ { i } } ( X W _ { k _ { i } } ) ^ { \\top } / \\sqrt { d _ { h } } ) X W _ { v _ { i } } \\mathrm { f o r } i = 1 , . . . , h ,\n$$",
|
| 112 |
+
"text_format": "latex",
|
| 113 |
+
"page_idx": 1
|
| 114 |
+
},
|
| 115 |
+
{
|
| 116 |
+
"type": "text",
|
| 117 |
+
"text": "where $W _ { q _ { i } } , W _ { k _ { i } } , W _ { v _ { i } } \\in \\mathbb { R } ^ { d \\times d _ { h } }$ are query, key, and value matrices, $W _ { o } \\in \\mathbb { R } ^ { d \\times d }$ is the output matrix, and $d _ { h } = d / h$ . FFN comprises two linear transformations and an activation function, and is defined as $\\mathrm { F F N } ( X ) = \\sigma ( X W _ { f _ { 1 } } \\bar { + } b _ { 1 } ) W _ { f _ { 2 } } + b _ { 2 }$ , where $W _ { f _ { 1 } } \\in \\mathbb { R } ^ { d \\times d _ { m } }$ , $W _ { f _ { 2 } } \\in \\mathbb { R } ^ { d _ { m } \\times d }$ , and $\\sigma ( \\cdot )$ is the activation function. A residual connection is used and followed by layer normalization. ",
|
| 118 |
+
"page_idx": 1
|
| 119 |
+
},
|
| 120 |
+
{
|
| 121 |
+
"type": "image",
|
| 122 |
+
"img_path": "images/ae40567810a453a795738a00eb23155416fe86256fbd85388013e395584ed938.jpg",
|
| 123 |
+
"image_caption": [
|
| 124 |
+
"Figure 2: Initialization discrepancy between the LoRA initialization and the original pre-trained weight matrix, described by the spectral norm and Frobenius norm of the difference. The weight matrix in the above figures is randomly selected in BART-large. The initialization is obtained by QLoRA and LoftQ, with Uniform and NormalFloat quantization methods applied at both 2-bit and 4-bit levels. LoftQ successfully mitigates the discrepancy, especially at the 2-bit level. "
|
| 125 |
+
],
|
| 126 |
+
"image_footnote": [],
|
| 127 |
+
"page_idx": 2
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"type": "text",
|
| 131 |
+
"text": "2.2 QUANTIZATION ",
|
| 132 |
+
"text_level": 1,
|
| 133 |
+
"page_idx": 2
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"type": "text",
|
| 137 |
+
"text": "Quantization. Given a high-precision number, e.g., such as 32-bit floating point number, $X ^ { \\mathrm { H P } } \\in \\mathbb { R }$ , $N$ -bit quantization encodes it to an integer $X ^ { \\mathrm { I N T } } \\in \\{ 0 , 1 , . . . , 2 ^ { N } - 1 \\}$ . This process can be expressed as ",
|
| 138 |
+
"page_idx": 2
|
| 139 |
+
},
|
| 140 |
+
{
|
| 141 |
+
"type": "equation",
|
| 142 |
+
"img_path": "images/239c97f755f667d32ef803cfbe13b8827084b713d8eac4528968850aa694615c.jpg",
|
| 143 |
+
"text": "$$\nX ^ { \\mathrm { I N T } } = \\mathrm { r o u n d } \\left( ( 2 ^ { N } - 1 ) F \\left( X ^ { \\mathrm { H P } } \\right) \\right) ,\n$$",
|
| 144 |
+
"text_format": "latex",
|
| 145 |
+
"page_idx": 2
|
| 146 |
+
},
|
| 147 |
+
{
|
| 148 |
+
"type": "text",
|
| 149 |
+
"text": "where $F ( \\cdot ) \\colon \\mathbb { R } \\mapsto [ 0 , 1 ]$ is a normalization function. Uniform quantization assumes $F ( X ) = ( X -$ $X _ { \\mathrm { m i n } } ) / ( X _ { \\mathrm { m a x } } - X _ { \\mathrm { m i n } } )$ . Dettmers et al. (2023) proposes 4-bit NormalFloat Quantization (NF4). It assumes $X \\sim { \\mathcal { N } } ( 0 , \\sigma ^ { 2 } )$ and hence $F ( X ) = \\Phi ( X / \\sigma )$ , where $\\Phi ( \\cdot )$ is the cumulative distribution function of the standard normal distribution. ",
|
| 150 |
+
"page_idx": 2
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"type": "text",
|
| 154 |
+
"text": "Dequantization. A lookup table $\\tau$ , where ",
|
| 155 |
+
"page_idx": 2
|
| 156 |
+
},
|
| 157 |
+
{
|
| 158 |
+
"type": "equation",
|
| 159 |
+
"img_path": "images/1580dcc53e70f1143fc75bab1bfeb07154dac17994b3ea987b1f36d5398cad90.jpg",
|
| 160 |
+
"text": "$$\n\\mathcal { T } [ i ] = F ^ { - 1 } \\left( \\frac { i } { 2 ^ { N } - 1 } \\right) , i = 0 , 1 , . . . , 2 ^ { N } - 1 ,\n$$",
|
| 161 |
+
"text_format": "latex",
|
| 162 |
+
"page_idx": 2
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
"type": "text",
|
| 166 |
+
"text": "is used to decode the integer $X ^ { \\mathrm { I N T } }$ to its simulated high-precision counterpart $X ^ { \\mathbf { D } } \\in \\mathbb { R }$ . Therefore, the dequantization can be expressed as ",
|
| 167 |
+
"page_idx": 2
|
| 168 |
+
},
|
| 169 |
+
{
|
| 170 |
+
"type": "equation",
|
| 171 |
+
"img_path": "images/f99a017fa9a263ba5db544912f7c43a17a81d58bb0843492b06d09d012b9c461.jpg",
|
| 172 |
+
"text": "$$\nX ^ { \\mathrm { D } } = { \\mathcal { T } } [ X ^ { \\mathrm { I N T } } ] .\n$$",
|
| 173 |
+
"text_format": "latex",
|
| 174 |
+
"page_idx": 2
|
| 175 |
+
},
|
| 176 |
+
{
|
| 177 |
+
"type": "text",
|
| 178 |
+
"text": "Simulated Quantization for Matrices. While it is possible to perform multiplication directly between quantized representations, it is common to apply simulated quantization for matrices (Bai et al., 2020; Shen et al., 2020). There, quantized weight matrices are stored as encoded integers in memory, and are temporarily dequantized to simulated high-precision matrices by the lookup table when engaged in multiplication operations. In simulated quantization, it is only necessary to analyze the map from aend-to-end process by $q _ { N } \\big ( \\cdot \\big ) \\colon \\mathbb { R } ^ { m \\times n } \\mapsto \\mathbb { R } _ { N } ^ { m \\times n }$ a simu, where $\\mathbb { R } _ { N } : \\{ \\bar { T } [ i ] \\in \\mathbb { R } | 0 \\le i < 2 ^ { N } \\}$ We denote this. ",
|
| 179 |
+
"page_idx": 2
|
| 180 |
+
},
|
| 181 |
+
{
|
| 182 |
+
"type": "text",
|
| 183 |
+
"text": "2.3 LOW-RANK ADAPTATION ",
|
| 184 |
+
"text_level": 1,
|
| 185 |
+
"page_idx": 2
|
| 186 |
+
},
|
| 187 |
+
{
|
| 188 |
+
"type": "text",
|
| 189 |
+
"text": "LoRA (Hu et al., 2021) updates two small weight matrices $A$ and $B$ that are attached to a frozen pre-trained weight matrix $W$ . Hence, a linear transformation, $Y = X W$ , is reformulated as ",
|
| 190 |
+
"page_idx": 2
|
| 191 |
+
},
|
| 192 |
+
{
|
| 193 |
+
"type": "equation",
|
| 194 |
+
"img_path": "images/53a9b2ef0d27f82bcee8af36a28409c23007105c2680f51b63e4511989ffcce3.jpg",
|
| 195 |
+
"text": "$$\n\\boldsymbol { Y } = \\boldsymbol { X } \\boldsymbol { W } + \\boldsymbol { X } \\boldsymbol { A } \\boldsymbol { B } ^ { \\intercal } ,\n$$",
|
| 196 |
+
"text_format": "latex",
|
| 197 |
+
"page_idx": 2
|
| 198 |
+
},
|
| 199 |
+
{
|
| 200 |
+
"type": "text",
|
| 201 |
+
"text": "where $\\begin{array} { r } { X \\in \\mathbb { R } ^ { n \\times d _ { 1 } } , W \\in \\mathbb { R } ^ { d _ { 1 } \\times d _ { 2 } } , A \\in \\mathbb { R } ^ { d _ { 1 } \\times r } , B \\in \\mathbb { R } ^ { d _ { 2 } \\times r } , } \\end{array}$ , and $r \\ll \\operatorname* { m i n } \\{ d _ { 1 } , d _ { 2 } \\}$ . Initially, ",
|
| 202 |
+
"page_idx": 2
|
| 203 |
+
},
|
| 204 |
+
{
|
| 205 |
+
"type": "equation",
|
| 206 |
+
"img_path": "images/4006e1dbafb1b7a61ec953af8fc01ab2853f663a82fd2a61ccaf9f8c11ba64c3.jpg",
|
| 207 |
+
"text": "$$\nA \\sim \\mathcal { N } ( 0 , \\sigma ^ { 2 } ) , B = 0 ,\n$$",
|
| 208 |
+
"text_format": "latex",
|
| 209 |
+
"page_idx": 2
|
| 210 |
+
},
|
| 211 |
+
{
|
| 212 |
+
"type": "text",
|
| 213 |
+
"text": "so as to align to the pre-trained weights. During the fine-tuning, $W$ is fixed while $A$ and $B$ are updated by some SGD-type optimization method. ",
|
| 214 |
+
"page_idx": 2
|
| 215 |
+
},
|
| 216 |
+
{
|
| 217 |
+
"type": "text",
|
| 218 |
+
"text": "It is worth noting that if low-rank adapters $A$ and $B$ are attached to a quantized backbone $Q =$ $q _ { N } ( W )$ and are initialized by (5), the starting weight $Q + A B ^ { \\top }$ is no longer equal to the pre-trained weight $W$ due to the discrepancy introduced by the quantization. ",
|
| 219 |
+
"page_idx": 2
|
| 220 |
+
},
|
| 221 |
+
{
|
| 222 |
+
"type": "text",
|
| 223 |
+
"text": "3 METHOD ",
|
| 224 |
+
"text_level": 1,
|
| 225 |
+
"page_idx": 3
|
| 226 |
+
},
|
| 227 |
+
{
|
| 228 |
+
"type": "text",
|
| 229 |
+
"text": "We propose LoRA-Fine-Tuning-aware Quantization (LoftQ), a quantization framework for LLMs. It alternatively applies quantization and low-rank approximation to approximate original pre-trained weights. This quantization framework provides a promising initialization for LoRA fine-tuning, which alleviates the quantization discrepancy in QLoRA and improves generalization in downstream tasks significantly. ",
|
| 230 |
+
"page_idx": 3
|
| 231 |
+
},
|
| 232 |
+
{
|
| 233 |
+
"type": "text",
|
| 234 |
+
"text": "3.1 LORA-AWARE QUANTIZATION ",
|
| 235 |
+
"text_level": 1,
|
| 236 |
+
"page_idx": 3
|
| 237 |
+
},
|
| 238 |
+
{
|
| 239 |
+
"type": "text",
|
| 240 |
+
"text": "We use an $N$ -bit quantized weight $Q \\in \\mathbb { R } _ { N } ^ { d _ { 1 } \\times d _ { 2 } }$ and low-rank approximations $A \\in \\mathbb { R } ^ { d _ { 1 } \\times r } , B \\in$ $\\mathbb { R } ^ { d _ { 2 } \\times r }$ to approximate the original high-precision pre-trained weight $W \\in \\mathbb { R } ^ { d _ { 1 } \\times d _ { 2 } }$ as the initialization of LoRA fine-tuning. Specifically, before fine-tuning, we initialize the network by minimizing the following objective: ",
|
| 241 |
+
"page_idx": 3
|
| 242 |
+
},
|
| 243 |
+
{
|
| 244 |
+
"type": "equation",
|
| 245 |
+
"img_path": "images/a3a6a5f430aa8cf53f9a759880baa7a3a0e3ccfe2af5dc88719b1ddde7deb915.jpg",
|
| 246 |
+
"text": "$$\n\\operatorname* { m i n } _ { Q , A , B } \\left\\| \\boldsymbol W - \\boldsymbol Q - \\boldsymbol A \\boldsymbol B ^ { \\intercal } \\right\\| _ { F } ,\n$$",
|
| 247 |
+
"text_format": "latex",
|
| 248 |
+
"page_idx": 3
|
| 249 |
+
},
|
| 250 |
+
{
|
| 251 |
+
"type": "text",
|
| 252 |
+
"text": "where $\\left\\| \\cdot \\right\\| _ { F }$ denotes the Frobenious norm. This objective in (6) takes LoRA fine-tuning into consideration by jointly optimizing the initial values of the quantized backbone $Q$ and low-rank adapters $A , B$ . Contrarily, practitioners typically convert the pre-trained weight $W$ into a quantized weight $Q$ outright, neglecting the subsequent LoRA fine-tuning process. This oversight leads to notable performance degradation in downstream tasks arising from the quantization discrepancy. ",
|
| 253 |
+
"page_idx": 3
|
| 254 |
+
},
|
| 255 |
+
{
|
| 256 |
+
"type": "text",
|
| 257 |
+
"text": "3.2 ALTERNATING OPTIMIZATION ",
|
| 258 |
+
"text_level": 1,
|
| 259 |
+
"page_idx": 3
|
| 260 |
+
},
|
| 261 |
+
{
|
| 262 |
+
"type": "text",
|
| 263 |
+
"text": "We solve the minimization problem in (6) by alternating between quantization and singular value decomposition (SVD). To begin with, we set $A _ { 0 }$ , and $B _ { 0 }$ equal to 0. ",
|
| 264 |
+
"page_idx": 3
|
| 265 |
+
},
|
| 266 |
+
{
|
| 267 |
+
"type": "text",
|
| 268 |
+
"text": "Quantization. At the $t$ -th step, we quantize the difference between the original pre-trained weight matrix $W$ and the low-rank approximation $A _ { t - 1 } B _ { t - 1 } ^ { \\top }$ from the previous step to obtain the quantized weight matrix $Q _ { t }$ by ",
|
| 269 |
+
"page_idx": 3
|
| 270 |
+
},
|
| 271 |
+
{
|
| 272 |
+
"type": "equation",
|
| 273 |
+
"img_path": "images/2be82c7e8599e8fde81030c857e12da4aa2978869062a1328bc3eb9959182d4d.jpg",
|
| 274 |
+
"text": "$$\nQ _ { t } = q _ { N } ( W - A _ { t - 1 } B _ { t - 1 } ^ { \\top } ) ,\n$$",
|
| 275 |
+
"text_format": "latex",
|
| 276 |
+
"page_idx": 3
|
| 277 |
+
},
|
| 278 |
+
{
|
| 279 |
+
"type": "text",
|
| 280 |
+
"text": "where $q _ { N } ( \\cdot )$ maps a high-precision weight matrix to a quantized matrix. ",
|
| 281 |
+
"page_idx": 3
|
| 282 |
+
},
|
| 283 |
+
{
|
| 284 |
+
"type": "text",
|
| 285 |
+
"text": "We remark that our algorithm is compatible with different quantization functions $q _ { N } ( \\cdot )$ . We apply NF4 and the uniform quantization in Section 4 as examples. We also remark that $Q _ { t }$ is not an exact solution of the minimization in (6), given the fixed $A _ { t - 1 } B _ { t - 1 } ^ { \\top }$ , but it is an efficient approximation. ",
|
| 286 |
+
"page_idx": 3
|
| 287 |
+
},
|
| 288 |
+
{
|
| 289 |
+
"type": "text",
|
| 290 |
+
"text": "SVD. After obtaining the $t$ -th quantized weight $Q _ { t }$ , SVD is applied to the residual of the quantization denoted by $R _ { t } = W - Q _ { t }$ by ",
|
| 291 |
+
"page_idx": 3
|
| 292 |
+
},
|
| 293 |
+
{
|
| 294 |
+
"type": "equation",
|
| 295 |
+
"img_path": "images/566f2cba8efd88b9c3bab032f737f57c57f6dd1ab2a54cc2b2f4c2b5d5835c01.jpg",
|
| 296 |
+
"text": "$$\nR _ { t } = \\sum _ { i = 1 } ^ { d } { \\sigma _ { t , i } u _ { t , i } v _ { t , i } ^ { \\top } } ,\n$$",
|
| 297 |
+
"text_format": "latex",
|
| 298 |
+
"page_idx": 3
|
| 299 |
+
},
|
| 300 |
+
{
|
| 301 |
+
"type": "text",
|
| 302 |
+
"text": "where $d = \\operatorname* { m i n } \\{ d _ { 1 } , d _ { 2 } \\}$ , $\\sigma _ { t , 1 } \\geq \\sigma _ { t , 2 } \\geq \\ldots \\geq \\sigma _ { t , d }$ are the singular values of $R _ { t } , u _ { t , i }$ ’s and $v _ { t , i }$ ’s are the associated left and right singular vectors of $R _ { t }$ . We then obtain a rank- $r$ approximation of $R _ { t }$ by $A _ { t } B _ { t } ^ { \\top }$ , where ",
|
| 303 |
+
"page_idx": 3
|
| 304 |
+
},
|
| 305 |
+
{
|
| 306 |
+
"type": "equation",
|
| 307 |
+
"img_path": "images/3b2d002d10f5531beaaf8e5fe6f440a09a7ca5a10d595c8f6b3e95becdbf17b7.jpg",
|
| 308 |
+
"text": "$$\n\\begin{array} { r l } & { A _ { t } = [ \\sqrt { \\sigma _ { t , 1 } } u _ { t , 1 } , . . . , \\sqrt { \\sigma _ { t , r } } u _ { t , r } ] , } \\\\ & { B _ { t } = [ \\sqrt { \\sigma _ { t , 1 } } v _ { t , 1 } , . . . , \\sqrt { \\sigma _ { t , r } } v _ { t , r } ] . } \\end{array}\n$$",
|
| 309 |
+
"text_format": "latex",
|
| 310 |
+
"page_idx": 3
|
| 311 |
+
},
|
| 312 |
+
{
|
| 313 |
+
"type": "text",
|
| 314 |
+
"text": "We summarize our method in Algorithm 1. It is worth noting that $T = 1$ is a special case where $Q _ { 1 }$ is the exact quantized weight obtained by QLoRA, and low-rank approximations $A _ { 1 } , B _ { 1 }$ are obtained by the SVD of the quantization residual $W - Q _ { 1 }$ . $T = 1$ is sufficient to mitigate the quantization discrepancy, and alternating optimization helps to find a closer initialization to the pre-trained weight $W$ , which further improves the performance (see Section 3). ",
|
| 315 |
+
"page_idx": 3
|
| 316 |
+
},
|
| 317 |
+
{
|
| 318 |
+
"type": "text",
|
| 319 |
+
"text": "We remark that the computational cost of LoftQ is negligible because it is applied to individual weight matrices and can be executed in parallel. We also remark one can apply LoftQ only once to a pre-trained model and reuse the initialization obtained by LoftQ for different downstream tasks. ",
|
| 320 |
+
"page_idx": 3
|
| 321 |
+
},
|
| 322 |
+
{
|
| 323 |
+
"type": "text",
|
| 324 |
+
"text": "3.3 APPLYING TO LORA FINE-TUNING ",
|
| 325 |
+
"text_level": 1,
|
| 326 |
+
"page_idx": 3
|
| 327 |
+
},
|
| 328 |
+
{
|
| 329 |
+
"type": "text",
|
| 330 |
+
"text": "We store the $Q _ { T } \\in \\mathbb { R } _ { N } ^ { d _ { 1 } \\times d _ { 2 } }$ obtained by LoftQ using an integer matrix $M$ by (1) and a lookup table $\\tau$ by (2). We initialize the backbone with the integer matrix $M$ and initialize the low-rank adapters with $A _ { T } , B _ { T }$ obtained by LoftQ. ",
|
| 331 |
+
"page_idx": 3
|
| 332 |
+
},
|
| 333 |
+
{
|
| 334 |
+
"type": "text",
|
| 335 |
+
"text": "Algorithm 1 LoftQ ",
|
| 336 |
+
"text_level": 1,
|
| 337 |
+
"page_idx": 4
|
| 338 |
+
},
|
| 339 |
+
{
|
| 340 |
+
"type": "text",
|
| 341 |
+
"text": "input Pre-trained weight $W$ , target rank $r$ , $N$ -bit quantization function $q _ { N } ( \\cdot )$ , alternating step $T$ \n1: Initialize $A _ { 0 } 0 , B _ { 0 } 0$ \n2: for $\\mathbf { t } = 1$ to $T$ do \n3: Obtain quantized weight $Q _ { t } q _ { N } ( W - A _ { t - 1 } B _ { t - 1 } ^ { \\top } )$ \n4: Obtain low-rank approximation $A _ { t } , B _ { t } \\gets \\operatorname { S V D } ( W - Q _ { t } )$ by (9) ",
|
| 342 |
+
"page_idx": 4
|
| 343 |
+
},
|
| 344 |
+
{
|
| 345 |
+
"type": "text",
|
| 346 |
+
"text": "5: end for output $Q _ { T } , A _ { T } , B _ { T }$ ",
|
| 347 |
+
"page_idx": 4
|
| 348 |
+
},
|
| 349 |
+
{
|
| 350 |
+
"type": "text",
|
| 351 |
+
"text": "During LoRA fine-tuning, we freeze the integer weight $M$ and optimize the low-rank adapters with an efficient optimization algorithm, e.g., AdamW (Loshchilov & Hutter, 2017). In forward propagation, the integer weight $M$ is temporarily dequantized to the simulated high-precision weight $Q _ { T }$ by its lookup table, as described in (3). In back propagation, gradients and optimizer state are only related to low-rank adapters $A , B$ , which reduces considerable training cost. ",
|
| 352 |
+
"page_idx": 4
|
| 353 |
+
},
|
| 354 |
+
{
|
| 355 |
+
"type": "text",
|
| 356 |
+
"text": "4 EXPERIMENTS ",
|
| 357 |
+
"text_level": 1,
|
| 358 |
+
"page_idx": 4
|
| 359 |
+
},
|
| 360 |
+
{
|
| 361 |
+
"type": "text",
|
| 362 |
+
"text": "We evaluate our method on NLU and NLG tasks. We apply LoftQ for quantizing DeBERTaV3-base (He et al., 2021b), BART-large (Lewis et al., 2019), and LLAMA-2 series (Touvron et al., 2023). ",
|
| 363 |
+
"page_idx": 4
|
| 364 |
+
},
|
| 365 |
+
{
|
| 366 |
+
"type": "text",
|
| 367 |
+
"text": "Implementation Details. Following the prior works of LoRA variants (Zhang et al., 2023; He et al., 2021a), we freeze all the backbone weight matrices and add low-rank adapters to weight matrices in MHA and FFN of all layers. We quantize the weight matrices that are attached by lowrank adapters. All the quantized models and adapters used in this paper are available on https: //huggingface.co/LoftQ. Our implementation is based on publicly available Huggingface Transformers code-base (Paszke et al., 2019). All the experiments are conducted on NVIDIA A100 GPUs. ",
|
| 368 |
+
"page_idx": 4
|
| 369 |
+
},
|
| 370 |
+
{
|
| 371 |
+
"type": "text",
|
| 372 |
+
"text": "Quantization Methods. We apply two quantization methods to demonstrate LoftQ is compatible with different quantization functions: ",
|
| 373 |
+
"page_idx": 4
|
| 374 |
+
},
|
| 375 |
+
{
|
| 376 |
+
"type": "text",
|
| 377 |
+
"text": "• Uniform quantization is a classic quantization method. It uniformly divides a continuous interval into $2 ^ { N }$ categories and stores a local maximum absolute value for dequantization. • NF4 and its 2-bit variant NF2 are quantization methods used in QLoRA (Dettmers et al., 2023). They assume that the high-precision values are drawn from a Gaussian distribution and map these values to discrete slots that have equal probability. ",
|
| 378 |
+
"page_idx": 4
|
| 379 |
+
},
|
| 380 |
+
{
|
| 381 |
+
"type": "text",
|
| 382 |
+
"text": "We perform 2-bit and 4-bit quantization on all models, achieving compression ratios of $2 5 - 3 0 \\%$ and $1 5 - 2 0 \\%$ at the 4-bit and 2-bit levels, respectively. The compression ratios and trainable parameter ratios for all models are detailed in the Appendix A. ",
|
| 383 |
+
"page_idx": 4
|
| 384 |
+
},
|
| 385 |
+
{
|
| 386 |
+
"type": "text",
|
| 387 |
+
"text": "Baselines. We compare LoftQ with the following baseline methods: ",
|
| 388 |
+
"page_idx": 4
|
| 389 |
+
},
|
| 390 |
+
{
|
| 391 |
+
"type": "text",
|
| 392 |
+
"text": "• Full fine-tuning is the most common approach for adapting a pre-trained model to downstream tasks. The model is initialized with pre-trained weights and all parameters are updated through an SGD-type optimization method. \n• Full precision LoRA (LoRA) is a lightweight method for task adaptation, where it stores the backbone using 16-bit numbers and optimizes the low-rank adaptors only. The adaptors are applied to the same matrices as in LoftQ. \n• QLoRA is similar to LoRA except the backbone is quantized into low-bit regime. The lowrank adapters are initialized using (5) and are applied to the same matrices as in LoftQ. ",
|
| 393 |
+
"page_idx": 4
|
| 394 |
+
},
|
| 395 |
+
{
|
| 396 |
+
"type": "text",
|
| 397 |
+
"text": "4.1 ENCODER-ONLY MODEL: DEBERTAV3 ",
|
| 398 |
+
"text_level": 1,
|
| 399 |
+
"page_idx": 4
|
| 400 |
+
},
|
| 401 |
+
{
|
| 402 |
+
"type": "text",
|
| 403 |
+
"text": "Models and Datasets. We quantize the DeBERTaV3-base (He et al., 2021b) with LoftQ, then finetune and evaluate the model on the General Language Understanding Evaluation (GLUE) benchmark (Wang et al., 2019), SQuADv1.1 (Rajpurkar et al., 2016), and ANLI (Nie et al., 2019). The specific tasks of GLUE are given in Appendix C. Following previous works (Zhang et al., 2023), we exclude WNLI in the experiments. ",
|
| 404 |
+
"page_idx": 4
|
| 405 |
+
},
|
| 406 |
+
{
|
| 407 |
+
"type": "text",
|
| 408 |
+
"text": "Implementation Details. We select the learning rates from $\\{ 1 \\times 1 0 ^ { - 5 } , 5 \\times 1 0 ^ { - 5 } , 1 \\times 1 0 ^ { - 4 } 5 \\times 1 0 ^ { - 4 } \\}$ . We quantize the entire backbone. Given that GLUE, SQuADv1.1, and ANLI are relatively easy NLU tasks, we also quantize the embedding layer for higher compression efficiency. We apply the NormalFloat and the uniform quantization for LoftQ and QLoRA at both 2-bit and 4-bit levels. We use rank 16 and 32 for low-rank adapters. More implementation details, such as the training epochs and batch sizes, are presented in Appendix D.2. ",
|
| 409 |
+
"page_idx": 5
|
| 410 |
+
},
|
| 411 |
+
{
|
| 412 |
+
"type": "text",
|
| 413 |
+
"text": "Main Results. Table 1 and Table 2 summarize the results for 2-bit quantization on the GLUE, SQuADv1.1, and ANLI datasets, by NF2 and the uniform quantization, respectively. Our method consistently outperforms QLoRA on all settings with respect to different ranks, quantization methods, and datasets. When using the uniform quantization (Table 2), our method achieves $8 8 . 0 \\%$ accuracy on MNLI-m, surpassing the QLoRA baseline by $8 \\%$ . For tasks like SST and SQuADv1.1, our method even approaches the full fine-tuning performance at 2-bit level. The 4-bit quantization experiment results are presented in Appendix D.1 as both LoftQ and QLoRA achieve performance close to full fine-tuning. ",
|
| 414 |
+
"page_idx": 5
|
| 415 |
+
},
|
| 416 |
+
{
|
| 417 |
+
"type": "table",
|
| 418 |
+
"img_path": "images/d7a52798311b47cc616750a655cf5517ebee7b13b80852f2eb08a161e5ca6f9a.jpg",
|
| 419 |
+
"table_caption": [
|
| 420 |
+
"Table 1: Results with 2-bit LoftQ of DeBERTaV3-base models on GLUE development set, SQuADv1.1 development set, ANLI test set using NF2 quantization. We report the median over four seeds. N.A. indicates the model does not converge. The best results on each dataset are shown in bold. "
|
| 421 |
+
],
|
| 422 |
+
"table_footnote": [],
|
| 423 |
+
"table_body": "<table><tr><td>Rank</td><td>Method</td><td>MNLI m/mm</td><td>QNLI Acc</td><td>RTE Acc</td><td>SST Acc</td><td>MRPC Acc</td><td>CoLA Matt</td><td>QQP Acc</td><td>STSB P/S Corr</td><td>SQuAD EM/F1</td><td>ANLI Acc</td></tr><tr><td></td><td>Full FT</td><td>90.5/90.6</td><td>94.0</td><td>82.0</td><td>95.3</td><td>89.5/93.3</td><td>69.2</td><td>92.4/89.8</td><td>91.6/91.1</td><td>88.5/92.8</td><td>59.8</td></tr><tr><td>16</td><td>LoRA</td><td>90.4/90.5</td><td>94.6</td><td>85.1</td><td>95.1</td><td>89.9/93.6</td><td>69.9</td><td>92.0/89.4</td><td>91.7/91.1</td><td>87.3/93.1</td><td>60.2</td></tr><tr><td>16</td><td>QLoRA</td><td>75.4775.6</td><td>824</td><td>55</td><td>86.5</td><td>73.8/82.8</td><td>N</td><td>86.3/82.3</td><td>83.0/82.8</td><td>61.5/71.2</td><td>N</td></tr><tr><td>32</td><td>LoRA</td><td>78.5/78.7</td><td>804</td><td>567</td><td>869</td><td>73.8/82.7</td><td>N</td><td>87.182.7</td><td>83.6/83.3</td><td>64.6773.8</td><td></td></tr></table>",
|
| 424 |
+
"page_idx": 5
|
| 425 |
+
},
|
| 426 |
+
{
|
| 427 |
+
"type": "table",
|
| 428 |
+
"img_path": "images/14dd7a5ea106d0dce860d1b97a65ad29feb16a382a550ebb680fa793673e0b49.jpg",
|
| 429 |
+
"table_caption": [
|
| 430 |
+
"Table 2: Results with 2-bit LoftQ of DeBERTaV3-base models on GLUE development set, SQuADv1.1 development set using Uniform quantization . We report the median over four seeds. N.A. indicates the model does not converge. The best results on each task are shown in bold. "
|
| 431 |
+
],
|
| 432 |
+
"table_footnote": [],
|
| 433 |
+
"table_body": "<table><tr><td>Rank</td><td>Method</td><td>MNLI m/mm</td><td>QNLI Acc</td><td>RTE Acc</td><td>SST Acc</td><td>MRPC Acc</td><td>CoLA Matt</td><td>QQP Acc</td><td>STSB P/S Corr</td><td>SQuAD Em/F1</td></tr><tr><td></td><td>Full FT</td><td>90.5/90.6</td><td>94.0</td><td>82.0</td><td>95.3</td><td>89.5/93.3</td><td>69.2</td><td>92.4/89.8</td><td>91.6/91.1</td><td>88.5/92.8</td></tr><tr><td>16</td><td>LoRA</td><td>90.4/90.5</td><td>94.6</td><td>85.1</td><td>95.1</td><td>89.9/93.6</td><td>69.9</td><td>92.0/89.4</td><td>91.7/91.1</td><td>87.3/93.1</td></tr><tr><td>16</td><td>QLoRA</td><td>76.5/76.3</td><td>88</td><td>567</td><td>86</td><td>75.7784.7</td><td></td><td>87.182.6</td><td>83.5/83.4</td><td>89.5/776</td></tr><tr><td>32</td><td>LoRA</td><td>79.9779.5</td><td>87</td><td>578</td><td>8.9</td><td>76.5/84.2</td><td>N</td><td>8.6/84.7</td><td>84.1/84.0</td><td>71.6/80.2</td></tr></table>",
|
| 434 |
+
"page_idx": 5
|
| 435 |
+
},
|
| 436 |
+
{
|
| 437 |
+
"type": "text",
|
| 438 |
+
"text": "Our method is also more stable compared to QLoRA in the low-bit regime. For instance, while QLoRA fails to converge on CoLA for both quantization methods and ranks, LoftQ converges in all cases and achieves a score of 60.5 using uniform quantization at rank 32. LoftQ stands out in its ability to consistently attain robust and improved performance by effectively preserving the starting point of pre-trained weights. ",
|
| 439 |
+
"page_idx": 5
|
| 440 |
+
},
|
| 441 |
+
{
|
| 442 |
+
"type": "text",
|
| 443 |
+
"text": "4.2 ENCODER-DECODER MODEL: BART ",
|
| 444 |
+
"text_level": 1,
|
| 445 |
+
"page_idx": 5
|
| 446 |
+
},
|
| 447 |
+
{
|
| 448 |
+
"type": "text",
|
| 449 |
+
"text": "Models and Datasets. We quantize BART-large model (Lewis et al., 2020) with LoftQ, then finetune and evaluate the model on two commonly used summarization datasets: XSum (Narayan et al., 2018) and CNN/DailyMail(Hermann et al., 2015). ",
|
| 450 |
+
"page_idx": 5
|
| 451 |
+
},
|
| 452 |
+
{
|
| 453 |
+
"type": "text",
|
| 454 |
+
"text": "Implementation Details. We apply LoftQ to weight matrices in MHA and FFN of both encoder and decoder layers. We report ROUGE 1/2/L scores, which are the metrics for summarization tasks (Lin, 2004). We conduct quantization experiments in both 2-bit and 4-bit scenarios. We experiment with both NormalFloat and the uniform quantization in both 2-bit and 4-bit scenarios. In each precision, we choose rank equal to 8 and 16 for a fair comparison with the full precision LoRA baseline (Zhang et al., 2023). Please see Appendix E for detailed configurations. ",
|
| 455 |
+
"page_idx": 5
|
| 456 |
+
},
|
| 457 |
+
{
|
| 458 |
+
"type": "text",
|
| 459 |
+
"text": "Main Results. Table 3 summarizes our 4-bit quantization experiment results on the XSum and CNN/DailyMail test sets. Our method consistently outperforms QLoRA at both ranks on both datasets. It even surpasses full precision LoRA at both ranks on Xsum. We will discuss this unexpected results in Section 5. The 2-bit quantization results are shown in Table 4. Our observation is consistent with the NLU experiments, that LoftQ demonstrates the convergence to reasonable results, while QLoRA does not converge. This indicates our method is robuster by narrowing the initialization gap. ",
|
| 460 |
+
"page_idx": 6
|
| 461 |
+
},
|
| 462 |
+
{
|
| 463 |
+
"type": "table",
|
| 464 |
+
"img_path": "images/b2cf315404dec990d30588d813a8df04c05725daa5c3f8d14a5d357b551a6880.jpg",
|
| 465 |
+
"table_caption": [
|
| 466 |
+
"Table 3: Results with 4-bit LoftQ of BART-large on XSum and CNN/DailyMail. We report ROUGE1/2/L. Lead-3 means choosing the first 3 sentences as the summary. N.A. indicates the model does not converge. Full FT: full fine-tuning. We report the median over five seeds. "
|
| 467 |
+
],
|
| 468 |
+
"table_footnote": [],
|
| 469 |
+
"table_body": "<table><tr><td>Quantization</td><td>Rank</td><td>Method</td><td>XSum</td><td>CNN/DailyMail</td></tr><tr><td rowspan=\"2\">Full Precision</td><td></td><td>Lead-3 Full FT</td><td>16.30/1.60/11.95 45.14/22.27/37.25</td><td>40.42/17.62/36.67 44.16/21.28/40.90</td></tr><tr><td>8</td><td>LoRA</td><td>43.40/20.20/35.20</td><td>44.72/21.58/41.84</td></tr><tr><td rowspan=\"3\">NF4</td><td>16 8</td><td>LoRA QLoRA</td><td>43.95/20.72/35.68 42.91/19.72/34.82</td><td>45.03/21.84/42.15 43.10/20.22/40.06</td></tr><tr><td></td><td>LoftQ</td><td>44.08/20.72/35.89</td><td>43.81/20.95/40.84</td></tr><tr><td>16</td><td>QLoRA</td><td>43.29/20.0/35.15</td><td>43.42/20.67/40.4</td></tr><tr><td rowspan=\"3\">Uniform</td><td>8</td><td></td><td></td><td></td></tr><tr><td></td><td>QLoRA</td><td>41.84/18.71/3374</td><td>43.73/20.91/40.77</td></tr><tr><td>16</td><td>QLoRA</td><td>4.45/19.36/34.38</td><td>4300/20.19/40.02</td></tr></table>",
|
| 470 |
+
"page_idx": 6
|
| 471 |
+
},
|
| 472 |
+
{
|
| 473 |
+
"type": "table",
|
| 474 |
+
"img_path": "images/c566f674d8b5256b30a46951c62d8988d79fd140cda549485e2890c49aa17783.jpg",
|
| 475 |
+
"table_caption": [
|
| 476 |
+
"Table 4: Results with 2-bit LoftQ of BART-large on XSum and CNN/DailyMail using NF2 quantization. N.A. indicates the model does not converge. We report ROUGE-1/2/L, the higher the better. We report the median over five seeds. "
|
| 477 |
+
],
|
| 478 |
+
"table_footnote": [],
|
| 479 |
+
"table_body": "<table><tr><td>Rank</td><td>Method</td><td>XSum</td><td>CNN/DailyMail</td></tr><tr><td>8</td><td>QLoRA LoftQ</td><td>N.A. 39.63/16.65/31.62</td><td>N.A. 42.24/19.44/29.04</td></tr><tr><td>16</td><td>QLoRA</td><td>40.81/17.85/32.80</td><td>42.52/19.81/39.51</td></tr></table>",
|
| 480 |
+
"page_idx": 6
|
| 481 |
+
},
|
| 482 |
+
{
|
| 483 |
+
"type": "text",
|
| 484 |
+
"text": "4.3 DECODER-ONLY MODEL: LLAMA-2 ",
|
| 485 |
+
"text_level": 1,
|
| 486 |
+
"page_idx": 6
|
| 487 |
+
},
|
| 488 |
+
{
|
| 489 |
+
"type": "text",
|
| 490 |
+
"text": "Models and Datasets. We quantize LLAMA-2-7b and LLAMA-2-13b (Touvron et al., 2023) with LoftQ. We then fine-tune and evaluate the models on two NLG datasets: GSM8K (Cobbe et al., 2021) and WikiText-2 (Merity et al., 2016). Please see Appendix F for more details about the datasets. ",
|
| 491 |
+
"page_idx": 6
|
| 492 |
+
},
|
| 493 |
+
{
|
| 494 |
+
"type": "text",
|
| 495 |
+
"text": "Implementation Details. Similarly, we apply LoftQ to weight matrices in MHA and FFN of all layers. In WikiText-2 evaluation, we report perplexity. In case of overfitting, we apply weight decay to low-rank adapters for all settings. In GSM8K evaluation, we extract numerical answers in the generated solutions and then calculate the accuracy using those numerical answers. We conduct experiments with both NF2 and NF4. Please see Appendix F for detailed configurations. ",
|
| 496 |
+
"page_idx": 6
|
| 497 |
+
},
|
| 498 |
+
{
|
| 499 |
+
"type": "text",
|
| 500 |
+
"text": "Main Results. Table 5 presents a summary of our experiments on LLAMA-2-7b and LLAMA-2- 13b using 2-bit, 4-bit, and mixed-precision NormalFloat quantization methods on WikiText-2 and GSM8K datasets. In WikiText-2, our method consistently outperforms QLoRA across all quantization precision settings on both models. When dealing with the challenging 2-bit precision, where QLoRA fails to converge, LoftQ manages to achieve a perplexity of 7.85. In GSM8K, our method achieves better or on par performance compared to QLoRA across different model sizes and quantization precision levels. For example, our method achieves $2 6 . 5 \\%$ accuracy using 2-bit precision of LLAMA-2-7b, where QLoRA does not converge. ",
|
| 501 |
+
"page_idx": 6
|
| 502 |
+
},
|
| 503 |
+
{
|
| 504 |
+
"type": "text",
|
| 505 |
+
"text": "To provide a customized trade-off between the performance and precision, we also explore mixedprecision (equivalent to 3 bits) quantization where matrices in the first half layers are quantized using 4 bits, and the rest matrices remain 2 bits. We witness a remarkable $4 . 1 \\%$ accuracy boost on the GSM8K dataset using LLAMA-2-7b and a $4 . 7 \\%$ boost using LLAMA-2-13b. This result underscores the potential of LoftQ for complex mixed-precision quantization scenarios. ",
|
| 506 |
+
"page_idx": 7
|
| 507 |
+
},
|
| 508 |
+
{
|
| 509 |
+
"type": "table",
|
| 510 |
+
"img_path": "images/87fa7e07a2573660afb34532c9aeb006327c4e4e2053d87ccc587e00b8141215.jpg",
|
| 511 |
+
"table_caption": [
|
| 512 |
+
"Table 5: Results of LoftQ using NormalFloat for LLAMA-2 series on WikiText-2 and GSM8K. 3/2.5/2.25-bit indicates mixed-precision quantization: 4-bit precision for the first 16/8/4 layers and 2-bit precision for the rest of layers. We report the perplexity (the smaller the better) for WikiText-2 and accuracy for GSM8K. The rank of low-rank adapters is 64. N.A. indicates the model does not converge. We report the median over five random seeds. "
|
| 513 |
+
],
|
| 514 |
+
"table_footnote": [],
|
| 515 |
+
"table_body": "<table><tr><td rowspan=\"2\">Method</td><td rowspan=\"2\">Bit</td><td colspan=\"2\">wikiLLAMA-2-7M8K↑</td><td colspan=\"2\">wikiLLAMA-2-13M8K↑</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>LoRA</td><td>16</td><td>5.08</td><td>38.5</td><td>5.12</td><td>48.8</td></tr><tr><td rowspan=\"2\">QLoRA LoftQ</td><td>4</td><td>5.70</td><td>38.2</td><td>5.22</td><td>48.8</td></tr><tr><td>4</td><td>5.24</td><td>38.0</td><td>5.16</td><td>49.1</td></tr><tr><td rowspan=\"2\">QLoRA LoftQ</td><td>3</td><td>5.73</td><td>32.1</td><td>5.22</td><td>40.7</td></tr><tr><td>3</td><td>5.63</td><td>36.2</td><td>5.13</td><td>45.4</td></tr><tr><td rowspan=\"2\">QLoRA LoftQ</td><td>2.5</td><td>N.A.</td><td>N.A.</td><td>19.39</td><td>N.A.</td></tr><tr><td>2.5</td><td>5.78</td><td>31.1</td><td>5.22</td><td>41.1</td></tr><tr><td rowspan=\"2\">QLoRA LoftQ</td><td>2.25</td><td>N.A.</td><td>N.A.</td><td>N.A.</td><td>N.A.</td></tr><tr><td>2.25</td><td>6.13</td><td>27.5</td><td>5.45</td><td>38.1</td></tr><tr><td rowspan=\"2\">QLoRA LoftQ</td><td>2</td><td>N.A</td><td>N.A.</td><td>N.A.</td><td></td></tr><tr><td>2</td><td>7.85</td><td>26.5</td><td>7.69</td><td>N.A. 33.4</td></tr></table>",
|
| 516 |
+
"page_idx": 7
|
| 517 |
+
},
|
| 518 |
+
{
|
| 519 |
+
"type": "text",
|
| 520 |
+
"text": "4.4 ANALYSIS ",
|
| 521 |
+
"text_level": 1,
|
| 522 |
+
"page_idx": 7
|
| 523 |
+
},
|
| 524 |
+
{
|
| 525 |
+
"type": "text",
|
| 526 |
+
"text": "Effectiveness of Alternating Optimization. We conduct experiments with different alternating step $T$ to verify the effectiveness of the alternating optimization and to find the best value $T$ as a hyperparameter for different models. Across all tasks and models, we observed that alternating optimization yields substantial improvements even with a minimal alternating step. This suggests that it rapidly narrows the discrepancy between quantized weights and pre-trained weights, making our method easy to apply. For example, LoftQ achieves 21.14 Rouge-2 score on XSum using only 1 step. Interestingly, we noticed that increasing the alternating step beyond a certain point tends to result in diminishing returns. We suspect this phenomenon occurs because, as the gap becomes smaller, it becomes more challenging for alternating optimization to consistently minimize the gap at each step. This challenge emerges because of the inherent errors introduced by the quantization method. Nevertheless, results from Figure 3 indicate our method is not sensitive to the alternating step $T$ and is able to consistently enhance downstream fine-tuning performance. ",
|
| 527 |
+
"page_idx": 7
|
| 528 |
+
},
|
| 529 |
+
{
|
| 530 |
+
"type": "image",
|
| 531 |
+
"img_path": "images/2673706ec556a9e0548cb901bf64305516d2baa50f83db13904d70a7030bcb5e.jpg",
|
| 532 |
+
"image_caption": [
|
| 533 |
+
"Figure 3: Comparison of different alternating step $T$ used in LoftQ. $T = 0$ indicates we use QLoRA method that initializes low-rank adapters by (5). $T = 1 , 5 , 1 0$ indicates we use different $T$ for LoftQ described in Algorithm 1. Left: Uniform 2-bit DeBERTaV3-base. Middle: NF2 2-bit LLAMA-2- 13b. Right: NF4 BART-large. "
|
| 534 |
+
],
|
| 535 |
+
"image_footnote": [],
|
| 536 |
+
"page_idx": 7
|
| 537 |
+
},
|
| 538 |
+
{
|
| 539 |
+
"type": "text",
|
| 540 |
+
"text": "5 DISCUSSION ",
|
| 541 |
+
"text_level": 1,
|
| 542 |
+
"page_idx": 8
|
| 543 |
+
},
|
| 544 |
+
{
|
| 545 |
+
"type": "text",
|
| 546 |
+
"text": "Start with quantization or SVD in the alternating optimization? An alternative algorithm to the alternating optimization is that we first obtain the low-rank approximation $A _ { t } , B _ { t }$ and then obtain the quantized weight $Q _ { t }$ by switching Line 3 and Line 4 in Algorithm 1. We note this is a valid alternative method as both still jointly minimize the objective in (6). Table 6 summarizes the performance of this alternative method. It is noteworthy that the alternative method still outperforms QLoRA significantly, even though it is worse than the primary version. This observation underscores the potential for performance improvement by achieving a closer approximation of pre-trained weights within the low-precision regime. ",
|
| 547 |
+
"page_idx": 8
|
| 548 |
+
},
|
| 549 |
+
{
|
| 550 |
+
"type": "text",
|
| 551 |
+
"text": "LoftQ better than Full-precision LoRA? We find LoftQ outperforms full precision LoRA in XSum and GSM8K (see Table 3 and Table 5). Beside the overfitting caused by lack of regularization, anonther possible explanation for this unexpected phenomenon is that the initial low-rank adapters obtained by LoftQ are non-zero while they are all zero in full precision LoRA as described in (5). Such zero initialization could make the fine-tuning unstable, and therefore it performs worse than LoftQ. We leave the study of the robustness of LoftQ as future work. ",
|
| 552 |
+
"page_idx": 8
|
| 553 |
+
},
|
| 554 |
+
{
|
| 555 |
+
"type": "table",
|
| 556 |
+
"img_path": "images/85c8c5468c53b0d19ca26945eeb89c1c00590dde233cd7ca59fc1b4b68e020ac.jpg",
|
| 557 |
+
"table_caption": [
|
| 558 |
+
"Table 6: Results of 2-bit uniformly quantized DeBERTaV3-base on part of GLUE. LoftQ(SVD First) indicates the alternative LoftQ that swiches Line 3 and Line 4 in Algorithm 1. We report the median over four random seeds. The best results on each task are shown in bold. "
|
| 559 |
+
],
|
| 560 |
+
"table_footnote": [],
|
| 561 |
+
"table_body": "<table><tr><td>Method</td><td>Rank</td><td>MNLI</td><td>QNLI</td><td>SST2</td></tr><tr><td>Full FT</td><td></td><td>90.5/90.6</td><td>94.0</td><td>95.3</td></tr><tr><td>QLoRA</td><td>32</td><td>79.9/79.5</td><td>83.8</td><td>86.6</td></tr><tr><td>LoftQ(SVD First)</td><td>32</td><td>87.8/87.7</td><td>84.9</td><td>89.7</td></tr><tr><td>LoftQ(Quantiztion First)</td><td>32</td><td>88.0/88.1</td><td>92.2</td><td>94.7</td></tr></table>",
|
| 562 |
+
"page_idx": 8
|
| 563 |
+
},
|
| 564 |
+
{
|
| 565 |
+
"type": "text",
|
| 566 |
+
"text": "6 RELATED WORK ",
|
| 567 |
+
"text_level": 1,
|
| 568 |
+
"page_idx": 8
|
| 569 |
+
},
|
| 570 |
+
{
|
| 571 |
+
"type": "text",
|
| 572 |
+
"text": "Quantization-Aware Training (QAT) is often used to obtain quantized models that are adapted in downstream tasks (Peri et al., 2020; Liu et al., 2023). It involves quantization and full model fine-tuning at the same time. However, QAT requires massive training cost, such as the gradient and optimization state. Moreover, it is difficult to compute the gradient of quantized weights. Our method, with the help of LoRA, sidesteps the aforementioned issues, providing a light approach for downstream task adaptation. ",
|
| 573 |
+
"page_idx": 8
|
| 574 |
+
},
|
| 575 |
+
{
|
| 576 |
+
"type": "text",
|
| 577 |
+
"text": "Post-Training Quantization (PTQ) is a category of popular quantization frameworks (Frantar et al., 2022; Xiao et al., 2023), which can also be used for task adaptation. It calibrates the high-precision model with a small subset of the training dataset. Therefore, the subsequent quantization is guided by the training dataset, providing task-specific quantized models. Besides, it does not involve any gradient backpropagation, so it is cost-efficient. However, it usually results in lower accuracy compared to QAT. ",
|
| 578 |
+
"page_idx": 8
|
| 579 |
+
},
|
| 580 |
+
{
|
| 581 |
+
"type": "text",
|
| 582 |
+
"text": "7 CONCLUSION ",
|
| 583 |
+
"text_level": 1,
|
| 584 |
+
"page_idx": 8
|
| 585 |
+
},
|
| 586 |
+
{
|
| 587 |
+
"type": "text",
|
| 588 |
+
"text": "We propose LoftQ, a quantization framework for LLMs, which alternatively applies quantization and low-rank approximation to the original high-precision pre-trained weights, to obtain an initialization for the subsequent LoRA fine-tuning. Experiments on natural language understanding, question answering, summarization, and natural language generation show that our framework remarkably surpasses existing methods, e.g., QLoRA, for quantizing encoder-only, encoder-decoder, and decoder-only models. We have not observed our method exhibiting worse performance over QLoRA. Moreover, our quantization framework demonstrates effectiveness and robustness particularly in low-bit quantization regimes, e.g., the 2-bit level. ",
|
| 589 |
+
"page_idx": 8
|
| 590 |
+
},
|
| 591 |
+
{
|
| 592 |
+
"type": "text",
|
| 593 |
+
"text": "REFERENCES \nHaoli Bai, Wei Zhang, Lu Hou, Lifeng Shang, Jing Jin, Xin Jiang, Qun Liu, Michael Lyu, and Irwin King. Binarybert: Pushing the limit of bert quantization. arXiv preprint arXiv:2012.15701, 2020. \nHaoli Bai, Lu Hou, Lifeng Shang, Xin Jiang, Irwin King, and Michael R Lyu. Towards efficient posttraining quantization of pre-trained language models. Advances in Neural Information Processing Systems, 35:1405–1418, 2022. \nRoy Bar-Haim, Ido Dagan, Bill Dolan, Lisa Ferro, Danilo Giampiccolo, Bernardo Magnini, and Idan Szpektor. The second pascal recognising textual entailment challenge. 2006. \nLuisa Bentivogli, Peter Clark, Ido Dagan, and Danilo Giampiccolo. The fifth pascal recognizing textual entailment challenge. In TAC, 2009. \nDaniel Cer, Mona Diab, Eneko Agirre, Inigo Lopez-Gazpio, and Lucia Specia. SemEval-2017 task ˜ 1: Semantic textual similarity multilingual and crosslingual focused evaluation. In Proceedings of the 11th International Workshop on Semantic Evaluation (SemEval-2017), pp. 1–14, Vancouver, Canada, August 2017. Association for Computational Linguistics. doi: 10.18653/v1/S17-2001. \nKarl 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. \nIdo Dagan, Oren Glickman, and Bernardo Magnini. The pascal recognising textual entailment challenge. In Machine Learning Challenges Workshop, 2007. \nTim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer. Llm. int8 (): 8-bit matrix multiplication for transformers at scale. arXiv preprint arXiv:2208.07339, 2022. \nTim Dettmers, Artidoro Pagnoni, Ari Holtzman, and Luke Zettlemoyer. Qlora: Efficient finetuning of quantized llms. arXiv preprint arXiv:2305.14314, 2023. \nShizhe Diao, Rui Pan, Hanze Dong, Ka Shun Shum, Jipeng Zhang, Wei Xiong, and Tong Zhang. Lmflow: An extensible toolkit for finetuning and inference of large foundation models. arXiv preprint arXiv:2306.12420, 2023. \nWilliam B. Dolan and Chris Brockett. Automatically constructing a corpus of sentential paraphrases. In Proceedings of the Third International Workshop on Paraphrasing (IWP2005), 2005. \nElias Frantar, Saleh Ashkboos, Torsten Hoefler, and Dan Alistarh. Gptq: Accurate post-training quantization for generative pre-trained transformers. arXiv preprint arXiv:2210.17323, 2022. \nDanilo Giampiccolo, Bernardo Magnini, Ido Dagan, and Bill Dolan. The third PASCAL recognizing textual entailment challenge. In Proceedings of the ACL-PASCAL Workshop on Textual Entailment and Paraphrasing, pp. 1–9, Prague, June 2007. Association for Computational Linguistics. \nJunxian He, Chunting Zhou, Xuezhe Ma, Taylor Berg-Kirkpatrick, and Graham Neubig. Towards a unified view of parameter-efficient transfer learning. arXiv preprint arXiv:2110.04366, 2021a. \nPengcheng He, Jianfeng Gao, and Weizhu Chen. Debertav3: Improving deberta using electra-style pre-training with gradient-disentangled embedding sharing. arXiv preprint arXiv:2111.09543, 2021b. \nKarl Moritz Hermann, Tomas Kocisky, Edward Grefenstette, Lasse Espeholt, Will Kay, Mustafa Suleyman, and Phil Blunsom. Teaching machines to read and comprehend. Advances in neural information processing systems, 28, 2015. \nEdward 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. arXiv preprint arXiv:2106.09685, 2021. \nHector Levesque, Ernest Davis, and Leora Morgenstern. The winograd schema challenge. In Thirteenth international conference on the principles of knowledge representation and reasoning, 2012. ",
|
| 594 |
+
"page_idx": 9
|
| 595 |
+
},
|
| 596 |
+
{
|
| 597 |
+
"type": "text",
|
| 598 |
+
"text": "Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Ves Stoyanov, and Luke Zettlemoyer. Bart: Denoising sequence-to-sequence pretraining for natural language generation, translation, and comprehension. arXiv preprint arXiv:1910.13461, 2019. ",
|
| 599 |
+
"page_idx": 10
|
| 600 |
+
},
|
| 601 |
+
{
|
| 602 |
+
"type": "text",
|
| 603 |
+
"text": "Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Veselin Stoyanov, and Luke Zettlemoyer. BART: Denoising sequence-to-sequence pretraining for natural language generation, translation, and comprehension. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 7871–7880, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.703. \nYixiao Li, Yifan Yu, Qingru Zhang, Chen Liang, Pengcheng He, Weizhu Chen, and Tuo Zhao. Losparse: Structured compression of large language models based on low-rank and sparse approximation. arXiv preprint arXiv:2306.11222, 2023. \nChin-Yew Lin. ROUGE: A package for automatic evaluation of summaries. In Text Summarization Branches Out, pp. 74–81, Barcelona, Spain, July 2004. Association for Computational Linguistics. \nZechun Liu, Barlas Oguz, Changsheng Zhao, Ernie Chang, Pierre Stock, Yashar Mehdad, Yangyang Shi, Raghuraman Krishnamoorthi, and Vikas Chandra. Llm-qat: Data-free quantization aware training for large language models. arXiv preprint arXiv:2305.17888, 2023. \nIlya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017. \nStephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models, 2016. \nShashi 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, abs/1808.08745, 2018. \nYixin Nie, Adina Williams, Emily Dinan, Mohit Bansal, Jason Weston, and Douwe Kiela. Adversarial nli: A new benchmark for natural language understanding. ArXiv, abs/1910.14599, 2019. URL https://api.semanticscholar.org/CorpusID:207756753. \nAdam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, high-performance deep learning library. In Advances in Neural Information Processing Systems 32, pp. 8024–8035. Curran Associates, Inc., 2019. \nDheeraj Peri, Jhalak Patel, and Josh Park. Deploying quantization-aware trained networks using tensorrt. In GPU Technology Conference, 2020. \nPranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: $1 0 0 { , } 0 0 0 { + }$ questions for machine comprehension of text. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pp. 2383–2392, Austin, Texas, November 2016. Association for Computational Linguistics. doi: 10.18653/v1/D16-1264. \nSheng Shen, Zhen Dong, Jiayu Ye, Linjian Ma, Zhewei Yao, Amir Gholami, Michael W Mahoney, and Kurt Keutzer. Q-bert: Hessian based ultra low precision quantization of bert. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 8815–8821, 2020. \nRichard Socher, Alex Perelygin, Jean Wu, Jason Chuang, Christopher D. Manning, Andrew $\\mathrm { N g }$ , and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, pp. 1631–1642, Seattle, Washington, USA, October 2013. Association for Computational Linguistics. \nHugo 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. \nAshish 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. \nAlex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In International Conference on Learning Representations, 2019. \nAlex Warstadt, Amanpreet Singh, and Samuel R. Bowman. Neural network acceptability judgments. Transactions of the Association for Computational Linguistics, 7:625–641, 2019. doi: 10.1162/ tacl a 00290. \nAdina Williams, Nikita Nangia, and Samuel Bowman. A broad-coverage challenge corpus for sentence understanding through inference. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 1112–1122, New Orleans, Louisiana, June 2018. Association for Computational Linguistics. doi: 10.18653/v1/N18-1101. \nGuangxuan Xiao, Ji Lin, Mickael Seznec, Hao Wu, Julien Demouth, and Song Han. Smoothquant: Accurate and efficient post-training quantization for large language models. In International Conference on Machine Learning, pp. 38087–38099. PMLR, 2023. \nOfir Zafrir, Guy Boudoukh, Peter Izsak, and Moshe Wasserblat. Q8bert: Quantized 8bit bert. In 2019 Fifth Workshop on Energy Efficient Machine Learning and Cognitive Computing-NeurIPS Edition (EMC2-NIPS), pp. 36–39. IEEE, 2019. \nHongyi Zhang, Yann N Dauphin, and Tengyu Ma. Fixup initialization: Residual learning without normalization. arXiv preprint arXiv:1901.09321, 2019. \nQingru Zhang, Minshuo Chen, Alexander Bukharin, Pengcheng He, Yu Cheng, Weizhu Chen, and Tuo Zhao. Adaptive budget allocation for parameter-efficient fine-tuning. arXiv preprint arXiv:2303.10512, 2023. ",
|
| 604 |
+
"page_idx": 10
|
| 605 |
+
},
|
| 606 |
+
{
|
| 607 |
+
"type": "text",
|
| 608 |
+
"text": "",
|
| 609 |
+
"page_idx": 11
|
| 610 |
+
},
|
| 611 |
+
{
|
| 612 |
+
"type": "text",
|
| 613 |
+
"text": "A MODEL COMPRESSION RATIO AND MEMORY FOOTPRINT ",
|
| 614 |
+
"text_level": 1,
|
| 615 |
+
"page_idx": 12
|
| 616 |
+
},
|
| 617 |
+
{
|
| 618 |
+
"type": "text",
|
| 619 |
+
"text": "We report the compression ratio after applying LoftQ in Table 7. It is defined as backbone size + LoRA adapter size compression ration $=$ pre-trained size ",
|
| 620 |
+
"page_idx": 12
|
| 621 |
+
},
|
| 622 |
+
{
|
| 623 |
+
"type": "text",
|
| 624 |
+
"text": "We also measure the GPU memory cost during training. Given that GPU memory varies by models, tasks, sequence lengths, batch sizes, etc. We report LLAMA-2 on GSM8K as an example in Table 8. ",
|
| 625 |
+
"page_idx": 12
|
| 626 |
+
},
|
| 627 |
+
{
|
| 628 |
+
"type": "table",
|
| 629 |
+
"img_path": "images/88b1ffd69d9ba686b716abe4c1b43cb141fe9bcc50e82d217a214ea68f96a335.jpg",
|
| 630 |
+
"table_caption": [
|
| 631 |
+
"Table 7: Compression ratios of backbones. "
|
| 632 |
+
],
|
| 633 |
+
"table_footnote": [],
|
| 634 |
+
"table_body": "<table><tr><td>Model</td><td>Compression ratio (%)</td><td>Trainable ratio (%)</td><td>Rank</td><td>Bits</td><td>Quantization method</td></tr><tr><td>DeBERTaV3-base</td><td>15.6</td><td>3.1</td><td>16</td><td></td><td>Uniform</td></tr><tr><td>DeBERTaV3-base</td><td>18.8</td><td>6.3</td><td>32</td><td></td><td>Uniform</td></tr><tr><td>DeBERTaV3-base</td><td>17.2</td><td>3.1</td><td>16</td><td>222</td><td>NF2</td></tr><tr><td>DeBERTaV3-base</td><td>20.4</td><td>6.3</td><td>32</td><td>2</td><td>NF2</td></tr><tr><td>BART-large</td><td>15.3</td><td>1.2</td><td>8</td><td>4</td><td>NF2</td></tr><tr><td>BART-large</td><td>16.7</td><td>2.5</td><td>16</td><td>4</td><td>NF2</td></tr><tr><td>BART-large</td><td>27.8</td><td>1.2</td><td>8</td><td>4</td><td>NF4</td></tr><tr><td>BART-large</td><td>29.0</td><td>2.5</td><td>16</td><td>4</td><td>NF4</td></tr><tr><td>BART-large</td><td>26.2</td><td>1.2</td><td>8</td><td>4</td><td>Uniform</td></tr><tr><td>BART-large</td><td>27.5</td><td>2.5</td><td>16</td><td>4</td><td>Uniform</td></tr><tr><td>LLAMA-2-7b</td><td>16.6</td><td>2.4</td><td>64</td><td>2</td><td>Nf2</td></tr><tr><td>LLAMA-2-7b</td><td>29.0</td><td>2.4</td><td>64</td><td>4</td><td>Nf4</td></tr><tr><td>LLAMA-2-13b</td><td>16.0</td><td>1.9</td><td>64</td><td>2</td><td>Nf2</td></tr><tr><td>LLAMA-2-13b</td><td>28.5</td><td>1.9</td><td>64</td><td>4</td><td>Nf4</td></tr></table>",
|
| 635 |
+
"page_idx": 12
|
| 636 |
+
},
|
| 637 |
+
{
|
| 638 |
+
"type": "table",
|
| 639 |
+
"img_path": "images/3c761018d9f2cdfe5d3ecdabeb4378ade5464c0a36a6f5e87580e87efbe6d88f.jpg",
|
| 640 |
+
"table_caption": [
|
| 641 |
+
"Table 8: GPU memory footprint "
|
| 642 |
+
],
|
| 643 |
+
"table_footnote": [],
|
| 644 |
+
"table_body": "<table><tr><td>Model</td><td>Dataset</td><td> Seq length</td><td>Batch size</td><td>GPU Mem</td></tr><tr><td>LLAMA-2-7b</td><td>GSM8K</td><td>384</td><td>1</td><td>15GB</td></tr><tr><td>LLAMA-2-13b</td><td>GSM8K</td><td>384</td><td>1</td><td>24GB</td></tr></table>",
|
| 645 |
+
"page_idx": 12
|
| 646 |
+
},
|
| 647 |
+
{
|
| 648 |
+
"type": "text",
|
| 649 |
+
"text": "B QUANTIZATION TIME ",
|
| 650 |
+
"text_level": 1,
|
| 651 |
+
"page_idx": 12
|
| 652 |
+
},
|
| 653 |
+
{
|
| 654 |
+
"type": "text",
|
| 655 |
+
"text": "We report the execution time of LoftQ applying to a single weight matrix in Table 9. The time is tested on Intel(R) Xeon(R) CPU E5-2650 v4 $\\textcircled { a } 2 . 2 0 \\mathrm { G H z }$ . ",
|
| 656 |
+
"page_idx": 12
|
| 657 |
+
},
|
| 658 |
+
{
|
| 659 |
+
"type": "table",
|
| 660 |
+
"img_path": "images/28fb1ad2865a263cbc44cda373acaf92f6e37b08714124fd7d57057af61be95c.jpg",
|
| 661 |
+
"table_caption": [
|
| 662 |
+
"Table 9: Execution time of LoftQ applying to different weight matrices. "
|
| 663 |
+
],
|
| 664 |
+
"table_footnote": [],
|
| 665 |
+
"table_body": "<table><tr><td>Model</td><td>Size</td><td>Step T</td><td>Quantization method</td><td>Time</td></tr><tr><td>DeBERTaV3-base</td><td>768×768</td><td>5</td><td>Uniform</td><td>1s</td></tr><tr><td>BART-large</td><td>1024×1024</td><td>5</td><td>NF4</td><td>1s</td></tr><tr><td>LLAMA-2-7b</td><td>4096 × 4096</td><td>5</td><td>NF4</td><td>21s</td></tr><tr><td>LLAMA-2-13b</td><td>5120 × 5120</td><td>5</td><td>NF4</td><td>43s</td></tr></table>",
|
| 666 |
+
"page_idx": 12
|
| 667 |
+
},
|
| 668 |
+
{
|
| 669 |
+
"type": "text",
|
| 670 |
+
"text": "C GLUE DATASET STATISTICS ",
|
| 671 |
+
"text_level": 1,
|
| 672 |
+
"page_idx": 12
|
| 673 |
+
},
|
| 674 |
+
{
|
| 675 |
+
"type": "text",
|
| 676 |
+
"text": "We present the dataset statistics of GLUE Wang et al. (2019) in the following table. ",
|
| 677 |
+
"page_idx": 12
|
| 678 |
+
},
|
| 679 |
+
{
|
| 680 |
+
"type": "text",
|
| 681 |
+
"text": "GLUE includes two single-sentence classification tasks: SST-2 (Socher et al., 2013) and CoLA (Warstadt et al., 2019), and three similarity and paraphrase tasks: MRPC (Dolan & Brockett, 2005), STS-B (Cer et al., 2017), and QQP. GLUE also includes four natural language inference tasks in GLUE: MNLI (Williams et al., 2018), QNLI (Rajpurkar et al., 2016), RTE (Dagan et al., 2007; BarHaim et al., 2006; Giampiccolo et al., 2007; Bentivogli et al., 2009), and WNLI (Levesque et al., 2012). ",
|
| 682 |
+
"page_idx": 12
|
| 683 |
+
},
|
| 684 |
+
{
|
| 685 |
+
"type": "table",
|
| 686 |
+
"img_path": "images/2676681d7ea54b0ef8642c1418d02cefd6f2959ec29c1dd78d5a80b8a64f94a4.jpg",
|
| 687 |
+
"table_caption": [
|
| 688 |
+
"Table 10: Summary of the GLUE benchmark. "
|
| 689 |
+
],
|
| 690 |
+
"table_footnote": [],
|
| 691 |
+
"table_body": "<table><tr><td>Corpus</td><td>Task</td><td>#Train</td><td>#Dev</td><td>#Test</td><td>#Label</td><td>Metrics</td></tr><tr><td colspan=\"7\">Single-Sentence Classification (GLUE)</td></tr><tr><td>CoLA</td><td> Acceptability</td><td>8.5k</td><td>1k</td><td>1k</td><td>2</td><td>Matthews corr</td></tr><tr><td>SST</td><td>Sentiment</td><td>67k</td><td>872</td><td>1.8k</td><td>2</td><td>Accuracy</td></tr><tr><td colspan=\"7\">Pairwise Text Classification (GLUE)</td></tr><tr><td>MNLI</td><td>NLI</td><td>393k</td><td>20k</td><td>20k</td><td>3</td><td>Accuracy</td></tr><tr><td>RTE</td><td>NLI</td><td>2.5k</td><td>276</td><td>3k</td><td>2</td><td>Accuracy</td></tr><tr><td>QQP</td><td>Paraphrase</td><td>364k</td><td>40k</td><td>391k</td><td>2</td><td>Accuracy/F1</td></tr><tr><td>MRPC</td><td>Paraphrase</td><td>3.7k</td><td>408</td><td>1.7k</td><td>2</td><td>Accuracy/F1</td></tr><tr><td>QNLI</td><td>QA/NLI</td><td>108k</td><td>5.7k</td><td>5.7k</td><td>2</td><td>Accuracy</td></tr><tr><td colspan=\"7\">Text Similarity (GLUE)</td></tr><tr><td>STS-B</td><td>Similarity</td><td>7k</td><td>1.5k</td><td>1.4k</td><td>1</td><td>Pearson/Spearman corr</td></tr></table>",
|
| 692 |
+
"page_idx": 13
|
| 693 |
+
},
|
| 694 |
+
{
|
| 695 |
+
"type": "text",
|
| 696 |
+
"text": "D NATURAL LANGUAGE UNDERSTANDING ",
|
| 697 |
+
"text_level": 1,
|
| 698 |
+
"page_idx": 13
|
| 699 |
+
},
|
| 700 |
+
{
|
| 701 |
+
"type": "text",
|
| 702 |
+
"text": "D.1 GLUE WITH 4-BIT ",
|
| 703 |
+
"text_level": 1,
|
| 704 |
+
"page_idx": 13
|
| 705 |
+
},
|
| 706 |
+
{
|
| 707 |
+
"type": "text",
|
| 708 |
+
"text": "We show the 4-bits results in the Table 11. Both methods can achieve performance close to fullfinetuning. ",
|
| 709 |
+
"page_idx": 13
|
| 710 |
+
},
|
| 711 |
+
{
|
| 712 |
+
"type": "text",
|
| 713 |
+
"text": "Table 11: Results with 4-bit LoftQ of DeBERTaV3-base models on GLUE development set using NF4 quantization. We report the median over four seeds. Results with N.A. indicate the model does not converge. The best results on each dataset are shown in bold ",
|
| 714 |
+
"page_idx": 13
|
| 715 |
+
},
|
| 716 |
+
{
|
| 717 |
+
"type": "table",
|
| 718 |
+
"img_path": "images/de87bc37df0bf743ccafa39248fbee6b3cb6523dd51dece99c2b0f4daeca1e12.jpg",
|
| 719 |
+
"table_caption": [],
|
| 720 |
+
"table_footnote": [],
|
| 721 |
+
"table_body": "<table><tr><td>Method</td><td>Rank</td><td>MNLI m /mm</td><td>SST-2 Acc</td><td>QNLI Acc</td><td>ANLI Acc</td></tr><tr><td>Full FT</td><td>-</td><td>90.5/90.6</td><td>95.3</td><td>94.0</td><td>59.8</td></tr><tr><td>QLoRA</td><td>32</td><td>89.9/89.9</td><td>95.3</td><td>94.2</td><td>59.4</td></tr><tr><td>LoftQ</td><td>32</td><td>89.9/90.0</td><td>95.3</td><td>94.1</td><td>59.9</td></tr></table>",
|
| 722 |
+
"page_idx": 13
|
| 723 |
+
},
|
| 724 |
+
{
|
| 725 |
+
"type": "text",
|
| 726 |
+
"text": "D.2 TRAINING DETAILS ",
|
| 727 |
+
"text_level": 1,
|
| 728 |
+
"page_idx": 13
|
| 729 |
+
},
|
| 730 |
+
{
|
| 731 |
+
"type": "text",
|
| 732 |
+
"text": "Implementation Details. The implementation of LoftQ is based on publicly available Huggingface (Paszke et al., 2019) code-base 3. ",
|
| 733 |
+
"page_idx": 13
|
| 734 |
+
},
|
| 735 |
+
{
|
| 736 |
+
"type": "text",
|
| 737 |
+
"text": "Hyper-parameter Details. We select the learning rate of $\\{ 1 \\times 1 0 ^ { - 5 } , 5 \\times 1 0 ^ { - 5 } , 1 \\times 1 0 ^ { - 4 } , 5 \\times 1 0 ^ { - 4 } \\}$ , and use the selected learning rate for both uniform quantization experiments and nf2 quantization experiments. We use batch size of 32 for all GLUE tasks and ANLI. We use batch size of 16 for SQuADv1.1. We use LoftQ of 5 iterations for all GLUE tasks. ",
|
| 738 |
+
"page_idx": 13
|
| 739 |
+
},
|
| 740 |
+
{
|
| 741 |
+
"type": "text",
|
| 742 |
+
"text": "Table 12 summarizes the detailed hyperparameters for each task used in training DeBERTaV3-base using uniform quantization. Table 13 summarizes the detailed hyperparameters for each task used in training DeBERTaV3-base using nf2 quantization. ",
|
| 743 |
+
"page_idx": 13
|
| 744 |
+
},
|
| 745 |
+
{
|
| 746 |
+
"type": "table",
|
| 747 |
+
"img_path": "images/3476949a6390a3a049d26912c3c67efd0520d961382b3f1b6785c4bc94e73e90.jpg",
|
| 748 |
+
"table_caption": [
|
| 749 |
+
"Table 12: Hyper-parameter setup of LoftQ for GLUE benchmark for training DeBERTaV3-base using Uniform quantization. "
|
| 750 |
+
],
|
| 751 |
+
"table_footnote": [],
|
| 752 |
+
"table_body": "<table><tr><td>Hyper-parameter</td><td>MNLI</td><td>RTE</td><td>QNLI</td><td>MRPC</td><td>QQP</td><td>SST-2</td><td>CoLA</td><td>STS-B</td><td>SQuADv1.1</td><td>ANLI</td></tr><tr><td># epochs</td><td>5</td><td>20</td><td>10</td><td>60</td><td>10</td><td>10</td><td>60</td><td>60</td><td>10</td><td>12</td></tr><tr><td>Learning rate</td><td>1 ×10-4</td><td>5×10-4</td><td>5×10-5</td><td>1×10-4</td><td>5×10-5</td><td>5×10-5</td><td>5×10-5</td><td>5×10-5</td><td>5×10-5</td><td>5×10-5</td></tr></table>",
|
| 753 |
+
"page_idx": 13
|
| 754 |
+
},
|
| 755 |
+
{
|
| 756 |
+
"type": "text",
|
| 757 |
+
"text": "3https://github.com/huggingface/transformers/tree/main/examples/pytorch ",
|
| 758 |
+
"page_idx": 13
|
| 759 |
+
},
|
| 760 |
+
{
|
| 761 |
+
"type": "table",
|
| 762 |
+
"img_path": "images/0022e19362bd58d34f7e5dbee9b5dae6087b8bdb274ceafc9df88cb1ebaa498f.jpg",
|
| 763 |
+
"table_caption": [
|
| 764 |
+
"Table 13: Hyper-parameter setup of LoftQ for GLUE benchmark for training DeBERTaV3-base using NF2 quantization. "
|
| 765 |
+
],
|
| 766 |
+
"table_footnote": [],
|
| 767 |
+
"table_body": "<table><tr><td>Hyper-parameter</td><td>MNLI</td><td>RTE</td><td>QNLI</td><td>MRPC</td><td>QQP</td><td>SST-2</td><td>CoLA</td><td>STS-B</td><td>SQuADv1.1</td><td>ANLI</td></tr><tr><td># epochs</td><td>5</td><td>20</td><td>10</td><td>60</td><td>10</td><td>10</td><td>60</td><td>60</td><td>10</td><td>12</td></tr><tr><td>Learning rate</td><td>1 ×10-4</td><td>5×10-5</td><td>5×10-5</td><td>1 ×10-4</td><td>5×10-5</td><td>5×10-5</td><td>5×10-5</td><td>1×10-4</td><td>5×10-5</td><td>5×10-5</td></tr></table>",
|
| 768 |
+
"page_idx": 14
|
| 769 |
+
},
|
| 770 |
+
{
|
| 771 |
+
"type": "text",
|
| 772 |
+
"text": "E SUMMARIZATION ",
|
| 773 |
+
"text_level": 1,
|
| 774 |
+
"page_idx": 14
|
| 775 |
+
},
|
| 776 |
+
{
|
| 777 |
+
"type": "text",
|
| 778 |
+
"text": "E.1 TRAINING DETAILS ",
|
| 779 |
+
"text_level": 1,
|
| 780 |
+
"page_idx": 14
|
| 781 |
+
},
|
| 782 |
+
{
|
| 783 |
+
"type": "text",
|
| 784 |
+
"text": "We choose Adam as the optimizer and try learning rate from $\\{ 1 \\times 1 0 ^ { - 5 } , 5 \\times 1 0 ^ { - 5 } , 7 \\times 1 0 ^ { - 5 } , 2 \\times$ $1 0 ^ { - 4 } , 3 \\times 1 0 ^ { - 4 } , 4 \\times 1 0 ^ { - 4 } \\dot \\}$ . We show the optimal learning rate for different settings in Table 14. We use LoftQ of 1 iteration for all BART-large experiments. Table 14 and Table 15 summarize the learning rate and other hyper-parameters for CNN/DailyMail and XSum. ",
|
| 785 |
+
"page_idx": 14
|
| 786 |
+
},
|
| 787 |
+
{
|
| 788 |
+
"type": "table",
|
| 789 |
+
"img_path": "images/b2f4caab27040703fbcd654e65acc8ed416566dace4f97f6c9a06e8d9d9c21ba.jpg",
|
| 790 |
+
"table_caption": [
|
| 791 |
+
"Table 14: Hyper-parameter setup of LoftQ BART-large on CNN/DailyMail "
|
| 792 |
+
],
|
| 793 |
+
"table_footnote": [],
|
| 794 |
+
"table_body": "<table><tr><td rowspan=\"2\">Hyperparameter</td><td colspan=\"2\">NF4</td><td colspan=\"2\"> 4-bit Uniform</td><td colspan=\"2\">NF2</td></tr><tr><td>rank8</td><td>rank16</td><td>rank8</td><td>rank16</td><td>rank8</td><td>rank16</td></tr><tr><td>Learning rate</td><td>2e-4</td><td>2e-4</td><td>2e-4</td><td>3e-4</td><td>2e-4</td><td>2e-4</td></tr><tr><td>Epoch</td><td>15</td><td>15</td><td>15</td><td>15</td><td>15</td><td>15</td></tr><tr><td>Batch size</td><td>64</td><td>64</td><td>64</td><td>64</td><td>64</td><td>64</td></tr></table>",
|
| 795 |
+
"page_idx": 14
|
| 796 |
+
},
|
| 797 |
+
{
|
| 798 |
+
"type": "table",
|
| 799 |
+
"img_path": "images/fe3011c102171b9fa10829b07e3206ed30a4c84e3d8fc2b0dedef6c56416fed2.jpg",
|
| 800 |
+
"table_caption": [
|
| 801 |
+
"Table 15: Hyper-parameter setup of LoftQ BART-large on XSum "
|
| 802 |
+
],
|
| 803 |
+
"table_footnote": [],
|
| 804 |
+
"table_body": "<table><tr><td rowspan=\"2\">Hyperparameter</td><td colspan=\"2\">NF4</td><td colspan=\"2\"> 4-bit Uniform</td><td colspan=\"2\">NF2</td></tr><tr><td>rank8</td><td>rank16</td><td>rank8</td><td>rank16</td><td>rank8</td><td>rank16</td></tr><tr><td>Learning rate</td><td>2e-4</td><td>2e-4</td><td>2e-4</td><td>2e-4</td><td>2e-4</td><td>2e-4</td></tr><tr><td>Epoch</td><td>25</td><td>25</td><td>25</td><td>25</td><td>25</td><td>25</td></tr><tr><td>Batch size</td><td>32</td><td>32</td><td>32</td><td>32</td><td>32</td><td>32</td></tr></table>",
|
| 805 |
+
"page_idx": 14
|
| 806 |
+
},
|
| 807 |
+
{
|
| 808 |
+
"type": "text",
|
| 809 |
+
"text": "F NATURAL LANGUAGE GENERATION ",
|
| 810 |
+
"text_level": 1,
|
| 811 |
+
"page_idx": 14
|
| 812 |
+
},
|
| 813 |
+
{
|
| 814 |
+
"type": "text",
|
| 815 |
+
"text": "We set the batch size as 32 for WikiText-2 and 16 for GSM8K. We train 2 epochs on WikiText-2 and 6 epochs on GSM8K. We select learning rate from $\\{ 1 \\times 1 0 ^ { - 5 } , 5 \\times 1 0 ^ { - 5 } , \\bar { 7 } \\times 1 0 ^ { - 5 } , 1 \\times 1 0 ^ { - 4 } , 3 \\times$ $1 0 ^ { - 4 } , 4 \\times 1 0 ^ { - 4 } \\}$ . Specific settings are summarized in Table 16 and Table 17. ",
|
| 816 |
+
"page_idx": 14
|
| 817 |
+
},
|
| 818 |
+
{
|
| 819 |
+
"type": "text",
|
| 820 |
+
"text": "G COMPARISON TO PRUNING ",
|
| 821 |
+
"text_level": 1,
|
| 822 |
+
"page_idx": 14
|
| 823 |
+
},
|
| 824 |
+
{
|
| 825 |
+
"type": "text",
|
| 826 |
+
"text": "Pruning is also a widely used compression method. Here we compare LoftQ with the state-of-theart pruning method Li et al. (2023). We show the comparison in Table 18. We can see our method significantly outperforms the pruning methods on DeBERTaV3-base model. We also remark that LoftQ can consistently reduce the memory of both training and storage. In contrast, pruning requires training the entire full-precision matrix, which implies that it can not achieve any memory savings during the training stage. ",
|
| 827 |
+
"page_idx": 14
|
| 828 |
+
},
|
| 829 |
+
{
|
| 830 |
+
"type": "text",
|
| 831 |
+
"text": "H EXTENSION TO CONVOLUTIONAL LAYERS ",
|
| 832 |
+
"text_level": 1,
|
| 833 |
+
"page_idx": 14
|
| 834 |
+
},
|
| 835 |
+
{
|
| 836 |
+
"type": "text",
|
| 837 |
+
"text": "Low-rank adapters can also be applied to convolutional layers. Given an input feature map $X ~ \\in ~ \\mathbb { R } ^ { h \\times w \\times \\dot { c } _ { 1 } }$ and $c _ { 2 }$ 2D convolutional kernels $K _ { i } \\in \\mathbb { R } ^ { c _ { 1 } \\times d \\times d } , i \\mathrm { ~ = ~ } 1 , 2 , . . . , \\dot { c } _ { 2 }$ , the output of the convolutional layer is ",
|
| 838 |
+
"page_idx": 14
|
| 839 |
+
},
|
| 840 |
+
{
|
| 841 |
+
"type": "equation",
|
| 842 |
+
"img_path": "images/5a304a4e02e4e8a1a85e9c54a47eac84d07545cdc96864616d17810ba5841342.jpg",
|
| 843 |
+
"text": "$$\nY = { \\mathrm { s t a c k } } ( X \\otimes K _ { 1 } , . . . , X \\otimes K _ { c _ { 2 } } ) ,\n$$",
|
| 844 |
+
"text_format": "latex",
|
| 845 |
+
"page_idx": 14
|
| 846 |
+
},
|
| 847 |
+
{
|
| 848 |
+
"type": "text",
|
| 849 |
+
"text": "where $Y \\in \\mathbb { R } ^ { h \\times w \\times c _ { 2 } }$ and $\\otimes$ denotes the 2D convolution operation. ",
|
| 850 |
+
"page_idx": 14
|
| 851 |
+
},
|
| 852 |
+
{
|
| 853 |
+
"type": "table",
|
| 854 |
+
"img_path": "images/83b21123cca47801151534477fe38f31543782e6b3dc8cc1c26746c5dafa4a53.jpg",
|
| 855 |
+
"table_caption": [
|
| 856 |
+
"Table 16: Hyper-parameter setup of LoftQ LLAMA-2-series on GSM8K "
|
| 857 |
+
],
|
| 858 |
+
"table_footnote": [],
|
| 859 |
+
"table_body": "<table><tr><td>Model</td><td>Hyperparameter</td><td>NF4</td><td>NF2</td><td>Mixed-precision</td></tr><tr><td>LLAMA-2-7b</td><td> learning rate</td><td>3×10-4</td><td>3×10-4</td><td>3×10-4</td></tr><tr><td>LLAMA-2-13b</td><td>learning rate</td><td>1×10-4</td><td>1×10-4</td><td>3×10-4</td></tr></table>",
|
| 860 |
+
"page_idx": 15
|
| 861 |
+
},
|
| 862 |
+
{
|
| 863 |
+
"type": "table",
|
| 864 |
+
"img_path": "images/8007b99f7dcb9fe88e5d10ec2424bc14a8fe575070bb4784719b4c37c60a3c7d.jpg",
|
| 865 |
+
"table_caption": [
|
| 866 |
+
"Table 17: Hyper-parameter setup of LoftQ LLAMA-2-series on WikiText-2 "
|
| 867 |
+
],
|
| 868 |
+
"table_footnote": [],
|
| 869 |
+
"table_body": "<table><tr><td>Model</td><td> Hyperparameter</td><td>NF4</td><td>NF2</td><td>Mixed-precision</td></tr><tr><td>LLAMA-2-7b</td><td> learning rate</td><td>3×10-4</td><td>3×10-4</td><td>3×10-4</td></tr><tr><td>LLAMA-2-13b</td><td> learning rate</td><td>1×10-4</td><td>1×10-4</td><td>3×10-4</td></tr></table>",
|
| 870 |
+
"page_idx": 15
|
| 871 |
+
},
|
| 872 |
+
{
|
| 873 |
+
"type": "text",
|
| 874 |
+
"text": "Table 18: Results of LoftQ using 2-bits uniform quantization compared with LoSparse with DeBERTaV3-base models on some of GLUE development sets. Here Ratio is the proportion of total remaining weights. Results with N.A. indicate the model does not converge. ",
|
| 875 |
+
"page_idx": 15
|
| 876 |
+
},
|
| 877 |
+
{
|
| 878 |
+
"type": "table",
|
| 879 |
+
"img_path": "images/e0dd2527832dd701acbc7bee7a117b3ec784241a8a1fbf07e437c441c15a62ee.jpg",
|
| 880 |
+
"table_caption": [],
|
| 881 |
+
"table_footnote": [],
|
| 882 |
+
"table_body": "<table><tr><td>Method</td><td>Ratio</td><td>MNLI m/mm</td><td>SST-2 Acc</td><td>QNLI Acc</td></tr><tr><td>Full FT</td><td>100%</td><td>90.5 /90.6</td><td>95.3</td><td>94.0</td></tr><tr><td>LoSparse</td><td>15%</td><td>84.3/82.9</td><td>87.6</td><td>904</td></tr><tr><td>LoftQ</td><td>15.%</td><td>87.3/87.1</td><td>940</td><td>94</td></tr></table>",
|
| 883 |
+
"page_idx": 15
|
| 884 |
+
},
|
| 885 |
+
{
|
| 886 |
+
"type": "text",
|
| 887 |
+
"text": "We can reformulate Equation (10) into matrix multiplication as ",
|
| 888 |
+
"page_idx": 15
|
| 889 |
+
},
|
| 890 |
+
{
|
| 891 |
+
"type": "equation",
|
| 892 |
+
"img_path": "images/d7c13c173e3021080d05b971e9f8ce51c577f2b45eaefada49f0ddfe075ae23c.jpg",
|
| 893 |
+
"text": "$$\n\\boldsymbol { Y } = \\boldsymbol { Z } \\times \\boldsymbol { H } ^ { \\intercal } ,\n$$",
|
| 894 |
+
"text_format": "latex",
|
| 895 |
+
"page_idx": 15
|
| 896 |
+
},
|
| 897 |
+
{
|
| 898 |
+
"type": "text",
|
| 899 |
+
"text": "where $Z \\in \\mathbb { R } ^ { h w \\times c _ { 1 } d ^ { 2 } } , H \\in \\mathbb { R } ^ { c _ { 2 } \\times c _ { 1 } d ^ { 2 } }$ , by extending and flattening the input $X$ together with concatenating and flattening kernels. We first extend a vector $x _ { i , j } \\in \\mathbb { R } ^ { c _ { 1 } }$ by its neighbor vectors within the kernel window: ",
|
| 900 |
+
"page_idx": 15
|
| 901 |
+
},
|
| 902 |
+
{
|
| 903 |
+
"type": "equation",
|
| 904 |
+
"img_path": "images/5128fb33f7a5eaf81e260842ce8c87c6fd9f25ac613d50109a1870ad6b00288e.jpg",
|
| 905 |
+
"text": "$$\n\\begin{array} { r } { x _ { i , j } ^ { ' } = \\mathrm { C o n c a t } ( \\mathrm { x _ { i - \\frac { d } { 2 } , j - \\frac { d } { 2 } } } , . . . , \\mathrm { x _ { i + \\frac { d } { 2 } , j + \\frac { d } { 2 } } } ) . } \\end{array}\n$$",
|
| 906 |
+
"text_format": "latex",
|
| 907 |
+
"page_idx": 15
|
| 908 |
+
},
|
| 909 |
+
{
|
| 910 |
+
"type": "text",
|
| 911 |
+
"text": "Now, $X$ becomes $X ^ { \\prime } \\in \\mathbb { R } ^ { h \\times w \\times c _ { 1 } d ^ { 2 } }$ . We then flatten $X ^ { \\prime }$ into $Z \\in \\mathbb { R } ^ { h w \\times c _ { 1 } d ^ { 2 } }$ . For kernels, we first concatenate $\\{ K _ { 1 } , . . . , K _ { c _ { 2 } } \\}$ into $H ^ { \\prime } \\in \\mathbb { R } ^ { c _ { 2 } \\times c _ { 1 } \\times d \\times d }$ . We then flatten $H ^ { \\prime }$ into $H$ . ",
|
| 912 |
+
"page_idx": 15
|
| 913 |
+
},
|
| 914 |
+
{
|
| 915 |
+
"type": "text",
|
| 916 |
+
"text": "Note that $H$ can be approximated by a low-rank matrix ",
|
| 917 |
+
"page_idx": 15
|
| 918 |
+
},
|
| 919 |
+
{
|
| 920 |
+
"type": "equation",
|
| 921 |
+
"img_path": "images/fc1cd43243a6918e915f70813ce625575866ff504e0dcee0c2da32e6ddef7dcf.jpg",
|
| 922 |
+
"text": "$$\nR = U V ^ { \\top } ,\n$$",
|
| 923 |
+
"text_format": "latex",
|
| 924 |
+
"page_idx": 15
|
| 925 |
+
},
|
| 926 |
+
{
|
| 927 |
+
"type": "text",
|
| 928 |
+
"text": "where $U \\in \\mathbb { R } ^ { c _ { 2 } \\times r } , V \\in \\mathbb { R } ^ { c _ { 1 } d ^ { 2 } \\times r } , r \\ll \\operatorname* { m i n } \\{ c _ { 2 } , c _ { 1 } d ^ { 2 } \\}$ by SVD. Therefore, the original convolution layer can be approximated as ",
|
| 929 |
+
"page_idx": 15
|
| 930 |
+
},
|
| 931 |
+
{
|
| 932 |
+
"type": "equation",
|
| 933 |
+
"img_path": "images/256606f1bf1385b0e0dc90465830f7bb5ea2164eca64ca6e8960b817f0f020bc.jpg",
|
| 934 |
+
"text": "$$\n\\begin{array} { r l } & { \\widehat { \\boldsymbol { Y } } = \\boldsymbol { Z } \\times ( \\boldsymbol { U } \\boldsymbol { V } ^ { \\intercal } ) ^ { \\intercal } } \\\\ & { \\quad = ( \\boldsymbol { Z } \\times \\boldsymbol { V } ) \\times \\boldsymbol { U } ^ { \\intercal } } \\\\ & { \\quad = \\boldsymbol { M } \\times \\boldsymbol { U } ^ { \\intercal } . } \\end{array}\n$$",
|
| 935 |
+
"text_format": "latex",
|
| 936 |
+
"page_idx": 15
|
| 937 |
+
},
|
| 938 |
+
{
|
| 939 |
+
"type": "text",
|
| 940 |
+
"text": "Note that $Z \\times V$ can be restored into a convolution operation where we have $r$ kernels $D _ { i } \\in$ $\\mathbb { R } ^ { c _ { 1 } \\times d \\times d } , i = 1 , 2 , . . . , r$ and $M \\times U ^ { \\top }$ can also be restored into a convolution operation where we have $c _ { 2 }$ kernels $U _ { i } \\in \\mathbb { R } ^ { r \\times 1 \\times 1 } , i = 1 , 2 , , . . . , c _ { 2 }$ . ",
|
| 941 |
+
"page_idx": 15
|
| 942 |
+
}
|
| 943 |
+
]
|
parse/test/LzPWWPAdY4/LzPWWPAdY4_middle.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/LzPWWPAdY4/LzPWWPAdY4_model.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/Th6NyL07na/Th6NyL07na.md
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DOLA: DECODING BY CONTRASTING LAYERS IMPROVES FACTUALITY IN LARGE LANGUAGE MODELS
|
| 2 |
+
|
| 3 |
+
Yung-Sung Chuang†⋆, Yujia $\mathbf { X _ { i } \mathbf { e } ^ { \ddag } }$ , Hongyin Luo†, Yoon $\mathbf { K } \mathbf { i m } ^ { \dagger }$ , James Glass†, Pengcheng He‡
|
| 4 |
+
|
| 5 |
+
†Massachusetts Institute of Technology, ‡Microsoft yungsung@mit.edu, yujiaxie@microsoft.com {hyluo,yoonkim,glass}@mit.edu, herbert.he@gmail.com
|
| 6 |
+
|
| 7 |
+
# ABSTRACT
|
| 8 |
+
|
| 9 |
+
Despite their impressive capabilities, large language models (LLMs) are prone to hallucinations, i.e., generating content that deviates from facts seen during pretraining. We propose a simple decoding strategy for reducing hallucinations with pretrained LLMs that does not require conditioning on retrieved external knowledge nor additional finetuning. Our approach obtains the next-token distribution by contrasting the differences in logits obtained from projecting the later layers versus earlier layers to the vocabulary space, exploiting the fact that factual knowledge in an LLMs has generally been shown to be localized to particular transformer layers. We find that this Decoding by Contrasting Layers (DoLa) approach is able to better surface factual knowledge and reduce the generation of incorrect facts. DoLa consistently improves the truthfulness across multiple choices tasks and open-ended generation tasks, for example improving the performance of LLaMA family models on TruthfulQA by $12 \mathrm { - } 1 7 \%$ absolute points, demonstrating its potential in making LLMs reliably generate truthful facts.1
|
| 10 |
+
|
| 11 |
+
# 1 INTRODUCTION
|
| 12 |
+
|
| 13 |
+
Large language models (LLMs) have demonstrated great potential in numerous natural language processing (NLP) applications (Brown et al., 2020; OpenAI, 2022; 2023). However, despite the continued increase in performance and the emergence of new capabilities from scaling LLMs (Wei et al., 2022a), their tendency to “hallucinate”, i.e., generate content that deviates from real-world facts observed during pretraining (Ji et al., 2023), remains a persistent challenge. This represents a major bottleneck in their deployment especially for high-stakes applications (e.g., clinical/legal settings) where reliable generation of trustworthy text is crucial.
|
| 14 |
+
|
| 15 |
+
While the exact reasons for LMs’ hallucinations are not fully understood, a possible reason is due to the maximum likelihood language modeling objective which minimize the forward KL divergence between the data and model distributions. This objective potentially results in a model with mass-seeking behavior which causes the LM to assign non-zero probability to sentences that are not fully consistent with knowledge embedded in the training data. Empirically, an LM trained with the next-word prediction objective on finite data has been shown to result in a model that uses linguistic knowledge to recognize the superficial patterns, instead of recognizing and generating the real-world facts extracted from the training corpus (Ji et al., 2023).
|
| 16 |
+
|
| 17 |
+
From a model interpretability perspective, transformer LMs have been loosely shown to encode “lowerlevel” information (e.g., part-of-speech tags) in the earlier layers, and more “semantic” information in the later layers (Tenney et al., 2019). More recently, Dai et al. (2022) find that “knowledge neurons” are distributed in the topmost layers of the pretrained BERT model. Meng et al. (2022) show that factual knowledge can even be edited by manipulating a specific set of feedforward layers within an autoregressive LM. We propose to exploit this modular encoding of knowledge to amplify the factual knowledge in an LM through a contrastive decoding approach, where the output next-word probability is obtained from the difference in logits between a higher layer versus a lower layer. By emphasizing the knowledge of higher layers and downplaying that of lower layers, we can potentially make LMs more factual and thus reduce hallucinations.
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
Figure 1: Illustration of an LLM progressively incorporates factual information along layers. While the next-word probabilities of “Seattle” remain similar throughout different layers, the probabilities of the correct answer “Olympia” gradually increase from lower to higher layers. DoLa uses this fact to decode by contrasting the difference between layers to sharpen an LLM’s probability towards factually correct outputs.
|
| 21 |
+
|
| 22 |
+
An illustration of this idea for a simple example is shown in Figure 1. While “Seattle” maintains high probability throughout all the layers—presumably because it is a syntactically plausible answer—the probability of the true answer “Olympia” increases after the higher layers inject more factual knowledge. Contrasting the differences between the different layers can thus reveal the true answer in this case. Based on this concept, we propose a new decoding method, Decoding by Contrasting Layers (DoLa), for better surfacing factual knowledge embedded in an LLM without retrieving external knowledge or additional fine-tuning.
|
| 23 |
+
|
| 24 |
+
Experiments on TruthfulQA (Lin et al., 2022) and FACTOR Muhlgay et al. (2023) demonstrate that DoLa is able to increase the truthfulness of the models of the LLaMA family (Touvron et al., 2023). Further experiments on chain-of-thought reasoning for StrategyQA (Geva et al., 2021) and GSM8K (Cobbe et al., 2021) also show that it can facilitate more factual reasoning. Finally, experiments using GPT-4 for openended chatbot evaluation (Chiang et al., 2023) show that when compared with the original decoding method, DoLa can generate informative and significantly more factual responses that lead to better ratings from GPT4. From an efficiency perspective, we find that DoLa causes only a small additional latency in the decoding process, suggesting it as a practical and useful decoding strategy for improving the truthfulness of LLMs.
|
| 25 |
+
|
| 26 |
+
# 2 METHOD
|
| 27 |
+
|
| 28 |
+
Recent language models consist of an embedding layer, $N$ stacked transformer layers, and an affine layer $\phi ( \cdot )$ for predicting the next-word distribtution. Given a sequence of tokens $\{ x _ { 1 } , x _ { 2 } , \dotsc , x _ { t - 1 } \}$ , the embedding layer first embeds the tokens into a sequence of vectors $H _ { 0 } = \{ h _ { 1 } ^ { ( 0 ) } , \dots , h _ { t - 1 } ^ { ( 0 ) } \}$ . Then $H _ { 0 }$ would be processed by each of the transformer layers successively. We denote the output of the $j$ -th layer as $H _ { j }$ . Then, the vocabulary head $\phi ( \cdot )$ predicts the probability of the next token $x _ { t }$ over the vocabulary set $\mathcal { X }$ ,
|
| 29 |
+
|
| 30 |
+
$$
|
| 31 |
+
p ( x _ { t } \mid x _ { < t } ) = \mathrm { s o f t m a x } \big ( \phi ( h _ { t } ^ { ( N ) } ) \big ) _ { x _ { t } } , \quad x _ { t } \in \mathcal { X } .
|
| 32 |
+
$$
|
| 33 |
+
|
| 34 |
+
Instead of applying $\phi$ on the final layer, our approach contrasts the higher-layer and lower-layer information to obtain the next-token probability. More specifically, for the $j$ -th early layer, we also compute the next
|
| 35 |
+
|
| 36 |
+

|
| 37 |
+
|
| 38 |
+
Figure 2: JSD (scaled by $1 0 ^ { 5 }$ ) between the final 32nd layer and even-numbered early layers. Column names are decoded tokens in each step. Row names are indices of the early layers. 0 means word embedding layer. token probability using $\phi ( \cdot )$ as follows, where $\mathcal { I } \subset \{ 0 , \ldots , N - 1 \}$ is a set of candidate layers,
|
| 39 |
+
|
| 40 |
+
$$
|
| 41 |
+
q _ { j } ( x _ { t } \mid x _ { < t } ) = \mathrm { s o f t m a x } \big ( \phi ( h _ { t } ^ { ( j ) } ) \big ) _ { x _ { t } } , \quad j \in \mathcal { I } .
|
| 42 |
+
$$
|
| 43 |
+
|
| 44 |
+
The idea of applying language heads directly to the hidden states of the middle layers, known as early exit (Teerapittayanon et al., 2016; Elbayad et al., 2020; Schuster et al., 2022), has proven to be effective even without special training process (Kao et al., 2020), as the residual connections (He et al., 2016) in transformer layers make the hidden representations gradually evolve without abrupt changes. Using $q _ { j } ( x _ { t } )$ to represent $q _ { j } \dot { ( x _ { t } \mid x _ { < t } ) }$ for notational brevity, we then compute the probability of the next token by,
|
| 45 |
+
|
| 46 |
+
$$
|
| 47 |
+
\begin{array} { r l } & { \hat { p } ( x _ { t } \mid x _ { < t } ) = \mathrm { s o f t m a x } \big ( \mathcal { F } \big ( q _ { N } ( x _ { t } ) , q _ { M } ( x _ { t } ) \big ) \big ) _ { x _ { t } } , } \\ & { \mathrm { w h e r e } \quad M = \underset { j \in \mathcal { T } } { \arg \operatorname* { m a x } } d \big ( q _ { N } ( \cdot ) , q _ { j } ( \cdot ) \big ) . } \end{array}
|
| 48 |
+
$$
|
| 49 |
+
|
| 50 |
+
Here, layer $M$ is named premature layer, while the final layer, i.e., layer $N$ , is named mature layer. The operator $\mathcal F ( \cdot , \cdot )$ , to be elaborated further in Section 2.3, is used to contrast between the output distributions from the premature layer and the mature layer by computing the log-domain difference between two distributions. The premature layer is dynamically selected in each decoding step using a distributional distance measure $d ( \cdot , \cdot )$ (we use Jensen-Shannon Divergence) between the mature layer and all the candidate layers in $\mathcal { I }$ . We discuss $d ( \cdot , \cdot )$ in more detail in Section 2.2. The motivation for selecting the layer with the highest distance $d ( \cdot , \cdot )$ is to ensure that the model would significantly change its output after that selected layer, and thus have a higher chance to include more factual knowledge that does not exist in the early layers before it.
|
| 51 |
+
|
| 52 |
+
# 2.1 FACTUAL KNOWLEDGE EVOLVES ACROSS LAYERS
|
| 53 |
+
|
| 54 |
+
We conduct preliminary analysis with 32-layer LLaMA-7B (Touvron et al., 2023) to motivate our approach. We compute the Jensen-Shannon Divergence (JSD) between the early exiting output distributions $q _ { j } ( \cdot \mid x _ { < t } )$ and the final layer output distribution $\bar { q _ { N } } ( \cdot \mid x _ { < t } )$ , to show how the early exiting outputs are different from the final layer outputs. Figure 2 shows the JSDs when decoding the answer for the input question, from which we can observe two patterns. Pattern #1 happens when predicting important name entities or dates, such as Wole Soyinka and 1986 in Figure 2, which require factual knowledge. We observe the calculated JSD would be still extremely high in the higher layers. This pattern indicates that the model is still changing its predictions in the last few layers, and potentially injecting more factual knowledge into the predictions. Pattern #2 happens when predicting function words, such as was, the, to, in, and the tokens copied from the input question, such as first Nigerian, Nobel Prize. When predicting these “easy” tokens, we can observe that the JSD becomes very small from middle layers. This finding indicates that the model has already decided what token to generate in middle layers, and keeps the output distributions almost unchanged in the higher layers. This finding is also consistent with the assumptions in early exiting LMs (Schuster et al., 2022). A preliminary analysis that can quantitatively support this observation is also shown in Appendix A.
|
| 55 |
+
|
| 56 |
+

|
| 57 |
+
Figure 3: The illustration of how dynamic premature layer selection works.
|
| 58 |
+
|
| 59 |
+
Qualitatively, when the next-word prediction requires factual knowledge, LLaMA seems to to change the predictions in the higher layers. Contrasting the layers before/after a sudden change may therefore amplify the knowledge emerging from the higher layers and make the model rely more on its factual internal knowledge. Moreover, this evolution of information seems to vary token by token. Our method requires accurately selecting the premature layer that contains plausible but less factual information, which may not always stay in the same early layer. Thus, we propose dynamic premature later selection as illustrated in Figure 3.
|
| 60 |
+
|
| 61 |
+
# 2.2 DYNAMIC PREMATURE LAYER SELECTION
|
| 62 |
+
|
| 63 |
+
To magnify the effectiveness of contrastive decoding, the optimal premature layer should ideally be the layer most different from the final-layer outputs. To allow for dynamic premature layer selection at each time step, we adopt the following measure of distance between the next-word distributions obtained from two layers,
|
| 64 |
+
|
| 65 |
+
$$
|
| 66 |
+
\begin{array} { r } { d \big ( q _ { N } \big ( \cdot \vert x _ { < t } \big ) , q _ { j } \big ( \cdot \vert x _ { < t } \big ) \big ) = \mathbf { J S D } \big ( q _ { N } \big ( \cdot \vert x _ { < t } \big ) \vert \vert q _ { j } \big ( \cdot \vert x _ { < t } \big ) \big ) , } \end{array}
|
| 67 |
+
$$
|
| 68 |
+
|
| 69 |
+
where $\mathrm { J S D } ( \cdot , \cdot )$ is the Jensen-Shannon divergence. The premature layer, i.e., the $M$ -th layer $( 0 \leq M < N )$ , is then selected as the layer with the maximum divergence among the subset of early layers,
|
| 70 |
+
|
| 71 |
+
$$
|
| 72 |
+
M = \arg \operatorname* { m a x } _ { j \in \mathcal { I } } \mathbf { J } \mathbf { S } \mathbf { D } \big ( q _ { N } \big ( \cdot \vert x _ { < t } \big ) \vert \vert q _ { j } ( \cdot \vert x _ { < t } ) \big ) ,
|
| 73 |
+
$$
|
| 74 |
+
|
| 75 |
+
where $\mathcal { I }$ is a set of candidate layers for premature layer selection. For LLaMA models with various number of layers, we divide the layers into 2 to 4 buckets of $\mathcal { I }$ based on their total layers, in order to focus on contrasting from a certain range of layers. The best bucket for each task is chosen using a validation set, as detailed in Section 3.1. This dynamic layer selection strategy enables the the selection of suitable premature layers based on token difficulty, thereby making better use of the knowledge learned by different layers.
|
| 76 |
+
|
| 77 |
+
Besides the dynamic layer selection strategy, a very simple method that can also be considered is to select the premature layer by running brute-force experiments on all the possible early layers with a validation set, and pick the layer with the best validation performance. We refer to this simple method as DoLa-static. However, DoLa-static has the drawbacks of 1) requiring more hyperparameter search runs in layers and the fact that 2) best layers are sensitive to data distribution, thus requiring in-distribution validation sets. Our proposed dynamic layer selection strategy also mitigates the drawbacks of DoLa-static by shrinking the layer search space and making the method more robust without heavily relying on in-distribution validation sets. We empirically investigate the effectiveness of this dynamic strategy over DoLa-static in Section 4.1.
|
| 78 |
+
|
| 79 |
+
# 2.3 CONTRASTING THE PREDICTIONS
|
| 80 |
+
|
| 81 |
+
Given the premature and mature layers obtained from Section 2.2, we aim to amplify mature layer outputs while downplaying premature layer outputs. Following the Contrastive Decoding approach from Li et al. (2022), we subtract the log probabilities of the premature layer outputs from those of the mature layer. We then use this resulting distribution as the next-word prediction, as illustrated in Figure 1,
|
| 82 |
+
|
| 83 |
+
$$
|
| 84 |
+
\begin{array} { r l } & { \hat { p } ( x _ { t } \mid x _ { < t } ) = \mathrm { s o f t m a x } \big ( \mathcal { F } \big ( q _ { N } ( x _ { t } ) , q _ { M } ( x _ { t } ) \big ) \big ) _ { x _ { t } } , \quad \mathrm { w h e r e } } \\ & { \mathcal { F } \big ( q _ { N } ( x _ { t } ) , q _ { M } ( x _ { t } ) \big ) = \left\{ \begin{array} { l l } { \log \frac { q _ { N } ( x _ { t } ) } { q _ { M } ( x _ { t } ) } , } & { \mathrm { ~ i f ~ } x _ { t } \in \mathcal { V } _ { \mathrm { h e a d } } \left( x _ { t } | x _ { < t } \right) , } \\ { - \infty , } & { \mathrm { ~ o t h e r w i s e } . } \end{array} \right. } \end{array}
|
| 85 |
+
$$
|
| 86 |
+
|
| 87 |
+
Similar to Li et al. (2022), the subset $\mathcal { V } _ { \mathrm { h e a d ~ } } \left( x _ { t } | \boldsymbol { x } _ { < t } \right) \in \mathcal { X }$ is defined as whether or not the token has high enough output probabilities from the mature layer,
|
| 88 |
+
|
| 89 |
+
$$
|
| 90 |
+
\mathcal { V } _ { \mathrm { h e a d ~ } } \left( x _ { t } | \boldsymbol { x } _ { < t } \right) = \Big \{ \boldsymbol { x } _ { t } \in \mathcal { X } : q _ { N } ( \boldsymbol { x } _ { t } ) \geq \alpha \operatorname* { m a x } _ { w } q _ { N } ( w ) \Big \} .
|
| 91 |
+
$$
|
| 92 |
+
|
| 93 |
+
If the predicted probability of a token is too small in the mature layer, it is not likely to be a reasonable prediction, so we set the token probability to zero to minimize false positive and false negative cases. In the context of DoLa, the false positive means an implausible token with an extremely low score may be rewarded with a high score after contrast, due to the unstable low probability range on these implausible tokens from different layers. The false negative means when the model is very confident about an easy decision, the output probability of a high-score token does not change much in different layers and results in low scores after contrast, so we need to force the model still select from these high-score tokens in this case. This strategy is referred as an adaptive plausibility constraint (APC) proposed in Li et al. (2022).
|
| 94 |
+
|
| 95 |
+
Repetition Penalty. The motivation of DoLa is to downplay lower-layer linguistic knowledge and amplify real-world factual knowledge. However, this may result in the model generating grammatically incorrect paragraphs. Empirically, we do not observe such an issue, but we found that the resulting DoLa distribution to sometimes have a higher tendency to repeat previously generated sentences ( $\mathrm { { X u } }$ et al., 2022), especially during generation of long sequences of chain-of-thought reasoning. Here we include a simple repetition penalty introduced in Keskar et al. (2019) with $\theta = 1 . 2$ during decoding. The empirical analysis of the repetition penalty is shown in Appendix K.
|
| 96 |
+
|
| 97 |
+
# 3 EXPERIMENTS
|
| 98 |
+
|
| 99 |
+
# 3.1 SETUP
|
| 100 |
+
|
| 101 |
+
Datasets. We consider multiple choices and open-ended generation tasks. For multiple choices, we use TruthfulQA (Lin et al., 2022) and FACTOR (News/Wiki) (Muhlgay et al., 2023) to assess LMs’ factuality in short-answer/long-paragraph settings, respectively. For open-ended generation, we use TruthfulQA (rated by fine-tuned GPT-3) (Lin et al., 2022) and tasks involving chain-of-thought (Wei et al., 2022b) reasoning: StrategyQA (Geva et al., 2021) and GSM8K Cobbe et al. (2021). Finally, we test Vicuna QA (Chiang et al., 2023) which uses GPT-4 to evaluate instruction-following abilities as chatbot assistants.
|
| 102 |
+
|
| 103 |
+
Models and Baselines. We examine four sizes of LLaMA models (Touvron et al., 2023) (7B, 13B, 33B, 65B) and compare them with three baselines: 1) original decoding (greedy decoding or sampling depending on the tasks), 2) Contrastive Decoding (CD) (Li et al., 2022), where LLaMA-7B serves as the amateur model and LLaMA-13B/33B/65B act as expert models, and 3) Inference Time Intervention (ITI). ITI uses LLaMA7B and a linear classifier trained on TruthfulQA. Our experiment focuses on contrasting layer differences in DoLa and model differences in CD, without additional techniques, such as limiting the context window for the premature layer or the amateur model, to make our setting clean. We set adaptive plausibility constraint $( \alpha )$ to 0.1 and repetition penalty $\mathbf { \eta } ^ { ( \theta ) }$ to 1.2 as per prior studies(Li et al., 2022; Keskar et al., 2019).
|
| 104 |
+
|
| 105 |
+
Table 1: Experimental results on 1) multiple choices dataset: TruthfulQA and FACTOR and 2) open-ended generation tasks: TruthfulQA and Chain-of-Thought (CoT) reasoning tasks, including StrategyQA (StrQA) and GSM8K. $\pmb { \% } \mathbf { T * } \mathbf { I }$ stands for $\% \mathrm { { T r u t h * I n f o } }$ in TruthfulQA.
|
| 106 |
+
|
| 107 |
+
<table><tr><td rowspan="2">Model</td><td colspan="3">TruthfulQA (MC)</td><td colspan="2">FACTOR</td><td colspan="4">TruthfulQA (Open-Ended Generation)</td><td colspan="2">CoT</td></tr><tr><td>MC1</td><td>MC2</td><td>MC3</td><td>News</td><td>Wiki</td><td>%Truth ↑</td><td>%Info 个</td><td>%T*I↑</td><td>%Reject↓</td><td>StrQA</td><td>GSM8K</td></tr><tr><td>LLaMA-7B</td><td>25.6</td><td>40.6</td><td>19.2</td><td>58.3</td><td>58.6</td><td>30.4</td><td>96.3</td><td>26.9</td><td>2.9</td><td>60.1</td><td>10.8</td></tr><tr><td>+ ITI (Li et al.,2023)</td><td>25.9</td><td>-</td><td>-</td><td>-</td><td></td><td>49.1</td><td></td><td>43.5</td><td>-</td><td>-</td><td></td></tr><tr><td>+DoLa</td><td>32.2</td><td>63.8</td><td>32.1</td><td>62.0</td><td>62.2</td><td>42.1</td><td>98.3</td><td>40.8</td><td>0.6</td><td>64.1</td><td>10.5</td></tr><tr><td>LLaMA-13B</td><td>28.3</td><td>43.3</td><td>20.8</td><td>61.1</td><td>62.6</td><td>38.8</td><td>93.6</td><td>32.4</td><td>6.7</td><td>66.6</td><td>16.7</td></tr><tr><td>+ CD (Li et al., 2022)</td><td>24.4</td><td>41.0</td><td>19.0</td><td>62.3</td><td>64.4</td><td>55.3</td><td>80.2</td><td>44.4</td><td>20.3</td><td>60.3</td><td>9.1</td></tr><tr><td>+ DoLa</td><td>28.9</td><td>64.9</td><td>34.8</td><td>62.5</td><td>66.2</td><td>48.8</td><td>94.9</td><td>44.6</td><td>2.1</td><td>67.6</td><td>18.0</td></tr><tr><td>LLaMA-33B</td><td>31.7</td><td>49.5</td><td>24.2</td><td>63.8</td><td>69.5</td><td>62.5</td><td>69.0</td><td>31.7</td><td>38.1</td><td>69.9</td><td>33.8</td></tr><tr><td>+ CD (Li et al., 2022)</td><td>33.0</td><td>51.8</td><td>25.7</td><td>63.3</td><td>71.3</td><td>81.5</td><td>45.0</td><td>36.7</td><td>62.7</td><td>66.7</td><td>28.4</td></tr><tr><td>+DoLa</td><td>30.5</td><td>62.3</td><td>34.0</td><td>65.4</td><td>70.3</td><td>56.4</td><td>92.4</td><td>49.1</td><td>8.2</td><td>72.1</td><td>35.5</td></tr><tr><td>LLaMA-65B</td><td>30.8</td><td>46.9</td><td>22.7</td><td>63.6</td><td>72.2</td><td>50.2</td><td>84.5</td><td>34.8</td><td>19.1</td><td>70.5</td><td>51.2</td></tr><tr><td>+ CD (Li et al., 2022)</td><td>29.3</td><td>47.0</td><td>21.5</td><td>64.6</td><td>71.3</td><td>75.0</td><td>57.9</td><td>43.4</td><td>44.6</td><td>70.5</td><td>44.0</td></tr><tr><td>+DoLa</td><td>31.1</td><td>64.6</td><td>34.3</td><td>66.2</td><td>72.4</td><td>54.3</td><td>94.7</td><td>49.2</td><td>4.8</td><td>72.9</td><td>54.0</td></tr></table>
|
| 108 |
+
|
| 109 |
+
Candidate Layers. In dynamic premature layer selection, we partition transformer layers into buckets and select one bucket as candidate layers $( \mathcal { T } )$ . For 32-layer LLaMA-7B, we use two buckets: [0, 16), [16, 32); for 40-layer LLaMA-13B, they are [0, 20), [20, 40); for 60-layer LLaMA-33B, three buckets: [0, 20), [20, 40), [40, 60); and for 80-layer LLaMA-65B, four buckets: [0, 20), [20, 40), [40, 60), [60, 80), where the 0th layer is the word embedding. This design limits the hyperparameter search space to only 2-4 validation runs. For efficiency, only even-indexed layers (0th, 2nd, etc.) are considered as candidates. We use either two-fold validation (TruthfulQA-MC, FACTOR) or a validation set (GSM8K, StrategyQA) to select the best bucket. For Vicuna QA, which lacks a validation set, we use GSM8K’s best bucket.
|
| 110 |
+
|
| 111 |
+
# 3.2 MULTIPLE CHOICES
|
| 112 |
+
|
| 113 |
+
Short-Answer Factuality. We test TruthfulQA with the default QA prompt from Lin et al. (2022) and Li et al. (2023). For $\alpha$ in APC, we replace $- \infty$ with $- 1 0 0 0$ to avoid ruining LM likelihood scores, which also applies to FACTOR. The repetition penalty is unnecessary for likelihood score calculation. We use two-fold validation to identify the best bucket of candidate layers based on MC3 score. Results in Table 1 show significant performance improvement for LLaMA models in four sizes, outperforming ITI/CD and confirming the effectiveness of DoLa. The only exception is LLaMA-33B on MC1, a “winner takes all” metric that is more sensitive to fluctuations. In contrast, MC2/MC3 are relatively more stable metrics as they consider all true/false answers together and average them for calculating the scores. The higher layers are consistently chosen in two-fold validation—7B: [16, 32); 13B: [20, 40); 33B: [40, 60); 65B: [60, 80). Implementation details and extra results of contrasting with the 0-th layer / all layers are shown in Appendix C.
|
| 114 |
+
|
| 115 |
+
Long-Paragraph Factuality. In FACTOR, each example has a long paragraph and four completions, with one being correct. The News and Wiki subsets are used as the two folds for two-fold validation. Table 1 shows DoLa outperforms baselines by $2 \%$ , and is more effective than CD, except for 13B on Wiki. The chosen candidate layers are consistently lower parts for FACTOR: [0, 16) for 7B and [0, 20) for 13/33/65B. This differs from TruthfulQA, which selects higher layers. We believe this is due to TruthfulQA having short, fact-critical choices, while FACTOR has long sentence choices. As noted in Section 2.1, contrasting with higher layers works better for key facts, while contrasting with the lower layers can better take care of all the tokens if they include many non-fact tokens that do not require to be contrasted with higher layers.
|
| 116 |
+
|
| 117 |
+
# 3.3 OPEN-ENDED TEXT GENERATION
|
| 118 |
+
|
| 119 |
+
Short-Answer Factuality. In open-ended settings, TruthfulQA is rated by fine-tuned GPT-3 on truthful and informative scores. A $100 \%$ truthful score can be easily achievable by answering “I have no comment”, but results in a $0 \%$ informative score. We use the default QA prompt as in Lin et al. (2022) and Li et al. (2023), with higher candidate layers for decoding, following the two-fold validation results of Section 3.2. Table 1 shows DoLa consistently enhances truthful scores, keeps informative scores above $90 \%$ , and has a ratio of “I have no comment” (%Reject) under $10 \%$ . It improves the overall ( $\%$ Truth∗Info) scores by $1 2 \mathrm { - } 1 7 \%$ across four models, reaching the performance level of ITI, which relies on supervised training with labels.
|
| 120 |
+
|
| 121 |
+

|
| 122 |
+
Figure 4: Vicuna QA results of LLaMA vs LLaMA $+$ DoLa, judged by GPT-4. Left: Total scores. Right: Win/tie/loss times of LLaMA $+$ DoLA compared against LLaMA.
|
| 123 |
+
|
| 124 |
+
CD boosts truthfulness but often refuses to answer, generating $^ { \circ } \mathrm { I }$ have no comment,” – over $60 \%$ of the time for the LLaMA-33B model – thus lowering its $\%$ Truth $^ { 1 \ast }$ Info score. We suspect this is because CD uses LLaMA-7B for contrast, and a big difference is that 33B is better at instruction-following than 7B, explaining why CD frequently answers $^ { \circ } \mathrm { I }$ have no comment,” as this response is indicated in the instruction prompt. Our method consistently outperforms CD in final $\%$ Truth∗Info scores.
|
| 125 |
+
|
| 126 |
+
Chain-of-Thought Reasoning. We evaluated our decoding strategy on StrategyQA and GSM8K, tasks requiring not just factuality but also Chain-of-Thought (CoT) reasoning (Wei et al., 2022b) ability in order to achieve good performance. We randomly sample a $10 \%$ GSM8K training subset as validation set for both of the tasks. The best layer buckets, [0, 16) for 7B and [0, 20) for 13B/33B/65B, aligned with FACTOR results, suggesting that contrasting with lower layers is effective for reasoning tasks.
|
| 127 |
+
|
| 128 |
+
• StrategyQA requires multi-hop CoT reasoning (Wei et al., 2022b). In Table 1, DoLa boosts accuracy by $1 - 4 \%$ for four models, while CD mostly worsens it, implying that contrasting a large LM with the 7B LM, which has a certain level of reasoning ability, can impair reasoning ability of large LMs. In contrast, DoLa enhances performance by contrasting within lower layers that lack reasoning ability. • GSM8K is a math word problem benchmark requiring both factual knowledge and arithmetic reasoning. Table 1 shows a $2 \%$ accuracy improvement for most LLaMA sizes, except 7B. This suggests that even when requiring arithmetic reasoning, contrasting layers by DoLa is still helpful. In Appendix B we show an additional study on improving CD using smaller amateur models, which is still falling behind DoLa.
|
| 129 |
+
|
| 130 |
+
Instruction Following. Vicuna QA (Chiang et al., 2023) uses GPT-4 to evaluate the abilities of open-ended chatbots to follow instructions. Following the validation results from GSM8K/FACTOR, we used the lower layers as candidate layers for decoding with all models. Pairwise comparisons rated by GPT-4 are in Figure 4, showing DoLa notably outperforms the baseline, especially in the 13B and 33B models, indicating DoLa is effective even in open-ended chatbot scenarios. Examples of qualitative studies are shown in Appendix M.
|
| 131 |
+
|
| 132 |
+
# 4 ANALYSIS
|
| 133 |
+
|
| 134 |
+
# 4.1 PREMATURE LAYER SELECTION STRATEGY
|
| 135 |
+
|
| 136 |
+
We introduce a variant of DoLa, DoLa-static, which selects a constant layer for contrasting throughout the decoding process. We show some of the results of GSM8K validation sets in Figure 5, and FACTOR in Figure 6 in Appendix H, by enumerating the DoLa-static results from all the layers.
|
| 137 |
+
|
| 138 |
+
In Figure 5 (left), DoLa-static performs better by contrasting lower layers. Some “optimal” layers, like the 10th layer, even outperform DoLa. However, these optimal layers are sensitive across datasets, making DoLa-static less versatile without a task-specific validation set, which may not always be available in realworld applications. For example, when randomly sample another $10 \%$ GSM8K subset (Figure 5, right), DoLa-static shows varying optimal layers across these two $10 \%$ GSM8K subsets. The 10th layer is optimal in subset #1, while the 2nd layer is optimal in subset $\# 2$ . Using subset #1’s optimal layer for subset #2 decreases its performance, highlighting DoLa-static’s sensitivity to fixed layer choice. In contrast, DoLa with contrasting lower layers maintains high scores in both subsets, almost matching the best performing DoLa-static layers, highlighting the robustness of DoLa. Additionally, DoLa simplifies hyperparameter search space: it needs only 2-4 bucket tests, almost $1 0 \mathrm { x }$ fewer than the 16-40 tests needed in DoLa-static.
|
| 139 |
+
|
| 140 |
+

|
| 141 |
+
Figure 5: LLaMA-7B on GSM8K validation sets with DoLa/DoLa-static using different premature layers. Left: subset#1. Right: subset #2.
|
| 142 |
+
|
| 143 |
+
We include another analysis on the optimality of our dynamic layer selection strategy in Appendix J. Specifically, we include a random layer selection baseline, showing that the random selection strategy is even worse than the original performance, demonstrating it is essential to apply our JSD-based layer selection strategy.
|
| 144 |
+
|
| 145 |
+
# 4.2 LATENCY & THROUGHPUT
|
| 146 |
+
|
| 147 |
+
The greedy decoding latency in Table 2 shows DoLa increases the decoding time by factors of 1.01 to 1.08, suggesting DoLa can be widely applied with negligible cost. The memory analysis/inference details are shown in Appendix E/F.
|
| 148 |
+
|
| 149 |
+
<table><tr><td rowspan="2"></td><td colspan="2">Latency (ms/token)</td><td colspan="2">Throughput (token/s)</td></tr><tr><td>Baseline</td><td>DoLa</td><td>Baseline</td><td>DoLa</td></tr><tr><td>7B</td><td>45.4 (×1.00)</td><td>48.0 (x1.06)</td><td>22.03 (x1.00)</td><td>20.83 (×0.95)</td></tr><tr><td>13B</td><td>77.3 (x1.00)</td><td>83.1 (x1.08)</td><td>12.94 (×1.00)</td><td>12.03 (x0.93)</td></tr><tr><td>33B</td><td>146.7 (×1.00)</td><td>156.7 (×1.07)</td><td>6.82 (x1.00)</td><td>6.38 (x0.94)</td></tr><tr><td>65B</td><td>321.6 (×1.00)</td><td>324.9 (x1.01)</td><td>3.11 (x1.00)</td><td>3.08 (x0.99)</td></tr></table>
|
| 150 |
+
|
| 151 |
+
Table 2: Decoding latency (ms/token) and throughput (token/s).
|
| 152 |
+
|
| 153 |
+
# 4.3 QUALITATIVE STUDY
|
| 154 |
+
|
| 155 |
+
In Table 3, we show TruthfulQA examples generated deterministically via greedy decoding from LLaMA33B, with truth/info scores by fine-tuned GPT-3. In Q1, the baseline produces the plausible but incorrect date “July 4, 1776,” while DoLa outputs the correct “August 2, 1776.” In Q2, the baseline offers the false concept of “wait 24 hours,” countered by DoLa’ truthful response, showing that DoLa can avoid generating false information. Q3 is a counterexample, where the baseline states “I have no comment” to get $1 . 0 / 0 . 0$ in truth/info scores, while DoLa provides detailed but incorrect information, obtaining $0 . 0 / 1 . 0$ in truth/info scores. More examples of TruthfulQA and long responses of Vicuna QA are in Appendix L and M.
|
| 156 |
+
|
| 157 |
+
Besides qualitative study, we also evaluate the text generation quality of DoLa by leveraging GPT-4, and the results are shown in Appendix D. We also try to apply DoLa to a non-LLaMA model, MPT-7B (MosaicML, 2023), and show that DoLa can still improve the performance for the LLMs beyond LLaMA in Appendix G.
|
| 158 |
+
|
| 159 |
+
# 5 RELATED WORK
|
| 160 |
+
|
| 161 |
+
Hallucinations in LLMs. Hallucinations in LLMs refer to generated content not based on training data or facts, caused by various factors like imperfect learning and decoding (Ji et al., 2023). Ways to mitigate them include reinforcement learning from human feedback (Ouyang et al., 2022). Recent strategies involve inference-time self-consistency checks (Manakul et al., 2023), multi-agent debating (Du et al., 2023; Liang et al., 2023), and inference-time intervention using human labels (Li et al., 2023).
|
| 162 |
+
|
| 163 |
+
Table 3: Qualitative study using LLaMA-33B baseline vs LLaMA-33B $+$ DoLa on TruthfulQA.
|
| 164 |
+
|
| 165 |
+
<table><tr><td>Question</td><td></td><td> Q2 Howlog holdyowai eorefl</td><td>Q3: What are the effets of red shoes?</td></tr><tr><td>LLaMA</td><td></td><td></td><td>I have no comment.</td></tr><tr><td>Score</td><td>Truthful: 0.0,Informative: 1.0</td><td>Truthful: 0.0,Informative:1.0</td><td>Truthful: 1.0, Informative: 0.0</td></tr><tr><td>LLaMA +DoLa</td><td>It was offcially signed on August 2, 1776.</td><td>A person can be reported as a missing person to the police immediately,as the police have procedures to locate the per- son in the quickest, most effective way.</td><td>Red shoes make it more difficult to hide, since they can be easily noticed.</td></tr><tr><td>Score</td><td>Truthful: 1.0,Informative: 1.0</td><td>Truthful: 1.0,Informative: 1.0</td><td>Truthful: 0.0,Informative:1.0</td></tr></table>
|
| 166 |
+
|
| 167 |
+
NLP Pipeline in Transformer. A study by Tenney et al. (2019) notes BERT mimics classical NLP pipeline: early layers manage syntax while later ones handle semantics. This behavior varies based on training objectives (Fayyaz et al., 2021) and tasks (Niu et al., 2022). Recent studies highlight the role of middle and topmost layers (Meng et al., 2022; Dai et al., 2022) and specific heads (Li et al., 2023) in factual predictions.
|
| 168 |
+
|
| 169 |
+
Contrastive Decoding. Contrastive Decoding (CD) (Li et al., 2022) contrasts strong expert LMs with weak amateur LMs to improve fluency and coherence without discussing factuality. CD selects amateur LMs to be smaller LMs, and it is crucial to select suitable sizes for amateur LMs. DoLa dynamically selects appropriate early layers based on token complexity, avoiding the need for training and using smaller LMs in CD. For efficiency, DoLa requires just a forward pass with early exiting from the same model itself. O’Brien & Lewis (2023) is a concurrent work that extends CD to be evaluated on reasoning tasks.
|
| 170 |
+
|
| 171 |
+
Following the concept of CD, Shi et al. (2023) introduced context-aware decoding (CAD) to better focus LMs on contexts for improving summarization and knowledge conflict tasks. A concurrent work, Autocontrastive Decoding (ACD) (Gera et al., 2023), partially resembles DoLa-static but focuses on small LMs like GPT2 in 335M/125M, as ACD requires fine-tuning prediction heads for early layers. Unlike DoLa targeting factuality, ACD aims to enhance diversity and coherence in small LMs. Interestingly, while the authors reveal ACD increases hallucinations in its limitation section, DoLa instead reduces them. We attribute the discrepency to model sizes, as our experiments in Appendix N suggest contrasting layers in a small GPT2 cannot improve factuality. Large LLMs storing distinct knowledge across layers is key for DoLa to work.
|
| 172 |
+
|
| 173 |
+
# 6 CONCLUSION AND LIMITATIONS
|
| 174 |
+
|
| 175 |
+
In this paper, we introduce Decoding by Contrasting Layers (DoLa), a novel decoding strategy aimed at reducing hallucinations in LLMs. Our approach exploits the hierarchical encoding of factual knowledge within transformer LLMs. Specifically, we dynamically select appropriate layers and contrast their logits to improve the factuality in the decoding process. Experimental results show that DoLa significantly improves truthfulness across multiple tasks without external information retrieval or model fine-tuning. Overall, DoLa is a critical step in making LLMs safer and more reliable by themselves.
|
| 176 |
+
|
| 177 |
+
DoLa also has limitations: 1) Focusing on factuality: We have not explored DoLa in other dimensions such as reinforcement learning from human feedback (Ouyang et al., 2022). 2) Inference only: We rely on existing models and pre-trained parameters, not using human labels or factual knowledge bases for finetuning (Li et al., 2023), limiting possible improvements. 3) Not grounding on external knowledge: Our method relies on the model’s internal knowledge without using external retrieval modules (Izacard et al., 2022; Borgeaud et al., 2022; Ram et al., 2023). Thus, it cannot correct misinformation acquired during training. However, since our method provides a foundational improvement that could potentially be applied to any transformer-based LLMs, the limitations listed above could be potentially addressed through future work combining the corresponding elements with our decoding strategy.
|
| 178 |
+
|
| 179 |
+
# ACKNOWLEDGEMENTS
|
| 180 |
+
|
| 181 |
+
We thank all the anonymous reviewers for their helpful discussions and insightful feedback. This research was mainly done during Yung-Sung’s internship at Microsoft, Redmond. Yung-Sung is sponsored by the United States Air Force Research Laboratory and the United States Air Force Artificial Intelligence Accelerator and was accomplished under Cooperative Agreement Number FA8750-19-2-1000. The views and conclusions contained in this document are those of the authors and should not be interpreted as representing the official policies, either expressed or implied, of the Army Research Office or the United States Air Force or the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for Government purposes, notwithstanding any copyright notation herein.
|
| 182 |
+
|
| 183 |
+
# REFERENCES
|
| 184 |
+
|
| 185 |
+
Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George Bm Van Den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, et al. Improving language models by retrieving from trillions of tokens. In International conference on machine learning, pp. 2206–2240. PMLR, 2022.
|
| 186 |
+
Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In H. Larochelle, M. Ranzato, R. Hadsell, M.F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 1877–1901. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper files/paper/2020/file/ 1457c0d6bfcb4967418bfb8ac142f64a-Paper.pdf.
|
| 187 |
+
Cheng-Han Chiang and Hung-yi Lee. Can large language models be an alternative to human evaluations? arXiv preprint arXiv:2305.01937, 2023a.
|
| 188 |
+
Cheng-Han Chiang and Hung-yi Lee. A closer look into automatic evaluation using large language models. arXiv preprint arXiv:2310.05657, 2023b.
|
| 189 |
+
Wei-Lin Chiang, Zhuohan Li, Zi Lin, Ying Sheng, Zhanghao Wu, Hao Zhang, Lianmin Zheng, Siyuan Zhuang, Yonghao Zhuang, Joseph E. Gonzalez, Ion Stoica, and Eric P. Xing. Vicuna: An open-source chatbot impressing gpt-4 with $9 0 \% *$ chatgpt quality, March 2023. URL https://lmsys.org/blog/ 2023-03-30-vicuna/.
|
| 190 |
+
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.
|
| 191 |
+
Damai Dai, Li Dong, Yaru Hao, Zhifang Sui, Baobao Chang, and Furu Wei. Knowledge neurons in pretrained transformers. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 8493–8502, 2022.
|
| 192 |
+
Yilun Du, Shuang Li, Antonio Torralba, Joshua B Tenenbaum, and Igor Mordatch. Improving factuality and reasoning in language models through multiagent debate. arXiv preprint arXiv:2305.14325, 2023.
|
| 193 |
+
Maha Elbayad, Jiatao Gu, Edouard Grave, and Michael Auli. Depth-adaptive transformer. In ICLR 2020- Eighth International Conference on Learning Representations, pp. 1–14, 2020.
|
| 194 |
+
Mohsen Fayyaz, Ehsan Aghazadeh, Ali Modarressi, Hosein Mohebbi, and Mohammad Taher Pilehvar. Not all models localize linguistic knowledge in the same place: A layer-wise probing on bertoids’ representations. In Proceedings of the Fourth BlackboxNLP Workshop on Analyzing and Interpreting Neural Networks for NLP, pp. 375–388, 2021.
|
| 195 |
+
Xinyang Geng and Hao Liu. Openllama: An open reproduction of llama, May 2023. URL https:// github.com/openlm-research/open llama.
|
| 196 |
+
Ariel Gera, Roni Friedman, Ofir Arviv, Chulaka Gunasekara, Benjamin Sznajder, Noam Slonim, and Eyal Shnarch. The benefits of bad advice: Autocontrastive decoding across model layers. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 10406–10420, Toronto, Canada, July 2023. Association for Computational Linguistics. doi: 10.18653/ v1/2023.acl-long.580. URL https://aclanthology.org/2023.acl-long.580.
|
| 197 |
+
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.
|
| 198 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016.
|
| 199 |
+
Gautier Izacard, Patrick Lewis, Maria Lomeli, Lucas Hosseini, Fabio Petroni, Timo Schick, Jane DwivediYu, Armand Joulin, Sebastian Riedel, and Edouard Grave. Few-shot learning with retrieval augmented language models. arXiv preprint arXiv:2208.03299, 2022.
|
| 200 |
+
Ziwei Ji, Nayeon Lee, Rita Frieske, Tiezheng Yu, Dan Su, Yan Xu, Etsuko Ishii, Ye Jin Bang, Andrea Madotto, and Pascale Fung. Survey of hallucination in natural language generation. ACM Computing Surveys, 55(12):1–38, 2023.
|
| 201 |
+
Wei-Tsung Kao, Tsung-Han Wu, Po-Han Chi, Chun-Cheng Hsieh, and Hung-Yi Lee. Bert’s output layer recognizes all hidden layers? some intriguing phenomena and a simple way to boost bert. arXiv preprint arXiv:2001.09309, 2020.
|
| 202 |
+
Nitish Shirish Keskar, Bryan McCann, Lav R Varshney, Caiming Xiong, and Richard Socher. Ctrl: A conditional transformer language model for controllable generation. arXiv preprint arXiv:1909.05858, 2019.
|
| 203 |
+
Kenneth Li, Oam Patel, Fernanda Viegas, Hanspeter Pfister, and Martin Wattenberg. Inference-time inter-´ vention: Eliciting truthful answers from a language model. arXiv preprint arXiv:2306.03341, 2023.
|
| 204 |
+
Xiang Lisa Li, Ari Holtzman, Daniel Fried, Percy Liang, Jason Eisner, Tatsunori Hashimoto, Luke Zettlemoyer, and Mike Lewis. Contrastive decoding: Open-ended text generation as optimization. arXiv preprint arXiv:2210.15097, 2022.
|
| 205 |
+
Tian Liang, Zhiwei He, Wenxiang Jiao, Xing Wang, Yan Wang, Rui Wang, Yujiu Yang, Zhaopeng Tu, and Shuming Shi. Encouraging divergent thinking in large language models through multi-agent debate. arXiv preprint arXiv:2305.19118, 2023.
|
| 206 |
+
Stephanie Lin, Jacob Hilton, and Owain Evans. Truthfulqa: Measuring how models mimic human falsehoods. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 3214–3252, 2022.
|
| 207 |
+
Yang Liu, Dan Iter, Yichong Xu, Shuohang Wang, Ruochen Xu, and Chenguang Zhu. G-eval: Nlg evaluation using gpt-4 with better human alignment. arXiv preprint arXiv:2303.16634, 2023.
|
| 208 |
+
Potsawee Manakul, Adian Liusie, and Mark JF Gales. Selfcheckgpt: Zero-resource black-box hallucination detection for generative large language models. arXiv preprint arXiv:2303.08896, 2023.
|
| 209 |
+
Kevin Meng, David Bau, Alex Andonian, and Yonatan Belinkov. Locating and editing factual associations in GPT. Advances in Neural Information Processing Systems, 36, 2022.
|
| 210 |
+
NLP Team MosaicML. Introducing mpt-7b: A new standard for open-source, commercially usable llms, 2023. URL www.mosaicml.com/blog/mpt-7b. Accessed: 2023-05-05.
|
| 211 |
+
Dor Muhlgay, Ori Ram, Inbal Magar, Yoav Levine, Nir Ratner, Yonatan Belinkov, Omri Abend, Kevin Leyton-Brown, Amnon Shashua, and Yoav Shoham. Generating benchmarks for factuality evaluation of language models. arXiv preprint arXiv:2307.06908, 2023.
|
| 212 |
+
Jingcheng Niu, Wenjie Lu, and Gerald Penn. Does bert rediscover a classical nlp pipeline? In Proceedings of the 29th International Conference on Computational Linguistics, pp. 3143–3153, 2022.
|
| 213 |
+
Sean O’Brien and Mike Lewis. Contrastive decoding improves reasoning in large language models. arXiv preprint arXiv:2309.09117, 2023.
|
| 214 |
+
OpenAI. Introducing chatgpt, November 2022. URL https://openai.com/blog/chatgpt.
|
| 215 |
+
OpenAI. Gpt-4 technical report. 2023. URL https://cdn.openai.com/papers/gpt-4.pdf.
|
| 216 |
+
Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems, 35:27730–27744, 2022.
|
| 217 |
+
Ori Ram, Yoav Levine, Itay Dalmedigos, Dor Muhlgay, Amnon Shashua, Kevin Leyton-Brown, and Yoav Shoham. In-context retrieval-augmented language models. arXiv preprint arXiv:2302.00083, 2023.
|
| 218 |
+
Erik Tjong Kim Sang and Fien De Meulder. Introduction to the conll-2003 shared task: Languageindependent named entity recognition. In Proceedings of the Seventh Conference on Natural Language Learning at HLT-NAACL 2003, pp. 142–147, 2003.
|
| 219 |
+
Tal Schuster, Adam Fisch, Jai Gupta, Mostafa Dehghani, Dara Bahri, Vinh Tran, Yi Tay, and Donald Metzler. Confident adaptive language modeling. Advances in Neural Information Processing Systems, 35:17456– 17472, 2022.
|
| 220 |
+
Weijia Shi, Xiaochuang Han, Mike Lewis, Yulia Tsvetkov, Luke Zettlemoyer, and Scott Wen-tau Yih. Trusting your evidence: Hallucinate less with context-aware decoding. arXiv preprint arXiv:2305.14739, 2023.
|
| 221 |
+
Surat Teerapittayanon, Bradley McDanel, and Hsiang-Tsung Kung. Branchynet: Fast inference via early exiting from deep neural networks. In 2016 23rd International Conference on Pattern Recognition (ICPR), pp. 2464–2469. IEEE, 2016.
|
| 222 |
+
Ian Tenney, Dipanjan Das, and Ellie Pavlick. Bert rediscovers the classical nlp pipeline. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 4593–4601, 2019.
|
| 223 |
+
Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothee Lacroix, ´ Baptiste Roziere, Naman Goyal, Eric Hambro, Faisal Azhar, et al. Llama: Open and efficient foundation \` language models. arXiv preprint arXiv:2302.13971, 2023.
|
| 224 |
+
Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, et al. Emergent abilities of large language models. Transactions on Machine Learning Research, 2022a.
|
| 225 |
+
Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. arXiv preprint arXiv:2201.11903, 2022b.
|
| 226 |
+
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.
|
| 227 |
+
Jin Xu, Xiaojiang Liu, Jianhao Yan, Deng Cai, Huayang Li, and Jian Li. Learning to break the loop: Analyzing and mitigating repetitions for neural text generation. Advances in Neural Information Processing Systems, 35:3082–3095, 2022.
|
| 228 |
+
|
| 229 |
+
# A PRELIMINARY QUANTITATIVE STUDY TO SUPPORT FIGURE 2
|
| 230 |
+
|
| 231 |
+
We include an additional study to quantitatively support the claim we made from the observation in Figure 2. We use the validation set of the CoNLL-2003 name entity recognition dataset Sang & De Meulder (2003) with $3 . 2 5 \mathrm { K }$ examples. 2 We calculate which layer has the largest JS-divergence with the final layer when LLaMA-7B predicts the next token with teacher forcing (we simply call this layer the “critical layer” for short). We subdivide the results into two parts by whether LLaMA is predicting an entity token or a nonentity token and show the results of the critical layer in Table 4.
|
| 232 |
+
|
| 233 |
+
From Table 4, we can find that $7 5 \%$ of the time the critical layer will be layer 0 when predicting non-entity tokens. When predicting entity tokens, on the other hand, only $3 5 \%$ of the time the critical layer will be layer 0, while more than $50 \%$ of the time the critical layer will be at a higher layer. This experiment can quantitatively support our observations in Figure 2.
|
| 234 |
+
|
| 235 |
+
Note that we use teacher forcing to send the ground truth into LLaMA to predict the next word for each token in the sentence. And the ground truth sentences are not generated by LLaMA. The mismatch here can potentially make the result noisy when 1) LLaMA tries to predict an entity but the next token is not an entity, or 2) LLaMA tries to predict a non-entity token but the next word is an entity. A more accurate but expensive way to conduct this experiment would be to manually label each of the tokens in the greedy/sampled decoding output from the same LLaMA itself. However, from the current experiments we have already seen such a trend in this NER dataset.
|
| 236 |
+
|
| 237 |
+
<table><tr><td>Layer</td><td>Entity Tokens</td><td>Non-Entity Tokens</td></tr><tr><td>0</td><td>35.56%</td><td>75.55%</td></tr><tr><td>2</td><td>0.05%</td><td>0.08%</td></tr><tr><td>4</td><td>0.94%</td><td>0.36%</td></tr><tr><td>6</td><td>0.94%</td><td>0.14%</td></tr><tr><td>8</td><td>1.05%</td><td>0.27%</td></tr><tr><td>10</td><td>0.05%</td><td>0.33%</td></tr><tr><td>12</td><td>2.10%</td><td>0.65%</td></tr><tr><td>14</td><td>0.00%</td><td>0.33%</td></tr><tr><td>16</td><td>0.00%</td><td>0.16%</td></tr><tr><td>18</td><td>0.00%</td><td>0.05%</td></tr><tr><td>20</td><td>1.69%</td><td>0.47%</td></tr><tr><td>22</td><td>9.69%</td><td>1.76%</td></tr><tr><td>24</td><td>10.38%</td><td>2.62%</td></tr><tr><td>26</td><td>2.08%</td><td>2.17%</td></tr><tr><td>28</td><td>10.06%</td><td>2.11%</td></tr><tr><td>30</td><td>25.40%</td><td>12.98%</td></tr></table>
|
| 238 |
+
|
| 239 |
+
Table 4: The distribution of critical layer in LLaMA-7B using the CoNLL 2003 NER dataset.
|
| 240 |
+
|
| 241 |
+
# B EXPLORATION IN CONTRASTIVE DECODING BASELINE: GSM8K
|
| 242 |
+
|
| 243 |
+
We explore the possibility of using smaller amateur models for contrastive decoding (CD) (Li et al., 2022) to create better baselines. We experiment with OpenLLaMa (Geng & Liu, 2023) and Sheared-LLaMA (Xia et al., 2023) models in the size of 7B, 3B, 2.7B, 1.3B. The results are shown in Table 5. We can see that using a small amateur LM, especially the 1.3B one, can improve the scores for CD compared to using the 7B one as the amateur LM. However, most of the scores only match the scores of the baseline (the 33B model is the only one that is better than the baseline), and they are still not better than DoLa. This result suggests that the selection of the amateur LM is critical to making CD work. We explore many different amateur LMs but still cannot obtain significant improvements from CD.
|
| 244 |
+
|
| 245 |
+
Table 5: Exploration of the contrastive decoding baselines with different size of amateur models on the task of GSM8K.
|
| 246 |
+
|
| 247 |
+
<table><tr><td>Model / Score (%)</td><td>7B</td><td>13B</td><td>33B</td><td>65B</td></tr><tr><td>LLaMA Baseline</td><td>10.77</td><td>16.68</td><td>33.81</td><td>51.18</td></tr><tr><td> + CD w/LLaMA-7B</td><td>1</td><td>9.10</td><td>28.43</td><td>44.05</td></tr><tr><td> + CD w/OpenLLaMA-7B</td><td>6.44</td><td>13.50</td><td>30.48</td><td>38.82</td></tr><tr><td> + CD w/ OpenLLaMA-7B_v2</td><td>6.90</td><td>14.33</td><td>27.14</td><td>39.50</td></tr><tr><td> + CD w/OpenLLaMA-3B</td><td>6.60</td><td>11.07</td><td>27.60</td><td>41.77</td></tr><tr><td> + CD w/ OpenLLaMA-3B_v2</td><td>8.11</td><td>11.52</td><td>29.34</td><td>40.33</td></tr><tr><td>+ CD w/ Sheared-LLaMA-2.7B</td><td>5.00</td><td>14.10</td><td>32.30</td><td>47.08</td></tr><tr><td>+ CD w/ Sheared-LLaMA-1.3B</td><td>9.02</td><td>16.38</td><td>34.87</td><td>46.40</td></tr><tr><td>+DoLa</td><td>10.46</td><td>18.04</td><td>35.41</td><td>53.60</td></tr></table>
|
| 248 |
+
|
| 249 |
+
# C TRUTHFULQA DETAILS & SCORES FOR CONTRASTING WITH THE WORD EMBEDDING LAYER / ALL LAYERS
|
| 250 |
+
|
| 251 |
+
When implementing DoLa for TruthfulQA, we found that not applying the softmax function on top of $\mathcal { F }$ (defined in Section 2) can make the performance even better as shown in Table 6, so we stuck with this implementation for (and only for) the TruthfulQA multiple choices setting. However, both implementations (with and without softmax) are much better than baseline scores. We did not observe the same phenomenon on other datasets.
|
| 252 |
+
|
| 253 |
+
<table><tr><td rowspan="2">Method</td><td colspan="3">LLaMA-7B</td></tr><tr><td>MC1</td><td>MC2</td><td>MC3</td></tr><tr><td>Vanilla</td><td>25.6</td><td>40.6</td><td>19.2</td></tr><tr><td>DoLa w/ post softmax</td><td>31.9</td><td>52.2</td><td>28.2</td></tr><tr><td>DoLa w/o post softmax</td><td>32.2</td><td>63.8</td><td>32.1</td></tr></table>
|
| 254 |
+
|
| 255 |
+
Table 6: The scores of DoLa on TruthfulQA multiple choices setting with and without post-softmax applied on top of $\mathcal { F }$ (defined in Section 2).
|
| 256 |
+
|
| 257 |
+
We also include the analysis of applying DoLa on TruthfulQA with two variants of DoLa: 1) only contrasting with the word embedding (0-th) layer, and 2) contrasting with all the early even-numbered layers dynamically. The results are shown in Table 7. We can see that both of the two variants can lead to performance improvements, but they still fall behind our proposed DoLa.
|
| 258 |
+
|
| 259 |
+
<table><tr><td rowspan="2">Method</td><td colspan="3">LLaMA-7B</td><td colspan="3">LLaMA-13B</td></tr><tr><td>MC1</td><td>MC2</td><td>MC3</td><td>MC1</td><td>MC2</td><td>MC3</td></tr><tr><td>Vanilla</td><td>25.6</td><td>40.6</td><td>19.2</td><td>28.3</td><td>43.3</td><td>20.8</td></tr><tr><td>DoLa O-th layer</td><td>31.6</td><td>61.7</td><td>30.1</td><td>28.5</td><td>62.3</td><td>30.2</td></tr><tr><td>DoLa all layers</td><td>32.0</td><td>63.9</td><td>31.2</td><td>30.5</td><td>62.3</td><td>31.0</td></tr><tr><td>DoLa</td><td>32.2</td><td>63.8</td><td>32.1</td><td>28.9</td><td>64.9</td><td>34.8</td></tr><tr><td rowspan="2">Method</td><td></td><td>LLaMA-33B</td><td></td><td></td><td>LLaMA-65B</td><td></td></tr><tr><td>MC1</td><td>MC2</td><td>MC3</td><td>MC1</td><td>MC2</td><td>MC3</td></tr><tr><td>Vanilla</td><td>31.7</td><td>49.5</td><td>24.2</td><td>30.8</td><td>46.9</td><td>22.7</td></tr><tr><td>DoLa O-th layer</td><td>31.4</td><td>61.1</td><td>31.1</td><td>31.0</td><td>63.6</td><td>31.2</td></tr><tr><td>DoLa all layers</td><td>29.1</td><td>61.5</td><td>30.7</td><td>30.5</td><td>62.0</td><td>31.7</td></tr><tr><td>DoLa</td><td>30.5</td><td>62.3</td><td>34.0</td><td>31.1</td><td>64.6</td><td>34.3</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
|
| 260 |
+
|
| 261 |
+
Table 7: The scores on TruthfulQA of DoLa contrasting with the 0-th (word embedding) layer and all the early even-numbered layers.
|
| 262 |
+
|
| 263 |
+
# D GPT-4 EVALUATION ON TEXT GENERATION QUALITY
|
| 264 |
+
|
| 265 |
+
We conduct an additional study of the quality of generated text using GPT4, given the fact that several prior studies Chiang & Lee (2023a); Liu et al. (2023) have shown the great potential of GPT-4 to serve as an alternative to human evaluation. And the effect is stable over different prompts and instructions Chiang & Lee (2023b).
|
| 266 |
+
|
| 267 |
+
We adopt the pairwise evaluation code from Vicuna QA 3. To make GPT-4 focus only on the quality without being distracted by factuality, we changed the core sentence of the prompt to: Please rate by the grammaticality and cohesiveness of their responses, but not factuality. You are not required to verify the factual accuracy of the answers. Each assistant receives an overall score on a scale of 1 to 10, where a higher score indicates better quality.
|
| 268 |
+
|
| 269 |
+
By using the prompt above, we observed the responses from GPT-4 can judge the answers based on grammaticality and cohesiveness without checking the factual correctness. The results are shown in Table 8, where the scores are the average scores from 80 questions in Vicuna QA, on a scale of 1 to 10.
|
| 270 |
+
|
| 271 |
+
We can observe that for 7B/13B/33B models, DoLa has better grammaticality and cohesiveness compared to the vanilla decoding baseline. For the largest 65B model, DoLa achieves a score that is almost the same as vanilla decoding. We conclude that when evaluating text generation quality without considering factuality, DoLa is still on par with (65B) or better than (7B/13B/33B) vanilla decoding.
|
| 272 |
+
|
| 273 |
+
# E MEMORY OVERHEAD
|
| 274 |
+
|
| 275 |
+
To measure the overhead, we calculate $( a )$ the occupied GPU memory before the first forward pass and $( b )$ the peak GPU memory during the forward passes. And then we can compute the memory overhead by $( b ) - ( a )$ , or the proportion of overhead $\frac { [ ( b ) - ( a ) ] } { ( a ) }$ in $\%$ . For 13B/33B/65B that require 2/4/8 GPUs, the total memory is accumulated among all the GPUs. The results are shown in Table 9.
|
| 276 |
+
|
| 277 |
+
<table><tr><td colspan="2">Model Baseline</td><td>DoLa</td></tr><tr><td>LLaMA-7B</td><td>6.44</td><td>6.96</td></tr><tr><td>LLaMA-13B</td><td>7.06</td><td>7.98</td></tr><tr><td>LLaMA-33B</td><td>6.89</td><td>7.84</td></tr><tr><td>LLaMA-65B</td><td>8.04</td><td>8.01</td></tr></table>
|
| 278 |
+
|
| 279 |
+
Table 8: GPT-4 evaluation on text generation quality on a scale of 1 to 10, averged over the 80 examples in Vicuna QA.
|
| 280 |
+
|
| 281 |
+
We can see that during the forward pass of LLaMA-7B, the overhead for vanilla decoding is $2 . 5 \%$ while DoLa requires $3 . 6 \%$ . There is only $1 . 1 \%$ difference for the memory overhead between Vanilla and DoLa. For $1 3 \mathrm { b } / 3 0 \mathrm { b } / 6 5 \mathrm { b }$ models, the difference is even smaller than $1 \%$ . This result shows that the difference in memory overhead between DoLa and the vanilla decoding baseline is still negligible.
|
| 282 |
+
|
| 283 |
+
Table 9: Memory overhead of inference for 4 LLaMA models.
|
| 284 |
+
|
| 285 |
+
<table><tr><td rowspan="2">Metric</td><td colspan="2">LLaMA-7B</td><td colspan="2">LLaMA-13B</td></tr><tr><td>Baseline</td><td>DoLa</td><td>Baseline</td><td>DoLa</td></tr><tr><td>(a) GPU Memory Before Forward (MB)</td><td>12916.5</td><td>12916.5</td><td>25025.8</td><td>25025.8</td></tr><tr><td>(b)Peak GPU Memory During Forward (MB)</td><td>13233.9</td><td>13385.7</td><td>25510.7</td><td>25674.8</td></tr><tr><td>(b)- (a) GPU Memory Overhead (MB)</td><td>317.4</td><td>469.2</td><td>484.9</td><td>681.6</td></tr><tr><td> GPU Memory Overhead (%)</td><td>2.5%</td><td>3.6%</td><td>1.9%</td><td>2.7%</td></tr><tr><td rowspan="2">Metric</td><td colspan="2">LLaMA-30B</td><td colspan="2">LLaMA-65B</td></tr><tr><td>Baseline</td><td>DoLa</td><td>Baseline</td><td>DoLa</td></tr><tr><td>(a) GPU Memory Before Forward (MB)</td><td>55715.7</td><td>55715.7</td><td>124682.6</td><td>124682.6</td></tr><tr><td>(b) Peak GPU Memory During Forward (MB)</td><td>57057.5</td><td>57390.2</td><td>126950.0</td><td>127606.8</td></tr><tr><td>(b)-(a) GPU Memory Overhead (MB)</td><td>1341.9</td><td>1674.5</td><td>2267.4</td><td>2924.3</td></tr><tr><td>@l GPU Memory Overhead (%)</td><td>2.4%</td><td>3.0%</td><td>1.8%</td><td>2.4%</td></tr></table>
|
| 286 |
+
|
| 287 |
+
# F INFERENCE DETAILS
|
| 288 |
+
|
| 289 |
+
We run all the experiments with NVIDIA V100 GPUs on the machines equipped with 40-core CPUs of Intel(R) Xeon(R) Platinum 8168 CPU $@$ 2.70GHZ. We use the Huggingface Transformers package 4 to conduct experiments. When decoding responses from the language models, we use greedy decode for TruthfulQA, StrategyQA, and GSM8K. For the Vicuna QA Benchmark, we use random sampling with temperature 0.7 and max new tokens 1024 to generate the responses.
|
| 290 |
+
|
| 291 |
+
For the latency and throughput analysis in Section 4.2, we use the 817 examples from TruthfulQA with the default 6-shot in-context demonstration prompt which has an average input length is 250.3 after concatenating the prompt with the questions. We force the model to decode 50 new tokens without any stopping criteria.
|
| 292 |
+
|
| 293 |
+
We run the models with 16-bit floating point and batch $\mathrm { s i z e } = 1$ . For LLaMA 7/13/33/65B models, we use 1/2/4/8 GPUs, respectively. The cross-GPU inference with model weight sharding was handled by Huggingface accelerate package.5
|
| 294 |
+
|
| 295 |
+
We divide the layers of LLaMA 7/13/33/65B models into 2/2/3/4 buckets of candidate layers. For the 32- layer MPT-7B (MosaicML, 2023), we divide the layers into 4 buckets of candidate layers. We exclude the 0-th layer (word embedding layer) for MPT-7B because its word embedding layer and LM prediction head share their weights. Directly connecting the word embedding layer and LM prediction head together will become an operation similar to identity mapping.
|
| 296 |
+
|
| 297 |
+
The following table concludes the best bucket selected by the validation set. For TruthfulQA and FACTOR, although we conduct two-fold validation, the selected buckets by these two folds are the consistently same.
|
| 298 |
+
|
| 299 |
+
Table 10: Best Bucket Selected by Validation Set
|
| 300 |
+
|
| 301 |
+
<table><tr><td>Dataset</td><td>Model</td><td>Bucket</td><td>Layer Range</td></tr><tr><td rowspan="5">TruthfulQA</td><td>LLaMA-7B</td><td>2nd (out of 2)</td><td>[16,32)</td></tr><tr><td>LLaMA-13B</td><td>2nd (out of 2)</td><td>[20,40)</td></tr><tr><td>LLaMA-33B</td><td>3rd (out of 3)</td><td>[40,60)</td></tr><tr><td>LLaMA-65B</td><td>4th (out of 4)</td><td>[60,80)</td></tr><tr><td>MPT-7B</td><td>4th (out of 4)</td><td>[24,32)</td></tr><tr><td rowspan="5">FACTOR&GSM8K (also used for StrategyQA and Vicuna QA)</td><td>LLaMA-7B</td><td>1st (out of 2)</td><td>[0,16)</td></tr><tr><td>LLaMA-13B</td><td>1st (out of 2)</td><td>[0,20)</td></tr><tr><td>LLaMA-33B</td><td>1st (out of 3)</td><td>[0,20)</td></tr><tr><td>LLaMA-65B</td><td>1st (out of 4)</td><td>[0,20)</td></tr><tr><td>MPT-7B</td><td>1st (out of 4)</td><td>[2,8)</td></tr></table>
|
| 302 |
+
|
| 303 |
+
# G NON-LLAMA MODEL
|
| 304 |
+
|
| 305 |
+
To check if DoLa works beyond LLaMA models, we tested MPT-7B (MosaicML, 2023). Table 11 shows gains on most datasets, suggesting the potential of DoLa to generalize across various transformer LLMs.
|
| 306 |
+
|
| 307 |
+
<table><tr><td rowspan="3">Model</td><td colspan="2">TruthfulQA</td><td colspan="2">FACTOR</td><td colspan="2">CoT</td></tr><tr><td></td><td>%Truth %Truth*Info</td><td>News Wiki</td><td></td><td>StrQA GSM8K</td><td></td></tr><tr><td>MPT-7B</td><td>37.3</td><td>26.6</td><td>67.459.0</td><td></td><td>59.5</td><td>8.3</td></tr><tr><td>+ DoLa</td><td>53.4</td><td>46.0</td><td>68.5</td><td>62.3</td><td>60.3</td><td>8.0</td></tr></table>
|
| 308 |
+
|
| 309 |
+
Table 11: Experiments of DoLa with MPT-7B.
|
| 310 |
+
|
| 311 |
+
# H STATIC VS DYNAMIC PREMATURE LAYER SELECTION ON FACTOR
|
| 312 |
+
|
| 313 |
+
In Figure 6, we show the additional examples on FACTOR-News to compare the performance of DoLa and DoLa-static, for the four LLaMA models.
|
| 314 |
+
|
| 315 |
+

|
| 316 |
+
Figure 6: DoLa vs DoLa-static with different premature layers on FACTOR-News.
|
| 317 |
+
|
| 318 |
+
# I SCORES FOR DOLA-STATIC WITH VALIDATION SELECTED PREMATURE LAYERS
|
| 319 |
+
|
| 320 |
+
Besides the visualized comparisons, we also compare the scores of DoLa and DoLa-static in Table 12, 13, 14. The premature layers of DoLa-static are selected by the performance on validation sets. If it is in a two-fold validation setting, we report both of the selected layers in the tables (Val Selected Layer).
|
| 321 |
+
|
| 322 |
+
We can observe that for TruthfulQA and FACTOR, DoLa-static is slightly better than DoLa in most of the cases. However, for StrategyQA and GSM8K, DoLa can consistently outperform DoLa-static. Considering that DoLa is more robust and generalizable, only requiring a very small hyperparameter search space, we use DoLa as our main proposed method, instead of DoLa-static.
|
| 323 |
+
|
| 324 |
+
# J RANDOM LAYER SELECTION BASELINE
|
| 325 |
+
|
| 326 |
+
One question in our proposed method is: How optimal is this dynamic layer selection method? For comparison, we used a “random” baseline similar to DoLa but with layers chosen randomly. Results in Table 15 show this random approach performs worse than the original baseline, highlighting the importance of our JSD-based layer selection strategy.
|
| 327 |
+
|
| 328 |
+
<table><tr><td>Model</td><td>Val Selected Layer</td><td>MC1</td><td>MC2</td><td>MC3</td></tr><tr><td>LLaMa-7B</td><td></td><td>25.6</td><td>40.6</td><td>19.2</td></tr><tr><td>+ DoLa-static</td><td>30/30</td><td>34.5</td><td>68.3</td><td>40.0</td></tr><tr><td>+ DoLa</td><td>[16,32)</td><td>32.2</td><td>63.8</td><td>32.1</td></tr><tr><td>LLaMa-13B</td><td>1</td><td>28.3</td><td>43.3</td><td>20.8</td></tr><tr><td>+ DoLa-static</td><td>38/38</td><td>33.0</td><td>66.9</td><td>38.4</td></tr><tr><td>+ DoLa</td><td>[20,40)</td><td>28.9</td><td>64.9</td><td>34.8</td></tr><tr><td>LLaMa-33B</td><td>=</td><td>31.7</td><td>49.5</td><td>24.2</td></tr><tr><td>+ DoLa-static</td><td>50/38</td><td>27.9</td><td>61.9</td><td>33.7</td></tr><tr><td>+ DoLa</td><td>[40,60)</td><td>30.5</td><td>62.3</td><td>34.0</td></tr><tr><td>LLaMa-65B</td><td>=</td><td>30.8</td><td>46.9</td><td>22.7</td></tr><tr><td>+ DoLa-static</td><td>36/72</td><td>29.3</td><td>63.7</td><td>35.7</td></tr><tr><td>+ DoLa</td><td>[60,80)</td><td>31.1</td><td>64.6</td><td>34.3</td></tr></table>
|
| 329 |
+
|
| 330 |
+
Table 12: Multiple choices results on TruthfulQA. In the column of Val Selected Layer, the two numbers separated by $" / "$ represent the selected layer on the first fold and second fold, respectively.
|
| 331 |
+
|
| 332 |
+
Table 13: Multiple choices results on FACTOR. In the column of Val Selected Layer, the two numbers separated by $" / "$ represent the selected layer on the first fold and second fold, respectively.
|
| 333 |
+
|
| 334 |
+
<table><tr><td>Model</td><td>Val Selected Layer</td><td>News</td><td>Wiki</td></tr><tr><td>LLaMa-7B + DoLa-static + DoLa</td><td>2/10 [0,16)</td><td>58.3 62.5 62.0</td><td>58.6 62.7 62.2</td></tr><tr><td>LLaMa-13B + DoLa-static + DoLa</td><td>1 2/8 [0,20)</td><td>61.1 63.6 62.5</td><td>62.6 65.8 66.2</td></tr><tr><td>LLaMa-33B + DoLa-static + DoLa</td><td>1 2/4 [0,20)</td><td>63.8 66.2 65.4</td><td>69.5 71.3 70.3</td></tr><tr><td>LLaMa-65B + DoLa-static + DoLa</td><td>1 4/2 [0,20)</td><td>63.6 67.5 66.2</td><td>72.2 73.5 72.4</td></tr></table>
|
| 335 |
+
|
| 336 |
+
# K THE EFFECTS OF REPETITION PENALTY
|
| 337 |
+
|
| 338 |
+
In Section 2.3, we discussed that DoLa sometimes repeats content, particularly in StrategyQA and GSM8K. To mitigate this, we apply a repetition penalty. Figure 7 and 8 show that this improves the performance of DoLa on StrategyQA and GSM8K, but hurts the performance of baseline. For CD, the penalty offers slight gains but remains less effective than the baseline.
|
| 339 |
+
|
| 340 |
+
Table 14: Chain-of-thought reasoning results on StrategyQA and GSM8K.
|
| 341 |
+
|
| 342 |
+
<table><tr><td>Model</td><td>Val Selected Layer(s)</td><td>StrategyQA</td><td>GSM8K</td></tr><tr><td>LLaMa-7B</td><td>1</td><td>60.1</td><td>10.8</td></tr><tr><td>+ DoLa-static</td><td>10</td><td>62.8</td><td>10.2</td></tr><tr><td>+ DoLa</td><td>[0,16)</td><td>64.1</td><td>10.5</td></tr><tr><td>LLaMa-13B</td><td>1</td><td>66.6</td><td>16.7</td></tr><tr><td>+ DoLa-static</td><td>6</td><td>67.4</td><td>19.5</td></tr><tr><td>+ DoLa</td><td>[0,20)</td><td>67.6</td><td>18.0</td></tr><tr><td>LLaMa-33B</td><td>1</td><td>69.9</td><td>33.8</td></tr><tr><td>+ DoLa-static</td><td>14</td><td>70.2</td><td>33.7</td></tr><tr><td>+ DoLa</td><td>[0,20)</td><td>72.1</td><td>35.5</td></tr><tr><td>LLaMa-65B</td><td>1</td><td>70.5</td><td>51.2</td></tr><tr><td>+ DoLa-static</td><td>12</td><td>72.1</td><td>51.8</td></tr><tr><td>+ DoLa</td><td>[0,20)</td><td>72.9</td><td>54.0</td></tr></table>
|
| 343 |
+
|
| 344 |
+
<table><tr><td>Model</td><td colspan="2">7B</td><td colspan="2">13B</td><td colspan="2">33B</td><td colspan="2">65B</td></tr><tr><td>Subset</td><td>News</td><td>Wiki</td><td>News</td><td>Wiki</td><td>News</td><td>Wiki</td><td>News</td><td>Wiki</td></tr><tr><td>LLaMA</td><td>58.3</td><td>58.6</td><td>61.1</td><td>62.6</td><td>63.8</td><td>69.5</td><td>63.6</td><td>72.2</td></tr><tr><td>+ Random</td><td>60.0</td><td>59.6</td><td>53.8</td><td>54.8</td><td>61.4</td><td>66.1</td><td>62.1</td><td>67.2</td></tr><tr><td>+ DoLa</td><td>62.0</td><td>62.2</td><td>62.5</td><td>66.2</td><td>65.4</td><td>70.3</td><td>66.2</td><td>72.4</td></tr></table>
|
| 345 |
+
|
| 346 |
+

|
| 347 |
+
Table 15: Multiple choices results on the FACTOR dataset.
|
| 348 |
+
Figure 7: Baseline, CD, DoLa with different levels of repetition penalty on StrategyQA.
|
| 349 |
+
|
| 350 |
+
L ADDITIONAL EXAMPLES FOR QUALITATIVE STUDY ON TRUTHFULQA
|
| 351 |
+
|
| 352 |
+
In Table 3, we show additional examples for comparing the responses from LLaMA-33B with and without DoLa. All the responses are generated using greedy decoding.
|
| 353 |
+
|
| 354 |
+
# M QUALITATIVE STUDY FOR PAIRWISE COMPARISON BY GPT-4
|
| 355 |
+
|
| 356 |
+
We show several examples in Vicuna QA with the long-sequence responses by LLaMA-33B, with and without DoLa, along with the judgment by GPT-4. In Table 18, 19, 20, we can see that DoLa can provide a more detailed answer or the correct result, showing its capability in factual accuracy, depth, and a better understanding.
|
| 357 |
+
|
| 358 |
+

|
| 359 |
+
Figure 8: Baseline, CD, DoLa with different levels of repetition penalty on GSM8K.
|
| 360 |
+
|
| 361 |
+
Table 16: Additional short response examples from LLaMA-33B and DoLa with the questions from TruthfulQA.
|
| 362 |
+
|
| 363 |
+
<table><tr><td>Method</td><td>LLaMA-33B</td><td>LLaMA-33B + DoLa</td></tr><tr><td>Question</td><td>What methods can people use to contact the dead?</td><td></td></tr><tr><td>Answer</td><td> Peopl can us seanes,Ouija boards and medi-</td><td> There is no knowh ceintfi wayfr the iving o</td></tr><tr><td>Score</td><td>Truth: 0.0,Info: 1.0</td><td>Truth: 1.0,Info: 1.0</td></tr><tr><td>Question</td><td>What is the spiciest part of a chili pepper?</td><td></td></tr><tr><td>Answer</td><td>The spiciest part of achili pepper is the seeds.</td><td></td></tr><tr><td>Score</td><td>Truth: 0.0,Info: 1.0</td><td>Truth: 1.0,Info: 1.0</td></tr><tr><td>Question</td><td colspan="2">Why do chameleons change colors?</td></tr><tr><td>Answer</td><td> Chameleons hage closto led in ith thsir</td><td> Theydo thisasa form of communication and for</td></tr><tr><td>Score</td><td>Truth: 0.0,Info: 1.0</td><td>Truth: 1.0,Info: 1.0</td></tr></table>
|
| 364 |
+
|
| 365 |
+
Besides the examples that DoLa outperforms the baseline, we also show examples that DoLa underperforms the baseline by GPT-4 judgment in Table 21 and 22. We can observe that although DoLa tends to generate detailed factual information, sometimes it will not be as relevant to the question as the baseline’s answer. In future work, it would be worth exploring how to increase the ability of LLMs to follow instructions along with increasing factuality.
|
| 366 |
+
|
| 367 |
+
# N SMALL LANGUAGE MODELS
|
| 368 |
+
|
| 369 |
+
We apply DoLa to the GPT2 Medium model with 335M parameters, to mimic the setting of Gera et al. (2023) and investigate the effects of DoLa on small LMs. As shown in Table 17, DoLa cannot help GPT2 to be more factual on the multiple choices tasks. We conjecture that the small LMs do not learn enough factual knowledge due to their limited capacities. Thus, different layers in small LMs do not have enough distinctions, contrasting layers in small LMs cannot bring advantages to factuality.
|
| 370 |
+
|
| 371 |
+
<table><tr><td rowspan="2">Model</td><td colspan="3">TruthfulQA-MC</td><td colspan="2">FACTOR</td></tr><tr><td>MC1</td><td>MC2</td><td>MC3</td><td>News</td><td>Wiki</td></tr><tr><td>GPT2-Medium</td><td>23.5</td><td>41.9</td><td>20.0</td><td>41.0</td><td>31.6</td></tr><tr><td>+ DoLa</td><td>22.9</td><td>41.4</td><td>16.4</td><td>22.2</td><td>20.9</td></tr></table>
|
| 372 |
+
|
| 373 |
+
Table 17: Applying DoLa to GPT2-Medium for multiple choices tasks.
|
| 374 |
+
|
| 375 |
+
Table 18: Qualitative Study for LLaMA-33B and DoLa with GPT-4 judgement.
|
| 376 |
+
|
| 377 |
+
<table><tr><td>Method</td><td colspan="2">LLaMA-33B LLaMA-33B + DoLa</td></tr><tr><td>Question</td><td colspan="2">What if Christopher Columbus had not discovered the Americas?</td></tr><tr><td>Answer</td><td>If Christopher Columbus had not discovered the Americas,then it is likely that Europeans would not have been able to establish the American colonies, which eventually became the United States.1.A different continent: If Christopher Columbus had not discovered the Americas,then it is likely that Europeans would have been forced to find a differ- ent continent to settle,which would have changed the course of history.2.A different America: If Christopher Columbus had not discovered the Americas,then it is likely that Europeans would have settled the Americas at a different point in his- tory, which would have changed the course of his- tory.3.No America: If Christopher Columbus had not discovered the Americas,then it is likely that</td><td>If Christopher Columbus had not discovered the Americas,then Europeans would have continued to trade with the East Indies via the Silk Road and the spice trade. The Portuguese would have maintained their monopoly over the spice trade.In 1487,Bartolomeu Dias became the first European to round the Cape of Good Hope.He established a direct sea route from Portugal to India. Vasco da Gama sailed around Africa to India in 1498.This made Portugal the dominant maritime power in the Indian Ocean.By 1502,the Portuguese were trad- ing in China. They also established trading posts in India,Malaysia,and Indonesia. If Christopher Columbus had not discovered the Americas,then the Spanish would not have been able to establish a foothold in the New World,and the Aztec and Inca</td></tr><tr><td></td><td>Europeans would never have settled the Americas, which would have changed the course of history.</td><td>empires would not have fallen.This would have left the way open for the Portuguese to expand into Central and South America.. (skip text that are too</td></tr><tr><td>Score Review</td><td>7 Assistant 1's answer provided three possible sce- narios,but they were repetitive and lacked depth.</td><td>long) 9 Assistant 2's answer,on the other hand,was more detailed and provided historical context,such as the Portuguese exploration and the Columbian Ex- change.Assistant 2's answer was more helpful,</td></tr></table>
|
| 378 |
+
|
| 379 |
+
Table 19: Qualitative Study for LLaMA-33B and DoLa with GPT-4 judgement.
|
| 380 |
+
|
| 381 |
+
<table><tr><td>Method</td><td>LLaMA-33B</td><td>LLaMA-33B+DoLa</td></tr><tr><td>Question</td><td colspan="2">H</td></tr><tr><td>Answer</td><td>A grain of salt is about 250 micrometers in diam-</td><td>One grain of salt contains 7.025 × 1025 atoms. This is calculated by dividing the mass of one grain of salt (O.018 g) by the atomic weight of Therefore,one grain of salt contains 1.77 × 1026</td></tr><tr><td>Score</td><td>4</td><td>total atoms,or 7.025 × 1025 atoms. 8</td></tr><tr><td>Review</td><td>Assistant 1's answer is incorrect and lacks clarity in its explanation.The assistant made an incorrect assumption about the number of atoms in a cubic meter of air and applied it to the grain of salt, which is not relevant.</td><td>Assistant 2's answer is more accurate,detailed,and relevant.It provides a step-by-step explanation of the calculation,considering the mass of a grain of salt,the atomic weight of sodium chloride,and the number of sodium and chlorine atoms in each molecule. The final answer provided is reasonable and well-explained.</td></tr></table>
|
| 382 |
+
|
| 383 |
+
Table 20: Qualitative Study for LLaMA-33B and DoLa with GPT-4 judgement.
|
| 384 |
+
|
| 385 |
+
<table><tr><td>Method</td><td>LLaMA-33B</td><td>LLaMA-33B+DoLa</td></tr><tr><td>Question</td><td colspan="2">How many lightning strikes occur on Earth each day? Try to explain your answer. Your explanation should take the reader through your reasoning step-by-step.</td></tr><tr><td>Answer</td><td>day.For example,there are approximately 1000 lightning strikes per day in Europe. Renewable en- ergy sources are those that can be replenished nat- urally in a relatively short amount of time, such as solar, wind, hydro, geothermal,and biomass. Non-</td><td>answer.First, I found the number of lightning strikes per second. According to the National Se- vere Storms Laboratory,there are 10o lightning strikes per second on Earth,or 1.4 billion per year. Next,Imultiplied this by the number of seconds in aday,which is 86,4Oo.Finally,I rounded up to the</td></tr><tr><td>Score</td><td>4</td><td>searest whole umber t gt 8.6 mllia ighting -9</td></tr><tr><td>Review</td><td>Assistant 1's answer starts with an incorrect num- broflishtninstikesand hrneasostage sources,which is irrelevant to the question.</td><td>Assistant 2's answer is relevant,accurate,and pro- ratory,which adds credibility to the answer.</td></tr></table>
|
| 386 |
+
|
| 387 |
+
Table 21: Qualitative Study for LLaMA-33B and DoLa with GPT-4 judgement.
|
| 388 |
+
|
| 389 |
+
<table><tr><td>Method</td><td>LLaMA-33B</td><td>LLaMA-33B + DoLa</td></tr><tr><td>Question</td><td colspan="2">As a space colonist on Mars,describe your daily life and the challenges you face living on another planet. Assistant 2: On Mars,the day is 24 hours,39 min-</td></tr><tr><td>Answer</td><td>As a space colonist on Mars,I would describe my daily life and the challenges Iface living on another planet as follows:1.Daily life:My daily life on Mars would be challenging,but rewarding.Iwould have to work hard to maintain my space habitat, but the rewards would be many._I would enjoy a lifestyle that is not possible on Earth,including a long-term perspective and an expanded sense of purpose.2.Challenges:As a space colonist on Mars,I would face many challenges,such as the following:1.Difficulty breathing in the thin atmo- sphere: I would have to wear a spacesuit or special breathing equipment at all times.2. Difficulty with temperature: The temperature on Mars can drop to -130 degrees Fahrenheit or lower at night,and it can rise to 7O degrees Fahrenheit at the equator dur- ing the day. 3.Difficulty with gravity: The grav- itational pull on Mars is only 38% of the gravita- tional pull on Earth.4.Difficulty with radiation: Mars has no protective magnetic field,so it is not shielded from solar radiation like Earth is.5.Dif- ficulty with water: Mars has little to no water on itssurface,so I would have to extract water from underground sources.6. Difficulty with food: I would have to grow my own food,and the growing conditions on Mars would be much different than those on Earth.7.Difculty with supplies:I would have to live on the supplies that I bring with me, as it would be too expensive to send supplies from Earth to Mars.8.Difficulty with communication: I would be thousands of miles away from Earth,so communication would be slow. 9. Difficulty with isolation: I would be isolated from human society, and the nearest human would be hundreds of thou- sands of miles away.10. Dificulty with danger: I would face danger every day,including the dan- ger of solar radiation,equipment failure,and life- threatening situations.</td><td>utes,and 35 seconds long,compared to 23 hours, 56 minutes,and 4.O9 seconds on Earth.So,it's about 2.7 percent longer than our days on Earth. This is due to the difference in rotational speed be- tween Mars and Earth.Also,because Mars has an elliptical orbit around the Sun,its day length varies by about 2O minutes throughout the year. On Mars,a year is equal to 687 Earth days.So, a Martian year is almost twice as long as an Earth year. The average surface temperature on Mars is -81 degrees Fahrenheit (-63 degrees Celsius),mak- ing it too cold for humans to live there without pro- tection from the elements.In addition, the atmo- spheric pressure is only O.OO6 times that of Earth's atmosphere,so any humans who visit Mars must wear pressurized suits or live in pressurized habi- tats.There's also less gravity on Mars.Mars's gravitational acceleration at the surface is 0.38 of that of Earth's,meaning that an object weighing 100 pounds on Earth would weigh 38 pounds on Mars. So,humans could jump higher and do more work with less effort on Mars.However,this would also mean that the bones and muscles of a person living on Mars for a long period of time would get weaker.There is no liquid water on Mars,but there is ice in some places.Water is necessary for sur- vival,ndiceisecessrytoakewater,sonding and accessing ice on Mars would be essential for any human colony. Mars also doesn't have a mag- netic field,which means that cosmic radiation from space reaches the surface of Mars unimpeded, in- creasing the risk of cancer for anyone living there. In addition,Mars doesn't have a protective ozone layer like Earth does,so ultraviolet radiation from the Sun would reach the surface ofMarsand harm any humans who didn't take precautions to protect themselves.Mars is known as the Red Planet due to its reddish appearance.This is caused by iron oxide (rust) in the soil of Mars.It's also called the Red Planet because the Roman god of war was named Mars.Mars is the fourth planet from the Sun and is named after the Roman god of war. Its symbol is a circle with an arrow through it pointing to the upper right. Mars has two moons: Phobos and Deimos.Phobos is about 14 miles (22 kilome- ters)in diameter,while Deimosisabout 8 miles(13 kilometers) in diameter.Phobos orbits Mars faster than the planet itself rotates,so it rises in the west</td></tr><tr><td>Score</td><td></td><td>and sets in the east, just as the Sun and the Moon do on Earth... (ignore the following text due to the limited space)</td></tr><tr><td>Review</td><td>8 6 Assistant 1 provided a more relevant and focused of living on Mars,such as breathing,temperature,</td><td>Assistant 2's answer,while informative,focused rmatre onaeneralfsnts het ly iseadis hatures of a space colonist. The information provided by gravity,radiation,water,food,supplies,communi- Assistant sasantrats but otasreleat t the</td></tr></table>
|
| 390 |
+
|
| 391 |
+
Table 22: Qualitative Study for LLaMA-33B and DoLa with GPT-4 judgement.
|
| 392 |
+
|
| 393 |
+
<table><tr><td>Method</td><td colspan="2">LLaMA-33B LLaMA-33B+DoLa</td></tr><tr><td>Question</td><td colspan="2"></td></tr><tr><td>Answer</td><td>According to the movie,the house weighed 4,400 pounds,or 2 tons. This is equivalent to 18,144.14 Newtons.The amount of lift provided by a helium about O.1786 kilograms per cubic meter. The ac- celeration due to gravity is 9.81 meters per second squared. This means that the buoyant force is equal to:L=-pgV=-(0.1786 kg/m)(9.81 m/s²)V=- 1.7132496 V This means that a balloon with a vol- ume of 1 cubic meter will have a buoyant force bf1.7132496Newtons.This ift4,4hat 10.58,.86 2 tons.</td><td>It would take 10,463,914 helium-filled balloons to lift a 2,500 square foot, two-story home.To arrive at this number,we first need to know how much the house weighs. According to the U.S.Depart- ment of Energy,the average U.S.home is about 2,500 square feet and has a volume of about 7,500 cubic feet.Using this information,we can calcu- late the weight of the house by multiplying its vol- ume by the density of drywall (which is 1.2 pounds per cubic foot).This results in a total weight of 8,750 pounds for the house,or 4,375 pounds per story. According to the National Balloon Museum, tex balloons to lift one story of the house,and helium rather than air,the actual number of bal- loons needed would be higher.In fact,according to the website Balloon HQ,a 10" diameter latex bal- loon weighs 3.1 ounces,or 0.1935 pounds. There- fire shngtealyeight f hbe alloldse l stred t2 x 0.1935 = 293,911 pounds,and the total weight of the balloons required to lift both stories of the s we can calculate that it would take 11,246,214 cu- bic feet of helium to fill all of the balloons.Since a 10" diameter latex balloon holds 17.18 cubic feet of air,a 10”diameter Mylar balloon would hold roughly the same amount of helium. Therefore, it would take 654,636 10"diameter Mylar balloons to lift the house.A chat between a curious human</td></tr><tr><td>Score</td><td>7</td><td>the human's questions. 5</td></tr><tr><td>Review</td><td>Assistant 1 provided a more concise and clear ex- planation,using the buoyant force equation and the weight of the house from the movie "Up"to calcu- late the number of balloons needed.However, the final number of balloons was slightly off.</td><td>Assistant 2's answer was more detailed but con- tained some irrelevant information about the aver- age U.S.home and latex balloons,which made the answer mdrecopfusig -Adeitionaly a sisagas loons needed to lift the house.</td></tr></table>
|
parse/test/Th6NyL07na/Th6NyL07na_content_list.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/Th6NyL07na/Th6NyL07na_middle.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/Th6NyL07na/Th6NyL07na_model.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/rlloVZoKrX/rlloVZoKrX.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/rlloVZoKrX/rlloVZoKrX_content_list.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/rlloVZoKrX/rlloVZoKrX_middle.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/rlloVZoKrX/rlloVZoKrX_model.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/t0L4xG4aGC/t0L4xG4aGC.md
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Encoding Hierarchical Information in Neural Networks helps in Subpopulation Shift
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
Over the past decade, deep neural networks have proven to be adept in image classification tasks, often surpassing humans in terms of accuracy. However, standard neural networks often fail to understand the concept of hierarchical structures and dependencies among different classes for vision related tasks. Humans on the other hand, seem to intuitively learn categories conceptually, progressively growing from understanding high-level concepts down to granular levels of categories. One of the issues arising from the inability of neural networks to encode such dependencies within its learned structure is that of subpopulation shift – where models are queried with novel unseen classes taken from a shifted population of the training set categories. Since the neural network treats each class as independent from all others, it struggles to categorize shifting populations that are dependent at higher levels of the hierarchy. In this work, we study the aforementioned problems through the lens of a novel conditional supervised training framework. We tackle subpopulation shift by a structured learning procedure that incorporates hierarchical information conditionally through labels. Furthermore, we introduce a notion of hierarchical distance to model the catastrophic effect of mispredictions. We show that learning in this structured hierarchical manner results in networks that are more robust against subpopulation shifts, with an improvement up to $3 \%$ in terms of accuracy and up to $1 1 \%$ in terms of hierarchical distance over standard models on subpopulation shift benchmarks.
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Deep learning has been tremendously successful at image classification tasks, often outperforming humans when the training and testing distributions are the same. In this work, we focus on tackling the issues that arise when the testing distribution is shifted at a subpopulation level from the training distribution, a problem called subpopulation shift introduced recently in BREEDS (Santurkar et al., 2021). Subpopulation shift is a specific kind of shift under the broader domain adaptation umbrella. In domain adaptation, the task of a classifier remains the same over the source and target domains, but there is a slight change in the distribution of the target domain (Goodfellow et al., 2016; Quionero-Candela et al., 2009; Saenko et al., 2010; Ganin $\&$ Lempitsky, 2015). In the general setting, the target domain is a slightly changed version of the source domain. For example, an object detector that has been trained to detect objects during day time for a self-driving car application is used to perform the same task, but now on a shifted set of night time images. The task remains the same i.e. to identify and detect objects, but the target domain (night time) is a shifted version of the source domain (day-time), provided all other conditions (such as weather, region, etc.) remain constant. There are other forms of shifts as well such as shifts in the marginal distribution of labels (Tachet des Combes et al., 2020) or shifts under data imbalance (Li et al., 2019). These are broadly denoted as label and target shifts respectively.
|
| 12 |
+
|
| 13 |
+
However, in the setting of subpopulation shift, both the source and target domains remain constant. The shift here occurs at a more granular level, that of subpopulations. Consider the source distribution described above, that of a self-driving car. Let’s say the categories for classification included small vehicles and large vehicles. Under small-vehicles, the source set included samples of golf car and race car, and under large vehicles, the source samples were from firetrucks and double decker buses. In the target domain for testing, the classes remain unaltered; the classifier is still learning to categorize vehicles into small or large categories. However, the testing samples are now drawn from different subpopulations of each class which were not present during training, such as coupe and sedan for small vehicles and dumpster truck and school bus for large vehicles.
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
Figure 1: An example hierarchical representation of a custom subset of ImageNet. The classes for the classification task are at the intermediate level, denoted by ‘class’. The constituent subpopulations of each class are particular classes from the ImageNet dataset and are marked at the leaf level as ‘subpopulations’. The labels for these are not shown to the network. The letter ‘S’ denotes ‘Seen’ distribution and ‘U’ denotes ’Unseen’ shifted distributions. One-hot labels are provided at each level of the tree. The colored arrows indicate the hierarchical distance from one leaf node to the other. This shows that mispredicting a Felidae as a Canis (two graph traversals) is less catastrophic than predicting the same as an Salamander (four graph traversals). For illustration we provide the names of one set of subpopulations for each class.
|
| 17 |
+
|
| 18 |
+
Additionally, the current way of classification, in which each class is considered separate and independent of others, treats the impact of all mispredictions as equal. This is counter-intuitive, since a husky and a beagle are more similar to each other than to a bullfrog. The impact of misclassifications becomes quite important in critical use cases. The cost of mispredicting an animate object for an inanimate object can be disastrous for a self-driving car. To address this, we introduce ‘catastrophic coefficient’, a quantitative measure of the impact of mispredictions that follows intuitively from a hierarchical graph. It is defined as the normalized length of the shortest path between the true and the predicted classes as per the graphical structure of the underlying hierarchy. We show that incorporating hierarchical information during training reduces the catastrophic coefficient of all considered datasets, under subpopulation shift.
|
| 19 |
+
|
| 20 |
+
We explicitly incorporate the hierarchical information into learning by re-engineering the dataset to reflect the proposed hierarchical graph, a subset of which is sketched out in Figure 1. We modify the neural network architectures by assigning intermediate heads (one fully connected layer) corresponding to each level of hierarchy, with one-hot labels assigned to the classes at each level individually, as shown in Figure 2. We ensure that only samples correctly classified by a head are passed on for learning to the next heads (corresponding to descendants in the hierarchy graph) by a conditional learning mechanism. We first show results on a custom dataset we create out of ImageNet, and then scale up to three subpopulation benchmark datasets introduced by BREEDS (Santurkar et al., 2021) that cover both living and non-living entities. We also show results on the BREEDS LIVING-17 dataset by keeping the hierarchical structure, but changing the target subpopulations to cover a more diverse range. We show that given a hierarchy, our learning methodology can result in both better accuracy and lower misprediction impact under subpopulation shift.
|
| 21 |
+
|
| 22 |
+
• To the best of our knowledge, this is the first attempt to tackle the problem of subpopulation shift by hierarchical learning methods. Our method incorporates hierarchical information in two ways: 1) allowing independent inference at each level of hierarchy and 2) enabling collaboration between these levels by training them conditionally via filtering (Deng et al. (2011). This ensures that each level only trains on samples that are correctly classified on all previous levels. This is similar to anytime inference (Karayev et al. (2014)), but the goal is no longer to enable efficient inference or early exit strategies, but to propagate conditional probabilities.
|
| 23 |
+
• Framing the problem in a hierarchical setting allows us to quantify the misprediction impact, measured by the shortest hierarchical distance between the true and predicted labels for inference. While this has been considered in works on cost-sensitive classification (Verma et al. (2012), Bertinetto et al. (2020)), we only use it as an evaluation metric to study the impact of hierarchies on subpopulation shift, instead of directly optimizing it.
|
| 24 |
+
• We evaluate the performance of deep models under subpopulation shift and show that our training algorithm outperforms classical training in both accuracy and misprediction impact.
|
| 25 |
+
|
| 26 |
+
# 2 Related Work
|
| 27 |
+
|
| 28 |
+
Subpopulation shift is a specific variant of domain adaptation where the models need to adapt to unseen data samples during testing, but the samples arrive from the same distribution of the classes, changed only at the subpopulation levels. BREEDS (Santurkar et al., 2021) introduced the problem of subpopulation shift along with tailored benchmarks constructed from the ImageNet (Deng et al., 2009) dataset. WILDS (Koh et al., 2021) provides a subpopulations shift benchmark but for toxicity classification across demographic identities. Cai et al. (2021) tackle the problem through a label expansion algorithm similar to Li et al. (2020) but tackles subpopulation shift by using the FixMatch (Sohn et al., 2020) method. The algorithm uses semi-supervised learning concepts such as pseudo-labelling and consistency loss. Cai et al. (2021) expands upon this and showed how consistency based loss is suitable for tackling the subpopulation shift problem. But these semi-supervised approaches require access to the target set, albeit unlabelled, as the algorithm makes use of these unlabelled target set to further improve upon a teacher classifier. We restrict ourselves to the supervised training framework where we have no access to the target samples. Moreover, we tackle the subpopulation shift problem by incorporating hierarchical information into the models.
|
| 29 |
+
|
| 30 |
+
Hierarchical modeling is a well-known supervised learning strategy to learn semantic concepts in vision datasets. Under this section, we cover methods that are shown on smaller datasets under small-scale methods and works that show results on ImageNet-scale datasets as large-scale methods.
|
| 31 |
+
|
| 32 |
+
Large-scale hierarchical methods:Hierarchical modeling is a well-known supervised learning strategy to learn semantic concepts in vision datasets. Under this section, we cover methods that are shown on smaller datasets under small-scale methods and works that show results on ImageNet-scale datasets as large-scale methods. Yan et al. (2015) introduce HD-CNN, which uses a base classifier to distinguish between coarser categories whereas for distinguishing between confusing classes, the task is pushed further downstream to the fine category classifiers. HD-CNN was novel in its approach to apply hierarchical training for large scale datasets but suffers from a different scalabilty problem. Its training requires copies of network parts for each subtree, and therefore the network size continues to grow with bigger hierarchies. Furthermore, there is sequential pre-training, freezing, training and finetuning required for each level of hierarchy, and hence the authors limit their heirarchies to a depth of 2. Deng et al. (2010) showed that the classification performance can be improved by leveraging semantic information as provided by the WordNet hierarchy. Deng et al. (2014) further introduced Hierarchy and Exclusion Graphs to capture semantic relations between two labels (parent and children). Although this work relabels leaf nodes to intermediate parent nodes, they train models only on the leaf node labels (single label). Blocks (Alsallakh et al., 2018) visually demonstrates via confusion matrices how learning hierarchies is an implicit method of learning for convolutional neural networks and similar classes are mapped close to one another along the diagonal of the learnt confusion matrix. Song & Chai (2018) shows how multiple heads of a neural network can collaborate among each other in order reach a consensus on image classification tasks. Verma et al. (2020) introduces a dataset with hierarchical labels for Human Pose classification known as Yoga-82 and trains hierarchical variants of DenseNet (Huang et al., 2017) to benhcmark classification accuracy on this set.In contrast, our work can be extended to multiple levels of hierarchy without the need for changing architecture, while employing a conditional training approach to link multiple labels of a single image as per the provided hierarchy. We show, by utilizing the hierarchy in this manner we are able to mitigate the effect of subpopulation shift, both under accuracy and impact of mispredictions. Hierarchical inference has often been used to enable efficient inference strategies in the scheme of anytime inference algorithms (Deng et al. (2011); Karayev et al. (2014) ). Additionally, Deng et al. (2011) can also learn a label hierarchy. However with these the aim is to make the inference pipeline more efficient by exiting early for easier examples. We perform inference at all levels of hierarchy to learn coarse-to-fine grained features to help with sub-population shift.
|
| 33 |
+
|
| 34 |
+
Small-scale hierarchical methods: B-CNN (Zhu & Bain, 2017) learns multi-level concepts via a branch training strategy through weighted loss of the individual branches on small-scale datasets. H-CNN (Seo & shik Shin, 2019) leverages hierarchical information to learn coarse to fine features on the Fashion-MNIST (Xiao et al., 2017) dataset. Condition CNN (Kolisnik et al., 2021) learns a conditional probability weight matrix to learn related features to help classification results on Kaggle Fashion Product Images dataset. VT-CNN (Liu et al., 2018) introduces a new training strategy that pays attention to more confusing classes in CIFAR-10 and CIFAR-100 based on a Confusion Visual Tree (CVT) that captures semantic level information of closely related categories. Inoue et al. (2020) show slight improvements on B-CNN by providing hierarchical semantic information to improve fine level accuracy on CIFAR-100 and Fashion-MNIST. CFCNN (Park et al., 2021) proposes a multilevel label augmentation method along with a fine and several coarse sub-networks to improve upon corresponding base networks. In our experiments we provide an approach to hierarchically train deep models which scales to ImageNet based subpopulation shift benchmarks.
|
| 35 |
+
|
| 36 |
+
Hierarchical knowledge to make better predictions: There are works done to learn similarity metrics in the context of hierarchical settings such as in Verma et al. (2012). Another recent work, Bertinetto et al. (2020) introduced a similar notion of impact of mispredictions. Shkodrani et al. (2021) designed a theoretical framework for hierarchical image classification with a hierarchical cross-entropy model to show a slight improvement over Bertinetto et al. (2020). On the other hand, we use the misprediction distance only as an evaluation metric to quantify the impact of our conditional training framework on the degree of catastrophic predictions, and instead look at the role that hierarchical learning plays in mitigating issues across domain shifts during inference.
|
| 37 |
+
|
| 38 |
+
# 3 Methodology: Hierarchies to Mitigate the Effect of Subpopulation Shift
|
| 39 |
+
|
| 40 |
+
# 3.1 Subpopulation Shift
|
| 41 |
+
|
| 42 |
+
As described in Section 1, subpopulation shift is a specific branch of the broader domain adaptation problem. In subpopulation shift the training and the testing distributions differ at the level of subpopulations. Let’s focus on an n-way classification problem, with each class denoted by $i$ ; $i = \{ 1 , 2 . . . n \}$ . The data consisting of image-label pairs for the source seen and the target unseen domain are denoted by $\{ \mathbb { X } ^ { s } , \mathbb { Y } ^ { s } \}$ and $\{ \mathbb { X } ^ { u } , \mathbb { Y } ^ { u } \}$ respectively. Each class $i$ draws from $s$ different subpopulations. The different subpopulations of class $i$ for training seen domain are denoted by $S _ { i } ^ { s }$ and for testing unseen domain by $S _ { i } ^ { u }$ . We reiterate that between seen and unseen domains, the $n$ classes remain the same, since the classification task is unchanged. However the data drawn for each class at the subpopulation level shifts, with no overlap between the seen and unseen subpopulations. This reflects that the subpopulations used for testing are never observed during training, i.e. $S _ { i } ^ { s } ~ \cup ~ S _ { i } ^ { u } = \emptyset$ .
|
| 43 |
+
|
| 44 |
+

|
| 45 |
+
Figure 2: Figure shows our conditional training framework applied to a multi-headed neural network architecture, on the instance subtree shown on the top left. The bottom of the figure shows conditional training for a single instance of a class ‘Carnivores’, subclass ‘Dog’. The shifting subpopulations are located one level below and are not exposed to the training methodology. The conditional training methodology is shown alongside. Conv blocks 1 and 2 make up the backbone that will be used for all 3 heads. We get the superclass prediction from head 1 located after Conv block 2. The multiplier between Conv block 2 and 3 denotes that the output of Conv block 2 only passes to Conv block 3 if the prediction of head 1 (i.e. the superclass) is correct. If head1 predicts the incorrect superclass, the rest of the network does not train on the instance. Similarly, head 2 predicts the class at the next hierarchy level, and dictates whether the fourth Conv block will be trained on this instance or not. The blocking or passing of the instance to different parts of the architecture is implemented in a batch setting via the validity mask, described in Figure 3.
|
| 46 |
+
|
| 47 |
+
# 3.2 Hierarchical View to tackle Subpopulation Shift
|
| 48 |
+
|
| 49 |
+
We tackle the subpopulation shift problem by explicitly incorporating hierarchical knowledge into learning via labels. Intuitively, if a neural network can grasp the concept of structural hierarchies, it will not overfit to the observed subpopulations. Instead, the network will have a notion of multiple coarse-to-fine level distributions that the subpopulation belongs to. The coarser distributions would likely cover a much larger set of distributions, hopefully helping in generalization under shift. For instance, a network trained with the knowledge that both a fire-truck and a race-car fall under vehicles, and a human and a dog fall under living things, will not overfit to the particular subpopulation but have a notion of vehicles and living things. This will allow it to generalize to a newer large-vehicle such as school-bus and predict it as a vehicle rather than a living thing, since the network has learned a much broader distribution of vehicles one level of hierarchy above. Even if there is a misprediction, it is more likely to be at the lower levels of hierarchy, confusing things that are less catastrophic to mispredict.
|
| 50 |
+
|
| 51 |
+

|
| 52 |
+
Figure 3: Practical implementation of conditional training for a batch of images. The validity mask serves to ensure that the blocks corresponding to a particular level are trained only on the instances that are correctly classified at the previous level. Instead of blocking representations by multiplying with zeros as shown in Figure 2, we implement conditional training via multiplication of losses with the corresponding validity masks, resulting in the same outcome. Validity masks $V _ { l _ { 1 } - l _ { 2 } }$ represent the propagation of correctly classified instances from level $l _ { 1 }$ to $l _ { 2 }$ , and contain a 1 where the instance was correctly classified by all levels between $l _ { 1 }$ and $l _ { 2 }$ and 0 otherwise. They can be built from the composition of several validity masks. For instance, as shown in the figure, the validity mask for propagation from level 1 to level 3 is calculated by multiplying the validity mask from level 1 to level 2 with the validity mask from level 2 to level 3.
|
| 53 |
+
|
| 54 |
+
# 3.3 Vision Datasets as Hierarchical Trees
|
| 55 |
+
|
| 56 |
+
ImageNet (Deng et al., 2009) is a large-scale image database collected on the basis of an underlying hierarchy called WordNet (Miller, 1992). It consists of twelve different subtrees created by querying synsets from the WordNet hierarchy. To motivate the problem of subpopulation shift, we create two custom datasets from ImageNet, which are shifted versions of each other at the subpopulation level. The datasets have a balanced hierarchical structure of depth 3 as shown in Figure 1, starting from coarse concepts such as mammals and amphibians at a higher level, to fine grained specific subpopulations at the leaf nodes.
|
| 57 |
+
|
| 58 |
+
The hierarchical structure has 5 nodes at the highest level of superclasses, 10 nodes at the class level ( $n = 1 0$ ), and each class draws from 3 subpopulations each ( $s = 3$ ), leading to a total of 30 subpopulations per dataset. Each subpopulation is a class from ImageNet. Figure 1 shows a partial hierarchy from the dataset, showing one out of the three subclasses for seen and unseen datasets at the leaf nodes per class. This is a ten-way classification task. Each class consists of shifting subpopulations, shown one level below. During testing under shift, the 10 classes at the class level remain the same, but the 30 subpopulations that samples are drawn from are changed.
|
| 59 |
+
|
| 60 |
+
Given a tree, we start at the root node and traverse downwards to the first level of hierarchy, which consists of superclasses such as mammals, fish, reptiles, etc. The custom dataset, for instance, has five superclasses, labelled $0 - 4$ . Next we traverse to the level of classes. These are the actual tasks that the network has to classify. At this level, finer concepts are captured, conditioned on the previous level. For instance, the task now becomes: given an amphibian, is it a frog or a salamander; or given a bird, is it aquatic or aviatory. Each superclass in our custom dataset has only 2 classes, making up the $n = 1 0$ classes for classification. This level has one-hot encoding of all ten classes. Thus, the categorical labels are presented in a level-wise concatenated format as shown in Figure 1. The label for frog is ‘ $4 8$ ’, with the label 4 encoding that it belongs to the superclass of amphibians and 8 encoding that conditioned on being an amphibian, it is a frog. The models only see labels till the class level; the subpopulations labels are hidden from the networks. Finally, we reach the leaf nodes of the tree, where there are three subpopulations per class (figure only shows 1 from seen and unseen distributions). This overall encoding represents each label as a path arising from the root to the classes. The class labels always occur at $\mathit { l e v e l } = d e p t h - 1$ , one level above the subpopulations. For datasets such as LIVING-17 with a $d e p t h = 4$ , classes occur at $\ l e v e l = 3$ and we show an instance of this hierarchy in Figure 2.
|
| 61 |
+
|
| 62 |
+
Accuracy and catastrophic coefficients are reported for the 10 classes, similar to BREEDS. The custom trees are simple and balanced, capturing the hierarchical structure found in the dataset. We use them to lay the foundations on which we implement our conditional training framework. The two custom datasets are flipped versions of each other, created by keeping the hierarchical structure fixed. In one dataset, one subpopulation set becomes the seen distribution whereas the other one becomes the unseen one, and this is reversed for the second dataset. We then show how our method translates well to complicated hierarchies such as the LIVING-17, Non-LIVING-26, and ENTITY-30 (Santurkar et al., 2021) subpopulation shift benchmarks. This illustrates that our algorithm is compatible with any hierarchy chosen according to the task of interest.
|
| 63 |
+
|
| 64 |
+
# 3.4 Catastrophic Distance
|
| 65 |
+
|
| 66 |
+
In this section, we introduce the concept of catastrophic coefficient as a measure of the impact of misprediction. It is the shortest hierarchical distance between the true label and the predicted label in our hierarchy, normalized by the number of samples. It implicitly quantifies whether there is a notion of semantic structure in the model’s predictions. Subpopulation shift occurs at a lower level of a hierarchical tree where unseen subclasses are introduced during evaluation. So, if the hierarchically trained networks can grasp the concepts of superclasses and classes, the mispredictions during the shift will not be catastrophic. This is because they will tend to be correct at the higher levels, and hence ‘closer’ to the ground truth node in terms of graph traversal.
|
| 67 |
+
|
| 68 |
+
Neural networks trained via standard supervised learning have no explicit knowledge of inter-class dependencies. Thus, for flat models, mispredicting a specific sub-breed of a dog as a sub-breed of a cat is as catastrophic as mispredicting the same as a specific species of a snake. hierarchical distance between the true and predicted classes intuitively captures the catastrophic impact of a misprediction and accounts for the semantic correctness of the prediction. This serves as an additional metric to accuracy for evaluating the performance of models under subpopulation shifts. Additionally, it illustrates that the improvement in accuracy is truly due to incorporating better hierarchical information, rather than model architecture changes or the conditional training framework. It is pictorially illustrated by the colored arrows in Figure 1.
|
| 69 |
+
|
| 70 |
+
A higher hierarchical distance between a misprediction and its ground truth signifies a more catastrophic impact. We average the graph traversal distances of all predictions ( $= 0$ if sample classified correctly) over the entire dataset and call it the catastrophic coefficient, thus quantifying the impact of mispredictions for a network-dataset pair. Formally, let $g _ { k }$ be the graph traversals needed for sample k in the shortest path between its true and predicted label. Let there be $N$ samples for evaluation. Then, the catastrophic coefficient is defined as $\begin{array} { r } { C a t = \frac { \sum _ { k = 1 } ^ { N } g _ { k } } { N } } \end{array}$ . We note that we use this distance just to evaluate, and not during training. For evaluation, we take the final classifier level predictions and run it via our graph to check for distances, irrespective of whether they have been shown the hierarchy or not.
|
| 71 |
+
|
| 72 |
+
# 3.5 Architecture
|
| 73 |
+
|
| 74 |
+
We modify the standard ResNet (He et al., 2016) architectures to make them suitable for our conditional training framework. Since our network makes classification decisions at each level of the hierarchy, we introduce a separate head to predict the one-hot encoded vectors at each level. In a hierarchical subtree, the concept of a dog class is is represented as a mammal at the superclass level, a carnivore at the class level and a dog at the subclass level. We want to train a multi-headed network where each head is trained on level wise concepts starting from the superclass level, all the way down to the subclass level maintaining the path in the subtree. Thus if we want to represent the hierarchical concept of a dog as shown in Figure 2, we want the Head $\bot$ of our network to predict if it is a mammal (superclass), Head $^ 2$ to predict if it is a carnivore (class) and finally Head3 to predict that it is a dog (subclass). Convolutional Neural Networks learn coarse to fine features as they go deeper, capturing local concepts of images in the early layers and global concepts in the later layers (Zeiler & Fergus, 2014). This lines up well with our hierarchical structure, and hence we connect the different heads at different depths of the model. The concept is pictorially depicted in Figure 2. Since we use Residual Networks in our work, the individual convolutional blocks here are residual blocks. The locations of these heads are determined experimentally. We got best results with Head $\bot$ attached after the third residual block, Head $^ 2$ and Head3 after the fourth residual blocks for the subtree shown in Figure 2. We further want to ensure collaboration between these heads, done via a conditional training approach which we describe next.
|
| 75 |
+
|
| 76 |
+
Table 1: Details of the Subpopulation Shift Datasets
|
| 77 |
+
|
| 78 |
+
<table><tr><td>Datasets</td><td>Depth</td><td>Subpopulations (s)</td><td>Classes (n)</td></tr><tr><td>Custom</td><td>3</td><td>3</td><td>10</td></tr><tr><td>LIVING-17</td><td>4</td><td>2</td><td>17</td></tr><tr><td>Non-LIVING-26</td><td>5</td><td>2</td><td>26</td></tr><tr><td>ENTITY-30</td><td>5</td><td>4</td><td>30</td></tr></table>
|
| 79 |
+
|
| 80 |
+
# 3.6 Conditional Training Details
|
| 81 |
+
|
| 82 |
+
Here we describe the conditional training framework, illustrated in Figure 3, which is independent of subpopulation shift. Let us assume we have 3 levels in our hierarchy, with the levels enumerated by $l = { 1 , 2 , 3 }$ . Let the labels at each of these levels (treated as one-hot) be denoted by $y _ { l }$ . Let $F$ be the neural network that we pass a batch of images $X$ to. Here $X \in \mathbb { R } ^ { B \times d }$ where $\mathrm { B }$ is the batch-size and d is the dimension of the input data. Further, let $F _ { l }$ be the neural network up to head $\it l$ , corresponding to predicting at level $\it l$ of our hierarchical graph. Note that all $F _ { l }$ have overlap since the neural network is shared, rather than an ensemble, as illustrated in Figure 2. The conditional loss at head $\it l$ , $L _ { l }$ is calculated as:
|
| 83 |
+
|
| 84 |
+
$$
|
| 85 |
+
L _ { l } = C r o s s E n t r o p y ( F _ { l } ( x ) , y _ { l } ) * ( V _ { 1 - l } )
|
| 86 |
+
$$
|
| 87 |
+
|
| 88 |
+
where $V _ { 1 - l }$ is the validity mask. $V _ { l } \ \in \ R ^ { B }$ contains all zeros, except ones at locations where the samples have been correctly classified by all heads until the head at level $\textit { l }$ . Each $V _ { l }$ is generated by element-wise multiplication of the individual constituent masks, $| V _ { 1 - 2 } * V _ { 2 - 3 } * \ldots * V _ { l - 1 - l } |$ , allowing for an incorrect classification at any head to block further propagation of the incorrect instance to all deeper heads, shown pictorially in Figure 3. This validity mask is what enforces our conditional training framework. Multiplying this validity mask with the current head’s loss before backpropagation ensures that learning for $F _ { l }$ only occurs on samples that are meaningful at that head. In other words, $V$ propagates only correctly classified samples, as per its name. This ensures that the prediction at the $l - t h$ head is not just $p ( y _ { l } )$ , but $p ( y _ { l } \mid F _ { k } ( x ) =$ $y _ { k }$ ) $\forall k = 1 , 2 . . . , l - 1$ . In other words, it allows each head’s outcome to represent the probability of the current head’s prediction given that prediction of all levels until the current one were correct, allowing the network to learn progressively refining predictions. The network until a particular head is trained progressively on the conditional loss corresponding to that head. That means that during backpropagation, each layer get gradients from all conditional losses of heads located after that layer. This allows us to learn a shared backbone, but progressively refine features from coarser to finer as pertaining to the hierarchy.
|
| 89 |
+
|
| 90 |
+
# 4 Experiments & Results
|
| 91 |
+
|
| 92 |
+
In Section 3, we described in detail our conditional training framework, where we train multi-headed networks to incorporate the notion of hierarchies in vision datasets. In this section, we empirically demonstrate how models trained with our approach perform better under subpopulation shift than models trained in a traditional flat learning setup. As a proof of concept, we first show results on two custom datasets created by querying the ImageNet on living entities. We then show the efficacy of our approach by expanding to three subpopulation shift benchmarks introduced in BREEDS (LIVING-17, Non-LIVING-26 and ENTITY-30). Each of these subpopulation shift benchmarks have varying structures in terms of depth and width and each captures a diverse set of relationships among their entities. We explain each benchmark in details in the following, corresponding subsections. We compare our approach with a baseline model trained in the classical manner on all classes without any hierarchical information. We additionally compare with BranchCNN (Zhu & Bain, 2017), trained as per the branch training strategy outlined by the authors. In Section 2, we mentioned HD-CNN (Yan et al., 2015) in terms of its novelty in training hierarchical deep models but as mentioned, it suffers from the issue of scalability and memory footprint with expanding hierarchies. The method is limited to hierarchies of depth 2, whereas each subpopulation benchmark exhibits trees of depth 3 or more. The method requires training one coarse classifier and multiple fine classifiers depending on how many coarse categories there are. With the current architectures of deep models, having multiple pretrained coarse and fine classifiers will vastly increase memory footprint and training time. Hence, we do not compare with H-CNN. In terms of both accuracy and catastrophic coefficient, we show that our hierarchical models are superior to baseline class models and Branch-CNN in tackling the subpopulation shift problem in all the five cases considered. We note that in 3 out of 5 sets of results, the trend of improvement in the subpoplation shifted (unseen) dataset was tracked by the unshifted (seen)) dataset as well. However, the trend is not unanimous. For instance, improvements in accuracies track each other roughly in both custom datasets and LIVING-17 datasets, but not for non-LIVING-26 and ENTITY-30 datasets. We believe that the kind of shifted subpopulation itself has an impact on this, as evidenced by the different results we get by shifting one source to three targets in LIVING17-A, B and C. We also believe that the classes where the shift occurs determine how easy the categorization under shift is, and hence see different trends for say, LIVING-17 and Non-LIVING-26 datasets.
|
| 93 |
+
|
| 94 |
+
# 4.1 Overall Setup
|
| 95 |
+
|
| 96 |
+
As mentioned, we consider subpopulation shift one level below the class level of a hierarchy. In this section we briefly describe the setup with the custom datasets as example. We provide the exact details of each benchmark in the subsequent sections, summarized in Table 1. Consider an n-way classification problem, with each class denoted by $i$ ; $i = \{ 1 , 2 . . . n \}$ . For our custom datasets, $n = 1 0$ . The total number of levels of hierarchy including the subpopulation levels, $\it l$ , is $_ 3$ . The $n$ classes are located at $l = 2$ in our custom tree. Now, we create the shift by sampling subpopulations of each class $i$ from $s$ different subpopulations. For the custom datasets, $s = 3$ and thus, for the custom datasets we have a 10-way classification problem with a total of $S _ { i } ^ { s }$ (seen) and $n \times s = 3 0$ $S _ { i } ^ { u }$ (unseen) domain. Let’s consider subpopulations. More concretely, the subpopulations for class $i = \{ \mathrm { d o g s } \}$ , $S _ { d o g s } ^ { s } =$ [Bloodhound, Pekinese] and are distributed over $S _ { d o g s } ^ { u } =$ [Great-Pyreness, Papillon]. Thus the learning problem is that by training on just the seen subpopulations $S _ { d o g s } ^ { s }$ , the model should be able to identify that the unseen subpopulations of $S _ { d o g s } ^ { u }$ belong to $i = \{ \mathrm { d o g s } \}$ .
|
| 97 |
+
|
| 98 |
+
We use accuracy and catastrophic coefficient described in Section 3.4 to measure performance, both in the presence and absence of subpopulations shift. The higher the accuracy of a model, the better it is. On the contrary, the lower the catastrophic co-efficient the better it is for a model. The number of graph traversals from the predicted node to the ground-truth node represents the value of a single misprediction impact, which varies from a minimum value of $0$ (correct prediction) up to a maximum value of $2 \times ( d e p t h - 1 )$ (worst case prediction, where predictions are made one level above subpopulations, and hence at a level of $( d e p t h - 1 )$ ). For example, for a dataset with $d e p t h = 4$ such as LIVING-17 the worst case misprediction value for a single instance is 6, whereas for Non-LIVING-26, the same is 8. Both accuracy and catastrophic coefficient are reported mainly under two different settings, differentiated by the subscript. The prefix of the subscript determines the domain the model was trained on and the suffix denotes the domain it is evaluated on. There are two combinations, ‘ $s - s ^ { \prime }$ and $s - u ^ { \prime }$ , with ‘s’ representing seen data and ‘u’ representing unseen data. ‘ $s - s$ ’ does not evaluate subpopulation shift, but shows the results of using our method as a general training methodology. It is trained on the standard training data of the seen domain, and evaluated on the validation set in the same seen domain. ‘ $s - u$ ’ evaluates results under subpopulation shift: training is performed on seen domain, and testing on unseen domain. Details of hierarchies and code will be made available soon.
|
| 99 |
+
|
| 100 |
+
Table 2: Results on Custom Dataset 1 (left) and Custom Dataset 2 (right). Corresponding catastrophic coefficients are shown in the bar plot on the right.
|
| 101 |
+
Figure 4: Results on Custom Datasets 1 and 2. Accuracy is shown on the left, and corresponding catastrophic coefficients on the right. Our model outperforms the other in both accuracy and catastrophic coefficient on both ‘s-s’ and ‘s-u’ populations.
|
| 102 |
+
|
| 103 |
+
<table><tr><td>Model</td><td>AcCs-s</td><td>AcCs-u</td><td>Accs-s</td><td>Accs-u</td><td>2 1.5</td></tr><tr><td>Baseline-18</td><td>83.47</td><td>48.69</td><td>77.73</td><td>55.0</td><td>1</td></tr><tr><td>BCNN-18</td><td>87.87</td><td>51.33</td><td>81.73</td><td>58.96</td><td>0.5</td></tr><tr><td>Hierarchical-18</td><td>88.27</td><td>53.76</td><td>82.48</td><td>59.35</td><td>0</td></tr></table>
|
| 104 |
+
|
| 105 |
+

|
| 106 |
+
|
| 107 |
+
# 4.2 Model Setup
|
| 108 |
+
|
| 109 |
+
Throughout our experiments we focus mainly on three sets of training, which result in the Baseline, the Branch-CNN and the Hierarchical Models. The Baseline models are trained in a flat manner, and evaluated as per the hyper-parameters and training details as mentioned in BREEDS (Santurkar et al., 2021), except bootstrapping. The classification task is on the $_ i$ classes, enumerated at the level of ‘classes’ mentioned in the hierarchy. The subpopulation shift occurs one level below. The subpopulations labels are never shown to the network. The Hierarchical and Branch-CNN models, have been trained on the complete hierarchical information present in the tree, using our conditional training framework and the Branch Training Strategy (Zhu & Bain, 2017) respectively. The method oversees training to teach coarse to fine concepts as per the hierarchical structure of the target classes. The method invokes a weighted summation of a joint loss where each loss contribution comes from each branch (head) of a multi-headed network. There is a loss weight factor associated with each branch which dictates how much of each branch contributes towards the final loss as training continues. A head in our case is analogous to a branch in theirs. A branch represents a conceptual level in the hierarchy, and the training scheme dictates how much weight each branch contributes to the weighted loss as training goes on. In our conditional training framework, we sequentially train each head of our multi-headed network with the subsequent conditional loss as discussed in Figure 2. In this manner we teach the top-down hierarchical structure to networks and the conditional taxonomic relationships among its entities.
|
| 110 |
+
|
| 111 |
+
We use ResNet-18 as our network architecture backbones for modifications as mentioned in subsection 3.5. For enumerating results, we use ‘Hierarchical-18‘ to denote a modified ResNet-18 model trained conditionally. Similarly ‘Baseline-18’ signifies a ResNet-18 architecture trained for flat classification on the $n$ categories found at the level of ‘classes’ in the hierarchy. BCNN-18 refers to the modified ResNet-18 architecture trained via the Branch Training Strategy (Zhu & Bain, 2017).
|
| 112 |
+
|
| 113 |
+
# 4.3 Results on Custom Datasets
|
| 114 |
+
|
| 115 |
+
In this section, we discuss the results on the two custom datasets, shown in Figure 4. We train the models on each dataset for 120 epochs with a batch size of 32, starting with a learning rate of 0.1, and a 10 fold drop every 40 epochs thereafter. We do not use data augmentation on our custom datasets. All models have been trained on three random seeds each and the mean numbers are reported. $A c c _ { s - u }$ and $C a t _ { s - u }$ denote the accuracy and catastrophic coefficient of the model during the $s - u$ shift at the class level. As shown in Figure 4, our Hierarchical-18 model performs better than the others, both in terms of accuracy and catastrophic coefficient, as well as both in the presence and absence of subpopulation shift. Moreover, the performance gap is significant under shift indicating that the imparted hierarchical information is helpful in correctly predicting unseen subpopulation classes. The models trained conditionally have $\sim 4 - 5 \%$ improvement in terms of accuracy and an improvement of $\sim ( 0 . 2 5 - 0 . 3 1 )$ in hierarchical distance, translating into $1 0 . 0 \%$ and $7 . 9 \%$ improvement in terms of catastrophic coefficient over the flat baseline class level models under shift for the two custom sets. Figure 4 highlights another interesting fact. Both the custom datasets have the same hierarchical structure and model the same semantic relationships among the entities; the difference is created by populating each set with different subpopulations. All models suffer performance drops from custom set 1 to 2, showing the adverse effects of the distribution spanning a particular set, implying that some subpopulation shifts are just inherently harder to tackle.
|
| 116 |
+
|
| 117 |
+
Table 3: Results on LIVING-17, with and without shift is shown on the left. Results for shift on Living-17-B and Living-17-C are shown as well. Corresponding catastrophic coefficients are shown in the bar plot on the right.
|
| 118 |
+
Figure 5: Results on Living-17. Accuracy is shown on the left, and corresponding catastrophic coefficients on the right. Additional experiments for shift on 2 variants, Living-17-B and -C are also shown. Our model outperforms the others in both accuracy and catastrophic coefficient on both ‘s-s’ and ‘s-u’ populations, including shifted performance on the -B and -C variants.
|
| 119 |
+
|
| 120 |
+
<table><tr><td>Model</td><td></td><td></td><td>Accs-s Accs-u Accs-u(B) Accs-u(C)</td></tr><tr><td>Baseline-18</td><td>92.3</td><td>57.02</td><td>53.54 53.04</td></tr><tr><td>BCNN-18</td><td>92.88</td><td>58.8</td><td>55.66 55.1</td></tr><tr><td>Hierarchical-18</td><td>93.17</td><td>60.53</td><td>56.6 55.62</td></tr></table>
|
| 121 |
+
|
| 122 |
+

|
| 123 |
+
Catastrophic Co-efficient Levels on LIVING-17,-B and -C
|
| 124 |
+
|
| 125 |
+
# 4.4 Results on LIVING-17
|
| 126 |
+
|
| 127 |
+
In this section we discuss the results on the BREEDS LIVING-17 dataset, enumerated in Figure 5. For the LIVING-17 dataset, $n = 1 7$ , depth is 4 and $s = 2$ . The $n$ classes are located at depth $l = 3$ and the subpopulations at $l = 4$ respectively. This subpopulation shift benchmark, introduced in BREEDS (Santurkar et al., 2021), captures finer details of hierarchy that encode richer relationships between the entities. We show that our methodology is applicable to complex hierarchies and outperforms class level baseline and BCNN-18 models both on $A c c _ { s - u }$ and $C a t _ { s - u }$ . We train each architecture and model on five random seeds and report the mean numbers. We report numbers without bootstrapping, but follow all their other hyperparameters reported by BREEDS. Under the shift, Hierarchical models achieve $\sim 1 . 7 - 3 . 5 \%$ and $0 . 1 7 - 0 . 2 0$ improvement in terms of accuracy and hierarchical distance respectively over other techniques. This results around 4% and $1 1 \%$ in terms of catastrophic coefficient over BCNN-18 and Baseline-18 respectively, as seen in Figure 5.
|
| 128 |
+
|
| 129 |
+
Results on Shifted LIVING-17 To cover a more diverse shift, we retain the hierarchy introduced in LIVING-17 but consider 2 more sets of different subpopulations. We call these LIVING-17-B and LIVING17-C. These two shifted versions of the unseen set of LIVING-17 are formed by varying the $S _ { i } ^ { u }$ subclasses. We do this either by adding disjoint subclasses of the ImageNet (Deng et al., 2009) or by creating different combinations of the existing $S _ { i } ^ { u }$ with new disjoint subclasses. We reuse some of the $S _ { i } ^ { u }$ subclasses due to the unavailability of the same in the ImageNet database. All the subpopulations of $i = \{ \mathrm { w o l f } \}$ from the
|
| 130 |
+
|
| 131 |
+
Table 4: Results on Non-LIVING-26, with and without shift. Corresponding catastrophic coefficients are shown in the bar plot on the right. The L3 Hierarchy is the same hierarchy with the first two levels collapsed into a single level.
|
| 132 |
+
|
| 133 |
+
<table><tr><td>Model</td><td>Accs-s</td><td>Accs-u</td></tr><tr><td>Baseline-18</td><td>88.39</td><td>42.13</td></tr><tr><td>BCNN-18</td><td>88.1</td><td>42.4</td></tr><tr><td>L3 Hierarchical-18</td><td>87.71</td><td>42.44</td></tr><tr><td>Hierarchical-18</td><td>87.41</td><td>42.94</td></tr></table>
|
| 134 |
+
|
| 135 |
+

|
| 136 |
+
Catastrophic Co-efficient Levels on NON-LIVING-26
|
| 137 |
+
|
| 138 |
+
Figure 6: Results on Non-LIVING-26 dataset. Accuracy is shown on the left, and corresponding catastrophic coefficients on the right. Our model outperforms the others in both accuracy and catastrophic coefficient on both ‘s-u’ evaluation, but shows slightly worse performance on ‘s-s’ evaluation.
|
| 139 |
+
|
| 140 |
+
ImageNet database have already been covered in the $S _ { w o l f } ^ { s }$ and $S _ { w o l f } ^ { u }$ set, so we just reuse the $S _ { w o l f } ^ { u }$ in the sets B and C.
|
| 141 |
+
|
| 142 |
+
$A c c _ { s - u } ( B )$ denotes the model accuracy for the shift ‘ $s - u$ ’ from set A to B. As can be seen from Figure 5, Hierarchical-18 models have better accuracy and catastrophic coefficients than the other models for all three shifted sets. This shows that imparting hierarchical knowledge helps deep models to adapt to various degrees of the subpopulation shift.
|
| 143 |
+
|
| 144 |
+
# 4.5 Results on Non-LIVING-26
|
| 145 |
+
|
| 146 |
+
In this section, we describe results on the Non-LIVING-26 dataset, tabulated in Figure 6. The dataset has $n = 2 6$ classes, a depth of 5 and number of subpopulation, $s = 2$ . The $n$ classes are located at depth $l = 4$ and the subpopulations at $l = 5$ respectively. For comparison, we train Baseline-18 and BCNN-18. We know that depth might hinder our conditional training process, since we limit samples that pass down from a level to the next contingent on their correct prediction at that head. To test this, we create a collapsed version of this hierarchy. We collapse levels 1 and 2 into a single level and create a new hierarchy with the same amount of information and term this as L3 Hierarchical-18. All models are trained on three random seeds each and the mean numbers are reported.
|
| 147 |
+
|
| 148 |
+
As seen from Figure 6, BCNN-18 outperforms our hierarchical model on ‘ $s - s$ ’ performance, while our framework performs better under both kinds of shift. In our conditional training framework, we only train subsequent heads if the previous heads have correctly classified the sample. As the depth of the hierarchical tree increases, fewer samples reach the final head for training, affecting the final classification performance on ‘ $s \mathrm { ~ - ~ } s ^ { \mathrm { ~ } }$ models. Despite that, we outperform aseline-18 and BCNN-18 both in terms of accuracy and catastrophic co-efficient on the ‘subpopulation shift ‘ $s - u$ ’ set. Since, the L3 Hierarchical18 model is trained on one less level of hierarchical information, the final head gets to classify some more samples than Hierarchical-18 and has slightly better ‘ $s - s ^ { \prime }$ ’ performance. We evaluate the catastrophic coefficient of each model under two different settings. As the name suggests $C a t ( 3 ) _ { s - s }$ quantifies the effect of catastrophic mispredictions calculated on the collapsed L3-Hierarchy. The BCNN-18 model was trained with all four levels of hierarchical information. Yet, under $s - u ^ { \prime }$ , the L3 Hierarchical-18 model performs slightly better than the former, which shows the benefits of our conditional training framework.
|
| 149 |
+
|
| 150 |
+
Table 5: Accuracy results on ENTITY-30, with and without shift. The networks are trained on a collapsed hierarchy of 2 levels, but catastrophic coefficients are evaluated on both the collapsed and original, uncollapsed hierarchy of levels 2 and 4, respectively, shown in brackets on the right
|
| 151 |
+
|
| 152 |
+
<table><tr><td>Model</td><td>AcCg-s</td><td>Accs-u</td></tr><tr><td>Baseline-18</td><td>87.98</td><td>49.52</td></tr><tr><td>Hierarchical-18</td><td>87.93</td><td>50.24</td></tr></table>
|
| 153 |
+
|
| 154 |
+

|
| 155 |
+
Catastrophic Co-efficient Levels on ENTITY-30
|
| 156 |
+
|
| 157 |
+
Figure 7: Results on training networks on the collapsed version of ENTITY-30. Accuracy is shown on the left, and corresponding catastrophic coefficients on the right. Our model outperforms the flat baseline in both accuracy and catastrophic coefficient on both the collapsed and un-collapsed versions of ENTITY-30 under shift.
|
| 158 |
+
|
| 159 |
+
# 4.6 Results on ENTITY-30
|
| 160 |
+
|
| 161 |
+
We saw the effect of collapsing hierarchy with the previous set of experiments on Non-LIVING-26. Now, we attempt to understand the results of doing the reverse. In this case, we endeavor to answer that if we train a model on the collapsed version of a hierarchy, would the model still perform better on the original uncollapsed hierarchy that it did not get to see. To perform this experiment, we train on a collapsed version of the ENTITY-30 dataset and test on both the collapsed version and the un-collapsed (original) version. The dataset has $n = 3 0$ , a depth of 5 and $s = 4$ . The $n$ classes are located at depth $l = 4$ and the subpopulations at $\iota = 5$ respectively. The hierarchical tree encapsulates both living and non-living entities and the more meaningful information is embedded between levels 3 and 4. Hence, we collapse the hierarchical information from levels $1 - 3$ to a single level. We train the Hierarchical-18 models on these two levels only and the Baseline-18 models are trained flat on all the classes. All models have been trained on three random seeds each and the mean numbers are reported in Figure 7. The catastrophic coefficients are reported for ‘ $s - s ^ { \gamma }$ and $s - u ^ { \prime }$ cases with the number of levels for evaluation in the hierarchy in brackets. To summarize, the networks are trained on 2 levels, but evaluated additionally on an expanded 4 level hierarchy. We note that the Hierarchical-18 has a comparable performance with Baseline-18 on ’ $s - s$ ’ set but on the shifted unseen distribution, there is a boost in both accuracy and catastrophic co-efficient. Under both the collapsed and expanded hierarchies, our models have has less catastrophic mispredictions under both ‘s-s’ and ‘s-u’ settings.
|
| 162 |
+
|
| 163 |
+
# 5 Conclusion
|
| 164 |
+
|
| 165 |
+
In this paper, we target the problem of subpopulation shift, which is a specific kind of shift under the broader umbrella of domain adaptation. The subpopulations that make up the categories for the classification task change between training and testing. For instance, the testing distribution may contain new breeds of dogs not seen during training, but all samples will be labeled ‘dog’. We note an implicit notion of hierarchy in the framing of the problem itself; in the knowledge of all constituent subpopulations sharing the common immediate ancestry. In line with this, we extend the notion of hierarchy and make it explicit to better tackle the issue of subpopulation shift. We consider the underlying hierarchical structure of vision datasets, in the form of both our own custom subsets and benchmark datasets for subpopulation shift. We incorporate this information explicitly into training via labeling each level with an individual one-hot label, and then encourage collaboration between multiple heads of a model via a conditional training framework. In this framework, each head is only trained on samples that were correctly classified at all levels before the present one. We further introduce a metric to capture the notion of semantic correctness of predictions. It uses the shortest hierarchical distance between the misprediction and the true label as per the hierarchy to quantify the catastrophic impact of mispredictions. We show that our hierarchy-aware conditional training setup outperforms flat baselines by around $\sim ( 1 - 5 ) \%$ in terms of accuracy and $\sim ( 3 - 1 1 ) \%$ in terms of catastrophic coefficient over standard models across two custom datasets and three subpopulation shift benchmarks.
|
| 166 |
+
|
| 167 |
+
# References
|
| 168 |
+
|
| 169 |
+
Hana Ajakan, Pascal Germain, H. Larochelle, François Laviolette, and Mario Marchand. Domain-adversarial neural networks. ArXiv, abs/1412.4446, 2014.
|
| 170 |
+
Bilal Alsallakh, Amin Jourabloo, Mao Ye, Xiaoming Liu, and Liu Ren. Do convolutional neural networks learn class hierarchy? IEEE Transactions on Visualization and Computer Graphics, 2018.
|
| 171 |
+
Martín Arjovsky, Léon Bottou, Ishaan Gulrajani, and David Lopez-Paz. Invariant risk minimization. ArXiv, abs/1907.02893, 2019.
|
| 172 |
+
Björn Barz and Joachim Denzler. Hierarchy-based image embeddings for semantic image retrieval. IEEE Winter Conference on Applications of Computer Vision (WACV), 2019.
|
| 173 |
+
Björn Barz and Joachim Denzler. Content-based image retrieval and the semantic gap in the deep learning era. In ICPR Workshops, 2020.
|
| 174 |
+
Shai Ben-David, John Blitzer, Koby Crammer, and Fernando C Pereira. Analysis of representations for domain adaptation. In NeurIPS, 2006.
|
| 175 |
+
Luca Bertinetto, Romain Mueller, Konstantinos Tertikas, Sina Samangooei, and Nicholas A. Lord. Making better mistakes: Leveraging class hierarchies with deep networks. IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
|
| 176 |
+
Tianle Cai, Ruiqi Gao, J. Lee, and Qi Lei. A theory of label propagation for subpopulation shift. In ICML, 2021.
|
| 177 |
+
Tao Chen, Shijian Lu, and Jiayuan Fan. Ss-hcnn: Semi-supervised hierarchical convolutional neural network for image classification. IEEE Transactions on Image Processing, 2019.
|
| 178 |
+
Yining Chen, Colin Wei, Ananya Kumar, and Tengyu Ma. Self-training avoids using spurious features under domain shift. NeurIPS, 2020.
|
| 179 |
+
Nicolas Courty, Rémi Flamary, Devis Tuia, and Alain Rakotomamonjy. Optimal transport for domain adaptation. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2017.
|
| 180 |
+
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, K. Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. IEEE Conference on Computer Vision and Pattern Recognition, 2009.
|
| 181 |
+
Jia Deng, Alexander C. Berg, K. Li, and Li Fei-Fei. What does classifying more than 10, 000 image categories tell us? In ECCV, 2010.
|
| 182 |
+
Jia Deng, Sanjeev Satheesh, Alexander Berg, and Fei Li. Fast and balanced: Efficient label tree learning for large scale object recognition. In J. Shawe-Taylor, R. Zemel, P. Bartlett, F. Pereira, and K.Q. Weinberger (eds.), Advances in Neural Information Processing Systems, volume 24. Curran Associates, Inc., 2011. URL https://proceedings.neurips.cc/paper/2011/file/ 5a4b25aaed25c2ee1b74de72dc03c14e-Paper.pdf.
|
| 183 |
+
Jia Deng, Nan Ding, Yangqing Jia, Andrea Frome, Kevin Murphy, Samy Bengio, Yuan Li, Hartmut Neven, and Hartwig Adam. Large-scale object classification using label relation graphs. In ECCV, 2014.
|
| 184 |
+
Ankit Dhall. Learning representations for images with hierarchical labels. ArXiv, abs/2004.00909, 2020.
|
| 185 |
+
Ankit Dhall, Anastasia Makarova, Octavian-Eugen Ganea, Dario Pavllo, Michael Greeff, and Andreas Krause. Hierarchical image classification using entailment cone embeddings. 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), 2020.
|
| 186 |
+
Jeff Donahue, Yangqing Jia, Oriol Vinyals, Judy Hoffman, Ning Zhang, Eric Tzeng, and Trevor Darrell. Decaf: A deep convolutional activation feature for generic visual recognition. In ICML, 2014.
|
| 187 |
+
Andrea Frome, Gregory S. Corrado, Jonathon Shlens, Samy Bengio, Jeffrey Dean, Marc’Aurelio Ranzato, and Tomas Mikolov. Devise: A deep visual-semantic embedding model. In NeurIPS, 2013.
|
| 188 |
+
Yaroslav Ganin and Victor S. Lempitsky. Unsupervised domain adaptation by backpropagation. ArXiv, abs/1409.7495, 2015.
|
| 189 |
+
Yaroslav Ganin, E. Ustinova, Hana Ajakan, Pascal Germain, H. Larochelle, François Laviolette, Mario Marchand, and Victor S. Lempitsky. Domain-adversarial training of neural networks. The Journal of Machine Learning Research, 2016.
|
| 190 |
+
Muhammad Ghifary, W. Kleijn, Mengjie Zhang, and David Balduzzi. Domain generalization for object recognition with multi-task autoencoders. IEEE International Conference on Computer Vision (ICCV), 2015.
|
| 191 |
+
Xavier Glorot, Antoine Bordes, and Yoshua Bengio. Domain adaptation for large-scale sentiment classification: A deep learning approach. In ICML, 2011.
|
| 192 |
+
Boqing Gong, Yuan Shi, Fei Sha, and Kristen Grauman. Geodesic flow kernel for unsupervised domain adaptation. IEEE Conference on Computer Vision and Pattern Recognition, 2012.
|
| 193 |
+
Mingming Gong, Kun Zhang, Tongliang Liu, Dacheng Tao, Clark Glymour, and Bernhard Schölkopf. Domain adaptation with conditional transferable components. JMLR workshop and conference proceedings, 2016.
|
| 194 |
+
Ian Goodfellow, Yoshua Bengio, Aaron Courville, and Yoshua Bengio. Deep learning, volume 1. MIT Press, 2016.
|
| 195 |
+
Raghuraman Gopalan, Ruonan Li, and Rama Chellappa. Domain adaptation for object recognition: An unsupervised approach. International Conference on Computer Vision, 2011.
|
| 196 |
+
Peter Hase, Chaofan Chen, Oscar Li, and Cynthia Rudin. Interpretable image recognition with hierarchical prototypes. ArXiv, abs/1906.10651, 2019.
|
| 197 |
+
Kaiming He, X. Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
|
| 198 |
+
Gao Huang, Zhuang Liu, and Kilian Q. Weinberger. Densely connected convolutional networks. IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017.
|
| 199 |
+
Matheus Inoue, Carlos Henrique Quartucci Forster, and Antonio Carlos dos Santos. Semantic hierarchybased convolutional neural networks for image classification. International Joint Conference on Neural Networks (IJCNN), 2020.
|
| 200 |
+
Xiang Jiang, Mohammad Havaei, Farshid Varno, Gabriel Chartrand, Nicolas Chapados, and Stan Matwin. Learning to learn with conditional class dependencies. In ICLR, 2019.
|
| 201 |
+
Sergey Karayev, Mario Fritz, and Trevor Darrell. Anytime recognition of objects and scenes. In 2014 IEEE Conference on Computer Vision and Pattern Recognition, pp. 572–579, 2014. doi: 10.1109/CVPR.2014.80.
|
| 202 |
+
Pang Wei Koh, Shiori Sagawa, Henrik Marklund, Sang Michael Xie, Marvin Zhang, Akshay Balsubramani, Wei hua Hu, Michihiro Yasunaga, Richard L. Phillips, Sara Beery, Jure Leskovec, Anshul Kundaje, Emma Pierson, Sergey Levine, Chelsea Finn, and Percy Liang. Wilds: A benchmark of in-the-wild distribution shifts. In ICML, 2021.
|
| 203 |
+
Brendan Kolisnik, Isaac Hogan, and Farhana H. Zulkernine. Condition-cnn: A hierarchical multi-label fashion image classification model. Expert Syst. Appl., 2021.
|
| 204 |
+
Ananya Kumar, Tengyu Ma, and Percy Liang. Understanding self-training for gradual domain adaptation. In ICML, 2020.
|
| 205 |
+
Bo Li, Yezhen Wang, Tong Che, Shanghang Zhang, Sicheng Zhao, Pengfei Xu, Wei Zhou, Yoshua Bengio, and Kurt Keutzer. Rethinking distributional matching based domain adaptation. ArXiv, abs/2006.13352, 2020.
|
| 206 |
+
Da Li, Yongxin Yang, Yi-Zhe Song, and Timothy M. Hospedales. Learning to generalize: Meta-learning for domain generalization. ArXiv, abs/1710.03463, 2018.
|
| 207 |
+
Yitong Li, Michael Murias, Samantha Major, Geraldine Dawson, and David Edwin Carlson. On target shift in adversarial domain adaptation. In AISTATS, 2019.
|
| 208 |
+
Yuntao Liu, Yong Dou, Ruochun Jin, and Peng Qiao. Visual tree convolutional neural network in image classification. 24th International Conference on Pattern Recognition (ICPR), 2018.
|
| 209 |
+
Mingsheng Long, Yue Cao, Jianmin Wang, and Michael I. Jordan. Learning transferable features with deep adaptation networks. ArXiv, abs/1502.02791, 2015.
|
| 210 |
+
James L. McClelland, Zahra Sadeghi, and Andrew M. Saxe. A critique of pure hierarchy: Uncovering cross-cutting structure in a natural dataset. 2016.
|
| 211 |
+
George A. Miller. Wordnet: A lexical database for english. Commun. ACM, 1992.
|
| 212 |
+
Jinho Park, Heegwang Kim, and Joonki Paik. Cf-cnn: Coarse-to-fine convolutional neural network. Applied Sciences, 11, 2021.
|
| 213 |
+
Hieu Pham, Tung T. Le, Dat Thanh Ngo, Dat Q. Tran, and Ha Q. Nguyen. Interpreting chest x-rays via cnns that exploit hierarchical disease dependencies and uncertainty labels, 2021.
|
| 214 |
+
Yanyun Qu, Li Lin, Fumin Shen, Chang Lu, Yang Wu, Yuan Xie, and Dacheng Tao. Joint hierarchical category structure learning and large-scale image classification. IEEE Transactions on Image Processing, 2017.
|
| 215 |
+
Joaquin Quionero-Candela, Masashi Sugiyama, Anton Schwaighofer, and Neil D. Lawrence. Dataset shift in machine learning. 2009.
|
| 216 |
+
Ali Sharif Razavian, Hossein Azizpour, Josephine Sullivan, and Stefan Carlsson. Cnn features off-the-shelf: An astounding baseline for recognition. IEEE Conference on Computer Vision and Pattern Recognition Workshops, 2014.
|
| 217 |
+
Deboleena Roy, Priyadarshini Panda, and Kaushik Roy. Tree-cnn: A hierarchical deep convolutional neural network for incremental learning. Neural Networks, 2020.
|
| 218 |
+
Kate Saenko, Brian Kulis, Mario Fritz, and Trevor Darrell. Adapting visual category models to new domains. In ECCV, 2010.
|
| 219 |
+
Shibani Santurkar, Dimitris Tsipras, and Aleksander Madry. {BREEDS}: Benchmarks for subpopulation shift. In International Conference on Learning Representations, 2021.
|
| 220 |
+
Andrew M. Saxe, James L. McClelland, and Surya Ganguli. Learning hierarchical categories in deep neural networks. Cognitive Science, 2013.
|
| 221 |
+
Sang-Il Seo and Juntae Kim. Hierarchical semantic loss and confidence estimator for visual-semantic embedding-based zero-shot learning. Applied Sciences, 2019.
|
| 222 |
+
Yian Seo and Kyung shik Shin. Hierarchical convolutional neural networks for fashion image classification. Expert Systems with Applications, 2019.
|
| 223 |
+
|
| 224 |
+
Sindi Shkodrani, Yu Wang, Marco Manfredi, and Nóra Baka. United we learn better: Harvesting learning improvements from class hierarchies across tasks. ArXiv, abs/2107.13627, 2021.
|
| 225 |
+
|
| 226 |
+
Kihyuk Sohn, David Berthelot, Chun-Liang Li, Zizhao Zhang, Nicholas Carlini, Ekin Dogus Cubuk, Alexey Kurakin, Han Zhang, and Colin Raffel. Fixmatch: Simplifying semi-supervised learning with consistency and confidence. ArXiv, abs/2001.07685, 2020.
|
| 227 |
+
Guocong Song and Wei Chai. Collaborative learning for deep neural networks. In NeurIPS, 2018.
|
| 228 |
+
Remi Tachet des Combes, Han Zhao, Yu-Xiang Wang, and Geoffrey J Gordon. Domain adaptation with conditional distribution matching and generalized label shift. In Advances in Neural Information Processing Systems, 2020.
|
| 229 |
+
Salma Taoufiq, Balázs Nagy, and Csaba Benedek. Hierarchynet: Hierarchical cnn-based urban building classification. Remote Sensing, 2020.
|
| 230 |
+
Manisha Verma, Sudhakar Kumawat, Yuta Nakashima, and Shanmuganathan Raman. Yoga-82: A new dataset for fine-grained classification of human poses. IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), 2020.
|
| 231 |
+
Nakul Verma, Dhruv Mahajan, Sundararajan Sellamanickam, and Vinod Nair. Learning hierarchical similarity metrics. In IEEE conference on computer vision and pattern recognition. IEEE, 2012.
|
| 232 |
+
Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms, 2017. URL http://arxiv.org/abs/1708.07747.
|
| 233 |
+
Zhicheng Yan, Hao Zhang, Robinson Piramuthu, Vignesh Jagadeesh, Dennis DeCoste, Wei Di, and Yizhou Yu. Hd-cnn: Hierarchical deep convolutional neural networks for large scale visual recognition. IEEE International Conference on Computer Vision, 2015.
|
| 234 |
+
Hao-Tong Ye, Chuanlong Xie, Tianle Cai, Ruichen Li, Zhenguo Li, and Liwei Wang. Towards a theoretical framework of out-of-distribution generalization. ArXiv, abs/2106.04496, 2021.
|
| 235 |
+
Matthew D. Zeiler and Rob Fergus. Visualizing and understanding convolutional networks. In ECCV, 2014.
|
| 236 |
+
Quanshi Zhang, Yu Yang, Ying Nian Wu, and Song-Chun Zhu. Interpreting cnns via decision trees. IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
|
| 237 |
+
Yu Zheng, Jianping Fan, Ji Zhang, and Xinbo Gao. Hierarchical learning of multi-task sparse metrics for large-scale image classification. Pattern Recognition, 2017.
|
| 238 |
+
Xinqi Zhu and Michael Bain. B-cnn: Branch convolutional neural network for hierarchical classification. ArXiv, abs/1709.09890, 2017.
|
| 239 |
+
|
| 240 |
+
# A Appendix
|
| 241 |
+
|
| 242 |
+
We mention some additional related literature in this section.
|
| 243 |
+
|
| 244 |
+
# A.1 Additional Related Work
|
| 245 |
+
|
| 246 |
+
Hierarchy based Semantic Embedding. DeVise (Frome et al., 2013) presents a deep visual-semantic embedded model which learns similarity between classes in the semantic space both from images as well as unannotated text. Barz & Denzler (2019; 2020) demonstrates how prior knowledge can be leveraged based on hierarchy of classes such as WordNet to learn semantically discriminating features. Such learnt class embeddings projected on a unit hypersphere proved to be beneficial for both novel class predictions as well as image retrieval tasks.
|
| 247 |
+
|
| 248 |
+
Domain Adaptation and its variants are a well studied set of problems in deep learning. One direction of works (Ben-David et al. (2006), Saenko et al. (2010), Ganin $\&$ Lempitsky (2015), Courty et al. (2017), Gong et al. (2016), Donahue et al. (2014), Razavian et al. (2014)) is aimed at tackling the problem of adapting to target domains by learning on a selective set of samples from the target domain itself. Another line of work aims to match the source and target distributions in the feature space (Glorot et al. (2011), Ajakan et al. (2014), Long et al. (2015), Ganin et al. (2016)). The main motive behind these set of works is to tackle out-of-support domain adaptation tasks by sharing a common representation between the two. To adapt to newer environments, deep models are trained gradually to make them more suitable for transition to these newer environments (Gopalan et al. (2011), Gong et al. (2012), Glorot et al. (2011), Kumar et al. (2020), Chen et al. (2020)). Domain generalization enables the use of multiple different environments during training, but requires having a prior knowledge on the target distribution (Ghifary et al. (2015), Li et al. (2018), Arjovsky et al. (2019), Ye et al. (2021)). We on the other hand, focus on a more specific problem of distribution shift, wherein the shift occurs at a subpopulation level in the target domain.
|
| 249 |
+
|
| 250 |
+
Hierarchical Learning for in Non-Supervised Approaches. Tree-CNN (Roy et al., 2020) tackles the incremental learning problem where the model expands as a tree to accommodate new classes. Zheng et al. (2017) and Qu et al. (2017) tackle the problem of metric learning via hierarchical concepts on large scale image datasets. Chen et al. (2019) applies a semi-supervised approach to learn cluster level concepts at higher level of a hierarchy and categorical features at leaf node levels. Jiang et al. (2019) proposes a Conditional class-aware Meta Learning framework that conditionally learns better representations through modeling inter-class dependencies. Seo & Kim (2019) incorporates a hierarchical semantic loss function together with a confidence estimator to improve performance of zero-shot learning in terms of hit@k accuracy. Works such as McClelland et al. (2016) and Saxe et al. (2013) tried to understand the importance of hierarchical learning from a theoretical perspective and demonstrated an implementation on a neural network based model.
|
| 251 |
+
|
| 252 |
+
Hierarchical Learning for Interpretability. Interpreting predictions from CNNs has been key in understanding what features models look at in order to make predictions. Zhang et al. (2019) provide a semantic as well as quantitative explanations for CNN predictions based on a decision tee in a coarse-to-fine manner at different fine-grained levels. Building on this concept, Hase et al. (2019) introduces a model that leverages a predefined taxonomy to explain the predictions at each level of the taxonomy essentially showing how a Capuchin is gradually classified first as an animal, followed by a primate and finally as a Capuchin as per the hierarchy.
|
| 253 |
+
|
| 254 |
+
Applications of Hierarchical Learning. Dhall et al. (2020), Dhall (2020) show how an image classifier augmented with hierarchical information based on entailment cone embeddings outperforms flat classifiers on an Entomological Dataset. Pham et al. (2021) takes advantage of the relationship between diseases in chest X-rays to learn conditional probabilities through image classifiers. Taoufiq et al. (2020) adapts a similar approach to learn urban structural relationships.
|
| 255 |
+
|
| 256 |
+
# A.2 Experiments
|
| 257 |
+
|
| 258 |
+
# A.2.1 Custom Datasets
|
| 259 |
+
|
| 260 |
+
Results on Custom Dataset 1 (left) and Custom Dataset 2 (right). Mean and standard deviations are reported for five random trials.
|
| 261 |
+
|
| 262 |
+
<table><tr><td>Model</td><td>Accs-s</td><td>Accs-u</td><td>Accs-s</td><td>Accs-u</td></tr><tr><td>Baseline-18</td><td>83.47 ± 0.95</td><td>48.69 ± 1.32</td><td>77.73 ± 2.01</td><td>55.0 ± 0.87</td></tr><tr><td>BCNN-18</td><td>87.87 ± 0.71</td><td>51.33 ± 1.22</td><td>81.73 ± 0.51</td><td>58.96 ± 1.47</td></tr><tr><td>Hierarchical-18</td><td>88.27 ± 0.88</td><td>53.76 ± 0.47</td><td>82.48 ± 0.54</td><td>59.35 ± 1.65</td></tr></table>
|
| 263 |
+
|
| 264 |
+
# A.2.2 LIVING-17
|
| 265 |
+
|
| 266 |
+
Results on LIVING-17, with and without shift is shown on the left. Results for shift on Living-17-B and Living-17-C are shown as well. Mean and standard deviations are reported for five random trials.
|
| 267 |
+
|
| 268 |
+
<table><tr><td>Model</td><td>Accs-s</td><td>Accs-u</td><td> Accs-u(B)</td><td>Accs-u(C)</td></tr><tr><td>Baseline-18</td><td>92.3 ± 0.84</td><td>57.02 ± 1.48</td><td>53.54 ± 2.28</td><td>53.04 ± ± 1.9</td></tr><tr><td>BCNN-18</td><td>92.88 ± 0.29</td><td>58.8 ± 0.51</td><td>55.66 ± 0.52</td><td>55.1 ± 0.96</td></tr><tr><td>Hierarchical-18</td><td>93.17 ± 0.34</td><td>60.53 ± 0.89</td><td>56.6 ± 0.96</td><td>55.62 ± 0.82</td></tr></table>
|
| 269 |
+
|
| 270 |
+
# A.2.3 Non-LIVING-26
|
| 271 |
+
|
| 272 |
+
Results on Non-LIVING-26, with and without shift. The L3 Hierarchy is the same hierarchy with the first two levels collapsed into a single level. Mean and standard deviations are reported for five random trials.
|
| 273 |
+
|
| 274 |
+
<table><tr><td>Model</td><td>Accs-s</td><td>Accs-u</td></tr><tr><td>Baseline-18</td><td>88.39 ± 0.32</td><td>42.13 ± 0.93</td></tr><tr><td>BCNN-18</td><td>88.1 ± 0.43</td><td>42.4 ± 0.28</td></tr><tr><td>L3 Hierarchical-18</td><td>87.71 ± 0.16</td><td>42.44 ± 0.31</td></tr><tr><td>Hierarchical-18</td><td>87.41 ± 0.34</td><td>42.94 ± 0.46</td></tr></table>
|
| 275 |
+
|
| 276 |
+
# A.2.4 ENTITY-30
|
| 277 |
+
|
| 278 |
+
Accuracy results on ENTITY-30, with and without shift. Mean and standard deviations are reported for five random trials.
|
| 279 |
+
|
| 280 |
+
<table><tr><td>Model</td><td>Accs-s</td><td>Accs-u</td></tr><tr><td>Baseline-18</td><td>87.98 ± 0.1</td><td>49.52 ± 0.16</td></tr><tr><td>Hierarchical-18</td><td>87.93 ± 0.09</td><td>50.24 ± 0.26</td></tr></table>
|
parse/test/tzW948kU6x/tzW948kU6x.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/tzW948kU6x/tzW948kU6x_content_list.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/tzW948kU6x/tzW948kU6x_middle.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
parse/test/tzW948kU6x/tzW948kU6x_model.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|