Abstract
Large Language Models (LLMs) are increasingly required to process extensive contexts, yet they are fundamentally constrained by the quadratic computational and memory costs of self-attention. This paper presents HOMER (Hierarchical cOntext MERging), a training-free framework designed to extend the context window of pre-trained LLMs up to 64,000 tokens. By implementing a hierarchical divide-and-conquer strategy combined with a novel "propagative refinement" technique, HOMER achieves a reduction in peak GPU memory usage of over 70% while significantly outperforming existing long-context baselines in both retrieval accuracy and inference efficiency.
Introduction
The utility of LLMs is often limited by their "context window"—the maximum sequence length they can process. While applications like whole-document analysis or massive codebase processing demand long windows, standard transformer architectures suffer from quadratic scaling: doubling the input length quadruples the required memory and compute.
Existing attempts to mitigate this typically involve either expensive architectural retraining or positional encoding modifications (such as RoPE scaling). While the latter helps models interpret longer sequences, it does not address the underlying hardware bottlenecks. HOMER bridges this gap by providing a training-free, plug-and-play solution that makes long-context computation efficient enough for standard hardware without sacrificing model performance.
Methodology
HOMER operates through a structured hierarchical approach to context management, centered on three core pillars:
Hierarchical Merging and Token Reduction
Instead of processing a 64k-token sequence monolithically, HOMER employs a divide-and-conquer strategy. The input is partitioned into manageable chunks that are processed independently in the initial transformer layers. As the computation progresses into deeper layers, adjacent chunks are merged. To maintain a constant computational load, a calibrated significance score—derived from attention weights—is used to prune redundant tokens before each merge operation.
Propagative Refinement
A key innovation of HOMER is "propagative refinement." The researchers observed that deeper (upper) layers of a transformer are more effective at identifying globally significant tokens. HOMER leverages this by propagating pruning decisions made in the upper layers back down to the lower layers. This ensures a consistent and compressed KV-cache across the entire model, which is essential for efficient text generation.
Logarithmic Memory Scaling
By utilizing a depth-first search (DFS) approach on the hierarchical merging tree, HOMER reorders chunk processing to achieve logarithmic ($O(\log N)$) memory scaling relative to input length, rather than the standard linear or quadratic scaling.
Experimental Evaluation
The effectiveness of HOMER was validated using several long-range benchmarks:
- Passkey Retrieval: A "needle in a haystack" test requiring the model to find a specific number hidden within up to 32k tokens of noise.
- QuALITY: Multiple-choice QA based on long-form documents.
- PG-19: A book-based dataset used to measure perplexity and fluency over sequences up to 64k tokens.
Results and Discussion
HOMER demonstrates significant improvements across all key performance metrics compared to standard baselines like YaRN and NTK-aware scaling.
Superior Accuracy and Fluency
In the 32k-token passkey retrieval task, HOMER achieved 80.4% accuracy, a stark contrast to the 22.4% achieved by the best-performing baseline (YaRN). Furthermore, while other methods experienced perplexity explosions beyond 32k tokens, HOMER remained stable and fluent up to the 64k limit.
Efficiency Gains
The hierarchical structure leads to massive hardware savings. On 64k-token inputs, HOMER reduced peak GPU memory usage by over 70%. Additionally, by reducing the number of tokens processed in deeper layers, the model achieved an inference speedup of up to 162.6% when generating text from a 32k context.
Orthogonality
Importantly, HOMER is complementary to existing positional scaling techniques. The best results were consistently achieved by applying HOMER on top of methods like YaRN, suggesting it acts as an efficiency layer rather than a replacement for encoding schemes.
Conclusion
HOMER represents a significant advancement in making long-context LLMs practical. By moving beyond simple encoding hacks to a fundamental restructuring of how context is processed and refined, it enables existing models to handle massive documents with high accuracy and low overhead. Future work may explore fine-tuning the merging process or developing more task-specific pruning criteria to further push the boundaries of context length.
Summary updated