Large Language Models with Controllable Working Memory

Daliang Li, Ankit Singh Rawat, Manzil Zaheer, Xin Wang, Michal Lukasik, Andreas Veit, Felix X. Yu, Sanjiv Kumar

Large Language Models (LLMs) act as vast repositories of "world knowledge" acquired during pretraining. However, a fundamental tension exists between this internal parametric knowledge and the contextual information provided during inference, such as in Retrieval-Augmented Generation (RAG). This paper, presented at ACL 2023, introduces Knowledge Aware Finetuning (KAFT) to resolve this conflict by teaching models to prioritize information based on its relevance.

The Challenge: Parametric vs. Contextual Knowledge

LLMs often struggle to balance what they "know" from training with what they are "told" in a prompt. The authors identify two primary failure modes:

  1. Low Controllability: When provided context contradicts the model's internal weights (e.g., counterfactual scenarios or recent updates), the model may ignore the context and default to its internal, potentially outdated knowledge.
  2. Low Robustness: When provided context is irrelevant or noisy, the model may be distracted by it, failing to rely on its internal knowledge to provide a correct answer.
Examples of controllability and robustness challenges in QA.

The goal is to provide LLMs with a "controllable working memory"—the ability to use activations to temporarily prioritize new, relevant information over long-term memory stored in weights.

Knowledge Aware Finetuning (KAFT)

KAFT is a data augmentation strategy designed to enforce a specific priority hierarchy: Relevant Context > Parametric Knowledge > Irrelevant Context.

To implement this, standard QA datasets are augmented with four types of examples:

  • Relevant Context: Standard QA where the answer is explicitly in the context.
  • Counterfactual Context: Plausible but "fake" contexts that contradict known facts, forcing the model to follow the provided context.
  • Irrelevant Context: Noisy contexts unrelated to the question, requiring the model to ignore the noise and use internal knowledge.
  • Empty Context: Standard closed-book QA to maintain the model's internal knowledge base.

Crucially, KAFT models are also trained to output a relevance judgment (e.g., "from context" or "irrelevant context") alongside their answers, enhancing both interpretability and the model's ability to distinguish between information sources.

Key Insights and Results

The researchers evaluated KAFT across T5 and PaLM architectures, ranging from 3B to 540B parameters.

Performance of KAFT across model architectures and sizes.

Scale and "Stubbornness"

A surprising finding was that larger models, such as PaLM 540B, can be less controllable than smaller ones. Their stronger memorization of facts makes them more likely to ignore conflicting context in favor of internal weights. KAFT effectively mitigates this "stubbornness."

Performance Gains

  • Controllability: KAFT PaLM 540B demonstrated a 24x improvement in controllability over standard finetuning, successfully overriding internal knowledge when prompted with conflicting information.
  • Robustness: KAFT models showed significantly higher resistance to distractor contexts, with the 540B model being 6x more robust than standard noisy finetuning baselines.
  • Knowledge Integrity: Despite training on counterfactuals, KAFT models did not "leak" fake facts into their permanent knowledge. They learned the logic of context-following rather than memorizing the augmented data.

Conclusion

KAFT demonstrates that LLMs can be trained to manage their working memory more effectively without expensive weight editing. By explicitly teaching the model when to trust context and when to rely on internal knowledge, KAFT significantly improves the reliability of LLMs in dynamic, real-world applications like RAG. Future work may explore generalizing this approach to more open-ended reasoning tasks and developing dynamic data augmentation strategies.

Summary updated

BibTeX
@inproceedings{li2023large,
  author = {Daliang Li and Ankit Singh Rawat and Manzil Zaheer and Xin Wang and Michal Lukasik and Andreas Veit and Felix X. Yu and Sanjiv Kumar},
  title = {{Large Language Models with Controllable Working Memory}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.112},
}
Figure