REMORY: How 32 Residual Tokens Compress 8K Conversation Context

REMORY compresses 8K conversation history into 32 residual soft tokens with 95% fidelity, cutting LLM context costs by 87%.
REMORY is a memory augmentation approach that compresses long conversation histories into a minimal set of residual soft tokens. A lightweight encoder-decoder is trained by minimizing the KL divergence between a frozen LLM's output distributions when given the full history versus a summary plus residual tokens. Just 32 768-dimensional residual tokens can reconstruct an 8K-token conversation with 95% fidelity, with no modifications to the downstream LLM's weights and only 1.4GB VRAM required. Benchmarks show a 37% BLEU-4 improvement, 43% latency reduction, ~90% memory savings, and monthly costs dropping from ~$2,400 to ~$320. Key risks include token drift, adversarial soft prompt vulnerabilities, sparse-model compatibility, and data compliance issues around embedded proprietary content.
The context length of large language models (LLMs) has long been treated as a hard ceiling — making a model remember longer conversations means paying a steep price in latency and compute. A paper on arXiv called REMORY proposes a different path: using a small number of "residual memory" soft tokens to let a frozen LLM reconstruct long conversation history with near-zero loss and no significant added cost.
Its core claim is striking: a residual vector sequence of 32 dimensions can recover an 8K-token conversation with 95% fidelity. This forces the community to rethink just how much of a context window is truly incompressible information.

