modulabs / beyondBERT

11.5기의 beyondBERT의 토론 내용을 정리하는 repository입니다.
MIT License
59 stars 6 forks source link

Longformer: The Long-Document Transformer #12

Closed seopbo closed 4 years ago

seopbo commented 4 years ago

어떤 내용의 논문인가요? 👋

긴 글(수천수만 토큰)을 효율적으로 Transformer에 태우는 선택적 Attention 적용방법. 다른 모델들에도 갖다쓸 수 있다.

🙀 주의 🙀
이 논문은 기존 모델을 작게 만드는 것 X
Transformer의 사이즈를 작게 만드는게 X

기존 동일한 사이즈(동일한 GPU)에 훨씬 긴 문장/문단을 문장단위 안쪼개고 통으로 넣을 수 있다는 뜻 O

Abstract (요약) 🕵🏻‍♂️

Transformer-based models are unable to process long sequences due to their self-attention operation, which scales quadratically with the sequence length. To address this limitation, we introduce the Longformer with an attention mechanism that scales linearly with sequence length, making it easy to process documents of thousands of tokens or longer. Longformer's attention mechanism is a drop-in replacement for the standard self-attention and combines a local windowed attention with a task motivated global attention. Following prior work on long-sequence transformers, we evaluate Longformer on character-level language modeling and achieve state-of-the-art results on text8 and enwik8. In contrast to most prior work, we also pretrain Longformer and finetune it on a variety of downstream tasks. Our pretrained Longformer consistently outperforms RoBERTa on long document tasks and sets new state-of-the-art results on WikiHop and TriviaQA.

[간단정리]

  1. Transformer의 self attention 때문에 O(n^2)로 증가해서 긴 문장 처리하기가 어렵다.
  2. 그래서 우리는 Longformer라는 새로운 어텐션 기법을 제안한다.
  3. 이건 문장길이 따라 O(n)으로 Linear하게 증가한다.
  4. 그래서 몇천짜리 토큰도 Transformer로 처리할 수 있다.
  5. Char Level로하면 토큰 많으니 이거를 예시로 text8/enwiki8 학습하니 SoTA.
  6. Downstream Task로 할때도 긴 문장에서는 RoBERTa보다 낫다. (Wikihop/TriviaQA)

이 논문을 읽어서 무엇을 배울 수 있는지 알려주세요! 🤔

논문 개요

image

해결책: Longformer

방법론 / 모델 소개

어떻게 해결했나? -> Sparse Attention 방법 몇 가지를 제안함

image

(a) 가 기존의 FULL Attention

(b) 가 좌우로 w 개 보는 Window 사이즈를 지정한 Attention

(c) 는 (b)에서 중간중간 jumping한 window로 만든 Attention

(d) 는 특정위치에 있는 토큰에 대해서는 Global Attention을 부여

위의 문제로 인해 Attention의 종류를 Sliding Window Attention / Global Attention으로 구분 심지어 커스텀 CUDA 커널도 만듬!(놀라움!)

실험한 것들: 뭐가 성능을 올려주나?

image

학습 방법

그러면 길이는 최대 512 아닌가? -> Positional Emb 복붙해서 늘리기 😨 -> 이게 된다고? 잘 된다고 한다... -> BERT가 Local한거에 집중하기 때문에 된다고 함(Positional embedding시에)

image

진짜로 RoBERTa기반 위치 임베딩 복사하면 그 자체로 성능 나오고 +Longformer 학습시에도 빠른 converge 보여준다. (금방 BPC가 감소한다.) 학습 더 할수록 성능 향상 = 더 멀리 보는 Attention이 학습에 도움 되는 것을 보여주는 셈

성능 비교하기(설정에 따라)

테스트 데이터셋은 아래와 같이 엄청 긴 Token들이 많음(수천~만단위)

image

결과

image

같이 읽어보면 좋을 만한 글이나 이슈가 있을까요?

레퍼런스의 URL을 알려주세요! 🔗

https://arxiv.org/abs/2004.05150

Beomi commented 4 years ago

[질문]

만약 비슷한 느낌으로 작은데 + 비슷한 Sliding + Global Attention + ... 붙인 모델 만들면, 현재의 512길이 Transformer와 같은 길이 커버하지만 더 작고 비슷한 성능의 모델을 만들 수 있을까?

DataLama commented 4 years ago

[질문]

Q1) Longformer에 적용된 global attention은 Pretrain 단계에서는 적용하지 않고, fine tuning 단계에서만 task-specific하게 사용하는 것 같은데, 이러면 결국에는 Pretrain 단계에서는 정말 긴 시퀀스에서 토큰들 간의 Long term dependency는 학습하지 못하는 것은 똑같지 않나요???

Q2) Pretrain에 사용한 데이터셋 중에 Books 같은 경우는 Avg Doc Len이 95.9K (Table 5)인 반면, 모델의 model_max_length 는 4096인데, 해당 코퍼스들은 어떻게 처리했을까요?? 앞에서 longformer는 truncating이나 chunking을 사용하지 않고도 긴 시퀀스를 처리할 수 있다고 했는데 저 시퀀스를 어떻게 모델링에 활용했는지 궁금합니다.