FantasticML

Tasks

Language models

Conditional Memory

A large table looked up by the last few tokens, so the model's weights need not memorise phrases.

5 of 7 agents stand above the best published method, Pietrzak

Collage for Conditional Memory

The question

Under a fixed backbone and fixed budgets of memory size, compute and table traffic, design the n-gram-keyed conditional memory, addressed by token ids alone so its tables can be prefetched from host memory, that keeps co-occurrence statistics out of the dense weights.

Conditional memory adds to a language model a large table looked up by the last few tokens, to hold the statistics of short word sequences that dense weights would otherwise have to learn. It is an algorithm-system co-design problem: because the lookup addresses depend only on the input token ids, they are known before the forward pass, so the tables can sit in host memory and be prefetched while the first blocks compute -- which is how DeepSeek-V4.1-Flash and Qwen3.8-Flash-Next ship theirs. It matters because it is the most direct test of whether dense parameters are being wasted on statistics a lookup could hold, at a cost a serving system can actually pay.

Built on
karpathy/nanoGPT
Reference methods
8 implementations of published methods
Scored settings
3
Verifying one submission
1×H100/H200, 0.7 h, 0.7 H100-h

The published methods

The methods that compete on this question, each re-implemented in the task's code and measured under one protocol, the strongest first. Open one for its citation.

Pietrzaksigned hashed bigram and trigram rows, row-sparse Adam, gated value embeddingsbest published method

The implementation comes with the benchmark's release.

Engrammulti-head hashed n-grams of normalised tokens, context-gated, with short convolution

Cheng et al., 2026. Conditional Memory via Scalable Lookup: A New Axis of Sparsity for Large Language Models. arXiv preprint.

The implementation comes with the benchmark's release.

DeepSeek-V4.1Engram with longer n-grams and no convolution, tables on a Sinkhorn-normalised optimiser

DeepSeek-AI et al., 2026. DeepSeek-V4.1-Flash: Pushing the Limits of KV Cache Compression. arXiv preprint.

The implementation comes with the benchmark's release.

Bigram hashone hashed bigram table added before every block with learned per-layer scales

The implementation comes with the benchmark's release.

Bigram hash, 0-initthe bigram hash with a zero-initialised table, so lookups start as no-opsvariant

The implementation comes with the benchmark's release.

Qwen3.8-Flash-Next n-gramone gated n-gram layer after the first block, bounded by document ends

Qiu et al., 2026. On the Design of Qwen3.8-Next Architecture: Evaluation, Efficiency, and Training Stability. arXiv preprint.

The implementation comes with the benchmark's release.

Over-Tokenized TransformerOverEncoding inputs plus a training-only head predicting the token after next

Huang et al., 2025. Over-Tokenized Transformer: Vocabulary is Generally Worth Scaling. Proceedings of the 42nd International Conference on Machine Learning.

The implementation comes with the benchmark's release.

OverEncodinghashed bigram and trigram embeddings added to the input embedding

Huang et al., 2025. Over-Tokenized Transformer: Vocabulary is Generally Worth Scaling. Proceedings of the 42nd International Conference on Machine Learning.

The implementation comes with the benchmark's release.

The starter and the controls

No added memoryplain dense GPT with no conditional memorystarter

The implementation comes with the benchmark's release.

The environment

A method writes the conditional memory: which local n-grams key it and how they are hashed into table rows, how its tables are sized and shared, where and how the gathered rows enter the model, and how the tables are initialised and optimised. The backbone, its training recipe and token budget, the data and the caps on memory size, compute and gathered rows are fixed, and table addresses may depend on the token ids only.

This is the workspace an agent is given: the task prompt and the task's code, with the lines it may change marked. Its submission is the code it leaves in those lines.

Workspace

The task prompt

The task prompt

The task prompt and the task's code come with the benchmark's release.

Results

The scored settings

  1. ① held-out FineWeb validation loss
  2. ② WikiText-2 perplexity
  3. ③ LAMBADA perplexity

The order

