Embedding Tables Become the Biggest Part of Small Models: Should You Quantize or Freeze Them?

    When a model’s backbone is compressed to low-bit precision, the embedding table can become its largest component. This article explains why embedding layers are often excluded from quantization, distinguishes training-time freezing from compression-time freezing, and presents a practical process for evaluating memory savings, accuracy risks, and alternative compression strategies.

    1. After Compressing the Backbone, the Vocabulary Often Becomes the Largest Component

    Compressing a model backbone to 4-bit, 2-bit, or even ternary precision—approximately 1.58 bits—can reduce its size several times. At that point, many teams discover that the largest part of the model file is no longer the backbone, but the embedding table.

    The size of an embedding table can be estimated with a simple formula:

    1. V ≈ vocab_size × hidden_dim × bits / 8

    The result is measured in bytes.

    For example, with a vocabulary of 250,000 tokens, a hidden dimension of 768, and 16-bit storage:

    1. 250000 × 768 × 16 / 8 = 384,000,000 bytes

    That is approximately 384 MB in decimal units, or 366 MiB.

    A single table can therefore approach 400 MB. By comparison, the low-bit backbone of many small edge models may occupy only a few dozen megabytes.

    Consider another hypothetical example. Assume the model has 120 million non-embedding parameters. At 2-bit precision, they require approximately:

    1. 1.2 × 10^8 × 2 / 8 = 30 MB

    Adding a 384 MB embedding table stored at 16 bits produces a total of approximately 414 MB. The embedding table accounts for about 92.8% of the total. This is why the vocabulary becomes the dominant component after the backbone has been compressed.

    Memory accounting also deserves attention. Some reports specify that their memory figures exclude the embedding layer, effectively removing the largest component from the measurement. Always confirm what is included before comparing numbers.

    2. Why Common Quantization Methods Often Skip the Embedding Layer

    There are good reasons for this practice, mainly related to three differences between the backbone and the embedding layer.

    1. Different computation patterns. The backbone primarily performs matrix multiplications. After quantization, it can use low-bit integer operators, which can improve computation speed. The embedding layer, however, mainly performs table lookups. Quantizing it does not reduce the number of memory accesses. Its main benefit is storage reduction, while the impact on inference speed is limited.

    2. Different sensitivity to quantization error. The vocabulary maps text to semantic vectors. Low-frequency words, proper nouns, and tokens from less-represented languages may have fewer training updates and less stable representations. Quantization errors in these vectors can have a larger impact, leading to poorer recognition of rare words and more spelling errors in proper nouns.

    3. A more complicated engineering path. The output layer often shares weights with the embedding table. Compressing this part may require dequantization during lookup, mixed-precision operators, and sometimes custom kernels. The storage savings may not justify the additional engineering effort.

    Overall, quantization is most beneficial for compute-intensive components that tolerate some error. It is less effective for memory-intensive and semantically sensitive components. The embedding layer belongs to the latter category.

    3. What Does “Freezing” Actually Mean?

    The term “freezing” can refer to two different operations. They should be distinguished clearly.

    • Training-side freezing: The embedding table is not updated during training, while the backbone continues to be updated. This is commonly used for parameter-efficient fine-tuning because it reduces the memory required for gradients and optimizer states. In PyTorch, it is typically implemented with requires_grad_(False). This affects whether gradients are computed during training, but it does not change the parameter’s storage precision.
    • Compression-side freezing: The quantization process explicitly skips the embedding and output layers, preserving their original precision and storage format while applying low-bit quantization to the backbone.

    The two approaches can be used together, but they serve different purposes. Compression-side freezing makes the decision of whether to quantize the vocabulary explicit and allows it to be captured in code and configuration for reproducibility.

    The following pseudocode shows a layered quantization strategy:

    1. FROZEN_KEYS = ("embed", "wte", "lm_head")
    2. def quantize_model(model, bits=2):
    3. # named_parameters() deduplicates shared weights by default.
    4. # A shared weight appears only once.
    5. for name, param in model.named_parameters():
    6. if any(k in name for k in FROZEN_KEYS):
    7. continue # Explicitly skip: preserve original precision and format
    8. param.data = quantize_(param.data, bits=bits) # Quantize the backbone
    9. return model

    Here, quantize_ represents the implementation provided by the quantization framework in use and must be replaced accordingly.

    If parameters are traversed manually without using the framework’s deduplication behavior, shared weights must be handled explicitly. Otherwise, the same weight may be quantized more than once.

    4. A Decision Process: Calculate the Trade-Off Before Making Changes

    Do not decide whether to freeze the embedding table based on intuition alone. A practical evaluation can follow these four steps.

    1. Break down the model size. Measure the size and percentage of the backbone, embedding table, output layer, normalization layers, and activation buffers. If the embedding and output layers share weights, count the shared storage only once.

    2. Estimate the compression limit. Use the following formula to estimate the theoretical size of the embedding table at the target precision:

      1. V ≈ vocab_size × hidden_dim × target_bits / 8

      Then include additional overhead, such as quantization scale factors, to estimate the practical lower bound. If the quantized embedding table would still dominate the model, the savings from compressing the backbone may be offset by the vocabulary.

    3. Run a small-scale evaluation. Build an evaluation set covering frequent words, rare words, proper nouns, and the target languages. Compare two configurations: quantizing the embedding table and freezing it. Measure perplexity, entity recall, and downstream task accuracy. One possible acceptance rule is to treat a relative decline of more than 1% from the baseline as unacceptable. The appropriate threshold depends on the application.

    4. Run an end-to-end test. On the target device, measure peak memory, time to the first token, and throughput. A smaller model file does not necessarily translate into a proportional reduction in runtime memory because activation buffers and the KV cache may consume more memory.

    5. Benefits, Costs, and Alternatives

    Freezing the embedding layer offers three main benefits:

    • It is simple to implement and does not require custom operators.
    • It preserves semantic stability and reduces the risk of unexpected degradation for low-frequency tokens.
    • It can be combined with other quantization methods.

    The trade-off is equally clear: the reduction in file size is limited. The larger the embedding table’s share of the model, the lower the overall compression ratio will be compared with expectations.

    Instead of freezing the entire embedding layer, teams can also evaluate several compromise strategies.

    • Per-row low-bit quantization: Compute a separate scale factor for each row of the embedding table and quantize it to 8 bits or lower. The table is dequantized during lookup, adding little computation overhead. Storage can be approximately half that of 16-bit storage, while semantically sensitive rows can remain at higher precision.
    • Low-rank decomposition: Factor the embedding matrix into the product of two smaller matrices to reduce the parameter count. This may reduce expressive capacity, so it must be re-evaluated on the target benchmark.
    • Vocabulary pruning: Remove extremely low-frequency entries to reduce the vocabulary size directly. This changes the tokenizer and can affect downstream compatibility, making it the highest-risk option.

    The appropriate choice depends on the model’s size distribution, accuracy requirements, target hardware, and engineering constraints. For edge deployments, freezing the embedding layer is often the simplest way to preserve semantic quality, but it should be selected only after the resulting storage trade-off has been measured.