STEPS: Sequential Probability Tensor Estimation for Text-to-Image Hard Prompt Search

Yuning Qiu, Andong Wang, Chao Li, Haonan Huang, Guoxu Zhou, Qibin Zhao

Abstract

Text-to-image (T2I) diffusion models are highly sensitive to input prompts, yet finding optimal "hard prompts" is challenging due to the discrete and high-dimensional nature of language. We present STEPS (Sequential Probability Tensor Estimation), a framework that treats prompt search as a low-rank tensor estimation problem. By utilizing Tensor Train (TT) decomposition and a memory-bounded sampling strategy, STEPS efficiently navigates the search space, yielding higher-quality images and improved prompt transferability across models.

Introduction

Text-to-image diffusion models like Stable Diffusion have revolutionized content creation, but their performance is tightly coupled with the quality of the input text prompt. Finding the perfect string of words—a "hard prompt"—is notoriously difficult. Standard gradient descent cannot be applied directly to discrete words, and the search space is astronomical; a simple 10-token prompt can involve roughly $4.9 \times 10^{46}$ possible combinations. Previous approaches often relied on greedy coordinate-wise searches that get trapped in local optima or optimized in embedding space, which introduces significant quantization errors when projecting back to discrete tokens.

Methods

The core innovation of STEPS is reformulating prompt search as a Sequential Probability Tensor Estimation problem. This approach moves beyond local, word-by-word updates to model the joint probability of the entire prompt sequence.

Overview of the STEPS framework: (a) the iterative optimization process using Tensor Train decomposition and (b) the generation of images using the learned prompt in Stable Diffusion.

Tensor Train (TT) Decomposition

To manage the massive probability distribution of word combinations, STEPS employs TT decomposition. This mathematical technique represents a high-dimensional tensor as a sequence of small, low-rank "cores." This bypasses the curse of dimensionality, allowing the model to represent complex joint probabilities with linear rather than exponential complexity.

Optimization Strategy

  • Incremental Space Construction: STEPS uses first-order Taylor expansions (gradients) to identify the most promising $k$ candidate tokens at each step, gradually refining the search vocabulary.
  • Memory-bounded Sequential Optimization: To maintain efficiency, the authors introduce a memory budget ($l$). Instead of retaining every word considered, the system resamples a fixed number of high-probability entries from previous iterations. This preserves sequential dynamics without allowing the search space to explode.
  • Core Updates: The TT cores are updated using the Adam optimizer to minimize the negative log-likelihood of prompts that result in images most similar to the target.

Key Insights: The Low-Rank Discovery

A significant empirical finding of this work is that the "loss landscape" of prompts possesses an inherent low-rank structure. By analyzing the singular value distributions of the loss tensor, the researchers proved that prompt optimization can be effectively approximated in a lower-dimensional subspace. This global modeling allows STEPS to explore the search space more effectively than greedy methods.

Singular value distributions across different modes and the overall loss value distribution, providing empirical evidence for the low-rank structure of the prompt search space.

Experimental Results

STEPS was evaluated across six diverse datasets, including MS COCO, Celeb-A, and the I2P (Inappropriate Image Prompts) dataset for safety testing.

  • Superior Image Quality: On the MS COCO dataset, STEPS achieved a cosine similarity of 0.6720, significantly outperforming baselines like PEZ (0.6356) and MMA (0.6485).
  • Cross-Model Transferability: Prompts optimized on Stable Diffusion v2 using STEPS demonstrated better performance when transferred to the larger SDXL v1.0 model compared to other methods. This suggests that STEPS captures generalized semantic patterns rather than over-fitting to a specific model's quirks.
  • Adversarial Robustness: In NSFW "attack" scenarios, STEPS achieved the highest Attack Success Rate (ASR). On SD v2, it reached a 78.50% average ASR, demonstrating its ability to find prompts that circumvent keyword filters to generate prohibited content.

Conclusion

STEPS provides a robust mathematical framework for discrete prompt optimization by leveraging tensor decomposition. While it requires more computational overhead than simple random searches, its ability to capture global dependencies and its superior transferability make it a powerful tool for T2I research. Future work may extend this sequential tensor estimation framework to other discrete optimization domains, such as molecular discovery or architectural search.

Summary updated

BibTeX
@inproceedings{qiu2025steps,
  author = {Yuning Qiu and Andong Wang and Chao Li and Haonan Huang and Guoxu Zhou and Qibin Zhao},
  title = {{STEPS: Sequential Probability Tensor Estimation for Text-to-Image Hard Prompt Search}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.02667},
}
Figure