본 포스트에서는 2020년 Microsoft의 "DeBERTa: Decoding-enhanced BERT with Disentangled Attention" 논문에서 제안한 Deberta 모델을 Bert 모델과 비교하여 포인트만 모아 정리해보았다.
Disentangled attention mechanism
Word representation(단어 표현)
- BERT 입력 레이어의 각 단어 = 단일 벡터(word embedding + position embedding)
- DeBERTa의 각 단어 = 두 개의 벡터(content, position 각각을 인코딩)
Attention weight (단어 간 어텐션 가중치)
- (기존 어텐션 가중치 계산방법)
- (DeBERTa) content와 relative position에 기반한 disentangled matrices를 사용하여 연산 → “한 단어의 어텐션 가중치는 content 뿐만 아니라, relative position에도 의존”
Enhanced masked decoder
MLM (마스크 언어 모델링)
- (BERT) 사전학습 시, 마스크 토큰의 주변 단어를 사용하여 마스킹 된 단어가 무엇인지 예측하도록 빈칸을 채우는 태스크
- (DeBERTa) MLM시 주변 단어의 content와 position 정보를 사용
- Disentangled attention mechanism에서는 content, relative position를 먼저 판별하지만, 대부분 예측에 중요한 요소인 absolute position을 먼저 판별하지 않는다.
- 단어의 absolute position이 왜 중요한가?
- “a new store opened beside the new mall”
- ‘store’, ‘mall’이 마스킹 되었을 때, local context는 비슷하지만, store는 주어로 두 개의 syntactic role이 다르다.
- Syntactic 뉘앙스는 absolute position에 크게 의존하기 때문에 언어 모델링 시 매우 중요
- contents와 position의 aggregated contextual embeddings에 기반한 masked words를 디코딩하는 softmax layer 바로 이전에 absolute word position embedding 통합
Scale Invariant Fine-tuning
- 새로운 Virtual Adverserial 학습 알고리즘
- 모델의 일반화 향상을 위한 정규화 방법론
- 입력에 작은 변화(perturbations)을 만듦으로써 생성된 adversarial example에 모델의 robustness를 향상시키며 학습
- 모델이 정규화되면서 task-specific example이 주어지면, 모델이 해당 example의 adverarial perturbatiㅐn를 생성할 때 동일한 output distribution을 생성하게 한다.
- Virtual adversarial training
- (기존) 원본 단어 시퀀스가 아닌 word embedding에 perturbation 적용된다
- 임베딩 벡터값의 범위는 각 단어와 모델에 따라 다른데, 이 다양성은 수십 억개의 파라미터를 갖는 대형 모델에서 더 커지고, adversarial training의 불안정성을 야기한다
- (DeBERTa) 정규화된 단어 임베딩에 perturbation을 적용하여 학습 안정성을 향상시킴
- Word embedding vector → stochastic vector로 정규화
- 정규화된 벡터에 perturbation 적용
Deberta 모델은 절대 위치를 사용하는 기존의 트랜스포머 기반 모델과 달리 단어 쌍의 상대적 거리를 저장하는 2차원 행렬을 통해 텍스트의 위치 정보를 인코딩하기 때문에 단어 간의 관계를 잘 포착한다는 장점이 있다. 다양한 응용 태스크에서 뛰어난 성능을 보여주어, Deberta 등장 후 많은 논문에서 이 모델을 채택하여 사용하는 것을 보았다. 다만, 개인적인 문제로는 이 모델을 사용하여 서빙을 해보았을 때, 인코더에서 메모리 누수가 발생했었는데 관련 문제를 해결하지 못했다.
- Deberta 논문 https://arxiv.org/abs/2006.03654
'Research > NLP' 카테고리의 다른 글
Pre-training LLM 분류하기 (Encoder, Decoder, Encoder-Decoder) (0) | 2023.07.16 |
---|---|
[LLM 모음] Llama와 Alpaca (0) | 2023.06.11 |
[LLM 모음] InstructGPT의 훈련 과정 알아보기 (feat. RLHF) (1) | 2023.06.04 |
강화학습과 InstructGPT - part 1 (0) | 2023.05.28 |
[Paper review] Larger language models do in-context learning differently (번역정리) (0) | 2023.05.21 |