Hyphenated Prompts
You may have seen some folks like me using hyphenated prompts or may be you use them yourselves without any real conviction. To the best of my knowledge this is not mentioned in any official SDXL doc either. But it is true that when you join prompt words with hyphens, the AI will treat entire prompt as one compound word describing a single attribute, object, character or action. For example "laced-sleeveless-pink-tank" will be treated as the description of "a tank top that is pink in color, laced and sleeveless". If you are thinking that is ridiculous and ask me why would the AI do this?, then please lookup the dictionary definition of hyphen.
hyphen /hī′fən/
noun
1. A punctuation mark ( - ) used between the parts of a compound word or name or between the syllables of a word, especially when divided at the end of a line of text.
If you really think about it, AI models have been trained to understand languages and long texts easily by feeding it millions and millions of text. It is only natural that it knows what a hyphenated prompt means.
Implicit Weight:
You may already know how an AI is able to understand what we are saying, which is by using weights to group related words and phrases. The sample principle applies for hyphenated prompts. For example, the prompt "laced-sleeveless-pink-tank" will be given (slightly) more weight than the phrase "laced sleeveless pink tank"
Let us actually test this theory.
Prompt: Hyperrealistic photo of (a girl, wearing pink laced sleeveless tank and short red tight), next to (a shih tzu dog, wearing blue scarf)
CFG: 90%
Other than the fact there is a girl and a Shih Tzu in the picture, everything else is wrong. This is because the attributes like blue, pink, scarf are loosely grouped with the subjects and overall prompt. With a high CFG, these attributes are bleeding heavily between the characters. Of course, if you reduce the CFG you may get the expected result, but you may have to try multiple times tweaking the CFG before you get what you wanted.
Now let us try to describe the same scene using hyphenated prompts and let us make sure that we can see the whole body this time, so that we know if she is wearing the right bottom. We will also reduce the CFG rate slightly because hyphenated prompts carry some extra weight, so we don’t have restrict the model too much.
Hyperrealistic full-body photo of (a girl wearing pink-laced-sleeveless-tank and short-red-tight), next to (a shih-tzu-dog wearing blue-scarf)
CFG: 85%
There is still some attribute bleeding between the two characters, but the pic is much more close to the prompt. This time the girl is wearing a pink sleeveless tank and a short red tight pant. The dog is wearing a blue scarf.
Dashes:
Dashes are different from hyphens. The dictionary definition for a Dash is:
"A dash is longer than a hyphen and is commonly used to indicate a range or a pause. The most common types of dashes are the en dash (–) and the em dash
Since the AI model seems to under the use of hyphens, can we use dashes too? For example use the en dash to define a style. Let us test it out:
Example: Using en dash.
Prompt: Professional photography of pre–World War Building.
Example using hyphen
Professional photography of pre-World War Building.
Turns out that there is no difference between using hyphen or dash. But can we mix hyphens and dashes in a prompt to improve the prompt? For example in the last image of that girl with dog, the girl's dress is not laced. Could use a en dash to indicated the laced style? Let us try that:
Prompt: Hyperrealistic full-body photo of (a girl wearing pink–laced–sleeveless-tank and short–torn–red-tight), next to (a shih-tzu-dog wearing blue-scarf).
Nope! mixing dashes and hyphens actually confused the AI, because the general practice is to either use a hyphen (highly recommended) or use dashes. An article that uses both is considered to be poorly written. So I am guessing that AI doesn't like it either. But considering how the attributes such as "blue" or "short" bled into other objects and characters with using dashes, I would recommend sticking to hyphens.
What about SD 1.5?:
Well, I normally only use SDXL checkpoints. But since a few asked this question, I decided to test it out on both stock SD1.5 and DreamShaperV1.8.
Prompt: Hyperrealistic-full-body-photo: a-girl-wearing-pink-sleeveless-tank-and-short-red-pant, a-shih-tzu-puppy-wearing-blue-scarf
Model: DreamShaper V8
Width: 768
Height: 512
Scale: 8.5
Steps: 50
Sampler: DPM++ 2M SDE Karras
I had to change to few things. I had to use ", " instead of ", next to", otherwise the image produced had more girls or dogs or both. But importantly I had to join the character and dress descriptions with hyphens for ex "a-girl-wearing-pink-sleeveless-tank-and-short-red-pant" otherwise the output was completely off. But this means that using hyphenated prompts are better even in SD 1.5, which is the topic of this article. There are still some bleeding of attributes. For ex: the dog's scarf is short and pink (from the girl's dress attributes). Otherwise the picture is spot on!
Hope this helps. Do you have other tips, suggestions or questions? Please drop a comment below.