Investigating Prompt Engineering in Diffusion Models

Sam Witteveen, Martin AndrewsarXiv 2022

Abstract

With the spread of the use of Text2Img diffusion models such as DALL-E 2, Imagen, Mid Journey and Stable Diffusion, one challenge that artists face is selecting the right prompts to achieve the desired artistic output. We present techniques for measuring the effect that specific words and phrases in prompts have, and (in the Appendix) present guidance on the selection of prompts to produce desired effects.

Introduction

While text-to-image models have revolutionized digital art, the process of "prompting"—choosing the right words to achieve a specific result—remains largely a matter of trial and error. Users often rely on intuition without understanding the underlying mechanics of how specific linguistic categories influence the generated pixels. This research aims to turn this "art" into a science by measuring the semantic and perceptual impact of different word types.

Methodology

The core of the approach is controlled variation. To isolate the effect of a prompt change, the authors:

  1. Fixed the Latents: A specific random seed and consistent scheduler were used to ensure that any change in the output image was strictly due to the text prompt, not random variance.
  2. Differential Prompting: Starting with a base prompt (e.g., "A Mainecoon cat kneeling"), single modifiers or phrases were added.
  3. Perceptual Metrics: The study utilized LPIPS (Learned Perceptual Image Patch Similarity) to measure visual difference and CLIP Cosine Similarity to measure semantic distance between text embeddings.

The study utilized the Stable Diffusion model (v1.4/1.5) and generated a custom dataset of over 15,000 images derived from 2,000 prompt variations.

The Hierarchy of Impact

The research identifies a clear hierarchy in how much a word changes an image: Artists > Nouns > Descriptors.

Frequency histogram comparing the impact of descriptors versus nouns on image similarity. Higher similarity scores indicate less change from the base image.

Quantitatively, the average similarity to the base image was measured as:

  • Descriptors: 0.664 (Least change)
  • Nouns: 0.512 (Significant change)
  • Artists: 0.465 (Most change)

Adding "in the style of [Artist Name]" is the most disruptive change possible, fundamentally altering the geometry and color palette of the subject.

Qualitative Observations

Adjectives like "breathtaking" or "intricate" have a surprisingly low impact on overall image structure, acting as subtle modifiers. In contrast, lighting prompts (e.g., "cinematic lighting") can be bimodal; some act as subtle descriptors, while others force the model to manifest new physical objects, like lamps, to justify the light source.

Visual comparison of a base prompt ("a mainecoon cat kneeling") modified by various descriptors and style tags.

The study also debunked the "myth of infinite repetition." While users often repeat words to strengthen their effect, the authors found diminishing returns. Eventually, repetition stops refining the style and begins deleting parts of the subject.

Conclusion

The findings indicate that CLIP-based text similarity correlates more strongly with final image changes than other NLP metrics. This suggests that the diffusion model’s internal representations are naturally sensitive to the same semantic distances perceived by CLIP. These metrics could eventually be used as loss functions to create models that are more obedient to specific stylistic descriptors.

Summary updated

BibTeX
@misc{witteveen2022investigating,
  author = {Sam Witteveen and Martin Andrews},
  title = {{Investigating Prompt Engineering in Diffusion Models}},
  year = {2022},
  eprint = {2211.15462},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2211.15462},
}
Figure