Papers
Topics
Authors
Recent
Search
2000 character limit reached

STSCQ: Switchable Token-Specific Quantization

Updated 20 March 2026
  • Switchable Token-Specific Codebook Quantization is a method that employs token-specific codebooks and hierarchical grouping to achieve efficient compression of face images.
  • It integrates with vector quantization models like VQ-VAE and VQGAN, delivering improved rate–distortion performance and superior identity preservation compared to global codebook methods.
  • STSCQ uses a three-stage training process—including shared codebook initialization, token-specific refinement, and identity loss fine-tuning—to achieve significant gains in recognition accuracy at low bpp.

Switchable Token-Specific Codebook Quantization (STSCQ) is a codebook-based compression methodology optimized for face image compression at ultra-low bitrates. Distinguished from global codebook approaches, STSCQ introduces hierarchical image-level grouping and token-specific codebooks, significantly improving rate–distortion performance and face identity preservation. The design enables STSCQ to be integrated into any vector quantization-based representation learning pipeline, such as VQ-VAE, VQGAN, and TiTok, providing substantial gains over fixed-global codebook baselines at the same bits-per-pixel.

1. Model Structure and Pipeline

STSCQ operates atop the conventional "latent-space" autoencoder with vector quantization, consisting of the following principal components:

  • Encoder (Enc\mathrm{Enc}): Maps the input RGB face image xR256×256×3x \in \mathbb{R}^{256 \times 256 \times 3} to a grid of TT continuous latent tokens, ze=Enc(x)RT×dz_e = \mathrm{Enc}(x) \in \mathbb{R}^{T \times d}.
  • Routing and Codebook Selection: An image-level routing network GθG_\theta selects a codebook group for the entire image: k=G(ze){1,,M}k = G(z_e) \in \{1, \dots, M\}.
  • Token-Specific Quantization: For each token position tt, a unique codebook Ck,tRK×dC_{k, t} \in \mathbb{R}^{K \times d} is assigned, yielding zqt=QuantCk,t(zet)z_q^t = \mathrm{Quant}_{C_{k, t}}(z_e^t).
  • Decoder (Dec\mathrm{Dec}): Reconstructs the image from quantized tokens: x^=Dec({zqt}t=1T)\hat{x} = \mathrm{Dec}(\{z_q^t\}_{t=1}^T).

This architecture divides codebook capacity across MM image-level groups and TT token positions, yielding a total of M×TM \times T codebooks, each of size KK, in contrast to a single monolithic codebook of size NN.

2. Mathematical Formalism and Losses

The formulation introduces distinct codebooks CtiC^i_t for each group i{1,,M}i \in \{1, \dots, M\} and token position t{1,,T}t \in \{1, \dots, T\}. For a given image, the active codebook group is selected, and each token is quantized via nearest-neighbor:

zqt=QuantCti(zet)=argmineCtizete22z_q^t = \mathrm{Quant}_{C^i_t}(z_e^t) = \arg\min_{e \in C^i_t} \|z_e^t - e\|_2^2

Bit allocation is explicitly determined:

bpp=Tlog2K+log2MHW\mathrm{bpp} = \frac{T \cdot \lceil \log_2 K \rceil + \lceil \log_2 M \rceil}{H \cdot W}

The training objective is a composite of several losses:

  • Reconstruction and VQ Commitment Loss:

LVQ=xx^22+t=1Tsg(zet)zqt22+t=1Tsg(zqt)zet22+λpLper(x,x^)\mathcal{L}_{\mathrm{VQ}} = \|x - \hat{x}\|_2^2 + \sum_{t=1}^T \|\mathrm{sg}(z_e^t) - z_q^t\|_2^2 + \sum_{t=1}^T \|\mathrm{sg}(z_q^t) - z_e^t\|_2^2 + \lambda_p \mathcal{L}_{\mathrm{per}}(x, \hat{x})

where sg()\mathrm{sg}(\cdot) is the stop-gradient operator and Lper\mathcal{L}_{\mathrm{per}} denotes perceptual loss (e.g., LPIPS or VGG).

  • Routing Loss (Lrouter\mathcal{L}_{\mathrm{router}}):

Promotes balanced codebook usage, confident routing, and minimal quantization error through entropy, decision, and quantization-average losses.

  • Identity Consistency Loss:

