오늘 소개해 드릴 논문은 구글의 BERT와 페이스북 현재 메타의 RoBERTa를 기반으로 만들어진 모델입니다. RoBERTa + Disentangled Attention과 enhanced mask decode
두가지의 핵심 기술로 RoBERTa를 더욱 개선 시킨 모델이라고 이해하시면 될 것 같습니다. 추가적으로 Scale Invariant Fine Tuning을 도입하여 RoBERTa를 상당히 많은 테스크에서, NLU 테스크에서는 RoBERTa, BERT이상의 성능을 보여준 논문이기도 합니다.
논문의 자세한 리뷰부터, 백그라운드 지식까지, 자연어처리팀 진명훈님이 도와주셨습니다.
3. Introduction
3
• He et al., 2020 에서 제안된 모델
• DeBERTa: Decoding-enhanced BERT with Disentangled Attention
• Google의 BERT(2018)과 Facebook(현재 Meta)의 RoBERTa(2019) 기반
• RoBERTa + disentangled attention + enhanced mask decoder
• With half of the data used in RoBERTa (80GB)
• Scale Invariant Fine-Tuning 도입
• #5929 PR로 🤗transformers에 Merge됨
• Outperform RoBERTa an a majority of NLU tasks
• e.g., SQuAD, MNLI and RACE
5. Background: Positional Information
5
• The standard self-attention mechanism lacks a natural way to encode
word position information
• Add Positional Bias (ref: 딥논읽 Rotary Embedding 발표)
• Absolute Position Embedding
• Relative Position Embedding
6. Background: Masked Language Model
6
• Large-scale Transformer-based PLMs are typically pre-trained on large
amounts of text to learn contextual word representations using a self-
supervision objective, known as Masked Language Model (MLM)
max
𝜃
log 𝑝𝜃(𝑋| ෨
𝑋) ≈ max
𝜃
𝑖∈𝐶
log 𝑝𝜃
𝑥𝑖 = 𝑥𝑖
෨
𝑋
8. 3 Contributions
8
• Disentangled attention
• Transformer-xl처럼 additive하게 attention을 분해
• Shaw, Transformer-xl과 다르게 position-to-content term을 살림
• query token의 위치가 달라지는 부분도 반영
• Position-to-position term은 RPE에서 불필요하기 때문에 제거
• Enhanced Mask Decoder
• A new store opened beside the new mall
• Absolute position information 또한 중요하다!
• Scale Invariant Fine-Tuning
• Adversarial Training은 모델의 일반화에 도움을 준다
• NLP에서 embedding vector norm의 분산은 모델바이모델, 단어바이단어
• Word embedding을 normalize해주고 Perturbation을 추가하자!
9. Disentangled Attention
9
• Disentangled Attention: A two vector approach to content and position
embedding
• 논문에서 아래와 같은 수식을 제안하며 token repr을 content와 position에 대한
두 벡터로 decomposition 수행
• 이렇게 쪼개는 것은 사실 Transformer-XL에서 제안되었어요!
𝐴𝑖,𝑗 = 𝐻𝑖, 𝑃𝑖|𝑗 × 𝐻𝑗, 𝑃𝑗|𝑖
𝑇
= 𝐻𝑖𝐻𝑗
𝑇
+ 𝐻𝑖𝑃𝑗|𝑖
𝑇
+ 𝑃𝑖|𝑗𝐻𝑗
𝑇
+ 𝑃𝑖|𝑗𝑃𝑗|𝑖
𝑇
11. History: Relative Position Embedding
11
Transformer upgrade! Layer에 직접 위치 정보를 주입하자!
Self-Attention with Relative Position Representations
Music Transformer
18. Disentangled Attention
18
• Shaw 연구진 등의 기존 RPE 접근 방법은 content-to-content (a) term과
content-to-position (b) term을 사용하여 attention weights를 계산
• Attention weight는 어느 한 쪽 방향으로만 모델링할 수 없다.
• Position-to-content term (c) term 또한 중요하다!
• Relative position embedding에서 (d) term은 이미 고려하고 있음
19. Disentangled Attention
19
• k: maximum relative distance
• 𝛿 𝑖, 𝑗 ∈ 0,2𝑘
• 𝛿 𝑖, 𝑗 = ቐ
0
2𝑘 − 1
𝑖 − 𝑗 + 1
𝑖 − 𝑗 ≤ −𝑘
𝑖 − 𝑗 ≥ 𝑘
for
for
o. w
21. Enhanced Mask Decoder
21
• DeBERTa는 MLM으로 pre-trained
• MLM을 위해 context words의 content와 position information을 활용
• 하지만 absolute positions을 고려하지 않음
• e.g.,
• A new store opened beside the new mall
• BERT는 absolute positions을 input layer에 주입
• DeBERTa는 Transformer layer를 전부 거치고 Masked token prediction을 위
해 softmax layer를 통과시키기 전에 absolute positions을 주입
28. BertForMaskedLM
28
Transformer Layer
with disentangled attention
Transformer Layer
with disentangled attention
Transformer Layer
with disentangled attention
Transformer Layer
with disentangled attention
Transformer Layer
with disentangled attention
…
Sub-word embedding
Token type embedding
+
Encoder output
Encoder output
Encoder output
Encoder output
Encoder output
Absolute position embedding
Token type embedding …
CLS 딥 ##러 MASK 논 MASK 모임 SEP
lm_head
Token type embedding …
CLS 딥 ##러 ##닝 논 ##문 모임 SEP
lm_logits, lm_loss
BERT Module
29. DeBERTaForMaskedLM with EDM
29
Transformer Layer
with disentangled attention
Transformer Layer
with disentangled attention
Transformer Layer
with disentangled attention
Transformer Layer
with disentangled attention
Transformer Layer
with disentangled attention
…
Sub-word embedding
Token type embedding
+
DeBERTa Module
Encoder output
Encoder output
Encoder output
Encoder output (H)
Encoder output
Absolute position embedding
• (1)은 position_biased_input 옵션이 True인 경우에만 더해줌
• 분홍색 Transformer Layer는 shared
• lm_head는 word embedding matrix와 shared
• 저자에 의하면 EDM이 누락되도 PLM의 수렴에 영향을 끼치지 않는다고 함
• MLM training의 perplexity에 약간의 영향을 미치는 부분
Token type embedding …
CLS 딥 ##러 MASK 논 MASK 모임 SEP
Query state (I)
+
Transformer Layer
with disentangled attention
Transformer Layer
with disentangled attention
Query state (I)
EDM Module (n=2)
(1)
Encoder output
Token type embedding …
CLS 딥 ##러 ##닝 논 ##문 모임 SEP
lm_head
lm_logits, lm_loss
30. Scale Invariant Fine-Tuning
30
• Virtual adversarial training은 regularization method
• 모델의 일반화 성능을 강화
• Input에 small perturbation(noise)를 줘서 adversarial attack에도 동일한
output prediction을 만드는 것이 목적
• NLP task에서 perturbation은 word embedding에 주어짐
• 그러나 model by model, word by word로 emb vector의 norm은 상이함
• Bigger model일수록 분산은 커지고 adversarial training의 불안정성을 키움
• Layer norm에서 영감을 받아 normalized word embeddings에 perturbation을
추가하여 Adversarial Fine-Tuning
• 1.5B 모델에만 적용했고 comprehensive study는 향후에 진행할 예정
48. Conclusion
48
• Disentangled attention과 enhanced mask decoder로 RoBERTa 개선
• Downstream task에서 모델 일반화를 개선하기 위해 SIFT 제안
• Macro score 측면에서 SuperGLUE 벤치마크에서 인간의 성능을 상회
• 아직 인간 수준의 지능까진 도달하지 못함
• 최근에 V3가 나왔습니다! → 다음 차례에 wrap-up하며 발표하도록 하겠습니다.