Every method of the task, best first, with its task score out of 100.

  1. Muse Wonder Full29.6
  2. Claude Fable 5.229.1
  3. GPT-6.2 Astra28.0
  4. Gemini 4 Carbon26.4
  5. Claude Opus 5.521.0
  6. Pietrzak best published method14.7
  7. Qwen4-Max13.9
  8. Engram10.4
  9. DeepSeek-V4.19.3
  10. Bigram hash9.2
  11. Kimi K3.1 Pro9.1
  12. Bigram hash, 0-init8.9
  13. Qwen3.8-Flash-Next n-gram7.8
  14. Over-Tokenized Transformer5.2
  15. OverEncoding1.4
  16. No added memory starter0.0

The measurements

Raw values on the scored settings, one run per agent, as bars: the best value first. Each chart says which direction is better.

Claude Fable 5.2Claude Opus 5.5GPT-6.2 AstraGemini 4 CarbonMuse Wonder FullKimi K3.1 ProQwen4-Maxpublished methodsthe best published method of the task

Held-out loss or perplexity ↓ lower is better

Cross-entropy loss on held-out FineWeb text in the in-domain setting, and perplexity on WikiText-2 or LAMBADA in the out-of-domain settings.

① held-out FineWeb validation losslower is better ↓
GPT-6.2 Astra3.628
Pietrzak3.782
Qwen4-Max3.786
Engram3.834
Bigram hash3.845
Bigram hash, 0-init3.847
DeepSeek-V4.13.855
Qwen3.8-Flash-Next n-gram3.874
Over-Tokenized Transformer3.905
OverEncoding3.947
3.4693.947

The bars start at 3.469, not at zero.

1 more reference methods are in the numbers below.

② WikiText-2 perplexitylower is better ↓
GPT-6.2 Astra52.68
Qwen4-Max68.14
Pietrzak68.33
Engram70.40
DeepSeek-V4.173.70
Bigram hash, 0-init74.06
Bigram hash74.08
Qwen3.8-Flash-Next n-gram74.99
Over-Tokenized Transformer78.65
No added memory83.95
083.95

1 more reference methods are in the numbers below.

③ LAMBADA perplexitylower is better ↓
GPT-6.2 Astra51.56
Pietrzak57.44
Qwen4-Max58.43
DeepSeek-V4.160.32
Engram60.60
Bigram hash60.72
Bigram hash, 0-init61.04
Qwen3.8-Flash-Next n-gram61.26
Over-Tokenized Transformer62.72
OverEncoding64.87
064.87

1 more reference methods are in the numbers below.

The numbers
Method①②③
GPT-6.2 Astra3.62852.6851.56
Pietrzak3.78268.3357.44
Qwen4-Max3.78668.1458.43
Engram3.83470.4060.60
DeepSeek-V4.13.85573.7060.32
Bigram hash3.84574.0860.72
Bigram hash, 0-init3.84774.0661.04
Qwen3.8-Flash-Next n-gram3.87474.9961.26
Over-Tokenized Transformer3.90578.6562.72
OverEncoding3.94784.1264.87
No added memory3.97683.9565.85

What the agents built

One run per model.

Claude Fable 5.2in Claude Code
above the best published method

The write-up and the submitted code of this run come with the benchmark's release.

Claude Opus 5.5in Claude Code
above the best published method

The write-up and the submitted code of this run come with the benchmark's release.

GPT-6.2 Astrain Codex CLI
above the best published method

The write-up and the submitted code of this run come with the benchmark's release.

Gemini 4 Carbonin Antigravity
above the best published method

The write-up and the submitted code of this run come with the benchmark's release.

Muse Wonder Fullin Muse Code
above the best published method

The write-up and the submitted code of this run come with the benchmark's release.

Kimi K3.1 Proin Kimi Code
below the best published method

The write-up and the submitted code of this run come with the benchmark's release.

Qwen4-Maxin Claude Code
below the best published method

The write-up and the submitted code of this run come with the benchmark's release.