Towards Improved Text-Aligned Codebook Learning: Multi-Hierarchical Codebook-Text Alignment with Long Text

Guotao Liang, Baoquan Zhang, Zhiyuan Wen, Junteng Zhao, Yunming Ye, Kola Ye, Yao He

Abstract

In modern computer vision, image generation and understanding often rely on vector quantization to map continuous visual data into a discrete codebook. However, existing text-aligned codebook learning methods are frequently limited by concise, low-detail captions that fail to capture the nuanced semantics of an image. This paper introduces TA-VQ (Text-Augmented Vector Quantization), a framework designed to bridge this "semantic gap" by utilizing detailed, long-form text descriptions. By decomposing these descriptions into a hierarchy of words, phrases, and sentences, TA-VQ aligns visual features across multiple granularities. Our approach significantly improves image reconstruction quality and performance on downstream tasks such as visual question answering (VQA) and image captioning.

Introduction: The Semantic Gap in Quantization

Vector quantization (VQ) is a foundational step in many generative models, transforming images into a sequence of discrete tokens from a learned vocabulary. Recent efforts have sought to make these tokens more semantically meaningful by aligning them with natural language captions. Despite these advancements, standard datasets typically provide only brief descriptions (e.g., "a zebra grazing"). Such captions omit critical details regarding texture, spatial orientation, and background context, leading to a codebook that lacks fine-grained semantic depth.

To address this, we propose leveraging the descriptive power of Vision-Language Models (VLMs) to generate "Long Text" descriptions. This transition from concise to comprehensive text allows the model to learn a more robust and detailed visual representation.

The TA-VQ Framework

The TA-VQ framework operates through a structured three-step pipeline: text generation, multi-granularity encoding, and multi-hierarchical semantic alignment.

The TA-VQ architecture overview.
  1. Text Generation via VLM: We utilize a high-performance VLM (ShareGPT4V) to produce exhaustive "Long Text" descriptions for training images, ensuring that even minor visual details are represented in the linguistic domain.
  2. Multi-Granularity Text Encoding: The generated text is segmented into three distinct levels: words (focusing on descriptive nouns and adjectives), phrases, and full sentences. Each level is processed through a pre-trained BERT model to extract hierarchical semantic features.
  3. Multi-Hierarchical Alignment:
    • Hierarchical Encoder: We employ an image encoder where different layers correspond to specific text granularities. Lower layers, which capture basic textures and shapes, are aligned with word-level features, while deeper layers representing abstract concepts are aligned with sentence-level features.
  4. Sampling-based Alignment: To maintain computational efficiency when aligning high-dimensional image grids with complex text, we model the codebook as a Gaussian distribution. By sampling representative features and utilizing the Wasserstein distance, we reduce alignment complexity from $O(N^3)$ to $O(q^2)$, enabling scalable training.

Data Augmentation with Long Text

The core innovation of TA-VQ lies in its use of rich, descriptive data. Traditional captions often ignore the specific attributes of objects within a scene. By contrast, the "Long Text" approach explicitly describes attributes like the pattern of a zebra's stripes or the vibrant green of the surrounding field.

Comparison between original short captions and VLM-generated long text.

This hierarchical mirroring—where language structure (words to sentences) reflects visual structure (pixels to objects)—allows the model to learn a codebook that is both spatially aware and semantically precise.

Key Results and Performance

TA-VQ was evaluated across several benchmarks, including CelebA-HQ, CUB-200, and MS-COCO, demonstrating superior performance in both reconstruction and downstream applications:

  • Image Reconstruction: The model achieved a state-of-the-art Fréchet Inception Distance (FID) of 4.03 on the CUB-200 dataset, a significant improvement over previous methods like LG-VQ (4.40).
  • Cross-Modal Tasks: In image captioning on MS-COCO, the CIDEr-D score improved from 102.77 to 109.42, indicating that the text-aligned codebook provides a deeper understanding of scene context.
  • Visual Grounding: Enhanced word-level alignment resulted in higher accuracy for tasks requiring the model to identify specific objects based on descriptive prompts.

Conclusion and Future Directions

TA-VQ demonstrates that the quality of a learned visual codebook is intrinsically linked to the richness of the aligning text. By utilizing VLMs as "data augmenters" and implementing a multi-hierarchical alignment strategy, we can bridge the semantic gap inherent in traditional VQ-VAE/GAN models.

While the current framework is highly effective, future work could explore mitigating potential VLM biases and hallucinations. Additionally, extending this hierarchical alignment to temporal data (video) or 3D environments presents a promising avenue for developing even more sophisticated cross-modal AI systems.

Summary updated

BibTeX
@inproceedings{liang2025towards,
  author = {Guotao Liang and Baoquan Zhang and Zhiyuan Wen and Junteng Zhao and Yunming Ye and Kola Ye and Yao He},
  title = {{Towards Improved Text-Aligned Codebook Learning: Multi-Hierarchical Codebook-Text Alignment with Long Text}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.00384},
}
Figure