The COUNT: Counting N-grams Unlocks Scaling on Host Memory and Training-Free Adaptation
Abstract
COUNT improves language model efficiency by using precomputed n-gram counts stored in host memory to augment embeddings without learned parameters, boosting performance and enabling domain adaptation at inference.
The scaling relationship of compute and performance for language models (LMs) has been extensively studied; more recently, models are being designed to scale memory use, as well. In particular, adding embeddings for n-grams scales memory separately from compute use, because each pass only processes individual embedding rows, which are much smaller than the storage used for the whole embedding table. However, existing methods train embeddings from scratch, which needs expensive GPU memory for fast reading and writing. Meanwhile, the ordinary memory of the host system is cheap and underutilized by these training methods. To scale on host memory, we introduce COUNT (Counting Offline Unlocks N-gram Transformers), which builds n-gram embeddings without adding learned parameters by storing precomputed n-gram counts on host. We use the corpus frequencies to weight together the LM's own unembeddings of the next tokens most often following the current n-gram history. At a fixed compute budget, COUNT can be added as an additional input embedding for pretraining 1B-parameter LMs to improve validation loss as much as an LM with 57% more compute. If GPU memory is limited, using COUNT to let backbone parameters fill GPU memory gives better performance than splitting memory with additional learned n-gram embeddings. Beyond efficiency, COUNT allows switching in a different table of n-gram counts from a domain-specific corpus at inference time to adapt to a new task without any training.
Community
COUNT adds an n-gram embedding to a transformer without adding learned parameters. At each position, it looks up the most frequent next tokens in a table of corpus n-gram counts held in CPU RAM, and adds the model’s own output-head rows for those tokens to the token embedding. Because the table lives in host memory rather than on the GPU, it can grow to hundreds of GB, and swapping in a table counted on a new domain (math, biomedical, law) adapts a trained model with no further training. With a 1B backbone COUNT matches a standard transformer trained with 57% more compute.
We release the n-gram tables (17 GB to 797 GB, plus the three domain tables), and the checkpoints for COUNT and both baselines at 7 sizes from 60M to 1B parameters: https://huggingface.co/collections/IanMagnusson/count
This is an automated message from the Librarian Bot. I found the following papers similar to this paper.
The following papers were recommended by the Semantic Scholar API
- MoME: Mixture-of-Memory Embeddings for Context-Aware Sparse Lookup (2026)
- FactorEngram: Factorized N-gram Memory with Basis-Level Gating for Language Models (2026)
- Byte Language Models: Scaling, Emergent Abstractions, and Information Allocation (2026)
- Memory Attention (2026)
- LightMTP: Lightweight Latent Multi-Token Prediction (2026)
- Universal Test-Time Training (2026)
- The Surprising Effectiveness of Shared Memory in Looped Transformers (2026)
Please give a thumbs up to this comment if you found it helpful!
If you want recommendations for any Paper on Hugging Face checkout this Space
You can directly ask Librarian Bot for paper recommendations by tagging it in a comment: @librarian-bot recommend
Get this paper in your agent:
hf papers read 2610.20456 Don't have the latest CLI?
curl -LsSf https://hf.co/cli/install.sh | bash Models citing this paper 3
IanMagnusson/count-checkpoints-count
Datasets citing this paper 1
IanMagnusson/count-ngram-tables
Spaces citing this paper 0
No Space linking this paper