Q-MLLM: Vector Quantization for Robust Multimodal Large Language Model Security
Wei Zhao, Zhe Li, Yige Li, Jun Sun
TL;DR
Q-MLLM addresses the dual safety vulnerabilities of multimodal large language models: susceptibility of continuous visual representations to gradient-based attacks and the gap in transferring text-based safety to vision. It introduces two-level vector quantization at the vision encoder to produce discrete visual tokens, forming a non-differentiable bottleneck that disrupts adversarial optimization, complemented by an enhanced semantic safety signal via a quantized CLS token. The training comprises a two-stage process—pretraining with codebooks and projection while freezing encoders, followed by LLM-focused fine-tuning—to preserve safety guarantees while maintaining multimodal utility. Empirical results show near-perfect defense against jailbreak attacks (average DSR up to 98.4%) and strong protection against toxic-image attacks (average DSR up to 75.9%) with minimal impact on vision-language benchmarks and modest inference overhead, demonstrating that discretization can enable robust, scalable safety for multimodal AI systems. The work offers a practical defense that reduces reliance on expensive safety-tuning or detection pipelines and points to broader opportunities for discrete representations in secure AI systems.
Abstract
Multimodal Large Language Models (MLLMs) have demonstrated impressive capabilities in cross-modal understanding, but remain vulnerable to adversarial attacks through visual inputs despite robust textual safety mechanisms. These vulnerabilities arise from two core weaknesses: the continuous nature of visual representations, which allows for gradient-based attacks, and the inadequate transfer of text-based safety mechanisms to visual content. We introduce Q-MLLM, a novel architecture that integrates two-level vector quantization to create a discrete bottleneck against adversarial attacks while preserving multimodal reasoning capabilities. By discretizing visual representations at both pixel-patch and semantic levels, Q-MLLM blocks attack pathways and bridges the cross-modal safety alignment gap. Our two-stage training methodology ensures robust learning while maintaining model utility. Experiments demonstrate that Q-MLLM achieves significantly better defense success rate against both jailbreak attacks and toxic image attacks than existing approaches. Notably, Q-MLLM achieves perfect defense success rate (100\%) against jailbreak attacks except in one arguable case, while maintaining competitive performance on multiple utility benchmarks with minimal inference overhead. This work establishes vector quantization as an effective defense mechanism for secure multimodal AI systems without requiring expensive safety-specific fine-tuning or detection overhead. Code is available at https://github.com/Amadeuszhao/QMLLM.
