S ELF -D ISTILLATION FOR F URTHER P RE - TRAINING OF T RANSFORMERS
A BSTRACT
The application of pre-training large transformer models on massive amounts of unlabeled data and fine-tuning them on labeled datasets for diverse downstream tasks has demonstrated remarkable success in various vision and natural language processing tasks.
However, the direct fine-tuning approach may result in suboptimal performance if there exists a significant discrepancy between the pre-training and fine-tuning domains.
To address this issue, some previous studies have proposed further pre-training strategies to continue pre-training the model on the target unlabeled dataset before fine-tuning.
However, these strategies are limited to language models and may result in overfitting when applied to Vision Transformers.
To overcome this limitation, we present a novel approach of self-distillation as a regularization method for the further pre-training stage.
Our method first further pre-trains the initial pre-trained model on the target unlabeled data, and then uses it as a teacher for self-distillation.
Then we take the same initial pre-trained model as a student, and enforce its hidden representations to be close to those of the teacher while optimizing the student with a masked auto-encoding objective.
Our experiments demonstrate the superiority of self-distillation over relevant baselines on various benchmark datasets for image and text classification tasks.
Furthermore, we provide a theoretical analysis of our proposed method using a simplified model to shed light on how self-distillation for further pre-training can potentially enhance the performance of downstream tasks.
I NTRODUCTION
Pre-trained transformer models (Devlin et al., 2019; Brown et al., 2020; Liu et al., 2019; He et al., 2022) have been effective on various vision and natural language processing tasks.
The pre-trained models learn general representation from a large volume of unlabeled data so that they generalize well to various downstream tasks when they are fine-tuned on each task with a labeled dataset.
However, in many of real-world applications, it requires a considerable amount of effort to adapt the pre-trained model to a specific downstream task domain since there exists a significant distributional discrepancy between data for the pre-training and fine-tuning stage.
Moreover, it is difficult to collect a large amount of labeled data for such specific domains, which renders adaptation of the pre-trained model to downstream tasks more challenging.
[Figure]
Several works have proposed to tackle the problem of adapting pre-trained models to a specific domain.
A prevalent approach for adaptation of the pre-trained model is further pre-training where we continue to update the parameters of the pre-trained model on additionally curated domain-specific unlabeled data with self-supervision (Beltagy et al., 2019; Lee et al., 2020), before fine-tuning it on the target labeled data as depicted in
Figure 2b.
Gururangan et al.
(2020) also show that further pretraining only with the target unlabeled data is still effective without any extra data.
However, most of the existing further pretraining approaches have focused on language models, and we find that the further pre-training
[Figure]
strategy is not effective for Vision Transformer (ViT)
(Dosovitskiy et al., 2021).
As shown in Figure 1, ViT is vulnerable to overfitting and does not generalize well to downstream tasks as when we continue to pre-train it on the target unlabeled data.
Several regularization methods (Chen et al., 2020a; Gouk et al., 2021; Aghajanyan et al., 2021) have proposed to tackle the overfitting issue of large pre-trained models, however, they do not consider the adaptation process such as further pre-training.
Instead, they enforce the distance between the final fine-tuned weight and the pre-trained weight to be small to promote the transfer of the knowledge acquired from pre-training to downstream tasks for better generalization.
However, these regularizations hinder the adaptation of pre-trained models to downstream tasks especially when there is a significant distributional shift between the pre-trained data and target data.
It eventually results in worse generalization than the simple fine-tuning strategy.
To tackle these limitations, we propose self-distillation as a regularization for further pre-training on a target unlabeled dataset so that we can effectively adapt pre-trained models to the downstream task of various domains with a limited amount of labeled data.
For self-supervision, we focus on masked auto-encoding for pre-training since it does not depend on any data augmentations, compared to other self-supervised learning methods (Chen et al., 2020b;
He et al., 2020; Grill et al., 2020; Zbontar et al., 2021; Chen & He, 2021; Caron et al., 2021) which require data augmentations to construct positive pairs for self-supervised learning objective such as contrastive learning.
This is especially useful when it is hard to define meaningful data augmentations for a target domain.
Specifically, we take the pre-trained model with an encoder f θ init and a decoder g ϕ init which are pretrained on a massive amount of unlabeled data from general domain, and continue to pre-train it with masked auto-encoding (MAE) (Devlin et al., 2019;
He et al., 2022) objective on the target unlabeled data to obtain f θ 0 and g ϕ 0 .
After that, we set the encoder f
θ 0 as a teacher for self-distillation.
Then we take the copy of the pre-trained model ( f θ init , g ϕ init ) as a student, and match the representations of the student encoder and those of the teacher encoder while optimizing the student with the MAE on the target unlabeled data.
Finally, we fine-tune the self-distilled student f θ 1 on the target labeled data for the downstream task.
We illustrate the overview of our method in Figure 2c.
To verify the efficacy of our method, we empirically show that it significantly improves the generalization performance of a pre-trained ViT and language model RoBERTA
(Liu et al., 2019), and outperforms the relevant baselines on various image and text classification datasets.
Moreover, we theoretically analyze the proposed method with a simplified model to understand how self-distillation for further pre-training can potentially help improve the generalization performance on the target tasks after fine-tuning.
Our contribution is threefold:
• We propose self-distillation for further pre-training on the target unlabeled dataset, where we enforce representations of the student to be close to those of the further pre-trained teacher while training the student with masked-auto encoding objective.
• We theoretically analyze the proposed method with a simplified model to understand how self-distillation for further pre-training can potentially lead to better generalization performance of downstream tasks.
• We extensively validate our method on various image and text classification datasets with pre-trained transformers and show that ours outperforms the relevant baselines.
R ELATED W ORK
Self-Distillation Knowledge distillation is to transfer knowledge of teacher to student by minimizing a divergence between output of teacher and student (Hinton et al., 2014).
When the parameterization of student and teacher is identical, we call it self-distillation as a special case of the knowledge distillation.
Although there is no new information during self-distillation process, Furlanello et al.
(2018) have shown that the student from self-distillation achieves better generalization performance than the teacher.
A similar phenomenon has been consistently observed in other works (Yang et al., 2019; Ahn et al., 2019).
Several works propose a self-distillation without a pre-trained teacher network (Sun et al., 2019; Zhang et al., 2019; 2022).
They add auxiliarly classifiers to intermediate layers and train the classifiers to minimize divergence between the output of the classifier of the last layer and that of the auxiliary classifiers.
Mobahi et al.
(2020) theoretically analyze how selfdistillation induces regularization and reduces overfitting in Hilbert space.
However, all of them focus on self-distillation for supervised learning.
Instead, we empirically and theoretically show that self-distillation for further pre-training with self-supervision leads to better generalization of downstream tasks after fine-tuning the self-distilled model with target labeled data.
Further Pre-training Lee et al.
; Beltagy et al.
; Sun et al.
(2020) have shown the success of continual pre-training language model on a large number of corpora collected from target domain and fine-tuning the model on target labeled dataset.
However, it is computationally expensive to further pre-train the model on a large amount of unlabeled text data and it may not be feasible to collect such a large scale of unlabeled data on certain domains.
Instead, Gururangan et al.
(2020) devise a task-adaptive pre-training where we use only target unlabeled data for further pre-training language model before fine-tuning the model on the target labeled data.
To improve the effectiveness of further pre-training, Kang et al.
; Ye et al.
(2021) propose learning to mask input for masked auto-encoding with bilevel optimization, which requires a prohibitive computational cost.
However, all of them solely focus on pre-trained language models and we empirically find that naive further pre-training is not effective for Vision Transformers.
Regularization for Fine-tuning There are several works proposing regularization for fine-tuning a pre-trained model.
Chen et al.
(2020a) propose to modify Adam (Kingma & Ba, 2015) optimizer, called RecAdam, which enforces the fine-tuned model close to the initial pre-trained model by minimizing L 2 distance between fine-tuned and initial pre-trained weight.
Similarly, Gouk et al.
(2021) project the fine-tuned weight for every gradient descent update such that it lies within the sphere centered on the initial pre-trained weights with the distance induced by the norm of maximum absolute row sums (MARS).
Instead of explicitly minimizing the distance, motivated by trust region theory, Aghajanyan et al.
(2021) propose to minimize symmetric KL-divergence between the model output of an original input and that of the input perturbed by Gaussian noise.
However, all of them do not consider adaptation of pre-trained models to a specific target domain, which results in worse generalization performance of downstream tasks than a simple fine-tuning strategy.
M ETHOD 3. P RELIMINARIES
Problem Statement We assume that we are given ( θ init , ϕ init ) parameters of the neural network g ϕ init ◦ f θ init which is pre-trained on a large volume of unlabeled data with masked auto-encoding objective, where f θ init is an encoder which extracts hidden representation of an input and g ϕ init is an decoder reconstructing a masked input.
Our goal is to fine-tune the pre-trained model f θ init with a randomly initialized task specific head h ω on labeled dataset D tr = { ( x ( i ) , y ( i ) )
} n i =1 of a downstream classification task such that the model generalizes well to unseen test dataset D test .
A typical approach to achieve this goal is empirical risk minimization as follows:
[Equation]
algorithm
A
[Equation]
Require:
Unlabeled dataset D u , initialization θ init , ϕ init , learning rate α ∈ R ≥ 0 , round of self-distillation T ′ ∈ N + , masking probability γ ∈ (0 , 1) and batch size B . 1: θ 0 ← Further Pretrain ( D u , θ init , ϕ init , α, γ, B ) 2: for all t ← 1 , . .
, T ′ do 3:
Initialize θ t ← θ init and ϕ t ← ϕ init 4: while not converge do 5:
Sample a mini-batch { x ( j ) }
Bj =1 from D u 6: for all j ← 1 , . .
, B do 7:
Sample a mask z ( j ) ∼ p γ,K ( z ) 8:
Z ( j ) ← (cid:80) Kk
=1 z ( j ) k 9:
Get a masked input ˆ x ( j ) with z ( j ) 10: ℓ 1 j ← − (cid:80) Kk
=1 z ( j ) k Z ( j ) log p θ t ,ϕ t ( x ( j ) k
| ˆ x ( j ) ) 11: ℓ 2 j ← (cid:13)(cid:13)(cid:13)
f θ t ( x ( j ) ) − StopGrad ( f θ 0 ( x ( j ) ))
(cid:13)(cid:13)(cid:13) 212: end for 13:
L 1 ← 1 B (cid:80) Bj =1 ℓ 1 j , L 2 ← 1 B (cid:80) Bj =1 ℓ 2 j 14: θ t ← θ t − α
∂
( L 1 + L 2 ) ∂θ | θ = θ t 15: ϕ t ← ϕ t − α
∂ L 1 ∂ϕ | ϕ =
ϕ t 16: end while 17: θ 0 ← θ t 18: end for 19: return θ T ′
Require:
Unlabeled dataset D u , initialization θ init , ϕ init , learning rate α ∈ R ≥ 0 , mask- ing probability γ ∈ (0 , 1) , and batch size B .
θ
← θ init ϕ 0 ← ϕ converge do 3:
Sample mini j )
Bj =
D u 4: all j ← 1 , . . .
, B do 5:
Sample a mask z ( j ) ∼ p γ,T ( z ) 6:
Z ( j ) ← (cid:80) Kk
=1 z ( j ) k 7:
Get a masked input ˆ x ( j ) with z ( j ) 8: p k ← p θ 0 ,ϕ 0 ( x ( j ) k | ˆ x ( j ) ) 9: ℓ 1 j ← − (cid:80) Kk
=1 z ( j ) k Z ( j ) log p k 10: end for 11:
L ← 1 B (cid:80) Bj =1 ℓ 1 j 12: θ 0 ← θ 0 − α ∂ L ∂θ | θ = θ13: ϕ 0 ← ϕ 0 − α ∂ L ∂ϕ | ϕ
=
ϕ14: end while 15: return θ16:17: where L CE is a cross-entropy loss and A denotes a stochastic gradient descent algorithm to minimize
L CE on the dataset D tr with the initialization θ init .
Further Pre-training
However, the pre-trained model is prone to overfitting when it is fine-tuned on a small amount of domain-specific labeled data.
Gururangan et al.
(2020) have shown that further pre-training, where we continue to pre-train the model g ϕ init ◦ f θ init on the target unlabeled dataset
D u
= { x ( i ) } ni =1 and then fine-tune it on D tr , is effective for improving generalization performance when there is not enough domain-specific labeled data.
Note that D u is the exactly same as D tr except that we remove the labels y
( i ) .
In this work, we focus on the masked auto-encoding (Devlin et al., 2019;
He et al., 2022) as a pre-training objective function since its generality compared to other self-supervised methods (Chen et al., 2020b; He et al., 2020;
Grill et al., 2020;
He et al., 2020;
Chen & He, 2021; Caron et al., 2021) which require well-defined data augmentations to construct positive pairs for self-supervised learning.
Masked Auto-Encoding We briefly describe the masked auto-encoding objective (Liu et al., 2019;
He et al., 2022) for a language model such as RoBERTA (Liu et al., 2019) and Vision Transformer (ViT) (Dosovitskiy et al., 2021).
Let x ( i ) =
( x ( i ) 1 , . . .
, x ( i ) K ) be a sequence of patches for a image or tokens for a sentence with length K .
Then we independently sample a binary mask from Bernoulli distribution with probability γ for each x ( i ) k , denoted as z ( i ) =
( z ( i ) 1 , . . .
, z ( i ) K ) .
If z ( i ) k
= 1 , then x ( i ) k is replaced with a special “mask” token.
Otherwise, we use the same x ( i ) k for a masked input.
Let ˆ x ( i ) =
(ˆ x ( i ) 1 , . . .
, ˆ x ( i ) K ) be a masked input and let f θ , g ϕ be an encoder and decoder, respectively.
Then the final objective for masked auto-encoding is defined as follows:
[Equation]
where p γ,K ( z ) denotes a Binomial distribution with its parameters γ for probability that z k = 1 and
K for the number of trials.
Note that the negative log-likelihood is instantiated as cross-entropy loss for language models or mean square error for Vision Transformers.
See Appendix C for more detail.
3. S ELF -D ISTILLATION FOR F URTHER P RE - TRAINING
Although further pre-training strategy has been effective on text domain (Gururangan et al., 2020;
Lee et al., 2020; Sun et al., 2020), we empirically find that ViT with further pre-training overfits the target unlabeled data and does not generalize well to downstream image classification tasks.
In order to tackle the issue, we propose self-distillation as a regularization for further pre-training.
Specifically, given a pre-trained model g ϕ init ◦ f θ init , we first continue to train the model on the target unlabeled data D u with the masked auto-encoding objective as described in equation 2 to obtain the encoder f
θ 0 and decoder g ϕ 0 .
We discard the decoder and consider the encoder f θ 0 as a teacher for self-distillation.
Then we take the copy of the pre-trained initial network g ϕ init ◦ f θ init as a student and further pre-train the student with masked auto-encoding objective but enforce hidden representation of the encoder of the student f θ init to be close to that of the teacher f θ 0 as follows:
[Equation]
where θ and ϕ are initialized with the pre-trained parameters θ init and ϕ init , respectively and
StopGrad denotes the stop-gradient operation which does not back-propagate through the input.
As described in Algorithm 1, we can repeat this process to perform multiple rounds of selfdistillation ( T ′ > 1) where the student of the previous round becomes a teacher and a new student is initialized with the pre-trained weights θ init and ϕ init for the next round.
We empirically find that the first round of self-distillation plays the most significant role in improving the final generalization performance of downstream tasks.
Furthermore, theoretical analysis shows that the first round of self-distillation has the largest impact on regularization.
Thus, we perform a single round of self-distillation for computational efficiency.
After self-distillation, we discard the decoder g ϕand fine-tune the encoder of the student f θ 1 along with a randomly initialized task-specific head h ω by minimizing L CE ( θ, ω, ; D tr ) with the initialization θ 1 as described in equation 1.
T HEORETICAL A NALYSIS
In this section, we analyze how self-distillation affects the final model after fine-tuning in terms of generalization and regularization.
This section proves a generalization bound on the supervised loss for our method and shows that the generalization bound strictly decreases as the number of selfdistillation increases.
Moreover, we show that self-distillation acts as a regularizer on the distance between the initial weight before further pre-training and the final weight after fine-tuning.
The regularization effect is shown to have the largest impact in the first round of self-distillation, which suggests that the first round of self-distillation plays a more significant role in the final performance when compared to the other rounds.
We consider the dynamics of the weight vector w t,τ over time τ of fine-tuning after t rounds of selfdistillation, where w 0 , 0 is the result of further pre-training, and w t, 0 ∈ minimize w L t ( w ) is the result of the self-distillation of t rounds with L t ( w ) = 1 n (cid:80) ni
=1 ∥ f ( x i , w ) − f ( x i , w t − 1 , 0 ) ∥
22 + λ ∥ w ∥ 22 for some λ > 0 .
After t rounds of self-distillation, we consider the dynamics over fine-tuning time τ via gradient flow (Saxe et al., 2014; Kawaguchi, 2021): dw t,τ dτ = −∇L
( w t,τ ) , with the initialization w t,obtained by the self-distillation where L ( w ) = 12 (cid:80) ni =1 ℓ ( w, x i , y i ) with ℓ ( w, x, y ) =
∥
f ( x, w ) − y ∥
22 and y ∈ R p .
Here, the self-distillation and fine-tuning share a same training dataset s = { ( x i , y i ) } ni
=1 .
In this section, to obtain theoretical insights, we consider the regime of d > n and a simple abstract model, f ( x, w ) =
Wφ ( x ) ∈ R p , with some nonlinear map φ and the weight matrix
W ∈ R p × d where w = vec[ W ⊤ ] ∈ R dp and φ ( x ) ∈ R d .
Here, vec[ W ⊤ ] is a vectorization of the matrix W ⊤ .
Let us fix the fine-tuning time length T as 1 < τ ≤ T < ∞ .
Since d > n , there are infinitely many solutions to the problem of minimizing L ( w ) .
Thus, each of the finite length T and the over-parameterization d > n implies that the initialization w t, 0 at the fine-tuning phase via self-distillation plays an important role.
Let δ > 0 and t ∈ N 0 .
We then define F t = {A t ( s ) : s ∈ S} , where S is a set of all training datasets of size n such that with probability at least− δ , the training dataset s is in S .
For each training dataset s ∈ S , A t ( s ) =
w t,T is the final weight vector of the model after t rounds of selfdistillation and T time of fine-tuning.
Let us define the matrix Φ ∈ R d × n by Φ ij = φ ( x j ) i .
We assume that Φ is of full rank; i.e., rank(Φ)
= n since d ≥ n .
This is typically satisfied because if rank(Φ) <
n , there is some redundancy in the rows of the matrix Φ .
Denote by [ I p ⊗ Φ] ∈ R dp × np the Kronecker product of the identity matrix I
p ∈
R p × p and the matrix Φ .
We write its singular value decomposition by [ I p ⊗ Φ] = U Σ V ⊤ where U =
[ u 1 , u 2 . . .
, u dp ] ∈ R dp × dp contains the left-singular vectors u i ∈ R dp for i ∈ { 1 , . .
. , dp } and Σ ∈ R dp × np is a rectangular diagonal matrix with Σ ii = σ i ∈ R ≥ 0 for i ∈ { 1 , . .
. , np } and σ 1 ≥ σ 2 ≥ · · · ≥ σ np ≥ 0 .
Define M to be an upper bound on the loss as ℓ ( w, x, y ) ≤ M .
Define R to be an upper bound on the expected norm of the features as E x ∥ φ ( x ) ∥ 2 ≤ R .
We assume that w 0 , 0 ̸ = 0 ; if w 0 , 0 = 0 , then the target function in the self-distillation phase is always zero as f ( x i , w 0 , 0 )
=
for all i , which is unlikely the case in practice.
We define w init ∈ R dp to be the weight before further pre-training and define
[Equation]
The following theorem shows that the generalization bound on the supervised loss ℓ ( w t,T , x, y ) of the fine-tuning phase strictly decreases as we increase the number t of self-distillation rounds in the further pre-training phase:
Theorem 1.
There exists a constant c (that only depends on M ) such that with probability at least 1 − δ , the following holds:
[Equation]
where the function ζ ( t ) is strictly decreasing in t ∈ N 0 .
The proofs of all results in this section are presented in
Appendix A. Moreover, the following theorem shows that the tight upper bound on the distance between the initial weight w init and the final weight w t,T after T steps of fine-tuning (i.e., ∥ w init − w t,T ∥ 2 ) strictly decreases as the number t of self-distillation rounds increases:
Theorem 2.
There is a function ψ : N 0 → R ≥ 0 such that (1) ∥ w init − w t,T ∥ 2 = ψ ( t ) for some w init ∈ R dp , (2) ∥ w init − w t,T ∥ 2 ≤ ψ ( t ) for all w init ∈ R dp , (3) the function ψ ( t ) is strictly decreasing in t ∈ N 0 , (4) the function ψ ( t ) can be decomposed to ψ ( t ) =
(cid:112) G 1 + ψ 1 ( t )
+ 1 { t = 0 }B + Gwith constants G 1 , G 2 ≥ 0 in t where ψ 1 ( t ) is strictly decreasing in t ∈ N 0 and B = (cid:80) dpi = np +1 ( u ⊤ i w 0 , 0 ) 2 ≥ 0 .
Theorem 2 shows that the self-distillation acts as a regularizer on the distance between the initial weight w init and the final weight w t,T .
Since the Rademacher complexity of a set of vectors is invariant to a shift by a constant vector, this distance has been shown to control the generalization bound in previous papers in various models and settings, including deep neural networks (Bartlett &
Mendelson, 2002; Bartlett et al., 2017; Nagarajan & Kolter, 2019).
This suggests that self-distillation helps generalization via a regularization effect on the distance.
Moreover, the first round of selfdistillation is expected to have the largest impact based on Theorem 2 since Theorem 2 shows that we can completely remove the unnecessary component B of w 0 , 0 in the first round of self-distillation.
We have verified these theoretical predictions in the experiments where we show the correlation between the improvement via self-distillation and the distance that appeared in the generalization bound in the previous paper (Nagarajan & Kolter, 2019).
E XPERIMENT
Dataset For image classification problem, we use six datasets — FGVC Aircraft (Aircraft)
(Maji et al., 2013), Caltech UCSD Birds 200 (CUB)
(Wah et al., 2011), Chest X-ray (Kermany et al., 2018),
Describable Textures Dataset (DTD) (Cimpoi et al., 2014), Stanford Dogs (Khosla et al., 2011), and
Oxford 102 Flower (Nilsback & Zisserman, 2008).
For text classification problem, we use four datasets — Chemprot (Kringelum et al., 2016),
ACL-ARC (Jurgens et al., 2018), SCIERC (Luan et al., 2018), and Twitter-Emotion (Mohammad et al., 2018).
Please see Appendix D for more detail.
Implementation Detail For the image classification problem, we use Vision Transformer pretrained on unlabeled ImageNet dataset with masked auto-encoding (He et al., 2022) and fine-tune it on the downstream task with AdamW optimizer (Loshchilov & Hutter, 2019) for 10,000 steps with batch size 32.
Regarding further pre-training and self-distillation, we continue to pre-train the model for 20,000 steps with batch size 64.
We evaluate the Vision Transformers with accuracy.
For text classification, following the experimental setup from Gururangan et al.
(2020), we use
RoBERTA
(Liu et al., 2019) as a backbone network and fine-tune it on the target labeled dataset
[Table] [Table]
with AdamW optimizer for 10 epochs with batch size 32.
In terms of further pre-training and selfdistillation, we further pre-train RoBERTA for 100 epochs with batch size 128.
We evaluate the models with macro F1 for SCIERC, ACL-ARC, and Twitter-Emotion dataset, and micro F1 for
Chemprot dataset.
Baselines We compare our method against the following baselines targeting for fine-tuning pretrained models.
All the models are initialized with the pre-trained weights θ init and ϕ init .
Fine-tuning :
The model fine-tuned on target labeled dataset D tr without any further pre-training or regularization except dropout and weight decay.
RecAdam (Chen et al., 2020a) :
The model trained with RecAdam optimizer which is a variant of Adam optimizer (Kingma & Ba, 2015) and additionally penalizes L 2 distance between the fine-tuned and the initial pre-trained weight.
MARS (Gouk et al., 2021) :
The model trained to minimize the cross-entropy loss along with the regularization projecting the fine-tuned weight to lie within a sphere centered on the initial pretrained weights.
For each layer, the distance induced by Maximum Absolute Row Sum (MARS) matrix norm (max j (cid:80) i =1 | W j,i − U
j,i | ) is used for the regularization.
R3F (Aghajanyan et al., 2021) :
The model trained to minimize the cross-entropy loss as well as symmetric KL-divergence between softmax output of the original input and that of the input perturbed by Gaussian noise.
Further Pre-training (Gururangan et al., 2020) :
Task adaptive pre-training where we further pre-train the model on the unlabeled target dataset D u with masked auto-encoding objective and fine-tune it on the target labeled dataset D tr . 6.
Self-Distillation : This is our model which is further pre-trained on unlabeled target dataset D u with equation 3 and fine-tuned on the target labeled dataset D tr .
5. M AIN R ESULTS
As shown in Table 1, self-distillation consistently outperforms all the regularization methods and the further pre-training method on image datasets.
Notably, our method significantly improves the performance of the Chest X-ray dataset consisting of grey-scaled images for diagnosis of pneumonia.
In addition, self-distillation effectively tackles the Flower dataset which contains only 2,040 labeled examples.
In contrast, the other baselines do not show consistent improvement across all the image datasets.
For instance, further pre-training is effective for the Aircraft dataset, but significantly degrades the test accuracy on the DTD dataset.
Regularization methods such as RecAdam, MARS, and R3F barely improve generalization performance on most datasets or underperform the simple fine-tuning strategy on certain datasets.
This empirical evidence supports that the regularizations enforcing the fine-tuned models close to the initial pre-trained weight are not effective for adapting a pre-trained model to the target datasets of specific domains.
Furthermore, as shown in Table 2, we provide additional experimental results for text classification tasks.
Again, self-distillation significantly outperforms all of the baselines across all four datasets,
[Figure] [Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure] [Table] [Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
except RecAdam in the Chemprot dataset.
In contrast to the previous experiment, the further pretraining method improves the test F1 score of the simple fine-tuning method, yet it still underperforms our model.
For regularization methods — RecAdam, MARS, and R3F, they do not achieve consistent improvement across all three datasets.
RecAdam moderately improves the F1 score on the
SCIERC and Chemprot dataset but significantly degrades the generalization performance on ACLARC dataset.
Both MARS and R3F show poor performance on SCIERC and ACL-ARC datasets, and their performance slightly is worse than Fine-tuning method on the Chemprot dataset.
Result for Low Resource Data We further perform experiments to show how self-distillation effectively handles low resources of labeled data.
Given a full CIFAR-100 dataset (Krizhevsky et al., 2009) which contains 50,000 training pairs of an image and corresponding label, we plot the test accuracy of each model by varying the number of training instances.
Note that we also reduce the number of unlabeled images used for further pre-training or self-distillation.
As shown in
Figure 3, self-distillation consistently improves the generalization performance of both fine-tuning method and the model which is further pre-trained on the images from the CIFAR-100 dataset.
Notably, the gain by self-distillation becomes larger when the models are trained with an extremely small number of instances.
For example, self-distillation achieves 13% and 6% improvement of test accuracy compared to the model with simple fine-tuning when there are 1,000 and 2,500 labeled examples, respectively.
These empirical results verify that self-distillation can effectively adapt the pre-trained model to the target dataset even if there are extremely small amounts of labeled data.
Ablation Study We perform ablation study to verify the effectiveness of each component of self-distillation.
In Table 3, we show empirical results on both the CUB dataset and SCIERC data set while removing or replacing various components of self-distillation.
Firstly, we remove masked auto-encoding objective L MAE and train the model with only distillation loss
L Distill before fine-tuning.
On image dataset CUB, it does not make a significant difference, however, removing the masked auto-encoding objective degrades the generalization performance of the language model on text classification dataset SCIERC.
Alternatively, we remove the distillation loss L Distill in equation 3, which results in further pre-training method.
Furthermore, we continue to pre-train the model for twice longer steps as the original further pre-training method, denoted as Further Pre-train × 2 , to show that higher test accuracy of selfdistillation is not a consequence of longer pre-training.
Both of the models significantly underperform self-distillation, which shows the effectiveness of the self-distillation loss.
Lastly, we perform experiments for variants of distillation loss L Distill in equation 3.
Instead of matching representation of teacher and student, we enforce the reconstruction of masked inputs by teacher and student to be consistent, i.e., minimize θ,ϕ ∥ g ϕ ◦ f θ (ˆ x ) − g ϕ 0 ◦ f θ
(ˆ x ) ∥ 22 for
ViT or minimize θ,ϕ (cid:80)
Tt =1 D KL ( p θ 0 ,ϕ 0 ( x t | ˆ x ) ∥ p θ,ϕ ( x t | ˆ x )) for RoBERTA, denoted as Prediction- Matching.
Furthermore, we replace the distillation loss with the one minimizing L 2 or MARS distance between the parameters of student and teacher, denoted as Weight-Matching.
As shown in
Table 3, all these variants are not effective compared to the one minimizing the distance between hidden representations of the student and teacher.
Multi-Round of Self-Distillation
Lastly, we empirically show that the first round of selfdistillation plays the most significant role in improving generalization performance.
Specifically, we fine-tune each model after t round of self-distillation and plot the test accuracy on Oxford
Flower dataset, where 0 round of self-distillation ( t = 0) denotes the model with further pre-training.
As shown in Figure 4, the first round of self-distillation significantly improves the test accuracy of the model with further pre-training and the gain by self-distillation becomes marginal after the first round.
Considering the extra computational cost and marginal improvement of multi-round selfdistillation, we perform a single round of self-distillation for all the experiments.
[Figure]
5. F URTHER A NALYSIS
In this subsection, we present numerical experiments to analyze why self-distillation can potentially help improve the generalization performance of downstream tasks compared to further pre-training and empirically show that Theorem 1 and 2 can be extended to deep neural networks — transformers.
(a) Generalization gap:
In Figure 5a, we plot the generalization gap, which is test loss minus training loss on each labeled dataset, of self-distillation and further pre-training method.
Self-distillation improves the generalization gap of the further pre-training method across all the datasets.
It is consistent with Theorem 1 showing that self-distillation with a simplified model strictly decreases the generalization bound on the supervised loss of the fine-tuning stage.
(b) Effect of self-distillation on distance: To empirically validate Theorem 2 about regularization effects by self-distillation on L 2 distance between the initial pre-trained weight θ init and the final weight after fine-tuning, we plot the distance obtained from self-distillation and further pre-training.
Specifically, we compare the distance ∥ θ init − θ 1 ,T ∥ 2 and ∥ θ init − θ 0 ,T ∥ 2 , where θ t,τ is the pa- rameter after t round of self-distillation and τ steps of gradient descent for fine-tuning.
As shown in Figure 5b, self-distillation consistently decreases the distance and the reduced distance correlates with the better generalization gap in Figure 5a.
These empirical results confirm the connection between the L 2 distance from the initialization and generalization bound (Nagarajan & Kolter, 2019).
(c) Effect of multi-round self-distillation: Lastly, we empirically verify part of Theorem 2 which shows that the first round of self-distillation plays the most critical role of regularization on the
L 2 distance between the initial pre-trained weight θ init and the final weight θ t,T denoted as the parameter after t round of self-distillation and T steps of gradient descent for fine-tuning on VGG flower 102 dataset.
As shown in Figure 5c, self-distillation significantly decreases the distance at the first round ( t = 1) and the regularization effect on the distance diminishes afterward, where 0 round of self-distillation ( t = 0) denotes the model with further pre-training but without self-distillation.
C ONCLUSION
To effectively adapt pre-trained transformers to a target domain, we proposed self-distillation as a regularization for further pre-training.
Specifically, we first took the initial pre-trained transformer and continued to pre-train it with the masked auto-encoding objective on the target unlabeled dataset and considered the encoder part of the model as a teacher for self-distillation.
Then we took the copy of the same initial pre-trained model as a student and enforced representations of the student to be close to those of the teacher while optimizing the student with the masked auto-encoding objective on the target unlabeled dataset.
Finally, we fine-tuned the self-distilled student on the target labeled dataset.
Our empirical evaluation on various image and text classification benchmark datasets showed that self-distillation consistently improved generalization performance compared to relevant baselines.
Lastly, we provided the theoretical analysis of the proposed method with a simplified model to understand how self-distillation for further pre-training can potentially help improve the generalization performance of the downstream tasks.
R EPRODUCIBILITY S TATEMENT
We use Pytorch (Paszke et al., 2019) and transformers library (Wolf et al., 2020) from Huggingface to implement all the baselines and our proposed method in the experiments.
We have described our method of self-distillation for further pre-training in Algorithm 1 and specified all the experimental setup including hyperparameters in Section 5 and Appendix E.
For theoretical analysis, we have provided all the proofs in Appendix A.
A CKNOWLEDGMENTS
This work was supported by Institute of Information & communications Technology Planning &
Evaluation (IITP) grant funded by the Korea government(MSIT)
(No.2019-0-00075, Artificial Intelligence Graduate School Program(KAIST)), the Engineering Research Center Program through the National Research Foundation of Korea (NRF) funded by the Korean Government MSIT (NRF2018R1A5A1059921), Institute of Information & communications Technology Planning & Evaluation (IITP) grant funded by the Korea government(MSIT)
(No. 2021-0-02068, Artificial Intelligence Innovation Hub), the National Research Foundation of Korea (NRF) funded by the Ministry of Education (NRF-2021R1F1A1061655), Institute of Information & communications Technology
Planning & Evaluation (IITP) grant funded by the Korea government(MSIT)
(No.2022-0-00713),
KAIST-NAVER Hypercreative AI Center, Samsung Electronics (IO201214-08145-01).
A PPENDIX A P ROOFS
We also define the model output vector f t ∈ R n × p by ( f t ) ij = f
( x i , w t ) j .
For example, fis the initial teacher label matrix.
Let [ n ] = { 1 , . . . , n } .
Denote the rank of [ I p ⊗ Φ] by r = rank([ I p ⊗ Φ]) ≤ np .
Define ˜ U
=
[ u 1 , u 2 . . .
, u r ] ∈ R dp × r and P r
= I − ˜ U
˜ U ⊤ , which is the projection matrix onto the null space of ˜ U ⊤ .
We first prove the following lemma, which will be used in the proofs of Theorem 1 and Theorem 2 later:
Lemma 1.
For any t ∈ N 0 , w t, 0 = (cid:80) ri =
α i,t ˜ u i + 1 { t = 0 } v , where α i,t = 1 σ i (cid:16) 1 1+( nλ/σ 2 i ) (cid:17) t ∈ R , ˜ u i = ˜
y
i u
i ∈
R dp , ˜ y
i =
( V ⊤ vec[ f 0 ])
i ∈ R , and v =
P r w 0 , 0 .
Proof of Lemma 1.
Define w t := w t, 0 for t ∈ N + .
The necessary condition on the solution w t at step t is that ∇ L ( w t ) = 0 .
Thus, by solving ∇ L ( w t ) = 0 for w t , we have that w t =
([ I p ⊗ Φ][ I p ⊗ Φ] ⊤ + nλI ) − 1 [ I p ⊗ Φ] vec[ f t − 1 ] .
By using the singular value decomposition [ I p ⊗ Φ] = U Σ V ⊤ , since UU ⊤ =
U ⊤ U
=
I and V ⊤ V
=
I , we have that
[Equation]
⊤ + nλI ) − 1 Σ V ⊤ vec[ f t − 1 ] .
Therefore, w t = U (ΣΣ ⊤ + nλI ) − 1 Σ V ⊤ vec[ f t − 1 ].
Using this and [ I p ⊗ Φ]
= U Σ V ⊤ , vec[
[Equation]
Therefore, vec[ f t ] = V AV ⊤ vec[ f t − 1 ] where A = Σ ⊤ (ΣΣ ⊤ + nλI ) − 1 Σ .
Repeating this process for vec[ f t − 1 ] , since V ⊤ V
= I ,
[Equation]
Plugging this equation of vec[ f t − 1 ]
= V A t − 1 V ⊤ vec[ f 0 ] into the equation of w t =
U (ΣΣ ⊤ + nλI ) − 1 Σ V ⊤ vec[ f t − 1 ] , we have that
[Equation]
where B = (ΣΣ ⊤ + nλI ) − 1 Σ .
Here, we can rewrite the matrix B ∈ R dp × np as
[Equation]
where 0 ( dp − np )
× np is the ( dp − np ) by np matrix with all entries being zero, and ¯ B ∈ R np × np is a diagonal matrix defined by
[Equation]
Using this B in the above equation of w t =
UBA t − 1 V ⊤ vec[ f
[Equation]
] , w t =
U (cid:20) ¯ B 0 (
[Equation]
np (cid:21)
A
[Equation]
V
[Equation]
[ f 0 ] =
[ u
[Equation]
u
[Equation]
· · · u dp ] (cid:20) ¯ BA
[Equation] [Equation]
np
[Equation]
np (cid:21)
V ⊤
[Equation]
[ f 0 ] = ¯ U ¯ BA t − 1 V ⊤ vec[ f 0 ] where ¯ U =
[ u 1 , u 2 . . .
, u np ] ∈ R dp × np .
Since the matrix A = Σ ⊤ (ΣΣ ⊤ + nλI ) − 1 Σ ∈ R np × np is a diagonal matrix with its entry being A ii = σ 2 i ( σ 2 i + nλ ) − 1 , this can be further simplified as
[Equation]

[Equation]

[Equation]

[Equation]
 
[Equation]

[Equation]
 
[Equation]
where the last line follows from the fact that σ i ( σ 2 i + nλ ) − 1 ( σ 2 i ( σ 2 i + nλ ) − 1 ) t − 1 = 0 for all i > r .
Since σ i ( σ 2 i + nλ ) − 1 ( σ 2 i ( σ 2 i + nλ ) − 1 ) t − 1 =
σ 2 t − 1 i ( σ 2 i + nλ ) − t = 1 σ i ( σ 2 i σ 2 i + nλ ) t for i ≤ r , this implies that
[Equation]
Since t ∈ N + was arbitrary
[Equation]
this holds for any t ∈ N + .
This proves the first statement of the theorem for any t ∈ N + .
For t = 0 , since ˜
[Equation]
we have that
[Equation]
Thus,
[Equation]
Since ( I − ˜ U
˜ U ⊤ ) w 0 ,
= P r w 0 , 0 , this completes the first statement of the theorem for any t ∈ N 0 .
A. P ROOF OF T HEOREM
Proof.
Define Z :=
[ I p ⊗ Φ] ⊤ ∈ R ¯ n × ¯ d where ¯ n = np and ¯ d = dp .
Then,
[Equation]
where Y = vec[[ y 1 , . .
, y n ] ⊤ ] ∈ R ¯ n .
Since ∇L ( w t,τ ) =
Z ⊤ ( Zw t,τ − Y ) ,
[Equation]
Since rank(Φ) = n and d ≥ n , we have rank( Z ) =
¯ n by the property of the Kronecker product with the identity matrix.
Since rank( Z ) =
¯ n , there exists v ∈ R ¯ d such that Y =
Zv .
Thus,
[Equation] [Equation]
Since Z ⊤ =
U Σ V ⊤ , we have Z ⊤ Z
=
U ΣΣ ⊤
U ⊤ =
(cid:80)
¯ ni =1 σ 2 i u i u
⊤ i .
Thus,
[Equation]
Since the columns of U forms the basis of R ¯ d and w, v ∈ R ¯ d , we can write w t,τ = (cid:80) ¯ dk =1 c ( t,τ ) k u k and v = (cid:80) ¯ dk
=1 q k u k for some c ( t,τ ) k and q k .
Thus,
[Equation]
=
[Equation]
⊤ i
[Equation]
(cid:88)
[Equation]
=
[Equation]
n (cid:88) i = σ
[Equation]
( c (
[Equation]
− q
[Equation]
) u i .
Using w t,τ = (cid:80) ¯ dk =1 c ( t,τ ) k u k for the right-hand side too, we have that d dτ ¯ d (cid:88) i
=
c ( t,τ ) i u i = − ¯ n (cid:88)
i =
σ 2 i ( c ( t,τ ) i − q i ) u i .
This implies that for all i ∈ { 1 , . . .
, ¯ n } , d dτ c ( t,τ ) i = − σ 2 i ( c ( t,τ ) i − q i ) , and ddτ c ( t,τ ) i = 0 for all i / ∈ { 1 , . .
¯ n }
This can be also seen by the fact that dw t,τ dτ = − Z ⊤ ( Zw t,τ −
Zv ) with Z ⊤ =
U Σ V ⊤ and thus the dynamics only adds components of u i for i ∈ { 1 , . . .
, ¯ n } , and not for i / ∈ { 1 , . . .
, ¯ n } .
Thus, for components of u i for i / ∈ { 1 , . . .
, ¯ n } , the initial values stays.
In other words, for i / ∈ { 1 , . . . , ¯ n } , c ( t,τ ) i =
c ( t, 0) i .
On the other hand, for i ∈ { 1 , . .
, ¯ n } , since ddτ q i = 0 ,
[Equation]
Solving this for ( c ( t,τ ) i − q i ) , we have that for i ∈ { 1 , . .
, ¯ n } ,
[Equation]
This implies that
[Equation]
Combining these with w t,T = (cid:80) ¯ dk
=1 c ( t,T ) k u k , w t,T = ¯ d (cid:88) i =
c ( t,T )
i u i = ¯ n (cid:88)
i =
q i (1 − e − σ 2 i T ) u i + ¯ n (cid:88) i
=
c ( t, 0) i e − σ
[Equation]
Therefore, for any particular s ∈ S , since U =
[ u 1 , u 2 . . .
, u dp ] ∈ R dp × dp is an orthogonal matrix,
[Equation]
where q i , σ i , and c ( t, 0) i all depend on s .
By using Lemma 4 of (Pham et al., 2021) and taking union bound with P ( s / ∈ S ) ≤ δ , with probability at least 1 − δ , we have that w t,T ∈ F t and the following holds:
[Equation]
where R n ( F t )
=
E s,ξ [sup w ∈F t 1 n (cid:80) ni =1 ξ i ∥
Wφ ( x i ) − y i ∥ 22 ] , s =
(( x i , y i ))
ni =1 , w = vec[ W ⊤ ] , and ξ 1 , . .
. , ξ n are independent uniform random variables taking values in {− 1 , 1 } .
By using Corollary 4 of (Maurer, 2016), there exits a constant c (only depending on M ) such that,
[Equation]
where W k is the k -th row of W ,
ξ ik are independent uniform random variables taking values in {− 1 , 1 } , h = vec[ H ] ∈ R dp , and H ∈ R d × p with H jk =
(cid:80) ni
=1 ξ ik φ ( x i ) j .
Thus,
[Equation]
∥ w ∥
[Equation]
) n
E
[Equation]
Here,
E
[Equation]
(cid:118)(cid:117)(cid:117)(cid:116)
[Equation]
(cid:88)
j = p (cid:88) k
= (cid:32) n (cid:88) i = ξ
[Equation]
( x i )
[Equation]
(cid:33)
[Equation]
≤ (cid:118)(cid:117)(cid:117)(cid:116)
d (cid:88)
j = p (cid:88) k
=
E s
[Equation]
ξ (cid:32) n (cid:88) i = ξ
[Equation]
( x i ) j (cid:33)= (cid:118)(cid:117)(cid:117)(cid:116)
d (cid:88)
j = p (cid:88)
[Equation]
=
[Equation]
s n (cid:88) i = (
[Equation]
( x i )
[Equation] [Equation]
(8) = (cid:118)(cid:117)(cid:117)(cid:116) p (cid:88) k
= n (cid:88) i =
E s
[Equation]
(cid:88)
j = (
[Equation]
( x i )
[Equation] [Equation]
= (cid:118)(cid:117)(cid:117)(cid:116)
[Equation]
(cid:88)
[Equation]
n (cid:88)
[Equation] [Equation]
Equation 8 holds since
E
[Equation] [Equation]
] for all i, l ∈ [ n ] .
Thus,
[Equation]
Define ζ t (
[Equation]
) := (cid:118)
[Equation]
where q i , σ i , and c ( t, 0) i all depend on s .
With this, we define ζ ( t ) :
= sup s ∈S ζ t ( s ) .
Then, by combining equation 6, equation 7, and equation 9, with probability at least 1 − δ , the following holds:
[Equation]
Finally, from Lemma 1, for any t ∈ N 0 and i ∈ { 1 , . . .
, ¯ n } ,
[Equation]
Since 1 1+( nλ/σ 2 i ) < 1 (because nλ/σ 2 i > 0 ), the value of (cid:16)
[Equation]
2 t strictly decreases as t increases.
Since 1 σ 2 i > 0 and ˜ y 2 i ≥ 0 , this implies that ( c ( t, 0) i ) 2 is strictly decreasing in t ∈ N 0 unless c ( t, 0) i
= 0 .
Moreover, from Lemma 1, we have that
[Equation]
Since { u 1 , . . .
, u ¯ d } is a orthonormal basis for R ¯ d with inner product ⟨ x, y ⟩ = y ⊤ x , we get
[Equation]
u
[Equation] [Equation]
Since ˜ U ˜ U ⊤ w 0 , 0 = (cid:80) ¯ ni =1 ( u ⊤ i w 0 , 0 ) u i , we have that
[Equation]
= ¯ d (cid:88)
[Equation]
=
[Equation]
u
[Equation]
n
[Equation]
+
[Equation]
u ⊤
[Equation]
i
[Equation]
which implies that the u i component to span w t, 0 for i ∈ { ¯ n + 1 , . .
, ¯ d } is only present in ( I − ˜
U ˜ U ⊤ ) w 0 , 0 .
In other words,
[Equation]
Thus, for any t ∈ N 0 and i ∈ { ¯ n + 1 , . . .
, ¯ d } , we have that
[Equation]
These implies that ζ ( t ) is strictly decreasing in t ∈ N 0 unless w 0 , 0 = 0 .
A. P ROOF OF T HEOREM
Proof.
In this proof, we continue to use the results and the notation from the proof of Theorem 1.
By using equation 5 in the proof of Theorem 1, we have that
[Equation]
where
[Equation]
If w init = − αv t for some α > 0 , then
[Equation]
On the other hand, for any w init ∈ R dp ,
[Equation]
Thus, setting ψ ( t ) to be the following function satisfies conditions (1) and (2) in the statement:
[Equation]
Finally, from Lemma 1, for any t ∈ N 0 and i ∈ { 1 , . . .
, ¯ n } ,
[Equation]
which is strictly decreasing in t ∈ N 0 unless c ( t, 0) i = 0 for all i ∈ { 1 , . .
, ¯ n } as shown in the proof of Theorem 1.
Moreover, from Lemma 1, for any t ∈ N 0 and i ∈ { ¯ n + 1 , . . .
, ¯ d } ,
[Equation]
That is,
[Equation]
where
[Equation]
and
[Equation]
Since e − 2 σ 2 i T > 0 is a constant in t and we have previously shown that (cid:18)
σ i
[Equation]
is strictly decreasing in t ∈ N 0 unless w 0 , 0 = 0 .
It implies that both ψ 1 ( t ) and ψ ( t ) are strictly decreasing in t ∈ N 0 unless w 0 , 0 = 0 .
Remark 1.
Note that Theorem 2 also shows the distance between the weight of the teacher w t − 1 ,T and the initial pre-trained weight w init for all t ∈ N + .
Since the teacher at t ′ ∈ N + round of self-distillation used to be a student of the t ′ − 1 round of the self-distillation and Theorem 2 holds for all non-negative integer t ∈ N 0 , the distance between the initial weight and the teacher weight ∥ w init − w t − 1 ,T ∥ 2 strictly decreases for all t ∈ N + .
For instance, at t = 1 , we obtain the following inequality
[Equation]
where w 0 ,T is the weight of the initial teacher without self-distillation .
B A DDITIONAL E XPERIMENTS
In this section, we perform additional experiments to better analyze the proposed method, selfdistillation for further pre-training.
[Table] [Table]
Supervised Contrastive Learning For the main experiments on Section 5, we use the same objective function for pre-training and further pre-training.
One may wonder what happens if we use different objective at further pre-training stage.
In this experiment, we continue to pretrain the encoder of the pre-trained transformer (He et al., 2022) with supervised contrastive loss (Khosla et al., 2020) while fine-tuning a randomly initialized linear classifier with cross-entropy loss.
As shown in
Table 5, supervised contrastive learning (SupCon) significantly degrades the generalization performance of Vision Transformer on both X-ray and Flower datasets.
Based on this experimental result, we conjecture that the transformer pre-trained with a masked auto-encoding objective might not be compatible with the contrastive loss and thus we may use the same objective for pre-training and further pre-training.
Generalization Gap As shown in Figure 5a, self-distillation decreases generalization gap compared to further pre-training.
Additionally, we separately report training and test loss in Table 4.
Both of further pre-training and self-distillation reach near zero training loss, but self-distillation achieves way lower test loss than further pre-training as a consequence of regularization induced by self-distillation.
[Table]
Down Weighting of Masked Auto-Encoding Although we fix both weight of self-distillation and masked auto-encoding objective to 1 in equation 3, we vary λ ∈ (0 , 1] , the weight of masked auto-encoding objective ( λ L MAE ( θ, ϕ ; D u ) + L Distill ( θ ; θ 0 , D u )) and report test accuracy of Vision Transformer with self-distillation on the CUB dataset.
As shown in
Table 6, our proposed method is insensitive to the value of λ and thus there is no benefit to fine-tuning the weight of masked auto-encoding objective.
Extra Training Time To better analyze extra computational cost for further pre-training and self-distillation, we report training wall clock time for fine-tuning, further pre-training, and selfdistillation, respectively.
We train a Vision Transformer (Dosovitskiy et al., 2021) on CUB dataset with 3090 RTX GPU and Intel(R)
Xeon(R)
Silver 4210R CPU.
It takes 32 minutes and 18 seconds for fine-tuning the transformer.
We need an extra 1 hour 29 minutes 33 seconds for further pre-training and 5 hours 13 minutes 22 seconds for self-distillation.
C M ASKED A UTO -E NCODING
In this section, we describe the masked auto-encoding objective from equation 2 in more detail.
Given a sequence x = ( x 1 , . . .
, x K ) with length K , we sample mask z
= ( z 1 , . . .
, z K ) from a Binomial distribution p γ,K with probability for success γ ∈ (0 , 1) and the number of trials
K .
For each x k , we replace it with the special token “mask” if z k = 1 .
Otherwise we use the same x k for an masked input.
Let ˆ x =
(ˆ x 1 , . .
, ˆ x K ) be a masked input and let f θ , g ϕ be encoder and decoder, respectively.
We want to compute the log-likelihood of the reconstructed input (cid:80)
Kk =
z k log p θ,ϕ ( x k | ˆ x ) .
For language models, reconstruction of the masked input ˆ x k is predicting which token is masked out of pre-defined vocabulary with its size V , where each token is represented as an integer from { 1 , . .
, V } .
Thus the conditional probability of x k ∈ { 1 , . .
, V } given ˆ x is parameterized as follows:
[Equation]
where ( u 1 , . .
, u V ) =
g ϕ ( h k ) ∈
R V , (cid:34) | | h· · ·
[Equation]
K
[Equation]
θ
[Equation]
ˆ
[Equation]
R h × K .
For ViT, the sequence x consists of image patches and the reconstruction of the masked input is predicting pixel values for each masked patches, which is a regression problem.
Thus, we parameterize the conditional probability of a patch x k = ( x k, 1 , . . .
, x k,m ) ∈ R m given ˆ x as follows:
[Equation]
where µ k = ( µ k, 1 , . .
. , µ k,m ) ∈ R m ,
[Equation]
|
[Equation] [Equation]
Since σ > 0 and π are constants with respect to θ and ϕ , arg min θ,ϕ
[Equation]
D D ATASET
We describe statistics of all the image and text classification datasets used for our experiments in
Table 7 and
[Table]
[Table] [Table]
E H YPERPARAMETERS
In Table
[Table]
we summarize all the hyperparameters for Vision Transformer and RoBERTA.
[Table]