Introduction
Large Language Models (LLMs) have transformed natural language processing, yet they remain tethered by their "context window." Training models on extremely long sequences is computationally prohibitive, leading researchers to seek "length generalization"—the ability for a model trained on short contexts (e.g., 4,000 tokens) to maintain performance on much longer ones (e.g., 32,000 tokens).
While most efforts focus on input-side modifications like positional encodings, this paper identifies a critical, overlooked factor: output distribution misalignment. As input length increases, internal representations shift so significantly that the model's predictions diverge from the patterns learned during training, leading to a breakdown in reasoning and coherence.
The Problem: Output Space Misalignment
The authors argue that length generalization is fundamentally tied to the stability of the output space. Through synthetic case studies, they observed that Transformers generalize well on tasks where the output range is fixed (e.g., predicting the mean of a binary sequence, which is always between 0 and 1) but fail on tasks where the output scales with input length (e.g., predicting the total length).
In natural language, this manifests as a shift in the predicted token probabilities. When a model processes a long sequence, its prediction for the next token may differ wildly from what it would predict if it only saw the immediate preceding context. This discrepancy is what the authors term "Long-Short Misalignment."
Methodology: Alignment Regularization
To address this, the paper proposes a novel training objective that enforces consistency between long and short contexts. They introduce a metric based on Symmetrical Cross-Entropy (SCE) to quantify the divergence between the model's output for a full sequence and its output for a truncated "suffix" of that same text.
The final training objective is defined as: $$\mathcal{L}_{train}^* = \mathcal{L}_{train} + \alpha \cdot \mathcal{L}_{misalign}$$
During fine-tuning, the model is penalized if its predictions for a full sequence ($p$) differ from its predictions for a shorter version ($q$). This regularization forces the model to learn features that are robust to varying context lengths, ensuring that the "reasoning" remains stable regardless of how much history is visible.
Key Results and Insights
The researchers found that their "Long-Short Misalignment" metric ($\mathcal{L}_{misalign}$) is a much more reliable predictor of long-context performance than standard training loss. As shown in the table below, $\mathcal{L}_{misalign}$ has a strong negative correlation (-0.85) with LongBench-E scores, meaning lower misalignment directly leads to better long-context understanding.
Key findings include:
- Performance Gains: The alignment regularization improved LongBench-E scores by up to 2.4% over standard baselines.
- Lower Perplexity: Models exhibited significantly lower perplexity on 8k and 16k sequences, even when trained on shorter data.
- Efficiency: The method is highly efficient, adding only a 3-5% computational overhead per training step, making it a practical "plug-and-play" enhancement for existing long-context techniques like LongQLora.
Conclusion
By shifting the focus from input encodings to output consistency, Long-Short Alignment provides a robust framework for extending the effective context of LLMs. This approach demonstrates that maintaining a stable prediction target is just as important as how the model perceives position. Future work may extend these principles to alternative architectures like State Space Models or further optimize the sampling strategies for even greater context lengths.
Summary updated