FragRel: Exploiting Fragment-level Relations in the External Memory of Large Language Models
Xihang Yue, Linchao Zhu, Yi Yang
TL;DR
This work tackles the limitation of fixed context windows in LLMs by introducing fragment-level relations within an external memory framework. It proposes a relation-aware fragment assessment that combines independent fragment relevance with environment-informed scores derived from semantic, contextual, and code-structure relations, enabling a fragment-connected Hierarchical Memory (HieraMem-LLM). Through extensive experiments on long-story understanding, repository-level code generation, and memory-enhanced chatting, the approach shows consistent improvements over baselines, particularly with longer contexts and when using structure-based relations. The findings underscore the practical impact of encoding cross-fragment relations to better leverage external memory for long-context tasks, while acknowledging limitations around manually defined relations and parameter choices that invite future automation and broader validation.
Abstract
To process contexts with unlimited length using Large Language Models (LLMs), recent studies explore hierarchically managing the long text. Only several text fragments are taken from the external memory and passed into the temporary working memory, i.e., LLM's context window. However, existing approaches isolatedly handle the text fragments without considering their structural connections, thereby suffering limited capability on texts with intensive inter-relations, e.g., coherent stories and code repositories. This work attempts to resolve this by exploiting the fragment-level relations in external memory. First, we formulate the fragment-level relations and present several instantiations for different text types. Next, we introduce a relation-aware fragment assessment criteria upon previous independent fragment assessment. Finally, we present the fragment-connected Hierarchical Memory based LLM. We validate the benefits of involving these relations on long story understanding, repository-level code generation, and long-term chatting.
