Skip to main content
QUICK REVIEW

[論文レビュー] LongLoRA: Efficient Fine-tuning of Long-Context Large Language Models

Yukang Chen, Shengju Qian|arXiv (Cornell University)|Sep 21, 2023
Topic ModelingComputer Science被引用数 39
ひとこと要約

LongLoRA は Shifted Sparse Attention(S2-Attn)と trainable embedding および normalization 層を組み合わせることで、長い-context のファインチューニングを高コストを抑えて実現し、元の推論アーキテクチャを保持します。

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.

研究の動機と目的

  • Motivate extending the context window of pre-trained LLMs for long-document tasks without prohibitive compute.
  • Develop an efficient fine-tuning method that preserves standard attention architecture at inference time.
  • Introduce Shifted Sparse Attention to approximate full self-attention during training with low overhead.
  • Demonstrate that enabling trainable embeddings and normalization layers bridges the gap between LoRA and full fine-tuning for long-context adaptation.
  • Provide empirical evaluation across Llama2 sizes (7B/13B/70B) showing extended contexts with competitive perplexity and practical benefits.

提案手法

  • Introduce Shifted Sparse Attention (S2-Attn) that splits context into groups and performs attention within groups, with token shifts across half group sizes to enable inter-group information flow.
  • Fine-tune with LoRA plus trainable embedding and normalization layers (LoRA+) to allow effective long-context adaptation with limited additional parameters.
  • Maintain full, unmodified self-attention during inference to preserve compatibility with existing infrastructure and optimization (e.g., Flash-Attention2).
  • Leverage position embedding re-scaling via Position Interpolation for very long contexts.
  • Apply supervised fine-tuning with a long instruction-following dataset (LongAlpaca) to improve chat capabilities.

実験結果

リサーチクエスチョン

  • RQ1Can context length of pre-trained LLMs be extended efficiently without full-scale fine-tuning?
  • RQ2Does S2-Attn provide comparable performance to full attention during fine-tuning while reducing computation?
  • RQ3Does enabling trainable embedding and normalization layers close the performance gap between LoRA and full fine-tuning for long-context extension?
  • RQ4What maximum extended context lengths are achievable for different model sizes (7B, 13B, 70B) on practical hardware?
  • RQ5How does LongLoRA perform on long-context tasks such as retrieval and long-passkey experiments compared to existing open long-context LLMs?

主な発見

  • LongLoRA achieves perplexity comparable to full attention or full fine-tuning baselines at various extended context lengths, while reducing memory and training cost.
  • S2-Attn enables context extension with up to 1.8x memory savings and up to 1.8x training speedup when combined with Flash-Attention2/DeepSpeed.
  • With trainable embedding and normalization (LoRA+), the gap between LoRA and full fine-tuning narrows significantly for long-context adaptation.
  • On Llama2 7B/13B/70B, LongLoRA extends context lengths up to 100k (7B), 64k (13B), and 32k (70B) on a single 8x A100 machine.
  • In retrieval benchmarks (Topic retrieval with LongChat), LongLoRA performs comparably to state-of-the-art LongChat-13B, using efficient fine-tuning on RedPajama data.
  • Passkey retrieval experiments show maintained accuracy up to roughly 33k–34k contexts after fine-tuning to 32k, with graceful degradation beyond that range.

この論文を読む

Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。

Nubintでこの論文を読む

このレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。