TensorX
返回文献探索

Paper · arXiv 2401.18058

LongAlign: A Recipe for Long Context Alignment of Large Language Models

Yushi Bai, Xin Lv, Jiajie Zhang, Yuze He, Ji Qi, Lei Hou, Jie Tang, Yuxiao Dong, Juanzi Li

25 upvotesJanuary 31, 2024arXiv 预印本
AI 摘要

LongAlign improves the handling of long contexts in large language models through specialized instruction datasets, packing and batching strategies, loss weighting, and a benchmark for extended queries.

Self-Instructlong instruction-following datasetpacking strategiessorted batchingloss weightingLongBench-Chat benchmarklong context alignment

Abstract

Extending large language models to effectively handle long contexts requires instruction fine-tuning on input sequences of similar length. To address this, we present LongAlign -- a recipe of the instruction data, training, and evaluation for long context alignment. First, we construct a long instruction-following dataset using Self-Instruct. To ensure the data diversity, it covers a broad range of tasks from various long context sources. Second, we adopt the packing and sorted batching strategies to speed up supervised fine-tuning on data with varied length distributions. Additionally, we develop a loss weighting method to balance the contribution to the loss across different sequences during packing training. Third, we introduce the LongBench-Chat benchmark for evaluating instruction-following capabilities on queries of 10k-100k in length. Experiments show that LongAlign outperforms existing recipes for LLMs in long context tasks by up to 30\%, while also maintaining their proficiency in handling short, generic tasks. The code, data, and long-aligned models are open-sourced at https://github.com/THUDM/LongAlign.

北京市昌平区探索星信息技术及软件开发工作室

京ICP备2026059466号
LongAlign: A Recipe for Long Context Alignment of Large Language Models | TensorX