Embeddings Are Overpriced? A Frozen 16 MB Vocabulary for Small and Ternary Language Models
Organizations: QLNI, New South Wales, Australia
Abstract
In a small language model the vocabulary is the single largest part. In Gemma 3 270M the embedding table holds 168M of 268M parameters, and because quantisation methods leave the embedding in 16-bit, it is also most of the file once the rest of the model is compressed. We ask what that table actually buys. We replace it with one frozen table of 512-bit codes, 16 MB, with no trainable parameters, derived once from a pretrained embedding by principal-component projection and sign binarisation, and we train the same Gemma-shaped body from scratch on the same 2.05B tokens with and without it. The learned table buys 0.20 nats of validation loss for 2.6 times the trainable parameters, but on LAMBADA, HellaSwag and PIQA the frozen-table model is better or tied; only ARC-Easy favours the learned table. With a ternary BitNet b1.58 body the whole model is a 46 MB file, still ties the float model on LAMBADA and PIQA, and on a laptop CPU generates 615 to 740 tokens per second in 62 MB of memory, five to six times the speed of the float model's 8-bit GGUF in llama.cpp at a seventh of the memory. The frozen table wins by 1.7 to 2.3 nats on rare words, accepts 10,000 new words after training with a 3% cost where the learned table collapses by 43%, and all of it is released with the weights, the data and every evaluation answer.
Figures & tables
| part | parameters | share |
|---|---|---|
| embedding table (tied to the head) | 167.8M | 62.6% |
| feed-forward layers | 70.8M | 26.4% |
| attention | 29.5M | 11.0% |
| norms | 0.06M | 0.0% |
| total | 268.1M |
| trainable | LAMBADA | HellaSwag | ARC-Easy | PIQA | val loss | |
|---|---|---|---|---|---|---|
| A learned table, float | 268.1M | 21.6 (20.5-22.7) | 30.4 (29.4-31.2) | 45.9 (43.9-47.9) | 60.6 (58.3-62.8) | 3.155 |
| B frozen table, float | 101.0M | 23.2 (22.1-24.4) | 30.4 (29.4-31.2) | 42.5 (40.5-44.5) | 61.5 (59.2-63.8) | 3.358 |
| C frozen table, ternary | 101.2M | 22.5 (21.3-23.6) | 29.4 (28.6-30.3) | 41.0 (39.0-43.0) | 59.5 (57.2-61.7) | 3.439 |
| LAMBADA | HellaSwag | ARC-Easy | PIQA | loss | |
|---|---|---|---|---|---|
| B minus A | +1.6 (+0.7 to +2.6) | 0.0 (-0.6 to +0.6) tied | -3.4 (-5.1 to -1.7) | +0.9 (-0.8 to +2.6) tied | +0.203 |
| C minus A | +0.9 (-0.1 to +1.8) tied | -0.9 (-1.6 to -0.3) | -4.9 (-6.7 to -3.1) | -1.1 (-2.8 to +0.6) tied | +0.284 |
| C minus B | -0.8 (-1.7 to +0.2) tied | -0.9 (-1.5 to -0.3) | -1.5 (-2.9 to +0.1) tied | -2.0 (-3.5 to -0.5) | +0.081 |
| count in training | tokens in vocab | share of text | A | B | C | B minus A |
|---|---|---|---|---|---|---|
| 10-99 | 41,004 | 0.04% | 14.36 | 12.01 | 12.66 | -2.34 (-2.95 to -1.74) |
| 100-999 | 43,577 | 0.9% | 7.44 | 8.32 | 8.45 | +0.89 (+0.79 to +0.98) |
| 1k-9.9k | 48,178 | 7.9% | 5.71 | 6.51 | 6.60 | +0.80 (+0.78 to +0.83) |
| 10k-99k | 12,382 | 16.8% | 4.79 | 5.21 | 5.36 | +0.42 (+0.41 to +0.43) |
| 100k-999k | 1,885 | 22.3% | 3.87 | 4.07 | 4.18 | +0.20 (+0.19 to +0.20) |
| 1M and more | 161 | 52.0% | 1.85 | 1.88 | 1.93 | +0.035 (+0.032 to +0.037) |
| model | runtime and format | file | peak memory | tokens per second | perplexity |
|---|---|---|---|---|---|
| A, learned table, float | llama.cpp, GGUF f16 | 543 MB | 723 MB | 62 | 23.86 (0.19) |
| A | llama.cpp, GGUF Q8_0 | 292 MB | 471 MB | 116 | 23.86 (0.19) |
| A | llama.cpp, GGUF Q4_K_M | 253 MB | 446 MB | 130 | 23.97 (0.19) |
| C, frozen table, ternary | our kernel | 46 MB | 62 MB | 615 to 740 | 31.2 (from the loss in Table 2) |
| tokens added | tokens saved | A learned | B frozen | C frozen, ternary |
|---|---|---|---|---|
| 2,000 | 1.9% | +20.2% | +2.0% | +1.9% |
| 5,000 | 2.7% | +32.6% | +2.8% | +2.7% |
| 10,000 | 3.2% | +42.9% | +3.3% | +3.1% |
Embedding Compression
Embedding compression reduces the storage and computation needed for vector representations while preserving task-relevant information.
See all 49 papers