1day_1paper icon indicating copy to clipboard operation
1day_1paper copied to clipboard

[23] Long-Short Transformer: Efficient Transformers for Language and Vision

Open dhkim0225 opened this issue 3 years ago • 0 comments

paper code

long-range attention 과 short attention 을 각각 보자는 논문

INTRO

  • 다양한 efficient attention 나왔지만 language, vision 둘 다 좋은 성능을 내는 방법들이 없었음.
  • pattern을 박는 sparse attention 방법론은 attention의 가능성을 제한해 버림
  • low-rank projection 은 NLP 진영에서만 검증됨

Contributions

  • Long-Short Transformer (Transformer-LS) 제안
  • Long Range Arena (LRA) benchmark sota (S4 나오기 전까지 ..)
  • Auto-regressive, bidirectional 하게 linear complexity 로 해결 가능

Transformer-LS

image

Notions

image imagequery, key, value projection matrix for output i번째 head (dot-product attn) head 별 dimension

Short-term Attention via Segment-wise Sliding Window

LongFormer 나 BigBird 처럼 sliding window 수행. 다만, "segment" 기반으로 수행. PyTorch 에서는 단순히 pixel 마다 길이를 상하좌우 w 로 주는 것보다 이게 빨랐음 (?)

  1. input sequence 를 length w 의 disjoint segment로 나눔
  2. segment 내부에서는 전부 attend && home segment 의 좌우 2/w 크기만큼 추가 attend (총 2w 만큼 봄) image

아래 이미지는 LongFormer 의 sliding window attn figure image

물론 이 녀석을 쌓으면 long range 도 볼 수는 있지만, 성능이 떨어지니까 long range attention 관련 method 를 따로 둠.

autoregressive 하게 붙일 때는 attention을 다르게 붙임. 2d 그림으로 보면, image

Long-range Attention via Dynamic Projection

image prjection param (Linformer 처럼 learnable) i번째 head의 dynamic low-rank projection (r << n) image image

Aggregating Long-range and Short-term Attention

이제 long 과 short 를 합쳐줘야 하는데, Head마다 다른 attention mechanism 을 두고 합치는 방식이 아니라, local 과 global attn 값이 서로를 이해하는데 도움을 줄 수 있도록 구성했다고 한다.

position t 에서의 i번째 attention 은 다음과 같다. global low-rank projected keys and values local keys and values

image image

Dual LN

학습 초반에 의 norm 값이 다르기 때문에 Dual LN 을 제안

image image

Results

LRA

image

ImageNet

image image

AutoRegressive

image image

RobustNess

image

dhkim0225 avatar Nov 07 '21 01:11 dhkim0225