Civitai’s Prompt-Crafting Guide: Part 2 – Intermediate

Last UpdatedChanges
10/26/2023First version published

Intermediate Techniques

In Part 1 of our Prompt-Crafting Guide (http://education.civitai.com/civitais-prompt-crafting-guide-part-1-basics) we discussed the very essential elements of a Prompt; the constituent parts, how to structure an effective prompt, and some fundamental knowledge to getting started crafting the perfect scene.

In this guide we’re discussing a slightly more advanced technique that’s essential for any Prompter: adding emphasis, also known as Attention, to specific tokens in your prompt. By doing this, we can effectively highlight or downplay certain elements, giving us control over the final image that gets generated.

Understanding how to use emphasis effectively can drastically improve the precision and impact of our artworks.

Token Weighting & Emphasis

Depending on the platform or interface you’re using to create art, the way we implement emphasis can differ. However, if you’re working with Automatic1111‘s Web UI or using Civitai.com‘s On-Site Generator – as well as many other similar interfaces – the syntax is standard.

Emphasis

To increase a model’s attention to specific tokens, you can use parenthesis ( ). Alternatively, if you want to reduce a model’s attention to a certain token, you can use square brackets [ ]. This syntax was the original method of emphasis, and is still used (and effective!) in most of the Stable Diffusion interfaces.

The more parenthesis we add to our token, the more attention is given. We can include parenthesis, and square brackets, up to four times (((( )))), [[[[ ]]]]

The following table explains exactly how much each set of parentheses or square brackets increases (or reduces) attention;

Emphasis SyntaxEffect
a (token)Increases attention to the wrapped token by a factor of 1.1
a ((token))Increases attention to the wrapped token by a factor of 1.21 (1.1 * 1.1…)
a [token]Decreases attention of the wrapped token by a factor of 1.1
a [[token]]Decreases attention of the wrapped token by a factor of 1.21 (-1.1 * -1.1…)
a \(token\)Escapes the parenthesis characters to allow ( ) in our prompts, without applying emphasis.

Examples of Emphasis in Prompts

The following (extreme!) example shows how much we can vary an image by adding emphasis. The token stars is shown de-emphasizing the prevalence of stars in the first image, and significantly boosting the quantity and prevalence of stars, both in the background and foreground.

…statement sunglasses, in a park, sky, trees, moonlight, [stars], vivid colors…
…statement sunglasses, in a park, sky, trees, moonlight, ((((stars)))), vivid colors…

Token Weighting

Token Weighting works on exactly the same principle as the parenthesis emphasis syntax, but is a later addition to Stable Diffusion interfaces, and is far more common to see in prompts, having become the de-facto standard.

A token is weighted with the syntax (token:n.n), n being the desired factor of attention. Generally, when weighting tokens, we stay within the (token:0.5) to (token:1.6) range, as higher and lower values may produce unexpected results in our images!

Finding the “correct” Weight for a particular image requires trial and error, but it largely boils down to personal preference for particular features in the image.

The following table shows the syntax and the effect upon the token;

Emphasis SyntaxEffect
tokenIf a weight is not specified, a token is assumed to be 1.0 strength
(token:1.5)Increases attention to the wrapped token by a factor of 1.5
(token:0.25)Decreases attention to the wrapped token by a factor of 4 (1/ 0.25)

Examples of Token Weighting in Prompts

The following examples show the progression from a very low weight (moonlight:0.3) to an extremely high weight (moonlight:1.7), with the effect it has on our image output being immediately apparent;

…statement sunglasses, in a park, sky, trees, (moonlight:0.3), stars, vivid colors…
…statement sunglasses, in a park, sky, trees, (moonlight:1.7), stars, vivid colors…

Token Weighting for LoRA

You’ll often see Weights wrapping LoRA names in prompt, as Weighting is a fantastic way of adjusting the strength of a LoRA in our images. Often, LoRA are very “strong” and can overpower our prompt, or produce visual artifacts and undesirable details. To combat this, it’s common practice to reduce the strength of a LoRA to between 0.6 and 0.8.

This will vary from LoRA to LoRA, so testing and experimentation is required!

The example below shows the effect of a high powered LoRA, vs a slightly down-weighted LoRA , which produces a much more coherent and natural result.

…<lora:FaeTastic2:1.2>…
…<lora:FaeTastic2:0.8>…

Tips & Tricks

  • It’s best not to combine the two methods of weighting! It’s confusing to read, and they may conflict!
  • In many interfaces, selecting a word and using the CTRL + UP ARROW, or DOWN ARROW, will automatically increase the Weight of the selected word by 0.1.
  • Specifying Weight only works with ( ). You cannot use the syntax [token:n.n]

Conclusion

In this guide we’ve looked at an essential aspect of prompting, but there are many, many, advanced prompting techniques, syntax, tips and tricks, which we’ll cover in the final prompt-crafting guide!