Stable Diffusion Syntaxis ♥️

Aleksandr Limm
4 min readJan 4, 2024

--

Greetings, dear reader, in this article, I will tell you about different syntaxis available in Stable Diffusion. This helps you to reach more precise and creative results in your artwork. All constructions can be used in Positive and Negative prompts. Have fun.

In Stable Diffusion, a generation comes from the first LEFT word to the last RIGHT word. Each following right word will lay its influence onto all left words. First LEFT words have the strongest impact on Diffusion. Last RIGHT words have the fewest impact on Diffusion.

The prompt length in Stable Diffusion is unlimited if another is not set by your Stable Diffusion provider.

My selection of Stable Diffusion environment is AUTOMATIC1111.

easy setup version, collab version

Stable Diffusion Syntax Delimiters

There are several base delimiters

Dot (.) — Hard separator. This delimiter will prevent diffusion from laying new layers onto the previous tokens. It is majorly used in long prompts with a lot of objects, moods, and stories when proper separation is required.

Comma (,) — Soft separator. This delimiter splits tokens but saves a more coherent link between them. It’s the most often-used delimiter ever.

Bulletin (∙) — Soft separator, but different from “,” it allows to keep the token intact. When there’s no separation to many tokens — Stable diffusion will act more concretely for the exact token, allowing precious pedantical descriptions for some narrow topic/object/mood.

Example: ∙ Apple is red ∙ Apple is tasty ∙ Apple is full of vitamins

— That’s one single token that will draw an Apple filled with many properties you‘ll like.

“BREAK” — Very Hard Separator. This delimiter will prevent diffusion from laying new layers onto the previous tokens. It’s more strong than “.” This delimiter can include additional context descriptions at the end or beginning of the prompt to create some emphasis.

Example: I love this image BREAK Image of sunset on Miami Beach BREAK during our honeymoon year 1985

— At this prompt SD will prioritize drawing an “Image of sunset on Miami Beach” trying to integrate it with the idea that the image belongs to “Honeymoon year 1985” and it should cause “I love this image” feelings.

Stable Diffusion Syntax Constructions

Why use advanced syntax constructions?

  • Extend Imagination
  • More Creativity
  • Create New Concepts

1. Token Weight Control

In Stable Diffusion, you can control how much a certain word or a series of words will impact the end-generation result.

(Word: weight)

Word = any number of tokens

Weight = number in the range of 0 to infinity. Usually, it’s 0.7 to 1.5. More or less will distort the image significantly, try very high/low value, you get it.

This will make Stable Diffusion pay more or less attention to a given word(s).

Example: portrait with flowers: (roses:1.3), pions, tulips, lilies, (lavender:0.8)

— This prompt will create a portrait with flowers, where roses will be presented at 30% more volume than other flowers, and lavender respectively at 20% less volume.

2. Mixing words with the “AND” operator

Stable Diffusion will simultaneously generate a representation of several words on the canvas. Create images purely from imagination!

(word 1 AND word 2)

word 1 and word 2 = any words; You can add as many words as you want.
AND must be strictly written in uppercase.

This syntax will make Stable Diffusion diffuse an entity described as 2 words simultaneously.

Example: (Sun AND Moon AND Stars AND Satellites )

3. Mixing words with the operator “OR”

This will make Stable Diffusion select randomly between words included in construction at each step with equal chance. This is reflected in various randomizations.

( word 1 OR word 2)

word 1, word 2 = any words; You can add as many words as you want.
OR must be strictly written in uppercase.

4. Step-by-step mixing of words in Stable Diffusion.

Stable Diffusion will switch the generated word at each step. This combination allows the mixing of many words.

( word 1 | word 2 )

word 1, word 2 = any words; You can add as many words as you want
| is delimiter

Example: Portrait of (Silvester Stalone|Jason Statham|Leonardo Di Caprio)

- This will draw a portrait featuring the appearance of several people.

5. Generate until N step, then generate another

This construction will generate a concept until a certain step and then switch to another concept.

[ word 1 | word 2: steps fraction %]

word 1, word 2 = any words
steps fraction % = number in between 0.01 to 0.99 (1 to 99%)

Stable Diffusion will generate word 1, and after reaching the threshold mentioned as “steps fraction %” will switch to generate another word 2 at the same place where the previous concept was generated.

For example: [ camel | dog: 0.7 ]

- This prompt will draw the camel until 70% of the steps and then 30% of the steps will be given to the dog. Expect to get a camel with a dog face.

Wildcards

Another must-have thing in Stable Diffusion is Wildcards. They allow to random selection of text values from a list of values at a certain prompt location. Wildcards help you to diversify outputs and speed up production.

Setup Wildcards extension in Automatic1111

Example: a {house|apartment|lodge|cottage} in {summer|winter|autumn|spring} by {2$$artist1|artist2|artist3}

Will produce any of the following prompts:

  • A house in summer by artist1, artist2
  • A lodge in autumn by artist3, artist1
  • A cottage in winter by artist2, artist3

Example: This __fruit__ is __adjective__

__wildcard collection__ is pre-written by you and filled with any words.

Wildcards are stored in the SD folder by path: extension/sd-dynamic-prompts/wildcards

Another reason for using wildcards is the ability to randomly generate prompts using Text AIs. There are several to select from in this extension.

Conclusion

Thank you for reading, I hope this information makes sense to you. Follow me. Visit my profile to learn more interesting things. See ya! ♥️

--

--

No responses yet