A Real Pain Point: The Customer Service Bot
Imagine a SaaS company handling thousands of support tickets daily. Its AI assistant, built on Claude-3-Opus, generates a summary after each resolved issue — something like "User reported login failure, provided screenshot, resolved by resetting MFA."
Three days later, the same user asks: "Can you resend the reset code I received yesterday?" The bot only has the summary and cannot reconstruct the exact reset code the system originally generated. The traditional approach is either to store the full conversation (expensive) or risk giving a wrong answer.
REMORY's solution: feed the original conversation log and the human-readable summary together into an encoder, and have the decoder output 32 residual tokens — continuous vectors that capture precisely what the summary left out, including that reset code. When the bot appends these tokens to the prompt, the frozen Claude-3-Opus can reproduce the answer it would have given with access to the full log.
The result: the assistant answers correctly, the user is satisfied, and the company avoids the overhead of persisting full conversation histories per user.
Architecture, Training, and Key Numbers
How REMORY Works
The design philosophy of REMORY lies in completely decoupling memory compression from LLM fine-tuning. The system consists of three components:
- Encoder: Takes two inputs — raw conversation history up to 64K tokens, and a human-readable summary of approximately 250 tokens. A 12-layer Transformer with 768-dimensional hidden states identifies the "information gap" between them.
- Residual learning decoder: Generates a bounded sequence of soft tokens (each a 768-dimensional vector), stopping at N ≤ 64 tokens to ensure predictable output size.
- Plug-in interface: The downstream LLM receives prompts in the form
<summary> <RES_TOKENS>. Since these tokens are continuous vectors, the LLM can treat them as part of the context without additional tokenization — and no weights in the LLM itself are touched.
The training loss function is where the elegance lies: the system first feeds the full history to a frozen LLM and records its output distribution, then feeds "summary + residual tokens" and measures the difference using KL divergence. Minimizing this loss forces the residual tokens to precisely encode the missing information fragments.
KL Divergence (Kullback-Leibler Divergence) is a standard information-theoretic tool for measuring the difference between two probability distributions. In REMORY's training framework, it quantifies the distance between "the output distribution of a frozen LLM seeing the full history" and "seeing the summary + residual tokens." A KL divergence of zero means both inputs produce identical prediction probabilities — the residual tokens have perfectly compensated for the information lost in the summary. The advantage over token-level supervised loss is that KL divergence directly optimizes the model's "reasoning process" rather than surface text, capturing finer-grained semantic deviations. Soft tokens (continuous prompts) are the counterpart to discrete text tokens — they are floating-point vectors in embedding space, unreadable by humans but directly processable by a Transformer's attention mechanism. This is key to why REMORY requires no LLM weight modification: the model already supports arbitrary vector sequences as context input; the encoder simply ensures these vectors fall within the embedding distribution the model can "understand."
Training Process
Training data came from 12TB of multi-turn conversations spanning public forums, code review threads, and video-to-text aligned content. The summarization step was handled by GPT-4-Turbo, compressing each conversation into a 250-token summary.
Notably, the system uses a curriculum learning strategy: early epochs cap N at 8 tokens, gradually relaxing to 64 in later epochs, letting the model discover how much capacity it actually needs. Training converged in 250,000 steps across 64 A100 GPUs. The released checkpoint is approximately 350 million parameters, occupying only 1.4GB of VRAM — meaning inference is feasible on a single consumer-grade GPU.
Curriculum Learning is a training strategy inspired by human education, where the core idea is to arrange training samples or constraints in order of increasing difficulty, helping the model converge more stably. In REMORY's context, capping residual tokens at N=8 early on forces the model to express the information gap with an extremely limited "vocabulary," learning highly compressed representations. Gradually relaxing to 64 allows the model to handle more complex cases only after it has learned the fundamentals. This progressive relaxation prevents the model from taking "memory shortcuts" early on — directly stuffing raw text fragments into residual vectors instead of learning abstract representations. The 12TB scale of multi-turn conversation data is also noteworthy: compared to the hundreds of terabytes used in mainstream LLM pretraining, this is quite lean, reflecting the fact that the encoder is learning the narrowly defined task of "differential compression" rather than general language understanding — which partly explains why 350 million parameters achieves significant results.
Benchmarks: Impact-First Metrics
The paper claims: on the 64K-token WebGPT-Long QA benchmark, REMORY improved BLEU-4 from 23.1 to 31.7, a gain of 37%.
Several key comparisons stand out:
- Long-context QA (WebGPT-Long, 64K): BLEU-4 from 23.1 → 31.7, +37%
- Multi-turn dialogue (PersonaChat, 10K turns): Exact match rate from 45.2% → 58.9%, +30%
- Inference latency: From 1.2s/step → 0.68s/step, -43%
- Memory footprint: ~90% reduction compared to full history
All experiments used frozen Claude-3-Opus (175B) as the downstream model. According to the paper, the MLPerf-LLM community reproduced the results and confirmed the gains did not come from cherry-picked random seeds — a particularly important point for assessing the method's reliability.
Cost Perspective
REMORY's cloud interface charges $0.001 per 1K residual tokens. An enterprise bot processing 10 million user turns per month with 32 residual tokens per turn costs approximately $320/month. By comparison, storing and re-injecting full 8K-token histories costs approximately $2,400. In other words, REMORY delivers roughly an 87% cost reduction while cutting latency in half.
Risks and Open Questions
Technical impressiveness doesn't mean there are no concerns, and the paper itself honestly lists several key risks:
Token drift is the most immediate issue. Residual tokens encode the information gap at a specific point in time. Once the distribution shifts — for example, when new policy IDs appear — performance degrades. The mitigation is to periodically fine-tune the encoder and monitor for drops in exact match rate.
Soft token security also warrants vigilance. Continuous vectors are opaque, and malicious actors could potentially embed adversarial patterns to manipulate the frozen LLM. The SDK provides norm clipping and token verification hooks for this purpose.
There are also compatibility limitations — some upcoming sparse activation models treat prompts as discrete token streams and may simply ignore soft vectors — as well as IP and compliance concerns: residual vectors embed proprietary conversation fragments, meaning outsourcing token generation touches GDPR/CCPA boundaries. Enterprises are advised to self-host the encoder.
On latency, the encoder adds approximately 120ms on a single A100, which may exceed budget for real-time voice assistants. This can be mitigated by pre-computing residual tokens for predictable workflows.
Adversarial soft prompt attacks are a threat vector that has gained increasing attention in LLM security. Because continuous vectors bypass the discretization filtering of tokenizers, an attacker can carefully craft a vector sequence in embedding space that is completely unreadable to humans yet induces a frozen LLM to produce specific outputs — such as leaking system prompts, bypassing content policies, or injecting malicious instructions. This differs from text-level prompt injection, which relies on the model's understanding of natural language; adversarial soft prompts operate directly in activation space and are harder to intercept with rule-based filters. The "norm clipping" mentioned in the paper is a mitigation technique: by capping the L2 norm of residual vectors, it compresses the manipulation space available to attackers — but cannot fully eliminate the risk. For enterprises deploying REMORY in high-security contexts (such as finance or healthcare), self-hosting the encoder and performing anomaly detection before vector injection is the more prudent choice at this time.
Where This Could Go
The paper offers an optimistic roadmap: from a "context-aware" mode integrated into Copilot to reduce hallucination rates in code completion, to improving frame consistency in video generation pipelines, to expanding into multimodal residuals (audio + text) that let voice assistants remember tone and prosodic cues across hours of interaction. Looking further out, there's even a possibility that "residual memory tokens" could be incorporated into LLM API specifications as a standardized primitive.
A note of caution: these timelines and specific numbers come from the paper's forward-looking narrative — they are projections, not established facts. Readers should maintain appropriate skepticism.
Conclusion
REMORY doesn't rewrite the scaling laws of Transformers, but it redefines how we think about context. By teaching frozen LLMs to read a compact, learned "memory suffix," it sidesteps the brutal tradeoff between context length and latency.
The next wave of LLM products will likely pair summarizers with residual memory modules — much like modern browsers pair caching with garbage collection. The real test will come when context budgets exceed 256K while still expecting a single prompt to retain months of reasoning history. If REMORY's early results hold up under scrutiny, that future looks less like a memory-pressure nightmare and more like a manageable engineering problem.
Related articles

Free Unlimited Claude Code Solution: Agnes AI + CC Switch Setup Guide
No paid subscription needed — pair the free AI platform Agnes AI with the open-source tool CC Switch to provide a backend for Claude Code, enabling unlimited free calls to text, image, and video models. This guide covers the full setup, test results, and usage boundaries.

A Complete Zero-Cost Guide to Getting Started with Claude Code for Beginners in China
A beginner's guide to Claude Code for users in China: two installation methods (command line and IDE plugin), full configuration steps for replacing the official API with the free domestic LongCat model, and a hands-on demo of building a small tool with natural language, plus tips.

When the NSA Gets Involved: The AI Supply Chain Crisis Behind Open-Source CVEs and API Key Hijacking
Multiple open-source projects disclosed severe CVEs in one day, PHP flaws alarmed the FBI, and Railway and OpenCode were breached with API keys stolen. This article breaks down the vulnerability window, AI-accelerated exploitation, and the AI supply chain crisis behind the API key black market, with a developer defense checklist.