Prompt-Based Learning 3 | P-Tuning v2: Prompt Tuning Can Be Comparable to Fine-tuning Universally Across Scales and Tasks

|

1. Introduction

PLM은 광범위한 NLU task에 대해 성능을 향상시켰다. 널리 사용되는 방법인 fine-tuning은 PLM의 전체 parameter를 target task에 대해 update한다. fine-tuning은 좋은 성능을 내지만 모든 parameter에 대한 gradients와 optimizer state가 저장된다. 그리고 model의 parameter를 복사하여 가지고 있는 것은 PLM의 크기가 크기 때문에 매우 불편하다.

반면 Prompting은 PLM의 모든 parameter를 freeze시키고 prompt 형태의 query를 LM에 넣는 방식을 사용한다. 감성분석 task에 대해 예를 들어 보면 e.g. “Amazing movie!”라는 sample에 “This movie is [MASK]”라는 prompt를 붙여 PLM이 mask token이 “good”과 “bad” 중 어떤 token의 확률이 높은지 예측하도록 한다. Prompting은 따로 학습을 진행하지 않고 단순히 PLM을 copy하여 사용한다. 하지만 discrete prompting은 fine-tuning에 비해 suboptimal하다.

Prompt tuning은 continuous prompt를 tuning하는 방식이다. Liu et al. (2021); Lester et al. (2021)은 original input sequence의 embedding(continuous prompt)에 대해 추가로 학습을 진행하는 것을 제안하였다. 이 방법론의 경우 학습 시 continuous prompt만 update된다. prompt tuning은 prompting이 다양한 task에서 좋은 성능을 내도록 했지만 model size가 충분히 크지 않을 때(10 billion 이하일 때)는 여전히 fine-tuning보다 성능이 좋지 않다. 특히 QA task와 같은 sequence labeling task에서는 fine-tuning보다 현저히 성능이 떨어진다.

본 논문의 main contribution은 prompt tuning과 fine-tuning을 다양한 model scale과 NLU task에 대해 경험적으로 비교하는 것이다.

P-tuning v2의 접근법은 기술적으로 새로운 것은 아니다. Deep Prompt Tuning을 더 최적화한 것이라고 볼 수 있다. 가장 주요한 개선 사항은 input layer뿐만 아니라 pretrain model의 모든 layer에 continuous prompt를 적용하였다는 것이다. Deep prompt tuning은 continuous prompt를 늘림으로써 작은 모델과 어려운 task에 대한 fine-tuning과의 격차를 줄였다.

model size 300M-10B으로 수행한 다양한 extractive QA task나 NER(named entity recognition)과 같은 hard sequence tagging task에 대해 fine-tuning과 P-tuning v2 성능 비교를 하였다. P-tuning v2은 training time memory cost와 per-task storage cost를 대폭 줄임으로서 fine-tuning의 0.1%-3% parameter를 가지고 학습한다.

2. Preliminaries

1) NLU task

본 논문에서는 NLU task를 simple classification tasks 와 hard sequence labeling tasks로 나누어 본다. simple classification tasks에는 간단히 label을 분류하는 task로, GLUE와 SuperGLUE에 있는 대부분의 task들이 여기에 속한다. hard sequence labeling tasks에는 sequence로 이루어진 token에 대한 classification task이다. 여기에는 extractive QA task나 NER(named entity recognition)이 속한다.

2) Prompt Tuning

Notation

$\mathcal{V}\text{ :vocabulary of a language model}$

$\mathcal{M}\text{ :language model}$

$\mathbf{e}\text{ : embedding layer of Language Mpdel}$

discrete promptingdml 경우 prompt token $\text{{ “It”, “is”, “[MASK]” }}\subset \mathcal{V}$이 movie review classify에 일반적으로 사용될 수 있다. 예를 들어 “Amazing movie!”라는 input text $\mathbf{x}$가 있을 때 input embedding은 $\left [ \mathbf{e}(\mathbf{x}),\mathbf{e}(\mathbf{“It”}),\mathbf{e}(\mathbf{“is”}), \mathbf{e}(\mathbf{“[MASK]”}) \right ]$로 표현된다.

