arXiv:2602.07374cs.CLcs.AI2026-02

用1.5比特量化训练小模型,内存减半且性能不降。

TernaryLM: Memory-Efficient Language Modeling via Native 1.5-Bit Quantization with Adaptive Layer-wise Scaling

  • 从头训练时直接使用{-1,0,+1}三值权重,结合分层自适应缩放。
  • 在TinyStories上困惑度58.42,内存仅498MB(原模型1197MB)。
  • 适合资源受限场景,尤其对轻量级部署和抗过拟合有帮助。

大语言模型虽性能出色,但计算开销大,难以在边缘设备部署。本文提出TernaryLM,一个132M参数的Transformer模型,原生采用三值量化{-1, 0, +1}(有效精度约1.58比特),显著降低内存占用而不损失语言建模能力。不同于后训练量化,TernaryLM从零开始学习量化感知表示,使用直通估计器和逐层自适应缩放因子。实验表明:(1) 在TinyStories上验证困惑度为58.42,跨种子标准差±0.17,优化稳定;(2) 下游任务MRPC上F1达82.47%,优于DistilBERT,且预训练数据量仅为后者的1/55;(3) 内存减少2.4倍(498 MB vs 1,197 MB),延迟相当;(4) 三值约束带来隐式正则化,训练/验证损失比为1.05倍,远低于FP32基线的3.51倍,说明其能有效防止小语料过拟合。层间稀疏性分析显示中间层(L5-L9)达到60-62%量化稀疏度,高于首尾层的45-55%,为非均匀精度分配提供设计依据。代码与模型已开源。

原文摘要 · Abstract (English)

Large language models (LLMs) achieve remarkable performance but demand substantial computational resources, limiting deployment on edge devices and resource-constrained environments. We present TernaryLM, a 132M-parameter transformer trained natively with ternary quantization {-1, 0, +1} (log2(3) ~ 1.58-bit effective precision), achieving significant memory reduction without sacrificing language modeling capability. Unlike post-training quantization approaches that quantize pre-trained full-precision models, TernaryLM learns quantization-aware representations from scratch using straight-through estimators and adaptive per-layer scaling factors. Our experiments demonstrate: (1) validation perplexity of 58.42 on TinyStories with a cross-seed standard deviation of +/- 0.17 PPL, confirming stable optimization; (2) strong downstream transfer with 82.47% F1 on MRPC, surpassing DistilBERT despite using 55x less pretraining data; (3) 2.4x memory reduction (498 MB vs 1,197 MB for an FP32 model of identical architecture) with latency parity; and (4) an implicit regularization effect whereby the ternary constraint yields a train/val ratio of 1.05x versus 3.51x for the FP32 baseline, demonstrating that discrete weights prevent overfitting on small corpora. We provide layer-wise sparsity analysis revealing that middle transformer layers (L5-L9) achieve 60-62% quantization sparsity versus 45-55% for boundary layers, establishing an actionable design principle for non-uniform precision allocation. Our implementation and trained models are publicly available at https://github.com/1nisharg/TernaryLM-Memory-Efficient-Language-Modeling.

量化小模型内存优化三值

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。