LongLoRA: A New, More Efficient Way to Fine-Tune LLMs
Tags: learning, ai, programming, discuss
Published: 2023-09-23 04:00:00

As AI models like ChatGPT get bigger, training them requires more and more computing power. Researchers are looking for ways to train these large AI models without needing Google-scale resources. [A new paper](https://arxiv.org/pdf/2309.12307.pdf) explores a new method called LongLoRA that can efficiently train models on much longer texts.

<iframe src="https://aimodels.substack.com/embed" width="100%" height="auto" style="box-sizing:border-box;border:0px;display:block;overflow:hidden;width:720px;grid-column:main-start / main-end;margin-bottom:0px;margin-top:calc(1.6em*var(--content-spacing-multiplier, 1));color:rgb(21, 23, 26);font-family:Inter, -apple-system, "system-ui", "Segoe UI", Helvetica, Arial, sans-serif;font-size:18px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial"></iframe>

[*Subscribe*](https://aimodels.substack.com/) *or follow me on* [*Twitter*](https://twitter.com/mikeyoung44) *for more content like this!*

## Why this matters

Being able to train on longer texts allows the models to develop deeper understanding and reasoning. This could let them answer questions that require more context, like summarizing a long research paper.

The standard way of training these models on long texts takes a huge amount of computing power. For example, fine-tuning the 70B parameter LLaMA model on 32,000 tokens takes 128 high-end A100 GPUs!

More efficient training means these powerful models can be created and adapted with more reasonable resources. This expands access beyond just the biggest tech companies.

## The core ideas

The researchers focus on two main techniques:

1. **Approximating standard attention:** They use an attention pattern that looks locally instead of across the whole text. This "shift short attention" provides a good approximation during training while still allowing the full standard attention for inference.
    
2. **Improving low-rank adaptation:** Building on a technique called LoRA, they adjust only a small subset of weights rather than all of them. Plus they allow some embedding and normalization layers to also be tuned.
    

## What they accomplished

Using LongLoRA, they could fine-tune a 7B parameter model on texts up to 100,000 tokens long on a single 8-GPU machine. For comparison, previous work took 32 GPUs for only 8,000 tokens.

The efficiency gains were huge - LongLoRA cut the training cost by over 10x for the larger context sizes.

The models performed nearly as well as standard fine-tuning. For example, on a 32,768 token evaluation, the perplexity (a measure of prediction quality) was only 3% higher.

## Looking forward

This shows the promise of more efficient training techniques to handle ever-larger models and contexts. There's still more progress needed to match the full quality of standard fine-tuning.

But LongLoRA demonstrates that we can push towards training at a much greater scale, without requiring unreasonable resources. More efficient training will help democratize access to powerful AI systems.

<iframe src="https://aimodels.substack.com/embed" width="100%" height="auto" style="box-sizing:border-box;border:0px;display:block;overflow:hidden;width:720px;grid-column:main-start / main-end;margin-bottom:0px;margin-top:calc(1.6em*var(--content-spacing-multiplier, 1));color:rgb(21, 23, 26);font-family:Inter, -apple-system, "system-ui", "Segoe UI", Helvetica, Arial, sans-serif;font-size:18px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial"></iframe>

[*Subscribe*](https://aimodels.substack.com/) *or follow me on* [*Twitter*](https://twitter.com/mikeyoung44) *for more content like this!*