Lester et al. (2021)와 Liu et al. (2021) 논문에서는 PLM의 parameter는 freeze시켜 놓고 natural language prompts를 trainable continuous prompts로 교체한다.

trainable continuous embeddings $\text{[}\mathit{h}{0}, … , \mathit{h}{i} \text{]}$이 있을 때 input embedding sequences는 $\text{[}\mathbf{e}(\mathbf{x}),\mathit{h}{0}, … , \mathit{h}{i} , \mathbf{e}(\mathbf{“[MASK]”}) \text{]}$이다. Lester et al., 2021; Kim et al., 2021; Liu et al., 2021여구에서 10B parameter model로 수행한 Prompt tuning은 simple classification task에 대해 fine-tuning과 견줄 만하다는 것이 증명되었다.

3. P-Tuning v2

3.1. Lack of Universality

Prompt tuning은 많은 NLP task에서 꽤 좋은 성능을 보인다는 것이 증명되었다. 하지만 모델 크기와 task와 관련한 보편성 문제로 여전히 fine-tuning을 대체하기에는 부족하다.

1) Lack of universality across scales

앞서 언급한 바와 같이 10B 정도 되는 크기의 model을 사용했을 때는 fine-tuning과 견주어 볼 만하지만 일반적으로 사용되는 medium-sized models을 사용했을 때는 fine-tuning보다 성능이 좋지 않다.

2) Lack of universality across tasks

몇몇 NLU benchmark에 대해서는 fine-tuning보다 우월하지만 hard sequence tagging tasks에 대한 성능은 확실하지 않다. input token들에 대해 sequence로 구성된 label을 verbalizer를 통해 예측하는 것은 어렵고 복잡하다. 본 논문의 실험에서도 sequence tagging tasks의 성능이 fine-tuning에 비해 좋지 않은 것을 이후 실험 결과에서 확인할 수 있다.

실험에 앞서 본 논문에서는 deep prompt tuning 개념을 차용한 P-tuning v2를 제안한다.

3.2. Deep Prompt Tuning

Lester et al., 2021과 Liu et al., 2021에서의 continuous prompts는 input embedding sequence에만 들어갔다. 이 방법론에는 두 가지 문제점이 있다.

1) sequence length로 인해 제한된다.

2) input embedding이 model 추론에 직접적인 영향을 주지 않는다.

P-tuning v2에서는 위와 같은 문제를 해결하기 위해 deep prompt tuning의 개념을 끌어왔다. Figure 2에 표현된 것과 같이 다른 layer에 있는 prompt들은 prefix token처럼 추가했고 더 깊은 layer에 prompt를 추가하여 model 추론에 직접적인 영향을 주도록 하였다.

3.3. Optimization and Implementation

최고의 성능을 내기 위한 optimization과 implementation에 대한 유용한 디테일들이 있다.

1) Reparameterization

기존 연구들은 trainable embedding으로 변환하기 위해 MLP와 같은 reparameterization encoder를 사용한다. 하지만 NLU task에서 그게 큰 도움이 되지 않는 것을 발견했다. RTE, CoNLL04 등 몇몇 dataset에 대해서는 MLP가 좋은 영향을 미치지만 다른 task에서는 영향이 미미하거나 부정적인 것으로 확인 되었다.

2) Prompt Length

prompt 길이는 P-Tuning v2에서 중요한 역할을 한다. NLU task마다 최적의 prompt 길이가 다르다. 일반적으로 simple classification task의 경우 prompt 길이가 짧을 때, hard sequence labeling task의 경우에는 prompt 길이가 길 때 성능이 좋다.

3) Multi-task Learning

Multi-task learning은 각 task에 대해 fine-tuning을 하기 전, 여러 task에 대해 continuous prompt를 공유하여 최적화하는 것이다. P-tuning v2에서 Multi-task는 선택사항이다.

4) Classification Head

verbalizer를 예측하기 위해 LM head를 사용하는 것은 prompt tuning에서 주로 사용되는 방식이다. 하지만 이것이 full-data setting에서는 불필요하고 sequence labeling에 대해서는 호환되지 않는다. 그래서 P-tuning v2에서는 BERT와 같이 randomly-initialized된 classification head를 token 맨 앞에 붙이는 방식을 채택하였다.

