Long Context Alignment with Short Instructions and Synthesized Positions

Wenhao Wu, Yizhong Wang, Yao Fu, Xiang Yue, Dawei Zhu, Sujian LiarXiv 2024 · DOI

Abstract

While Large Language Models (LLMs) can now support context windows of 128K tokens or more through continuous pretraining, effective alignment for long-context tasks remains a significant challenge due to the scarcity of high-quality long-form instruction data. This paper introduces SkipAlign, a novel alignment technique that enhances a model's long-context capabilities using only short-form training data. By strategically "skipping" positional indices in standard instructions, SkipAlign simulates long-range dependencies. Our results show that a 6B model fine-tuned with SkipAlign can match the performance of GPT-3.5-Turbo-16k on long-context benchmarks while avoiding the "alignment tax" on general short-context tasks.

Introduction

Recent advancements have successfully extended the raw context windows of LLMs, but making these models functional for long-range tasks—such as summarizing massive documents or multi-file question answering—requires specific alignment. High-quality, extremely long instruction datasets are rare and difficult to annotate. Common workarounds like "packing" (concatenating unrelated short samples) often fail because the model does not learn to bridge dependencies across a single, coherent long-range conversation. SkipAlign addresses this by teaching models to handle long-range dependencies using existing short-form data through positional index manipulation.

The SkipAlign Method

SkipAlign, or Step-Skipping Alignment, manipulates the positional indices of short samples to "stretch" them across a target context window (e.g., 100K tokens). In a standard Transformer, tokens are assigned sequential indices. SkipAlign strategically inserts "skips" in these indices, forcing the model to attend to information across a massive "positional distance" during training.

The SkipAlign mechanism and its three strategies for positional index manipulation: Skip-ALL, Skip-Outer, and Skip-Inner.

The researchers evaluated three strategies for index skipping:

  1. Skip-All: Random skips throughout the sample.
  2. Skip-Inner: Skips placed between an instruction and its response.
  3. Skip-Outer (Default): Skips placed only between separate turns in a multi-turn dialogue.

Skip-Outer was found to be the most effective, as it maintains the local semantic integrity of individual question-answer pairs while simulating a conversation that spans a much larger positional distance.

Experimental Results

Long-Context Performance

A Yi-6B-200K model trained with SkipAlign achieved an average score of 45.3 on LongBench, outperforming GPT-3.5-Turbo-16k (44.6). This demonstrates that simulating distance via index manipulation is sufficient to activate a model's long-context potential.

Needle-in-a-Haystack Retrieval

In Needle-in-a-Haystack tests, which measure retrieval accuracy at various depths, SkipAlign significantly extended the effective retrieval window of a Llama-2-7B model compared to standard Supervised Fine-Tuning (SFT) and packing methods.

Needle-in-a-Haystack retrieval accuracy comparison across different alignment methods, showing SkipAlign's superior performance (61.6% accuracy).

Short-Context Integrity

Importantly, SkipAlign does not suffer from the "alignment tax." Models maintained or slightly improved their scores on standard benchmarks like MMLU (knowledge) and BBH (reasoning) compared to standard SFT, ensuring that general intelligence is preserved while long-context capabilities are added.

Discussion and Conclusion

SkipAlign is a highly efficient, data-centric trick that requires no additional data collection or architectural changes. The core insight is that the positional distance between related pieces of information is more critical for alignment than the actual number of tokens in a training sample. While this study focused on 100K target lengths, the method holds potential for extending models to 1M+ context lengths. Future work may explore combining SkipAlign with actual long-context data to further compound these benefits.

Summary updated

BibTeX
@misc{wu2024long,
  author = {Wenhao Wu and Yizhong Wang and Yao Fu and Xiang Yue and Dawei Zhu and Sujian Li},
  title = {{Long Context Alignment with Short Instructions and Synthesized Positions}},
  year = {2024},
  eprint = {2405.03939},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.03939},
}
Figure