Skip to main content
QUICK REVIEW

[Paper Review] Needle in the Haystack for Memory Based Large Language Models

Elliot Nelson, Γεώργιος Κόλλιας|arXiv (Cornell University)|Jul 1, 2024
Topic ModelingComputer Science5 citations
TL;DR

The paper demonstrates a 1.3B-parameter Larimar model with an external, CPU-held memory that enables long-context recall (up to 100K+ tokens) without task-specific training, outperforming baselines on passkey and needle-in-the-haystack tasks.

ABSTRACT

Current large language models (LLMs) often perform poorly on simple fact retrieval tasks. Here we investigate if coupling a dynamically adaptable external memory to a LLM can alleviate this problem. For this purpose, we test Larimar, a recently proposed language model architecture which uses an external associative memory, on long-context recall tasks including passkey and needle-in-the-haystack tests. We demonstrate that the external memory of Larimar, which allows fast write and read of an episode of text samples, can be used at test time to handle contexts much longer than those seen during training. We further show that the latent readouts from the memory (to which long contexts are written) control the decoder towards generating correct outputs, with the memory stored off of the GPU. Compared to existing transformer-based LLM architectures for long-context recall tasks that use larger parameter counts or modified attention mechanisms, a relatively smaller size Larimar is able to maintain strong performance without any task-specific training or training on longer contexts.

Motivation & Objective

  • Motivate improved long-context retrieval in LLMs.
  • Propose and evaluate an external memory mechanism integrated with Larimar for test-time long-context adaptation.
  • Demonstrate memory read/write operations that scale to very long contexts without increasing GPU memory usage.
  • Show that memory readouts condition the decoder to generate correct outputs.
  • Discuss practicality and limitations of CPU-based external memory for long-context tasks.

Proposed method

  • Use Larimar architecture with an external associative memory written via least-squares memory updates.
  • Write context segments to memory using encodings and writing keys.
  • Read from memory using a reading key derived from a prefix or query encoding.
  • Compute memory readout as z_read = w M and condition the decoder on this readout.
  • Control keys via a fixed key memory to ensure nearest-neighbor mapping links writes to reads.
  • Operate memory on CPU to scale memory size with context while keeping decoding on GPU.

Experimental results

Research questions

  • RQ1Can an externally held, dynamically updatable memory improve long-context recall in LLMs without task-specific training?
  • RQ2How does test-time, prefix-based key computation enable reliable retrieval for very long contexts (100K–1M tokens)?
  • RQ3What are the trade-offs in memory size, latency, and GPU usage when offloading memory to CPU for long-context tasks?
  • RQ4How does Larimar compare to baseline long-context retrieval models on passkey and needle-in-the-haystack tasks?

Key findings

  • Larimar maintains strong recall for long contexts (over 100K tokens) with a 1.3B parameter model without task-specific training.
  • Memory readouts can steer the decoder to generate correct outputs even when the full context is stored off-GPU.
  • Compared to baselines (Mistral 7B, Phi-3-Mini-128K), Larimar shows superior recall on the passkey and needle-in-the-haystack tasks at similar or smaller model sizes.
  • Using a prefix-based approach for writing keys improves recall for longer or more complex needles.
  • CPU-based external memory allows scaling to long contexts without increasing GPU memory usage.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.