Table1은 기존의 prompt tuning과 P-tuning v2의 major contribution을 정리한 것이다.

4. Experiments

본 논문에서는 일반적으로 사용되는 pre-trained model과 NLU task들을 기반으로 실험을 진행하였다. 그리고 fine-tuning을 제외한 모든 방법론은 frozen language model backbone을 기반으로 수행된다.

1) NLU Tasks

P-tuning v2의 NLU ability를 확인하기 위해 SuperGLUE를 사용하였다. 추가적으로 NER(named entity recognition), extractive Question Answering, semantic role labeling과 같은 sequence labeling tasks에 대해서도 실험을 진행했다.

2) Pre-trained Models

평가를 위한 사전 학습 모델로는 BERT-large, RoBERTa-large, DeBERTa-xlarge, GLM-xlarge/xxlarge를 사용하였다. 위 모델들은 모두 NLU task를 위한 bidirectional model들로, 300M-10B 사이의 size의 버전들이 존재한다.

3) Multitask Learning

multi-task setting을 위해 각 task type에 속한 모든 trainset을 모두 합치고 continuous prompt를 공유하는 동안 별도의 linear classifier를 둔다.

4.1 P-tuning v2: Across Scales

Table 2는 model scale에 따른 P-tuning 성능을 보여준다. SuperGLUE에 대해 model scale이 작을수록 P-tuning의 결과가 좋지 않은 것을 볼 수 있다. 반면 P-tuning v2는 작은 모델 기반에서도 모든 task에서 fine-tuning과 유사한 성능을 보인다. RTE에 대해서는 fine-tuning보다 더 좋은 성능을 낸 것을 확인할 수 있다. 2B-10B정도의 큰 scale model(GLM)로 진행한 실험에서는 fine-tuning과 P-tuning의 격차가 좁아졌다. 이전 연구들에서도 10B scale에서는 prompt tuning과 fine-tuning이 견줄만한 성능을 보였기 때문에 놀랍지 않지만 여기에서 중요한 것은 P-tuning v2의 경우에는 모든 scale에 걸쳐 fine-tuning과 유사한 성능을 보인다는 것이다.

4.2 P-tuning v2: Across Tasks

Tbale3에서 P-tuning이 모든 task에 대해 fine-tuning과 유사한 성능을 내는 것을 확인할 수 있다. P-tuning은 특히 QA task에서 좋지 않은 성능을 보인다. 그리고 SQuAD2.0에는 unanswerable question이 포함되어 있기 때문에 single-layer prompt tuning인 P-tuning으로 풀기에는 까다로웠을 것으로 예상한다. P-Tuning v2에서는 Multi-taks learning을 통해 QA를 제외한 모든 task에서 눈에 띄는 성능 향상이 이루어졌다.

4.3 Ablation Study

본 논문에서 제안된 요소들이 어떤 영향을 미쳤는지 확인하기 위해 해당 요소가 적용된 것과 아닌 것에 대한 비교를 해 본다.

1) Verbalizer with LM head v.s. [CLS] label with linear head.

verbalizer를 예측하기 위해 LM head linear head를사용하는 것이 기존 prompt tuning의 일반적인 요소였지만 P-tuning v2에서는 linear head를사용하는 것이 classification head로서 붙이는 방식 사용하였다. 비교해 보니 큰 차이는 없다.

2) Prompt depth

P-tuning과 P-tuning v2의 주요한 차이는 multi-layer continuous prompt이다. 해당 요소의 명확한 영향력을 확인하기 위해 prompt에 k개의 layer를 추가하였다. transformer layer가 많을수록 좋더라

5. Conclusions

모든 model scale, task에 거쳐 p-tuning v2를 통해 prompt tuning이 fine-tuning과 비슷한 성능을 낼 수 있다.

Reference

Xiao Liu, Kaixuan Ji, Yicheng Fu, Weng Lam Tam, Zhengxiao Du, Zhilin Yang, Jie Tang. “P-Tuning v2: Prompt Tuning Can Be Comparable to Fine-tuning Universally Across Scales and Tasks,”2022