CoMat: Aligning Text-to-Image Diffusion Model with Image-to-Text Concept Matching

Dongzhi Jiang, Guanglu Song, Xiaoshi Wu, Renrui Zhang, Dazhong Shen, Zhuofan Zong, Yu Liu, Hongsheng Li

Despite the impressive generative capabilities of text-to-image diffusion models like Stable Diffusion (SDXL), they frequently fail to faithfully follow complex prompts. CoMat is an end-to-end fine-tuning strategy designed to fix these models when they ignore parts of a prompt or mix up object attributes. By using an image-to-text captioning model to spot missing concepts and a segmentation model to strictly guide attention maps, CoMat significantly boosts prompt alignment without sacrificing image quality.

The Challenge of Prompt Misalignment

The authors break down text-to-image misalignment into two specific failure modes:

  1. Concept Ignorance: The model completely forgets to generate an object mentioned in the prompt (e.g., asking for a "purple suitcase" and getting no suitcase at all).
  2. Concept Mismapping: The model generates the object but binds the wrong attributes to it (e.g., generating a suitcase, but making it yellow instead of purple because it confused the color with a nearby "yellow boat").

Fundamentally, this happens because standard diffusion training treats the text prompt as a broad condition for denoising. It lacks explicit, token-by-token guidance to ensure every concept is accurately represented and localized.

The CoMat Methodology

To tackle these issues, the authors propose CoMat (Concept Matching), which fine-tunes a pre-trained diffusion model using three novel components:

  • Concept Activation (Fixing Ignorance): CoMat uses a frozen, pre-trained Image-to-Text (I2T) model (like BLIP) to evaluate the generated image. If a concept from the prompt is missing, the I2T model outputs a low log-likelihood score. By fine-tuning the diffusion model to maximize this score, the model is forced to "revisit" ignored text tokens and generate the missing objects.
  • Fidelity Preservation (Preventing Reward Hacking): If you only optimize for the I2T model's score, the diffusion model quickly learns to "hack" the reward, resulting in deep-fried, unrealistic images. To preserve image quality, CoMat introduces an adversarial discriminator (initialized from a pre-trained UNet) to ensure fine-tuned images remain indistinguishable from the original model's high-quality outputs. They also mix in noisy latents from real-world images during training to anchor the model to reality.
  • Attribute Concentration (Fixing Mismapping): To ensure attributes (like colors or textures) bind to the correct objects, CoMat uses an open-vocabulary segmentation model (Grounded-SAM) to find the exact pixel regions of entities in the generated image. It then applies a loss function that forces the cross-attention maps of attribute tokens to activate only within their corresponding object's segmentation mask.

Key Insights

During development, the researchers uncovered several interesting dynamics about diffusion models:

  • Nouns behave, but adjectives bleed: Visualizing attention maps reveals that diffusion models usually know where a noun is, but the attention maps for attribute tokens (like "yellow") often bleed across the entire image. Forcing attribute attention to stay strictly within the noun's bounding mask is a powerful structural prior that solves color and texture bleeding.
  • Negative learning is crucial: Because CoMat trains on images generated by the diffusion model itself (where objects are frequently missing or wrong), the model gets to learn from its own mistakes. This "negative concept mapping" is something that cannot be easily taught by only training on perfect, real-world image-text pairs.
  • Reward hacking is a major hurdle: The authors found that simply using a captioning model as a reward destroys image fidelity (FID scores worsened from 16.69 to 19.02). Using a discriminator that shares the same architecture as the diffusion model is a highly effective way to keep the generator honest.

Experimental Results

CoMat was applied to both SD1.5 and SDXL and evaluated across challenging benchmarks including T2I-CompBench, TIFA, and DPG-Bench. The fine-tuning strategy yielded state-of-the-art alignment improvements.

Qualitative comparison between SDXL and CoMat-SDXL
  • Massive Attribute Binding Boosts: On T2I-CompBench, CoMat-SDXL improved color binding scores from 0.5879 to 0.7827 and spatial relationship scores from 0.2131 to 0.2428 compared to base SDXL.
  • Breathing Life into Older Models: CoMat-SD1.5 improved its TIFA score by +7.4 points (78.4 to 85.8), making the older SD1.5 architecture highly competitive with newer models like PixArt-\u03b1 and Playground-v2.
  • Generalization to Dense Prompts: Even though CoMat was trained on standard prompts, it generalized beautifully to the dense, paragraph-long prompts in DPG-Bench, improving SDXL's score from 74.65 to 77.13.

Limitations and Future Work

While highly effective, CoMat does face a few limitations. The Attribute Concentration module relies on a segmentation model; if a prompt contains multiple objects with the same noun (e.g., "an Asian girl with an Indian girl"), the segmenter cannot differentiate them, meaning CoMat struggles to assign the correct attributes to each specific instance. Additionally, because the fine-tuning process requires unrolling the full iterative denoising process to generate an image for the I2T model to evaluate, training is computationally expensive.

Future work will explore using Multimodal Large Language Models (MLLMs) to provide even finer-grained guidance than standard captioning models, as well as adapting these alignment modules for text-to-video diffusion.

Summary updated

BibTeX
@inproceedings{jiang2024comat,
  author = {Dongzhi Jiang and Guanglu Song and Xiaoshi Wu and Renrui Zhang and Dazhong Shen and Zhuofan Zong and Yu Liu and Hongsheng Li},
  title = {{CoMat: Aligning Text-to-Image Diffusion Model with Image-to-Text Concept Matching}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=OW1ldvMNJ6},
}
Figure