기본 정보
- 저자
- DOI
- 10.18653/v1/2024.naacl-industry.5
- 저널
- –
- 발행년도
- 2024
- 발행기관
- –
- 피인용수
- 11
- 라이선스
- cc-by
- 논문 유형
- –
- 언어
- –
- 원문 페이지
- https://doi.org/10.18653/v1/2024.naacl-industry.5
- 토픽
- Advancements in Photolithography Techniques
- OpenAlex ID
- W4401043244
평가 내용
- 관련도
- 사업분야
- 패션 · (24) 패션(코오롱FnC)
- 부 분야
- –
- R&D 측면
- –
- 확신도
- –
- 근거 용어
- –
- 판단 근거
- 임베딩 유사도 기반 평가로 '패션 > 패션(코오롱FnC)' 분야에 선정된 논문입니다.
- R&D 활용 포인트
- –
- 평가 입력
- –
초록
본문 50,861자
본문 펼치기
섹션 본문 87문단 · 29,303자
(제목 없음)
1Supernet training of LLMs is of great interest in industrial applications as it confers the ability to produce a palette of smaller models at constant cost, regardless of the number of models (of different size / latency) produced.We propose a new method called Multistage Low-rank Fine-tuning of Super-transformers (MLFS) for parameter-efficient supernet training.We show that it is possible to obtain highquality encoder models that are suitable for commercial edge applications, and that while decoder-only models are resistant to a comparable degree of compression, decoders can be effectively sliced for a significant reduction in training time.A considerable amount of research has focused on compressing LLMs [45,31,25,26,18,15].Methods that train a single small model guided by a large teacher model such as DistilBERT [31] and BERT-PKD[33], either achieve limited compression or do not scale to a large number of deployment devices.Supernet training methods[14,39,6,20,22,17]were introduced to address these limitations: multiple smaller subnets within the supernet are trained simultaneously with weight-sharing.This one-time training approach produces a palette of smaller models, helping mitigate the computational cost of fine-tuning a model for each deployment scenario.However, the full-parameter supernet training approach is impractical when fine-tuning of an LLM is required for multiple deployment scenarios, limiting its utility for enterprises.Parameter-efficient fine-tuning (PEFT) methods such as Low-Rank Adaptation (LoRA) reduces the number of trainable parameters by allowing only rank-decomposition matrices to be trained while freezing the pre-trained weights of the model.PEFT methods, however, are not applicable to supernet training due to the implications on the weight-shared subnetworks.Our work bridges this gap to enable efficient fine-tuning of LLMs for edge devices.Our contributions are:1. We propose a parameter-efficient, distillation-based approach for supernet training of LLMs.
Introduction
2Given their sizes up to billions of parameters, [27,4], it is challenging for enterprises to fine-tune Large Language Models (LLMs), and furthermore they are not suitable for deployment on edge devices with limited memory and computational power.We wish to enable LLMs on edge environments for enterprise use cases.This requires the following two capabilities.(1) Accommodating a variety of edge device hardware: A single fine-tuned model is not optimal across the spectrum of devices.For industrial applications, a palette of fine-tuned LLMs is required for different hardware.(2) Dynamically changing resource levels: At run-time, the available resources on edge devices evolve over time, and appropriate model should be dynamically selected based on the available resources of each device.
32. We devise a gradient scaling scheme to improve convergence speed of any form of supernet training.
43. We demonstrate significant compression of encoder models for edge.We highlight the limits of comparable compression for decoder models, while demonstrating a huge reduction in the steps needed for convergence.
Related Work
5Classical compression methods have been used for LLMs including pruning [24,34], low rank approximation [23,21], and quantization [32,41,3].Knowledge distillation (KD) is adopted in BERT-PKD [33], tinyBERT [18], and distilBERT [31] and [12] in MiniLLM to distill knowledge from the layers of a large transformer model to a smaller one.See also the survey [45].All these existing methods produce a single compressed model, unsuitable for edge scenarios with multiple deployment devices having varying computational capability.
6Neural architecture search (NAS) based on reinforcement learning [46] and evolutionary algorithms [28,44] trains every possible architecture and is very slow.Weight-sharing NAS was thus developed: in Guo et al. [13], Cai et al. [5], the building blocks in the same layer are isolated as all architectures are single paths.Weight-sharing NAS does not scale well to large architecture search spaces, hence, weight-entangled NAS, where subnets with common parts share weights, was introduced.
7For resource-constrained edge deployment, supernet training [6,20,8,39,11,10] was developed as a mode of jointly training multiple subnetworks (subnets) with entangled weights: one trains the supernet only once for all deployment scenarios.Cai et al. [6] introduced an elastic convolutional neural network with "progressive shrinkage", where larger subnets are trained first.Recent works have improved sampling strategies, e.g. the sandwich rule with in-place distillation [40], attentive sampling [36], stochastic nature gradient [43], or post-training sampling [22].Our work is related to supernet training for transformer models [14,43,38,37,8].This gradient scaling technique can be used with any of the above supernet methods.
8Parameter-efficient fine-tuning (PEFT) has been of great benefit in fine tuning LLMs.BitFit [2] updates the bias terms in pre-trained models while freezing the remaining parameters.LoRA [16] decomposes attention weight gradients into low-rank matrices to reduce the number of trainable parameters.AdaLoRA [42] and QLoRA [9] further improve LoRA [16].Note that PEFT allows fine-tuning a base model on a single GPU but does not produce smaller models.None of the PEFT methods can be used for weight-entangled supernet training.
Solution Design
9For use in enterprise settings, the solution must allow fine-tuning of models on a small GPU footprint.
10In addition, inference cost in terms of storage must be minimised.We therefore design a solution which does not store the full size model checkpoint for every downstream task but only the frozen weights of the pre-trained base model and the low rank matrices.For inference in commercial edge use cases, we wish to enable storing the desired models locally for a wide variety of edge device resource requirements.We thus develop an approach where storage is minimised, storing only one base model and as many low rank adapter matrices as there are target model size variations, where low-rank adapters are very small.If the model is stored locally on an edge device, our proposed slicing operation takes place where the supernet fine-tuning is performed and the desired model is downloaded for inference.The slicing operation takes place for each model size-task combination and each resulting subnet can be cached for inference.
Problem Formulation
11First, we provide notation.Given a transformer model with architectural configuration Φ and weights W, we denote its forward-pass mapping by f Φ (•; W) : X → Y.We consider the output space Y to be the set of all non-negative vectors in R ν with elements summing to 1, where ν denotes the number of classes / vocabulary size).With slight abuse of notation, we write the forward-pass mapping of an input x ∈ X through a transformer model Φ as ŷ, z, h = f Φ (x; W), where ŷ ∈ Y denotes the predicted probability distribution over the (class labels) vocabulary, z denotes the vector of logits, and h represents a tuple of features such as hidden state vectors and attention values from different transformer layers.Note that ŷ = σ(z), where σ is the standard soft-max function that maps a vector of logits into a probability vector.Given a training data set D train ⊂ X × Y, model weights W are learnt by minimizing training loss:
12where E denotes expectation over training example (x, y) drawn uniformly at random from D train and ℓ denotes a loss function.Most commonly, ℓ is chosen to be a task specific loss function, ℓ task , such as cross-entropy (i.e., CE[•, •]) for classification or causal language modeling loss for generative models.
13Next, we introduce the super-transformer and related terminologies.We define three types of networks -Teacher network, Super-transformer (supernet) and Sub-transformer (subnet).The teacher is a fixed network with the same configuration as the pre-trained transformer.A super-transformer is a dynamic model whose architectural dimensions (embedding dimension, number of heads, number of layers, etc.) are configurable at run time.The maxnet (resp.minnet) is the largest (resp.smallest) network in the super-transformer's architecture space.Weight entanglement (weight-sharing) allows supertransformer weights to be used across sub-transformers, which are subsets of the super-transformer.Pre-trained transformer weights initialise the super-transformer.
14The dynamic nature of a super-transformer is explicitly specified via a set A, called configuration space, consisting of architectural configurations of all sub-transformer models under consideration.
15The definition of a super-transformer also includes how the configuration Φ ∈ A is to be mapped to a unique transformer model f Φ .A weight-sharing super-transformer uses a set of shared weights W Sup to define all sub-transformer models' weights.This is done through a weight projection operator Π that slices (selects an appropriate subset of) the super-transformer's weights W Sup into weights of a sub-transformer model:
16The aim of a weight-sharing super-transformer is to simultaneously train all the transformer models {f Φ (•; Π Φ (W)) : X → Y | Φ ∈ A} through the shared weights W Sup .A typical training objective for super-transformers is the training loss averaged over all model configurations in A:
17where E denotes expectation over model configuration Φ drawn uniformly at random from A and L Φ , as defined in (1), is averaged training loss for configuration Φ. Super-transformer weights, W Sup , are learnt with stochastic gradient (denoted ∇) of the super-transformer's loss L Sup estimated as
18where {Φ 1 , • • • , Φ K } are K sub-transformer configurations sampled from A to approximate the expectation in (3) and B is a mini-batch of training examples sampled from D train to approximate the expectation in (1).Fine-tuning LLM super-transformers is computationally challenging in enterprise use cases as it involves computing gradients of sub-transformers' loss functions with respect to a huge number of parameters.
Multistage Low-rank Fine-tuning of Super-transformers
19We therefore developed Multistage Low-rank Fine-tuning of Super-transformers (MLFS).Given a teacher model with configuration Φ Tch and pre-trained weights W pretrain
Tch
20, we assume that its weights (denoted W Tch ) can be fine-tuned on the given task by learning low-rank matrices A 0 , B 0 on top of pre-trained weights W pretrain Tch :
21where A 0 , B 0 are of (low) rank r.Note that pre-trained weights W pretrain Tch remain unchanged during super-transformer fine-tuning.The low-rank matrices, A 0 and B 0 , are learnt by minimizing the cross-entropy loss of the teacher model f ΦTch (•; W Tch ) : X → Y over the training data set D train .Specifically, we perform E 0 epochs of fine-tuning on the teacher to learn A 0 , B 0 .This is stage-0 of the multistage fine-tuning algorithm.We denote the teacher weights obtained at the end of stage-0 by W Tch .We now define a super-transformer with maxnet configuration the same as the teacher's.Thus the super-transformer's weights W Sup are of the same size as the teacher weights W Tch ).To fine-tune the super-transformer weights W Sup , in each of the subsequent stages, we freeze W Tch and propose learning two stage-specific low-rank matrices A s , B s , of the same rank, r, as A 0 , B 0 , that are shared across all sub-transformer models in that stage.To be precise, we impose the following structure on the weights of the sub-transformers at stage-s:
22Stage-s of the fine-tuning process involves learning only the low-rank matrices, A s , B s , by minimizing the super-transform loss as in (3).In stage-1, we sample sub-transformer models by sampling different widths from the super-transformer keeping the depth (number of layers) same as the maxnet.
23In stage-2, we sample sub-transformer models by sampling different widths as well as depths.We always sample the maxnet model from the super-transformer as the 1 st sub-transformer model, Φ 1 , at every iteration.We call this Multistage Low-rank Fine-tuning of Super-transformers (MLFS) and present it in the Appendix in Algorithm 1.
24Proposition 1 Let the individually fine-tuned weights of a subnet, Φ, be expressed as
25Then, MLFS has the following structure on ∆W Φ :
26where {A s , B s } s=0,1,2 are low-rank matrices shared across all sub-transformers Φ ∈ A.
27To illustrate the computational savings, recall W pretrain Tch ∈ R d×d , where d is typically of the order 10 4 −10 6 .For rank r (typically < 10) for the low-rank matrices:
28where r ≪ d.Then, the number of parameters to be learnt in the MLFS approach is 6rd.In contrast, full fine-tuning requires updating d 2 parameters at every iteration.
29Gradient Scaling For faster convergence of the smaller sub-transformers within a super-transformer, we propose a novel weighted-combination of the gradients of the sampled sub-transformers.
30Proposition 2 Let 1 st sampled sub-transformer, Φ 1 , be the maxnet be in every iteration.Then the scaled gradient of the super-transformer training loss, L Sup , in Algorithm 1 is given by
31where ∇ W denotes gradient w.r.t.only those weights that are being fine-tuned (in this case only the LoRA matrices), n j denotes the actual number of trainable weights in model configuration Φ j and γ ≥ 1 is a hyper-parameter.
32Proof: Each sub-transformer gradient in (10), grad j , is scaled by (n 1 /n j ), which is obtained from the relative weighting of the loss functions.Let L j (W) denote the j-th sub-transformer's loss.Using first-order Taylor expansion, we get:
33where ⟨•, •⟩ denotes inner (dot) product operation.Therefore, the steepest possible decrease in the loss function L Φj can be approximated as:
34where we approximate the ∥ • ∥ 1 norm using the zero-th norm, i.e., number of non-zero elements and n j stands for the actual number of trainable parameters in sub-transformer configuration Φ j .Since the decrease in the loss of a sub-transformer model Φ j is approximately proportional to the number of trainable model parameters (n j ), we scale the losses using (n 1 /n j ) γ , γ ≥ 1 so that training losses of smaller sub-transformer models converge at a rate similar to that of larger sub-transformer configurations.Recall that n 1 is the maximum number of trainable parameters as 1 st sampled sub-transformer Φ 1 is always the maxnet.□ Initialize the low-rank matrices {A s , B s } to be learned at stage s.
35for each Φ j ∈ A s do 8:
36Load the sub-transformer model Φ j with weights W Φj := Π Φj (W Sup ).
9:
37n j := # of fine-tuning weights in model configuration Φ j .
3810:
39Compute forward-pass on sub-transformer
4011:
41In the case of Φ 1 (maxnet), set the distillation factor α to 0.
4212:
43Find the loss:
4413:
45Compute backward-pass on sub-transformer Φ j to find (∇ As loss i j , ∇ Bs loss i j ).
14:
46end for 15:
47Update A s , B s using the gradients ( ∇As L Sup , ∇Bs L Sup ) of the super-transformer's loss:
48end for 17: end for Output: {A s , B s } 2 s=0 and fine-tuned super-transformer weights:
49Distillation Loss for Super-transformers: Knowledge distillation is straightforward in a fixednetwork fine-tuning setting.However, it is less so when fine-tuning a supernet, and in particular, fine-tuning a supernet using the proposed multistage LoRA based approach.Specifically, the subnets receive two types of knowledge distillation (KD) from the teacher: (a) the usual KD loss that utilizes the output logits of the teacher and (b) distillation of features from transformer layers [18] of the teacher.
50To define the distillation based losses precisely, let the forward-pass mapping of an input training sample x i through sub-transformer Φ j be ŷi j , z i j , h i Φj ← f Φj (x i ; W Φj ), where h i j := (h i,1 j , . . ., h i,l j , . ..) with h i,l j denoting the feature vector from l-th layer of sub-transformer Φ j .In super-transformers, the model (maxnet) having the largest configuration, Φ 1 , acts as the teacher and knowledge distillation loss for all other sub-transformers w.r.t the teacher is defined as
51where KL[•, •] denotes the standard KL divergence between two probability vectors, and t ≥ 1 is a hyper-parameter called the temperature.Let d j denote the embedding dimension (hidden size) in sub-transformer Φ j .We compute feature based distillation loss by projecting features h i,l Φj ∈ R dj to a low-dimensional space R d low :
52where g j maps each layer index of the sub-transformer configuration Φ j to that of the supertransformer ( / maxnet Φ 1 ).In this paper, we propose to share the maxnet's feature projection matrices {U l 1 ∈ R d low ×d1 } across all sub-transformer models.We do so by slicing the matrices {U l 1 }:
53where the operation [ ] Φj selects appropriate subset of columns depending on the configuration Φ j .
54To reduce the number of user-chosen hyper-parameters, we propose the following hyper-parameter sharing: β l j := β gj (l) , ∀j, l = 1, 2, . ... Thus, apart from setting fewer hyper-parameters, one needs to learn only maxnet's feature projection matrices {U l 1 : l = 1, 2, . ..}, making feature distillation in a super-transformer setting computationally efficient.Additionally, we save computation through use of features only from a fixed subset of maxnet layers for distillation across all sub-transformers: i.e., we use the following subset of maxnet layers: { g min (l) : l = 1, . . ., L min }, where L min denotes the number of transformer layers in the smallest sub-transformer Φ min and g min maps layer indices of Φ min to that of maxnet Φ 1 .
556 Low-rank approach for Distilling an LLM onto a Pre-trained student
56In this section, we considerthe standard single-stage distillation approach for training a smaller (student) model on a target task with help from a larger fine-tuned (teacher) model.Here, we assume availability of the following: (i) target data set D train for fine-tuning, (ii) a task specific loss function ℓ task , (iii) a teacher model with configuration Φ Tch and weights W Tch are already fine-tuned for the task, (iv) a smaller model than the teacher, called the student model, with configuration Φ Std & pre-trained weights W pretrain
Std
57. The goal is to efficiently fine-tune the student model on the target data with knowledge distillation from the larger teacher model.For computational efficiency, we make the following low-rank assumption (as in LoRA approach) on the fine-tuned weights of student model:
Compute forward-pass on the teacher model: ŷi
58Tch , z i Tch , h i Tch ← f ΦTch x i ; W Tch , ∀i ∈ B.
5:
59Compute forward-pass on the student model: ŷi
60Find the loss:
61Compute gradients (∇ A1 loss i , ∇ B1 loss i ) using backward-pass on the student model.
8:
62Update A 1 , B 1 using the gradients
639: end for Output: {A 1 , B 1 } and fine-tuned weights of the student model:
64Given an input sample x i , the knowledge distillation (KD) loss of the student model f ΦStd with respect to the teacher model f ΦStd is given by
65where σ(•) denotes the soft-max operation, KL[•, •] denotes the standard KL divergence between two probability vectors, and t ≥ 1 is called the KD temperature.
Given input x i , let h i
66Std := (h i,1 Std , . . ., h i,l Std , . ..) denote the feature vectors from all transformer layers of the student model with h i,l Std being the feature vector from l-th layer.Now, we define the feature based distillation loss as
67where the summation l is over (a subset of) the layers of the student model, {β l ≥ 0} are user chosen constants, ∥ • ∥ 2 denotes the Euclidean norm, and the function g maps each layer index l of the student model to a layer index g(l) of the teacher model for comparing corresponding features.The projection matrices {U l Std , U l Tch } are simultaneously learned along with the LoRA weights and are needed to compare the feature vectors from the student with those from the teacher by projecting them to a common low-dimensional space.To be precise,
68where d Tch & d Std denote the embedding (hidden) dimension of the teacher and the student model respectively.Usually, the dimension d low of the projected space is chosen to be small, 128 in our experiments.
Results on Encoder and Decoder LLMs
69We report performance on encoder tasks using GLUE [35] with BERT base as the teacher model Φ Tch .For decoder LLMs, we use Santacoder [1] and Codellama7B [29] on a python coding task using bigcode/the-stack data [19].We report performance of the sub-transformer models at the end of stage s = 2. On GLUE, we use the train set for fine-tuning and the dev set for accuracy evaluation.For santacoder, we evaluate performance using HumanEval [7] and report pass@1 scores.All experiments were conducted using PyTorch on a single Nvidia A100 (40GB) GPU.
70In MLFS, the Low rank matrices are added on the QKV vectors and the intermediate size of feedforward network (FFN) layers.We set β l = 0.1 ∀l in feature distillation loss and choose distillation factor α = 0.9.For training, we use a maximum sequence length of 128; effective batch size of 128 for QQP, MNLI, QNLI, and 64 for the other data sets.Training is done for a maximum of 8 epochs for all GLUE data sets except SST-2 for which we allocate maximum 3 epochs.We set an initial learning rate of 5e −4 for QNLI & MNLI, and 1e −3 for other GLUE data sets.We use rank r = 8 for the low rank matrices A, B unless mentioned otherwise.We choose gradient scaling hyper-parameter γ = 1 for SST-2 and γ = 2 for all other data sets.Following [16], we use the fine-tuned MNLI checkpoint to initialize the model weights for experiments on small data sets such as RTE and MRPC.
Performance of Encoder Models
71We compare performance of encoder models obtained with the MLFS approach against a static, fixed model (BERT base) from [43,14], two popular distilled variants of the fixed model: TinyBERT [18] and DistilBERT [31], and models trained using existing super-transformer methods (DynaBERT [14].Figure 1 shows the performance of the palette of models, from a 45M param.minnet to full-size 110M maxnet.Model performance against forward-pass latency is plotted in Figure 2. Encoder models produced by MLFS are at par or better than much costlier methods.Results of PD-BERT, BERT-PKD are from [43], static BERT from [43] for all except MRPC for which we use [14].Note that TinyBERT performs data augmentation leading to higher accuracy but much longer computation time.We do not perform data augmentation for fairness of the comparison to the other methods.The main observation is that MLFS provides accurate, smaller encoder models at 1/4 the size of the teacher and 1/3 its runtime latency on a single GPU.
72Ablation Study on Gradient Scaling In supernet training, the weights of maxnet and subnets are shared and trained simultaneously.The maxnet tends to converge and overfit earlier than smaller subnets.The different convergence rates renders selecting a single supernet checkpoint for all networks difficult.Gradient scaling solves this by speeding up convergence of the smaller subnets to match that of the larger subnets or the maxnet.Fig. 3 shows that gradient scaling improves minnet convergence, indicated by lower minnet loss.
73Ablation Study on Rank of A, B In Fig. 4, we examines the impact of rank r of the matrices A, B on performance.Note that the actual number of parameters fine-tuned vary as we vary the rank r.The aim is to provide good results for the smaller networks.Here, rank r = 8 works well across the GLUE data sets.Therefore, we use rank r = 8 for A, B for all other MLFS experiments.From the scale of the y-axis in 4, observe that MLFS is not overly sensitive to the chosen rank.Figure 4: Ablation study on MLFS rank of A, B. Maxnet (top: blue), minnet (bottom: green), and average of two medium-sized subnets (middle: orange).Rank r = 8 is optimal for small and medium subnets.
Performance of Decoder Models
74Turning now to decoder models, we consider two code-pre-trained LLMs, Santacoder [1] and Codellama7B [29].We evaluate a custom 0.7B parameter Santacoder model obtained from the 1.1B teacher.Due to an inability to fine-tune on the full 24M coding examples, we use up to 1.2M.Fig. 5 shows that MLFS pass@1 improves rapidly as number of tokens increases from a low 10k to 400k to 1.2M examples, only 5% of the 24M examples.Table 1 shows analogous results with 3 small MLFS models.The improvement in pass@1 indicates that the smaller models retain the ability to learn from the larger teacher.Full FT + random init.MLFS ( =0, r=8) MLFS ( =0.9, r=8) Teacher (Santacoder 1.1B) 1: HumanEval pass@1 (%) performance of 3 small models produced by MLFS from Santacoder 1.1B.Contrary to encoder models, the compression levels that retain sufficient performance of the teacher with decoders is less.While MLFS retains accuracy performance of encoder models at 1/4 the size of the teacher, the decoder models are reduced to at most 2/3 the teacher's size.
75MLFS slicing of the teacher model can, however, benefit decoder models by reducing substantially the training/fine-tuning time needed compared to a randomly-initialised model, as shown in Fig. 6 on Santacoder sliced from 1.1B to 0.7B.In other words, when a smaller model is required for edge inference, one can train it from a random initialisation, or slice from a teacher as does MLFS, and train starting from the sliced weights.The latter significantly reduces training time as seen in the validation loss curves.We see the same benefit on Codellama, as shown below.See [30] for a similar observation.
Validation loss
76Full FT + random init.MLFS ( =0, r=8) MLFS ( =0.9, r=8) 14.0 28.1 30.5 Table 2: HumanEval pass@1 (%) performance of 3 small models produced by MLFS from CodeLlama-7B-Python Ablation Study on Santacoder In Fig. 7, we compare HumanEval performance of a 0.7B Santacoder model fine-tuned through full fine-tuning (FT) from random initialisation vs. fullrank (non-LoRA) MLFS with (α = 0.9) and without (α = 0) distillation.The improvement in the evaluation numbers is remarkable even after fine-tuning on up to only 5% of the examples.HumanEval pass@1 (%) Full FT + random init.MLFS ( =0, r: full-rank) MLFS ( =0.9, r: full-rank) Teacher (Santacoder 1.1B)In Fig. 8, we see better convergence of validation loss on the Santacoder 0.7B for MLFS with distillation loss (α > 0).This demonstrates the benefit of MLFS distillation as compared to full MLFS fine tuning of the sliced model.
Perspectives
77Enterprise users require an efficient way to fine-tune LLMs for inference on edge devices of many sizes.We developed MLFS for such edge deployment scenarios.We demonstrate its benefits on encoder LLMs.We show the limitation of compressing decoder LLMs to a comparable degree; however, MLFS offers significant gains for smaller decoder training/fine-tuning by slicing from a larger pre-trained teacher.
Algorithm 1
78Multistage Low-rank Fine-tuning of Super-transformers (MLFS) Input: Transformer model (teacher) with configuration Φ Tch & off-the-shelf pre-trained weights W pretrain Tch , model configuration space A consisting of smaller (than Φ Tch ) transformer architectures of interest, D train : fine-tuning data set for the target task, r: rank of the low-rank matrices to be learned and distillation factor α ∈ [0, 1].Loss functions: Target task loss ℓ task , knowledge distillation loss ℓ KD , feature distillation loss ℓ FD .Multistage Training:1: for stage s = 0, 1, 2 do 2:
3 : 4 : 5 :
79for iteration = 1, ... do Get a mini-batch B of training examples: {(x i , y i ) ∈ D train | i ∈ B}.Load the super-transformer model with weights W Sup ← W pretrain Tch + s l=0 A l * B l .6:
1 :
80where A 1 , B 1 are LoRA matrices of low rank (typically rank r is chosen between 4 and 16).Algorithm 2 Low-rank approach for Distilling an LLM onto a Pre-trained Student Input: Larger transformer model (teacher) with configuration Φ Tch & weights W Tch already finetuned for the given target task, student model with configuration Φ Std & pre-trained weights W pretrain Std , D train : fine-tuning data set for the target task, r: rank of the low-rank matrices to be learned and distillation factor α ∈ [0, 1].Loss functions: Target task loss ℓ task , knowledge distillation loss ℓ KD , feature distillation loss ℓ FD .Initialize the low-rank matrices {A 1 , B 1 } for fine-tuning the student model f ΦStd weights: W Std := W pretrain Std + A 1 * B 1 , where W pretrain Std is kept frozen and only {A 1 , B 1 } are learned.2: for iteration = 1, 2, . . .do 3: Get a mini-batch B of training examples: {(x i , y i ) ∈ D train | i ∈ B}.
Figure 1 :
81Figure 1: Model size vs performance trade-off for task-specific BERT models produced by MLFS against other methods on 6 GLUE data sets.
Figure 2 :
82Figure 2: Latency vs performance trade-off for task-specific BERT models produced by MLFS against other methods on 6 GLUE data sets.
Figure 3 :
83Figure 3: Ablation study on gradient scaling: MLFS minnet convergence is improved using gradient scaling.
Figure 6 :
84Figure 6: Convergence comparison of validation loss while fine-tuning a custom model from random vs using MLFS.MLFS achieves low validation loss much faster.
Figure 7 :
85Figure 7: Superior performance of supernet training compared to other full fine-tuning based approaches on three data sets with 10K/400K/1.2Mexamples.
Figure 8 :
86Figure 8: Convergence comparison of validation loss while fine-tuning a custom model using MLFS with/without distillation.
Table 2 shows
87HumanEval performance of these models as the number of examples is increased from 200K to 400K.Again, we see that the sliced CodeLlama retain their ability to learn and improve quickly as the number of examples increases.Note that the full data set includes 24M examples; MLFS achieves nearly 75% of the performance of fullsize CodeLlama after less than 2% of the examples.
참고문헌
참고문헌 정보가 없습니다.