RiM: Reasoning in Memory - Unlocking LLM Working Memory
Core Insight
Human cognition uses working memory to hold and manipulate information internally without externalizing intermediate thoughts. RiM brings this capability to LLMs via fixed memory blocks that replace autoregressive reasoning generation.
Key Innovation: Decouples reasoning from generation, treating computation as internal process rather than external communication.
Methodology
1. Memory Block Architecture
# Conceptual structure
class MemoryBlock:
"""
Fixed sequence of special tokens that unlock working memory.
- Not generated: pre-defined special token sequences
- Single forward pass: compute-efficient (no autoregressive generation)
- Information carrier: holds intermediate reasoning state
"""
tokens: List[SpecialToken] # Fixed, not variable
processing: "single_forward_pass" # Parallel, not sequential
function: "latent_reasoning_state" # Internal, not externalized
2. Two-Stage Curriculum
Stage 1 - Grounding Phase:
- Predict explicit reasoning steps after each memory block
- Supervise intermediate reasoning process
- Establish memory block semantics
Stage 2 - Refinement Phase:
- Discard step-level supervision
- Iteratively refine final answer after memory blocks
- Enable pure latent reasoning without generation
3. Computational Advantage
| Method | Reasoning Steps | Compute Cost | Externalization |
|---|---|---|---|
| Chain-of-Thought | Generated autoregressively | O(k × n) tokens | Yes (external) |
| RiM Memory Blocks | Fixed special tokens | O(k) forward passes | No (internal) |
Key: Memory blocks are fixed, enabling single forward pass per block instead of sequential token generation.
Implementation Guidance
Memory Block Design
# Example: RiM training configuration
class RiMConfig:
memory_block_length: int = 64 # Fixed length special tokens
num_memory_blocks: int = 4 # Number of reasoning cycles
grounding_epochs: int = 1000 # Stage 1: explicit supervision
refinement_epochs: int = 2000 # Stage 2: answer refinement
# Curriculum stages
stage_1: "predict_explicit_steps" # Grounding
stage_2: "refine_answer_only" # Pure latent reasoning
Training Protocol
- Initialize: Define fixed memory block token sequences
- Grounding Stage:
- Insert memory blocks in input
- Supervise: predict reasoning steps after each block
- Train model to associate blocks with reasoning semantics
- Refinement Stage:
- Remove explicit reasoning supervision
- Supervise: final answer after all memory blocks
- Enable iterative refinement through blocks
Experimental Results
Performance Comparison
- Matches/exceeds existing latent reasoning methods
- Compute-efficient: no autoregressive thought generation overhead
- Cross-model: works across different LLM families and sizes
- Reasoning benchmarks: validated on standard reasoning tasks
Key Findings
- LLMs can be trained to use working memory effectively
- Fixed memory blocks enable internal computation without externalization
- Two-stage curriculum crucial for grounding then refining
- Single forward pass processing maintains efficiency
Cognitive Science Connection
Working Memory Theory Alignment
- Human working memory: holds/manipulates info without externalizing
- RiM memory blocks: analogous mechanism in LLMs
- Latent reasoning: internal computation, not communicative output
- Cognitive load: distributed across fixed blocks, not generated tokens
Neuroscience Implications
Human Working Memory:
capacity: "7 ± 2 items (Miller's law)"
function: "manipulate without externalize"
process: "internal cognitive operations"
RiM Memory Blocks:
capacity: "num_blocks × block_length"
function: "parallel latent reasoning"
process: "internal forward-pass computation"
Use Cases
When to Apply RiM
- Reasoning tasks requiring intermediate computation
- Compute-constrained scenarios (avoid autoregressive overhead)
- Latent reasoning applications (internal, not communicative)
- Working memory analogues in neural architectures
Integration Patterns
# Pattern 1: Enhance existing LLMs
class RiMEnhancedLLM:
base_model: PreTrainedLLM
memory_blocks: FixedTokenSequences
reasoning_mode: "latent" # vs. "autoregressive_chain_of_thought"
# Pattern 2: Hybrid reasoning
class HybridReasoning:
simple_tasks: "autoregressive" # Fast, no blocks
complex_tasks: "RiM_blocks" # Compute-efficient deep reasoning
Technical Details
Memory Block Token Design
- Special tokens:
[MEM_START],[MEM_BLOCK_1], ...,[MEM_END] - Fixed sequences: Pre-defined, not variable per task
- Position encoding: Maintains block identity across tasks
- Semantic grounding: Learned during Stage 1 curriculum
Architecture Considerations
Model Requirements:
- Attention mechanism: processes memory blocks in context
- Hidden states: carry reasoning information across blocks
- Token vocabulary: includes special memory block tokens
Training Requirements:
- Stage 1: reasoning step supervision data
- Stage 2: final answer supervision data
- Curriculum: gradual transition from grounding to refinement
Limitations & Considerations
- Fixed block design: Less flexible than generated reasoning chains
- Training overhead: Two-stage curriculum required
- Semantic grounding: Depends on Stage 1 supervision quality
- Block length: Trade-off between capacity and efficiency
Future Directions
- Dynamic block sizing: Adaptive memory block lengths
- Multi-modal RiM: Extend to vision-language reasoning
- Hierarchical blocks: Nested memory structures
- Neuroscience validation: Compare with human working memory fMRI
References
- Paper: "Unlocking the Working Memory of Large Language Models for Latent Reasoning" (arXiv:2605.30343)
- Authors: Lukas Aichberger, Sepp Hochreiter
- Key concepts: Working memory theory (Baddeley), latent reasoning, memory blocks
Related Skills
working-memory-heterogeneous-delays: Working memory in SNNsneuroai-beyond-bridging-neuroscience-ai: NeuroAI integrationllm-concept-neurons-control: LLM internal representationsattention-task-structure-cognitive-flexibility: Cognitive attention mechanisms
