Skip to main content
QUICK REVIEW

[논문 리뷰] LongLoRA: Efficient Fine-tuning of Long-Context Large Language Models

Yukang Chen, Shengju Qian|arXiv (Cornell University)|2023. 09. 21.
Topic ModelingComputer Science인용 수 39
한 줄 요약

LongLoRA는 Shifted Sparse Attention(S2-Attn)과 학습 가능한 임베딩 및 정규화 층을 결합하여 사전 학습된 LLM의 컨텍스트 창을 효율적으로 확장하고, 원래의 추론 아키텍처를 유지하면서 더 낮은 비용으로 긴 컨텍스트 미세 조정을 가능하게 합니다.

ABSTRACT

We present LongLoRA, an efficient fine-tuning approach that extends the context sizes of pre-trained large language models (LLMs), with limited computation cost. Typically, training LLMs with long context sizes is computationally expensive, requiring extensive training hours and GPU resources. For example, training on the context length of 8192 needs 16x computational costs in self-attention layers as that of 2048. In this paper, we speed up the context extension of LLMs in two aspects. On the one hand, although dense global attention is needed during inference, fine-tuning the model can be effectively and efficiently done by sparse local attention. The proposed shifted sparse attention effectively enables context extension, leading to non-trivial computation saving with similar performance to fine-tuning with vanilla attention. Particularly, it can be implemented with only two lines of code in training, while being optional in inference. On the other hand, we revisit the parameter-efficient fine-tuning regime for context expansion. Notably, we find that LoRA for context extension works well under the premise of trainable embedding and normalization. LongLoRA combines this improved LoRA with S^2-Attn. LongLoRA demonstrates strong empirical results on various tasks on Llama2 models from 7B/13B to 70B. LongLoRA extends Llama2 7B from 4k context to 100k, or Llama2 70B to 32k on a single 8x A100 machine. LongLoRA extends models' context while retaining their original architectures, and is compatible with most existing techniques, like Flash-Attention2. In addition, we further conduct supervised fine-tuning with LongLoRA and our long instruction-following LongAlpaca dataset.

연구 동기 및 목표

  • 사전 학습된 LLM의 컨텍스트 창을 긴 문서 작업을 위해 prohibitive compute 없이 확장하려는 동기를 부여한다.
  • 추론 시 표준 주의 아키텍처를 보존하는 효율적인 미세 조정 방법을 개발한다.
  • 학습 중 전체 자기 주의(attention)를 근사화하기 위한 오버헤드가 낮은 Shifted Sparse Attention를 도입한다.
  • LoRA와 전체 미세 조정 간의 격차를 긴 컨텍스트 적응을 통해 임베딩 및 정규화 층의 학습 가능성으로 해소한다.
  • 실험적으로 Llama2 계열(7B/13B/70B)에서 extended contexts를 경쟁력 있는 perplexity와 실용적 이점을 보여준다.

제안 방법

  • Context를 그룹으로 분할하고 그룹 내 주의를 수행하며, 반 그룹 크기로 토큰을 시프트시켜 그룹 간 정보 흐름을 가능하게 하는 Shifted Sparse Attention(S2-Attn)를 도입한다.
  • LoRA 플러스(LoRA+)로 학습 가능한 임베딩 및 정규화 층을 도입하여 제한된 추가 매개변수로 긴 컨텍스트 적응을 효과적으로 가능하게 한다.
  • 추론 시 전체를 수정 없이 자기 주의(attention)를 유지하여 기존 인프라 및 최적화(예: Flash-Attention2)와의 호환성을 보존한다.
  • 매우 긴 컨텍스트를 위한 위치 임베딩 재스케일링(Position Interpolation)을 활용한다.
  • LongAlpaca와 같은 긴 지시사항 준수 데이터셋으로 감독 학습 미세 조정을 적용하여 채팅 능력을 향상시킨다.

실험 결과

연구 질문

  • RQ1사전 학습된 LLM의 컨텍스트 길이를 전체 규모의 미세 조정 없이도 효율적으로 확장할 수 있는가?
  • RQ2S2-Attn은 미세 조정 시 전체 주의와 비슷한 성능을 제공하면서 계산을 줄이는가?
  • RQ3학습 가능한 임베딩 및 정규화 층을 활성화하면 긴 컨텍스트 확장을 위한 LoRA와 전체 미세 조정 간의 성능 차이가 좁혀지는가?
  • RQ4실용적인 하드웨어에서 서로 다른 모델 크기(7B, 13B, 70B)에 대해 달성 가능한 최대 확장 컨텍스트 길이는 어느 정도인가?
  • RQ5 LongLoRA는 기존의 오픈형 긴 컨텍스트 LLM과 비교할 때 Retrieval 및 Long-passkey 실험에서 긴 컨텍스트 작업에서 어떤 성능을 보이는가?

주요 결과

  • LongLoRA는 확장된 컨텍스트 길이에서 전체 주의 또는 전체 미세 조정 기준과 비교 가능한 perplexity를 달성하면서도 메모리 및 학습 비용을 감소시킨다.
  • S2-Attn은 Flash-Attention2/DeepSpeed와 결합될 때 컨텍스트 확장을 통해 메모리 절약 최대 1.8배, 학습 속도 최대 1.8배의 이득을 제공한다.
  • 학습 가능한 임베딩 및 정규화(LoRA+)를 도입하면 긴 컨텍스트 적응에 대한 LoRA와 전체 미세 조정 간의 격차가 크게 좁혀진다.
  • Llama2 7B/13B/70B에서 LongLoRA는 8x A100 기계 하나에서 각각 100k(7B), 64k(13B), 32k(70B)까지 컨텍스트 길이를 확장한다.
  • Retrieval 벤치마크(Topic retrieval with LongChat)에서 LongLoRA는 RedPajama 데이터에 대한 효율적인 미세 조정을 사용하여 최첨단 LongChat-13B와 비슷한 성능을 보인다.
  • Passkey retrieval 실험은 32k로 미세 조정한 이후 대략 33k–34k 컨텍스트까지 정확도가 유지되며 그 이상 범위에서 완만한 저하를 보인다.

이 논문 읽기

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

누빈트에서 이 논문 읽기

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