What Punctuation Does Stable Diffusion Use and Know?

The In-Depth Guide to Prompt Punctuation

Hello, padawan. You’ve leveled up from the basics of prompt writing and now you’re ready for the intermediate tips, yes? Good…that is good.

It’s time for you to understand how punctuation marks are used in Stable Diffusion. There are a handful that really matter when it comes to modifying your prompts. But which ones? In this guide, we’ll go over the punctuation marks that can affect your AI art and how to use them.

Model Usage Disclaimer

Quick note: I just want you to know that the example images found throughout this guide were generated using a custom model named DreamShaper. Not for any particular reason…I just like that model a lot and I got bored with the base version of Stable Diffusion. So if you want to copy any of my prompts, you’ll get similar results by using the same model.

What Punctuation Does Stable Diffusion Understand?

Stable Diffusion does have built-in functions for a few punctuation marks. This means that, by adding them into your prompts, they will cause a specific effect on your output images. Not all of the marks on this list do have a specified function, but some of them are used for other prompting reasons (I’m looking at you, comma).

The punctuation marks most commonly used in Stable Diffusion:

  1. Commas
  2. Parentheses
  3. Brackets
  4. Curly Brackets
  5. Colons
  6. Carets (or Chevrons)

Commas, Yay or Nay?

So what are commas used for in Stable Diffusion?

Commas are used as separators. They will divide up keywords in your prompt so it’s easier for you to read and comprehend. However, that does not mean Stable Diffusion knows which words to associate with each other based solely on commas. In fact, you can put in the same words in the same order with a variety of different commas and still get a similar image.

Why is that? Because The NLU language model that trained Stable Diffusion is statistical in nature, not intuitive like a human mind. Ittaught Stable Diffusion to associate certain word groupings with certain images and make inferences as to how they relate to each other.

Think the way that content tagging works. When posting on social media, you may put multiple tags on a pictures or video that describe the content. Well, when the algorithm was trained, it was given pairs of an image with a set of word tags. That is how Stable Diffusion knows what certain words, phrases, and even sentences may mean.

So commas will make your prompts more legible, but they are not actually necessary for the AI to understand your requests.

Comma Placement Example

Let’s look at an example. The following prompts have the same words but mean comma locations:

  • portrait of a woman, dark hair, blue sweater
  • portrait of a woman dark, hair blue, sweater
  • portrait of a woman dark hair blue sweater

To our human brains, it would look like the modifier words are changing subjects (in the first version, “blue” is paired with “sweater”, but in the second version “blue” is now modifying “hair”). But Stable Diffusion doesn’t look at the commas as separators like we do. For every prompt, Stable Diffusion gave us results of a woman with dark hair and a blue sweater regardless of comma location.

portrait of a woman, dark hair, blue sweaterportrait of a woman dark hair blue, sweaterportrait of a woman dark hair blue sweater

In summary, Stable Diffusion doesn’t really care about commas. But you can use them to organize your prompts for your own orderliness. Of course, any little change in the exact wording of a prompt will change the output image; but the example clearly shows that Stable Diffusion retains the general understanding of our prompt’s content based on what word pairs it expects.

What Do Parentheses Do in Stable Diffusion?

Parentheses in Stable Diffusion control the emphasis of words and phrases.

Whatever you put inside a set of parentheses will get more attention from the AI algorithm and will, therefore, be more prominent in your output images. You can also put multiple sets of parentheses around a word to really ramp up the effect. For more information on this, I have an article all about emphasis.

city in Autumn, coffee shop, street view, intricate, digital paintingcity in Autumn, ((((coffee shop)))), street view, intricate, digital painting

What are Brackets Used For?

Opposite to parentheses are the humble brackets. In Stable Diffusion, brackets are used to de-emphasize a word. If a certain word or phrase is too strong in a prompt (perhaps it’s overpowering other words), then you can use a pair of brackets to weaken it’s attention during generation.

city in Autumn, coffee shop, street view, intricate, digital paintingcity in [[[[Autumn]]]], coffee shop, street view, intricate, digital painting

Curly Brackets (Depends on the Repo)

Curly Brackets (look like { }, just so we’re clear) modify prompts in different ways depending on which interface of Stable Diffusion you are using.

Curly Brackets in Automatic1111 Web UI

In Automatic1111’s web interface, curly brackets are used for designing CSV Styles. In short, you can save a pre-made prompt into a styles file. You can then select that “Style” option in the dropdown options just below the Generate button. When you add a style, Stable Diffusion will add the text of that style to the end of your current prompt.

For example, let’s say you make a style prompt that says “blue sweater, in a cafe”. And you enter the following as your prompt: “Portrait of Jennifer Connelly”. If you then select your blue sweater style as “Style 1” and hit generate, here’s the actual prompt that Stable Diffusion will work from:

Portrait of Jennifer Connelly, blue sweater, in a cafe

The part I made bold is just to clarify that’s the part appended to your prompt by the CSV style.