Applied in fine-tuning, encouraging ArcFace-based recognition feature consistency.

3. Training Procedure

STSCQ employs a three-stage progressive training schedule:

  1. Stage 1: Switchable Token-Shared Codebooks
    • Replace global codebook with MM image-level sub-codebooks (shared across tokens).
    • Freeze encoder and decoder; optimize sub-codebooks and routing network.
    • Minimize reconstruction and routing loss.
  2. Stage 2: Token-Specific Codebook Learning
    • For each group ii and token tt, initialize CtiC^i_t from CiC^i.
    • Freeze encoder and decoder; optimize all CtiC^i_t and routing network.
    • Minimize sum of token-wise quantization errors and routing loss.
  3. Stage 3: Decoder Fine-Tuning with Identity Loss
    • Freeze codebooks and routing; train decoder only.
    • Supplement loss with ArcFace-based identity regularization.

4. Quantization Capacity, Rate–Distortion, and BPP Efficiency

A global codebook of size NN provides high capacity but becomes infeasible at low bpp, where index sizes must be reduced. By setting M=2sM = 2^s, K=N/2sK = N / 2^s, effective total codebook capacity MKNM \cdot K \approx N is preserved, since each group specializes in a specific facial attribute distribution. Token-specific codebooks CtiC^i_t further reduce the per-token quantization variance, maximizing usage, and substantially decreasing quantization errors at a given bpp. The model’s bpp is dictated primarily by Tlog2KT \log_2 K, with the group overhead log2M\log_2 M negligible for typical TT and KK.

5. Experimental Protocol and Evaluation

The method is trained and evaluated on standard face recognition datasets:

  • Training Set: CASIA-WebFace (\sim500K images, 10,575 identities)
  • Evaluation Sets: LFW, CFP-FP, AgeDB, CPLFW, CALFW
  • Preprocessing: 256×256256 \times 256 crops, random horizontal flips
  • Comparison Baselines: TiTok-S (T=128T=128), TiTok-L (T=32T=32), VQGAN/MaskGIT (T=256T=256)
  • Optimization: AdamW, learning rate 10410^{-4}, run on 8 NVIDIA V100 GPUs
  • Training Schedule: Stage 1: 100K steps; Stage 2: 400K; Stage 3: 100K
  • Metrics: Mean recognition accuracy (MeanAcc, ArcFace), identity similarity (IDS), bpp

6. Quantitative Results and Ablation Insights

At comparable or lower bpp, STSCQ yields substantial improvements over baselines:

Setting bpp Baseline MeanAcc STSCQ MeanAcc Baseline IDS STSCQ IDS
MaskGIT-VQGAN+STSCQ, T=256T=256 0.0503 90.70 93.51 0.6314 0.6659
TiTok-S, T=128T=128, K=4096K=4096 0.0234 87.56 91.66 0.5764 0.6120
TiTok-L, T=32T=32 0.0059 65.07 73.13
  • Codebook Count (MM): Performance increases with MM up to 16 (for K=1024K=1024), then degrades for M16M \gg 16 due to routing instability.
  • Token-Specific vs. Shared: Per-token splitting yields +1.6–2.5% MeanAcc gain at fixed bpp.
  • Inference Routing: Confident routing (CR) matches or surpasses nearest-neighbor quantization, with reduced latency and storage.
  • Codebook Utilization: Mean per-token utilization improved from ~54% (global/shared) to ~74% (token-specific), decreasing dead embeddings.

7. Implications, Generalization, and Limitations

STSCQ achieves high-fidelity, identity-preserving reconstructions at bitrates previously unattainable for face compression methods based on vector quantization. The approach generalizes to any codebook-based representation learning scheme, as the architecture and training objectives are modular. A plausible implication is that similar hierarchical, token-specific codebook strategies may benefit other semantic-rich domains beyond faces, especially at ultra-low bpp. The primary limitation is routing instability as the number of codebook groups MM becomes large. Further research may focus on robust routing mechanisms, capacity scaling, and extending these insights to non-facial image modalities.

For in-depth methodology, experiments, and implementation specifics, refer to "Switchable Token-Specific Codebook Quantization For Face Image Compression" (Wang et al., 27 Oct 2025).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Switchable Token-Specific Codebook Quantization (STSCQ).