How to Train Long-Context Language Models (Effectively)

Tianyu Gao, Alexander Wettig, Howard Yen, Danqi Chen

arXiv:2410.02660 · 2026-07-27 공개 · arXiv · PDF

long-context language-models instruction-tuning supervised-fine-tuning llama-3 context-window continued-pre-training code-repositories

Abstract

We study continued training and supervised fine-tuning (SFT) of a language model (LM) to make effective use of long-context information. We first establish a reliable evaluation protocol to guide model development -- instead of perplexity or simple needle-in-a-haystack (NIAH) tests, we use a broad set of long-context downstream tasks, and we evaluate models after SFT as this better reveals long-context abilities. Supported by our robust evaluations, we run thorough experiments to decide the data mix for continued pre-training, the instruction tuning dataset, and many other design choices such as position extrapolation. We find that (1) code repositories and books are excellent sources of long data, but it is crucial to combine them with high-quality short-context data; (2) training with a sequence length beyond the evaluation length boosts long-context performance; (3) for SFT, using only short instruction datasets yields strong performance on long-context tasks. Our final model, ProLong-8B, which is initialized from Llama-3 and trained on 40B tokens, demonstrates state-of-the-art long-context performance among similarly sized models at a length of 128K. ProLong outperforms Llama-3.1-8B-Instruct on the majority of long-context tasks despite using only 5% as many tokens during long-context training. Additionally, ProLong can effectively process up to 512K tokens, one of the longest context windows of publicly available LMs.

한국어 요약

한 줄 요약

ProLong-8B는 128K 토큰 길이에서 최고 성능을 보이는 8B 파라미터의 장문맥 언어 모델로, Llama-3.1-8B-Instruct 대비 5%의 토큰만 사용해 개선된 성능을 달성했다.

핵심 기여도

핵심 아이디어

기존 연구는 단순 퍼플렉시티나 NIAH 평가에 의존했지만, 본 연구는 장문맥 작업(예: RAG, 문서 요약, 다중 샘플 ICL)을 기반으로 평가 프로토콜을 설계했다. 이는 SFT 이후의 모델 성능을 정확히 반영하며, 훈련 전/후의 최적 설계 선택이 다를 수 있음을 보여준다. 특히, 단문 데이터만으로 SFT를 수행해도 장문맥 작업에서 우수한 성능을 얻을 수 있다는 점은 기존 관념과 상반된다. 이는 훈련 데이터의 질보다는 지시 학습의 방식이 장문맥 성능에 더 큰 영향을 미친다는 통찰을 제공한다.

기술적 접근법

주요 결과

의의 및 한계

ProLong은 장문맥 언어 모델의 훈련 전략을 재정의하며, 단문 데이터만으로도 장문맥 작업을 효과적으로 학습할 수 있음을 보여준다. 이는 데이터 비용을 절감하고, 개발자에게 실용적인 훈련 전략을 제시한다. 그러나 본 연구는 8B 파라미터 모델에만 적용되었으며, 더 큰 모델(예: 70B)에 대한 일반화 가능성은 명시되지 않음. 또한, 평가 데이터셋은 제한적이며, 실제 산업 환경에서의 성능은 추가 실험 필요.

실용적 활용

ProLong은 책 요약, 장문 문서 분석, 다중 샘플 기반 학습 등 장문 입력이 필요한 산업 및 연구 분야에 적용 가능하다. 특히, 훈련 데이터 비용을 줄이면서도 높은 성능을 유지할 수 있어, 리소스 제한이 있는 환경에서 유용하다.