Abstract
While large language models (LLMs) have made notable advancements in natural language processing, they continue to struggle with processing extensive text. Memory mechanism offers a flexible solution for managing long contexts, utilizing techniques such as compression, summarization, and structuring to facilitate nuanced and efficient handling of large volumes of text. However, existing techniques face challenges with static knowledge integration, leading to insufficient adaptation to task-specific needs and missing multi-segmentation relationships, which hinders the dynamic reorganization and logical combination of relevant segments during the response process. To address these issues, we introduce a novel strategy, Question then Reflection Memory Mechanism (QRMeM), incorporating a dual-structured memory pool. This pool synergizes static textual content with structured graph guidance, fostering a reflective trial-and-error approach for navigating and identifying relevant segments. Our evaluation across multiple-choice questions (MCQ) and multi-document question answering (Multi-doc QA) benchmarks showcases QRMeM enhanced performance compared to existing approaches.
Introduction
Despite the expansion of context windows in modern Large Language Models (LLMs), the "lost in the middle" phenomenon remains a significant hurdle. When processing massive documents, models often struggle to maintain focus on relevant information or fail to execute the complex, multi-hop reasoning required to connect distant facts. Traditional Retrieval-Augmented Generation (RAG) often lacks the depth to find non-obvious connections, while standard memory mechanisms frequently rely on static summaries that strip away critical nuances. QRMeM addresses this by bridging the gap between a user's specific query and the document's structure through a dynamic, query-oriented memory reorganization.
The QRMeM Framework
QRMeM is built upon a Dual-structured Memory Pool designed to balance high-fidelity detail with structural clarity:
- Long-term Static Memory: This consists of the original document partitioned into segments, ensuring that the full context and original wording are preserved.
- Structured Memory: A dynamic graph where nodes represent entities and edges represent relationships extracted from the text. This graph serves as a "map" for the model to navigate.
As shown in the iterative process above, the system uses the structured memory to guide its search through the static memory segments over multiple iterations, refining its focus based on the query's requirements.
Reflection-based Navigation
The core innovation of QRMeM is its iterative "trial-and-error" navigation loop. Rather than performing a single retrieval step, the model engages in a process of self-correction:
- Questioning: The process begins by identifying core entities within the user's query.
- Evaluation: The model assesses whether the currently retrieved segments contain enough information to answer the question.
- Reflection: If the information is insufficient, the LLM generates a specific "reason" for the failure (e.g., "This segment discusses the characters but does not mention the specific event requested").
- Navigation: Using this reason and the structured graph, the model identifies the next most relevant entity or segment to explore, effectively "reflecting" its way toward the answer.
This approach mimics Socratic inquiry, where the model's understanding of what it doesn't know informs its next search step. By forcing the model to articulate why a segment is insufficient, the search for the next piece of information becomes highly targeted and efficient.
Experimental Evaluation
The researchers evaluated QRMeM against several benchmarks, including QuALITY (long-narrative MCQ) and multi-hop reasoning datasets like HotpotQA, 2WikiMultihopQA, and MuSiQue.
Key Results
- Superior Accuracy: On the QuALITY dataset, QRMeM achieved an accuracy of 0.7207, outperforming GPT-3.5-turbo-16k (0.7162) and significantly surpassing Llama-2-70b-32k (0.5765).
- Multi-hop Mastery: In the MuSiQue dataset—a particularly challenging benchmark for multi-hop reasoning—QRMeM achieved an F1 score of 0.2094, nearly doubling the performance of several long-context baselines.
- Efficiency: The model typically reaches peak performance within 2–3 iterations, demonstrating that the reflection-based navigation is an efficient path-finding mechanism.
Conclusion and Future Work
QRMeM demonstrates that combining raw textual fidelity with dynamic, query-oriented structural guidance allows LLMs to overcome traditional context limitations. While the iterative nature of the reflection loop introduces higher computational costs and relies on accurate entity resolution, it provides a robust framework for complex reasoning over long documents. Future research will focus on optimizing the efficiency of graph updates and improving the robustness of entity extraction to further enhance the system's scalability.
Summary updated