Improving Long-Text Alignment for Text-to-Image Diffusion Models

Luping Liu, Chao Du, Tianyu Pang, Zehan Wang, Chongxuan Li, Dong Xu

Overview

LongAlign introduces a two-pronged strategy to address the "long-prompt problem" in text-to-image (T2I) models. It utilizes segment-level encoding to bypass the 77-token limit of CLIP and a decomposed preference optimization method that prevents the model from overfitting to aesthetics at the expense of text alignment. By fine-tuning Stable Diffusion (SD) v1.5 for just 20 hours, the authors created longSD, a model that outperforms newer foundation models like PixArt-$\alpha$ and Kandinsky v2.2 in following complex, multi-sentence instructions.

The Challenge of Long Prompts

Most popular text-to-image models rely on CLIP as their primary text encoder. While highly effective for short descriptions, CLIP has a strict limit of 77 tokens. When users provide long, descriptive prompts—often necessary for generating complex scenes—the model either truncates the text or loses track of fine-grained details.

While some newer models have transitioned to Large Language Model (LLM) encoders like T5 to handle longer sequences, they frequently lose the superior image-text alignment that CLIP’s contrastive pretraining provides. Furthermore, simply fine-tuning models on human preferences often leads to a "reward hacking" problem: the model learns to generate aesthetically pleasing images (e.g., high-quality textures and lighting) but ignores the specific semantic details requested in the prompt.

The LongAlign Methodology

To overcome these limitations, the authors propose two primary innovations:

1. Segment-Level Text Encoding

Instead of attempting to compress a long prompt into a single CLIP forward pass, LongAlign breaks the text into distinct segments (such as individual sentences). Each segment is encoded separately. To merge these encoded segments, the authors developed a specific concatenation strategy that carefully manages special tokens like <sot> (start of text) and <eot> (end of text). This prevents the token "confusion" that typically occurs when these markers are repeated across multiple encoded chunks.

2. Decomposed Preference Optimization

The researchers discovered that CLIP-based preference scores can be mathematically split into two orthogonal components:

  • A text-relevant part: Measures how accurately the image matches the prompt.
  • A text-irrelevant part: Measures general visual quality and aesthetics.

To prevent the model from overfitting to the "text-irrelevant" aesthetic part during fine-tuning, they introduced a gradient reweighting strategy. By applying a specific weight ($\omega$) to the text-irrelevant component, the training process prioritizes strict semantic alignment over mere visual appeal.

Training and Evaluation Datasets

The authors utilized a diverse mix of datasets for training and evaluation:

  • Training: Approximately 2 million images sourced from SAM, COCO2017, LLaVA (a subset of LAION/CC/SBU), and JourneyDB. All images were recaptioned using LLaVA-Next or ShareCaptioner to ensure high-quality, descriptive text pairings.
  • Evaluation: A 5,000-image evaluation dataset was reserved for calculating metrics like FID and Denscore. They also utilized DPG-Bench to assess structural variation (entities, attributes, relations) and employed GPT-4o as an automated judge to compare their model's outputs against established baselines.

Key Insights

  • The "Cone Effect" in CLIP: The paper highlights that CLIP text embeddings tend to cluster in a narrow "cone" within the representation space. The common direction (the center of the cone) largely represents text-irrelevant features. By identifying this direction, the researchers can isolate the actual semantic "meaning" of the prompt from aesthetic noise.
  • Aesthetics vs. Alignment: Fine-tuning often fails because the gradient from the aesthetic component is significantly stronger than the alignment component. Reweighting these gradients is essential for stable, alignment-focused training.
  • Weakly Supervised Segment Training: The segment-level loss allows the model to learn from long prompts without requiring expensive, manually annotated segment-to-image-part labels.

Results and Performance

The resulting model, longSD, demonstrates a dramatic improvement in following complex prompts:

  • Efficiency: The model was trained on 6 A100 GPUs for only about 20 hours, proving highly resource-efficient.
  • Alignment: In GPT-4o-based evaluations, the fully equipped model (longSD with segment encoding and reweighting) significantly outperformed SD-1.5, PixArt-$\alpha$, and Kandinsky v2.2 in strict T2I alignment.
  • Image Quality: On the 5k evaluation dataset, longSD achieved a Frechet Inception Distance (FID) of 19.63, beating the original SD-1.5 (24.96) and even surpassing the much larger SDXL (21.18) in specific benchmarks.

Limitations and Future Work

While LongAlign significantly pushes the boundaries of CLIP-based diffusion models, inherent constraints remain. CLIP’s fundamental architecture still limits the model's ability to understand extremely complex contextual dependencies or deep semantic nuances. Future work will likely explore more powerful training strategies that move beyond CLIP-based preference models entirely, potentially integrating sophisticated LLM-based feedback loops to further refine how models interpret the "long tail" of complex human language.

BibTeX
@inproceedings{liu2025improving,
  author = {Luping Liu and Chao Du and Tianyu Pang and Zehan Wang and Chongxuan Li and Dong Xu},
  title = {{Improving Long-Text Alignment for Text-to-Image Diffusion Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=2ZK8zyIt7o},
}
Figure