So where do the curly brackets come in? I can write a style that has the term {prompt} in it. By doing that, it will not take whatever your prompt may be and insert it into the style in place of the {prompt} tag. Here’s an example:

CSV Style: Portrait of {prompt} in a blue sweater, in a cafe

Your prompt: Jennifer Connelly

What Stable Diffusion is seeing as the whole prompt: Portrait of Jennifer Connelly in a blue sweater, in a cafe

Curly Brackets in Novel AI

Novel AI is a company that offers an image generation service based on a custom-trained model of Stable Diffusion. Their web interface uses curly brackets for emphasis instead of parentheses.

So if you happen to be using their online service, just substitute ( ) with { } and you’ll get increased attention on whatever is within those brackets.

How Do You Use Colons in Stable Diffusion?

Colons are used to apply specific numerical values to custom blends and emphasis settings. This is a more advanced topic, but I’ll try to summarize it here.

Emphasis with Colons

Let’s say you want to add attention to a word in your prompt. Normally, you can just throw some parentheses around the word. However, Automatic1111’s web UI has another feature: you can use just one set of parentheses, a colon, and then a decimal point value to specify how much you want that word emphasized. And this works for both increasing and decreasing attention. The formatting would be:

  • Phrase you want emphasized = (word:#)
  • A # value higher than 1 will increase attention to the word
  • A # value lower than 1 will decrease attention to the word
Example prompt: portrait of a woman, dark hair, blue sweater, with (freckles:1.5)
  • This would increase attention on the word “freckles” by a factor of 1.5
Example prompt: portrait of a woman, dark hair, blue sweater, with (freckles:0.25)
  • This would decrease attention on the word “freckles” by a factor of 4 (1/0.25)
portrait of a woman, dark hair, blue sweater, with frecklesportrait of a woman, dark hair, blue sweater, with (freckles:1.5)portrait of a woman, dark hair, blue sweater, with (freckles:0.25)

Subject Switching with Colons

Colons work in a very similar way to “switch out” subjects. That means you can get Stable Diffusion to mix together two subjects in the same image by changing them partway through processing. Let’s say you want the previous portrait example to look like a mixture of Jennifer Connelly and Ana de Armas. You can tell Stable Diffusion to start the image based on Connelly, but then switch to Armas after a certain number of steps.

Here’s the formatting for a blend:

(Subject1:Subject2:#steps)

If you enter “10” as your # of steps and set Stable Diffusion to use 20 steps, then that means the AI will process the image with Subject1 for 10 Steps and then Subject2 for the last 10 steps. Using the portrait example that I start with, it would be formatted as:

Portrait of [Jennifer Connelly:Ana de Armas:10], dark hair, blue sweater

Instead of using a specific number of steps, you can also use a decimal value. In that case, you could choose for the AI to spend 75% of the steps on Connelly and the remaining 25% on Armas. In that situation, your prompt would be:

Portrait of [Jennifer Connelly:Ana de Armas:0.75], dark hair, blue sweater

And in case you wanted to see how those would look…

Portrait of [Jennifer Connelly:Ana de Armas:10], dark hair, blue sweater

Portrait of [Jennifer Connelly:Ana de Armas:0.75], dark hair, blue sweater

Make sure that the colon is always touching both sides of the text; don’t leave any spaces.

Carets/Chevrons for Embeddings

Carets (also know as chevrons or angle brackets) are used to call up a textual inversion embedding within your prompt. Carets look like this: < >

If you want to use a textual inversion embedding in a prompt, then you can add the embedding’s token identifier keyword inside a pair of carets.

For example, let’s say you have an embedding of Emma Watson and you want to invoke it in your prompt (almost all the embeddings I’ve seen were for female celebs, so just go with it). In this example, let’s say the token identifier is “Emwatson”. So your prompt that would initiate the embedding would look like this:

Portrait of <emwatson>, streets of London, photo

Other Alleged Punctuation Tricks

I’ve seen claims that other punctuation marks can add further emphasis to a word. For example, this Twitter user suggests that adding exclamation points to a word increases it’s attention in the prompt. However, I do not think that’s necessarily the case.

In the examples that user provides, the images are changing as he adds more exclamations. But that’s because the output image will always change if you make even a single small edit to the prompt. You could literally add a gibberish word to your prompt and it would give you a different image, too! When I tested out exclamation points in a prompt, I could not see any significant emphasis on the word it was attached to.

So there may be an impact of using other punctuation marks in prompts, but because ANY change to a prompt will give different results it’s almost impossible to prove it objectively.

Unless I see actual documentation from the makers of these AI models specifying the effects of a specific punctuation mark (like we have for parentheses and brackets), then I’m apt to believe it’s not really emphasizing like some would purport.

Conclusion

And that covers all the punctuation marks that you need to know for making awesome art in Stable Diffusion. Thanks for sticking around. If you found this guide helpful, I have a few more you may like: