Learning to Reason and Memorize with Self-Notes

Jack Lanchantin, Shubham Toshniwal, Jason Weston, Arthur Szlam, Sainbayar Sukhbaatar

TL;DR

Instead of waiting until the end of a prompt to "think," large language models can now take "Self-Notes" on the fly while reading the input context. This simple change allows models to interleave reasoning steps and maintain an explicit working memory, significantly outperforming standard Chain-of-Thought and Scratchpad methods on complex multi-step reasoning and state-tracking tasks.

What Problem Does This Paper Address?

Large Language Models (LLMs) frequently stumble when faced with multi-step reasoning or long-term state tracking. A core reason for this is their fixed computation budget: a vanilla transformer allocates the same amount of compute per token, regardless of whether it's reading a simple word or a crucial piece of a complex logic puzzle.

Popular techniques like Chain-of-Thought (CoT) and Scratchpads attempt to fix this by letting models output their reasoning steps before generating a final answer. However, these methods force the model to wait until it has read the entire context and question before it can start thinking. This creates a long gap between a fact and the reasoning based on it. Furthermore, Scratchpad methods often require the model to copy the entire context into its generation window, which easily exhausts the model's maximum context length.

Methods

The authors introduce Self-Notes, a method that allows an autoregressive transformer to deviate from the input text at any point to explicitly think and write down intermediate thoughts.

Figure 1: [top] Vanilla language models directly generate the answer (A) given the context and the question (Q). [middle] Scratchpad and Chain-of-Thought methods encourage the model to generate reasoning tokens before answering the question, but only after it has read the entire context. [bottom] Self-Notes (ours) allows the model to generate multiple internal reasoning notes that interleave the input context and question.

During inference, if the model predicts a special "start note" token (e.g., <SN>), it pauses reading the context and autoregressively generates its own internal reasoning tokens. Once it generates an "end note" token (e.g., </SN>), it seamlessly resumes reading the original input text. These notes are appended directly into the context window, effectively serving as an explicit, recurrent working memory.

The paper explores four training paradigms for Self-Notes:

  1. Supervised: Trained on data explicitly enriched with ground-truth intermediate notes.
  2. Semi-supervised: Trained on a mix of data with and without notes, using a special prefix token to signal when the model should reason on its own at test time.
  3. Unsupervised: The model leverages its inherent ability to formulate questions, generating its own questions and answers as notes during test time without any ground-truth note training.
  4. Few-shot Prompted: Pretrained LLMs are given a few demonstrations where intermediate reasoning steps are written inline (e.g., inside parentheses).

Datasets

The method was evaluated across seven distinct text datasets:

  • Toy-Story: A new synthetic QA dataset introduced by the authors to evaluate multi-step forward reasoning. It requires models to chain together implicit relations (e.g., inferring an object's location based on who holds it and where they are).
  • Algorithmic & Boolean Variable: Synthetic programming tasks requiring the model to track variable states through loops, increments, and boolean logic gates over long dependency chains.
  • Chess Piecetype & Chess Move: Real-world chess tracking tasks where the model must implicitly track the positions and identities of pieces using only UCI notation moves.
  • MultiArith & GSM8K: Standard math word problem benchmarks used to evaluate the few-shot prompting setup.

Key Insights and Ideas

  • Proximity Matters: Interleaving thoughts while reading keeps reasoning steps physically closer to the relevant facts in the context window, making it easier for the transformer's attention mechanism to link them.
  • Overcoming Context Limits: Scratchpads fail on long sequences because they copy the entire context to the output. Self-Notes only insert brief, targeted updates, preventing the model from running out of context space.
  • Compute as a Choice: Self-Notes act as a form of adaptive computation. The model dynamically decides when a sentence requires extra "thinking time" based on the context.
  • Data Efficiency: In semi-supervised settings, giving the model ground-truth notes for just 1% of the training data was enough to trigger massive performance leaps over vanilla baselines.

Key Results

Self-Notes consistently outperformed both Vanilla and Scratchpad baselines, particularly on out-of-distribution (OOD) tasks with longer sequences or more reasoning steps:

  • Algorithmic State Tracking (OOD 101-200 statements): Supervised Self-Notes achieved 85.0% accuracy, completely crushing the Scratchpad baseline (11.6%) and the Vanilla model (24.4%).
  • Toy-Story (Harder 4-hop reasoning): Self-Notes hit 97.8% accuracy, outperforming Scratchpads (94.2%) and Vanilla (37.4%).
  • Few-Shot Prompting (MultiArith): Using a 6B GPT-J model, Self-Notes achieved 21.0% accuracy, outperforming standard Chain-of-Thought prompting (13.5%).

Limitations and Future Work

While highly effective, the supervised and few-shot versions of Self-Notes still rely on humans to manually annotate where and what the notes should be. This is just as labor-intensive as creating CoT datasets.

To mitigate this, the authors point to two exciting future directions: using reinforcement learning to let the model autonomously discover when and what to write in its notes, and investigating whether larger, next-generation LLMs can naturally develop the ability to take structured Self-Notes out of the box.

Summary updated

BibTeX
@inproceedings{lanchantin2023learning,
  author = {Jack Lanchantin and Shubham Toshniwal and Jason Weston and Arthur Szlam and Sainbayar Sukhbaatar},
  title = {{Learning to Reason and Memorize with Self-Notes}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=ZFwNdsDCRL},
}
Figure