Skip to main content
QUICK REVIEW

[논문 리뷰] LongNet: Scaling Transformers to 1,000,000,000 Tokens

Jiayu Ding, Shuming Ma|arXiv (Cornell University)|2023. 07. 05.
Topic ModelingComputer Science인용 수 34
한 줄 요약

LongNet은 확산된 주의(dilated attention)를 도입하여 Transformer를 10억 개 이상의 토큰으로 확장하되 선형에 가까운 복잡도로 만들고, 분산 학습을 가능하게 하며 짧은 시퀀스에서도 성능을 유지합니다.

ABSTRACT

Scaling sequence length has become a critical demand in the era of large language models. However, existing methods struggle with either computational complexity or model expressivity, rendering the maximum sequence length restricted. To address this issue, we introduce LongNet, a Transformer variant that can scale sequence length to more than 1 billion tokens, without sacrificing the performance on shorter sequences. Specifically, we propose dilated attention, which expands the attentive field exponentially as the distance grows. LongNet has significant advantages: 1) it has a linear computation complexity and a logarithm dependency between any two tokens in a sequence; 2) it can be served as a distributed trainer for extremely long sequences; 3) its dilated attention is a drop-in replacement for standard attention, which can be seamlessly integrated with the existing Transformer-based optimization. Experiments results demonstrate that LongNet yields strong performance on both long-sequence modeling and general language tasks. Our work opens up new possibilities for modeling very long sequences, e.g., treating a whole corpus or even the entire Internet as a sequence.

연구 동기 및 목표

  • 현재 한계를 넘어 Transformer에서 시퀀스 길이를 확장할 필요성을 제시한다.
  • 효율성을 유지하면서 주의 영역을 기하급수적으로 확장하기 위한 dilated attention 메커니즘을 제안한다.
  • 매우 긴 시퀀스를 처리하기 위해 다중 디바이스 간의 분산 학습을 가능하게 한다.
  • LongNet이 짧은 시퀀스에서의 성능을 보존하면서 컨텍스트 길이를 크게 확장함을 보여준다.
  • 기존 Transformer 최적화(커널 융합, 양자화 등)와의 실용적 통합을 제공한다.

제안 방법

  • 일반적인 self-attention을 Seg 기반의 dilation으로 Q, K, V를 시퀀스에 걸쳐 희소하게 만드는 dilated attention으로 교체한다.
  • 증가하는 세그먼트 크기와 dilation 비율을 갖는 다양한 dilated attention 패턴의 혼합을 사용하여 N에서 거의 선형 FLOPs와 로그 기반 토큰 의존성을 달성한다.
  • 각 헤드가 시프트된 희소 패턴을 사용해 다양한 지역/전역 정보를 포착하는 다중 헤드 dilated attention를 도입한다.
  • 소프트맥스 분모에서 도출된 가중치를 가진 다중 dilated attention의 가중 합으로 전체 출력을 수식화한다.
  • KV의 all-gather와 로컬 Q와 글로벌 KV 간의 크로스 어텐션을 포함해 시퀀스 차원을 디바이스에 걸쳐 분할하는 분산 학습 알고리즘을 설명한다.
  • 표준 최적화(FlashAttention, 커널 융합, 양자화)와 호환되는 Dense Transformer 변형으로 구현 호환성을 제공한다.

실험 결과

연구 질문

  • RQ1확대된 dilated attention이 계산 비용이나 메모리 비용을 과도하게 증가시키지 않으면서 Transformer 시퀀스 길이를 1B 토큰까지 확장할 수 있는가?
  • RQ2컨텍스트 길이를 확장하면서 LongNet이 짧은 시퀀스에서의 성능을 유지하거나 향상시키는가?
  • RQ3제안된 분산 학습 접근 방식이 단일 GPU 메모리 한계를 넘어서는 극도로 긴 시퀀스에 대해 효과적인가?
  • RQ4Dense/다른 희소 트랜스포머와 비교한 LongNet의 맥락 길이가 언어 모델링 성능과 스케일링 법칙에 어떤 영향을 미치는가?

주요 결과

  • LongNet은 시퀀스 길이에 대해 거의 선형에 근접한 계산 복잡도를 가지며 토큰 의존도는 O(log N)이다.
  • dilated attention은 장치 간 일정한 KV 통신 비용으로 분산 시퀀스 병렬 접근을 사용하여 최대 1B 토큰까지의 시퀀스 학습을 확장 가능하게 한다.
  • 언어 모델링 과제에서 LongNet은 더 긴 시퀀스 길이(2K, 8K, 16K, 32K)에서도 밀도 Transformer 및 희소 Transformer 기준선보다 일관되게 더 나은 성능을 보이며 perplexity가 더 낮다.
  • LongNet은 짧은 시퀀스에서도 강력한 성능을 유지하면서도 훨씬 더 긴 컨텍스트를 가능하게 하며 표준 Transformer와 유사한 계산 기반의 확장 법칙을 따른다.
  • 실험은 학습 중 컨텍스트 길이를 확장하는 것이 실제적임을 보여주며, 같은 또는 비교 가능한 계산 하에서 더 긴 컨텍스트가 더 나은 언어 모델링 결과를 낳는다.

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.