TernaryCLIP: Efficiently Compressing Vision-Language Models with Ternary Weights and Distilled Knowledge

Shu-Hao Zhang, Wei-Cheng Tang, Chen Wu, Peng Hu, Nan Li, Liang-Jie Zhang, Qi Zhang, Shao-Qun ZhangarXiv 2025 · DOI

Introduction

Large-scale multimodal models like CLIP have revolutionized AI's understanding of image-text relationships. However, their massive size presents significant deployment challenges, particularly for edge devices. These models typically require gigabytes of storage, exhibit high latency on low-power hardware, and often depend on massive labeled datasets for fine-tuning. While quantization can reduce model size, "extreme" quantization—such as ternary weights—often leads to a catastrophic drop in accuracy, especially when trying to maintain the delicate alignment between vision and text encoders.

Methodology: Ternarization and Triple Distillation

TernaryCLIP addresses these challenges through a framework that compresses weights to just 1.58 bits (ternary values: -1, 0, +1). The approach rests on two pillars:

  1. Ternarization-Aware Training: Rather than post-training rounding, the authors use Quantization-Aware Training (QAT). A "RoundClip" function and an adaptive scaling factor ($\gamma$) map weights to the ternary set. To maintain differentiability during training, a Straight-Through Estimator (STE) passes gradients to latent full-precision weights.
  2. Triple Distillation Strategy: To preserve performance, a high-capacity "Teacher" model (e.g., full-precision ViT-L/14) guides the ternary "Student" model via three knowledge transfer mechanisms:
  3. Contrastive Relational Distillation (CRD): Aligns similarity distributions.
  4. Interactive Contrastive Learning (ICL): Matches student image embeddings with teacher text embeddings.
  5. Feature Distillation (FD): Minimizes the distance between raw embedding vectors.
The TernaryCLIP framework consists of a ternarization process for model components and a triple distillation strategy to transfer knowledge from a full-precision teacher to a ternary student.

The framework was evaluated in two configurations: Q-FFN (quantizing only feed-forward layers) and Q-ALL (quantizing attention, embeddings, and feed-forward layers).

Experimental Setup

The models were trained on the Conceptual Captions 12M (CC12M) dataset. Evaluation spanned a comprehensive suite of 41 datasets to assess zero-shot capabilities, including 37 image classification tasks (e.g., ImageNet-1k, CIFAR-100), PASCAL VOC 2007 for multi-label classification, and three image-text retrieval datasets (Flickr8k, Flickr30k, and MS COCO).

Results: Performance and Efficiency

TernaryCLIP achieves remarkable compression without sacrificing significant accuracy. The Q-ALL model demonstrates a 16.98× compression ratio, reducing weight storage from approximately 1.6GB to just 35MB.

Comparison of TernaryCLIP against baseline and other quantization methods. The Q-ALL variant achieves a 99% quantization proportion and a 16.98× compression ratio.

Key performance metrics include:

  • Inference Speed: 2.3× faster on an Apple M4 Pro CPU using specialized kernels.
  • Memory Efficiency: 10× reduction in runtime memory consumption.
  • Zero-Shot Accuracy: On 37 classification tasks, the model maintained an average accuracy of 38.24%, outperforming 4-bit Post-Training Quantization (PTQ) methods (~32%) and nearing the distilled full-precision baseline (40.95%).
  • Retrieval Performance: On Flickr30k, it achieved a Recall@5 of 93.7% for image-to-text retrieval, closely matching the teacher's 97.8%.

Discussion: Sparsity and Scaling

The ternary weights naturally result in high sparsity (approximately 60%), where more than half the weights are zero. This sparsity allows for significant computational skipping on specialized hardware. Furthermore, the authors observed a scaling law for quantization: with sufficient training data and time, ternary models can converge remarkably close to full-precision performance. Notably, "self-distillation"—using a teacher with the same architecture as the student—proved highly effective, offering flexibility in training setups.

Conclusion and Future Work

TernaryCLIP proves that extreme weight compression is viable for complex multimodal models. While the weights are ternary, the activations currently remain in FP16. Future research aims to quantize activations to INT8 to further enhance efficiency, though this currently presents convergence challenges. Additionally, optimizing software for bit-wise ternary logic on specialized hardware could unlock even greater speedups.

Summary updated

BibTeX
@misc{zhang2025ternaryclip,
  author = {Shu-Hao Zhang and Wei-Cheng Tang and Chen Wu and Peng Hu and Nan Li and Liang-Jie Zhang and Qi Zhang and Shao-Qun Zhang},
  title = {{TernaryCLIP: Efficiently Compressing Vision-Language Models with Ternary Weights and Distilled Knowledge}},
  year = {2025},
  eprint = {2510.21879},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.21879},
}
Figure