Skip to content

Prompting basics

stassius edited this page May 28, 2023 · 7 revisions

What is prompt?

Imagine a giant geographic map and you want to find the coordinates of a buried treasures (your perfect image). You start at the point with coordinates (0,0). Each word in your prompt says which direction and how far you should go from your current location. Some words have more weight, they can drastically change your direction, some of them refine your position a bit. If you fancy math, think of words in your prompt as vectors. By altering your prompt, adding new words, you can find any possible image on this map. Good luck in the treasure hunting!

How to compose prompts?

There are many different resources on this topic. I would recommend reading this short "book": https://openart.ai/promptbook

Overall the prompt structure often ends up being like this:

MEDIUM (painting, photo, drawing) of an ADJECTIVE (green, big, red-haired) OBJECT (cat, Darth Vader, anime girl), DETAILS (wearing a hat, holding a gun), STYLE (by Greg Rutkowski, in style of Dali).

You can find a lot of prompt examples all over the internet, for example here: https://openart.ai/

What is negative prompt?

As we discussed earlier, each word leads you to some direction on the treasure map. Words in a negative prompt will move you in the opposite direction. So if you don't want to get black and white image, add black and white to your negative prompt, it should help. Don't underestimate the power of negative prompts. They can help you find your treasure quickly.

Is there a specific syntax for the prompts?

Yes, there is. In Automatic1111 you can use a couple of tricks to make your treasure hunting more controllable. For example, emphasis. It lets you increase or decrease a weight of a word or group of words. In order to use it you can put round brackets around your word and add a weight after a colon. a painting of a (cat:1.4) will raise the weight of the word "cat". an (oil painting:0.25) of a cat will decrease the weight of the words "oil painting".

It's a very important part of prompting. In Automatic webui you can select a word and press Ctrl+Up or Down to add the brackets and change the weight.

Is there a limit to the prompt size?

In the standard Stable Diffusion the prompt limit is 75 tokens. Token roughly equals to one word. But in A1111 there is no limit at all. Big prompts will be divided to 75-token chunks which will be processed together. There is even a special word BREAK to start a new chunk. Sometimes it could help with "color bleeding" effect, when different parts of your prompt start to influence each other.

How to use prompts in Stable Houdini?

The easiest way is to add them directly on the SD Dream node when the Prompt Source is set to "Custom". But I suggest to switch it to "Upstream attribute". This way you can read prompts from attributes: "prompt" for positive and "negprompt" for negative by default (you can change these names). There is a node called SD Prompt. It lets you compose your prompt and save it to the attribute.

image

To add a negative prompt just change the Attribute name to "negprompt".

image

Note that you can add multi-line text in the prompt field. All the carriage returns will be changed to spaces in the final prompt assembly process. You can chain SD Prompt nodes and the prompt string will append or prepend based on the Concatenation Type parameter. Prompts will be divided with the Separation symbol (comma by default).

image

Inside the prompt you can use all the A1111 syntax options. Also there is a slider called "Prompt strength". It adds round brackets around the whole prompt and change the weight accordingly.

image

How to read prompts from file?

Create a text file with each line being a separate prompt. Put down a CSV Input node. Select CSV Source: Custom File Path, choose your file. Add One Column to extract and name the attribute "prompt". After cook it will create as many tasks as there are lines in your file, and each task will have its own prompt.

image

What are custom values?

In Stable Houdini you can substitute parts of your prompt with new values. For example, add new Custom strings.

image

After that you can use them in your prompt by adding @0 for the first one and @1 for the second. Also Houdini expressions in backticks work to. For example you can put something like this: @'@pdg_index%ch("customStrings")'. Note that there are backticks around the expression. This expression will be looping through the custom strings based on the task number.

image

How to animate prompts?

You can use a float Custom Value in order to animate weights of words or even Loras and Hypernetworks.

In order to do this, add a Custom Value and tick Use Ramp. After that you can put #0 to your prompt in order to get the numeric value from this ramp. The syntax is as follows: #N means reading the value number N. #!N means read this value and multiply it by -1.

The value from the ramp is sampled based on the Normalized time parameter. You should put an expression there, for example @pdg_index/59 If you got 60 tasks it will be changed to a value between 0 and 1. Or you can tie this parameter to the number of tasks created by Generic Generator: @pdg_index/(ch("../genericgenerator1/itemcount")-1)

For example to get a sequence of a dog turning into a cat, use these values:

image

The result would look like this:

prompt_animation_1.mp4

Alternatively you can use a Wedge node and create your own animated value there. Put it directly in the Value field without "Use Ramp".