Weight Syntax for Stable Diffusion Prompts

Crafting effective prompts is critical for generating high-quality images with Stable Diffusion. Understanding the various syntax options for adjusting prompt weights allows more precise control over the AI’s focus and attention. This guide will provide an overview of key weighting techniques, along with examples and tips for prompt engineering.

Basic Weighting Syntax

The most basic way to adjust weights is by adding + or - symbols:

cat playing chess+

Adding + after a word or phrase tells Stable Diffusion to place more emphasis and attention on that element. The more + symbols, the higher the weight.

Conversely, adding - reduces the weight and makes an element less prominent. Multiple - symbols further decrease weight.

You can also use numbers from 0 to 2 instead, with 1 being the default:

cat playing (chess:1.2)

Higher numbers increase weight, while lower numbers reduce it. The numeric scale allows more granular control over weights.

Nesting Weights

Prompt weights can be nested to separately control elements:

(cat:1.5) playing (chess:0.8)

Here the cat’s weight is increased while the chess game’s presence is downplayed. Nesting provides precision when adjusting multiple aspects independently.

Advanced Weighting Techniques

In addition to basic weighting, Stable Diffusion offers advanced syntax for fine-tuning prompt attention and emphasis.

Dynamic Weighting

Dynamic weighting automatically adjusts prominence based on textual similarity. Words that appear multiple times gain more weight:

A red red apple on a table

Here “red” is emphasized and weighted higher than other words since it’s repeated. This technique lets the prompt itself determine weights dynamically.

Soft Prompts

Soft prompts downweight unwanted elements without fully removing them:

Beautiful woman, (ugly:-5)

The (ugly:-5) soft prompt reduces the likelihood of ugliness but doesn’t prohibit it outright. Soft prompts provide more creative freedom to the AI.

Weight Decay

Adding {weight_decay:n} applies exponential decay to weights as tokens pass through Stable Diffusion’s attention layers. Higher decay values focus attention on early words:

{weight_decay:0.8} cat playing chess

This front-loads emphasis onto “cat” rather than later words. Weight decay concentrates priority based on position.

Prompt Ordering

Word order also impacts weighting, with initial words receiving priority. Place the most important guidance first:

chess grandmaster cat

Here “chess grandmaster” will take precedence over “cat” since it appears earlier.

Summary

  • Use + and - to increase/decrease weights
  • Numbers from 0 to 2 provide more precise control
  • Nest weights with parentheses for independent adjustments
  • Dynamic weighting automatically emphasizes repetitions
  • Soft prompts downweight elements without removing them
  • Weight decay focuses attention on early words
  • Prioritize key guidance by placing it first

Carefully engineered weighting directs Stable Diffusion’s attention, leading to outputs better matched to your creative vision!

Useful Resources