In stable diffusion, a negative prompt can be used to specify elements that should not be part of the generated image.
Example:
Prompt: Portrait photo of a man
Negative Prompt: mustache
The negative prompt is often necessary because most models have difficulties interpreting the following prompt correctly
Prompt: Portrait photo of a man without mustache
and instead generate images of men with mustaches.
With LLMs, it is apparently also possible to specify a negative prompt (for example, with Text generation web UI).
I would like to know how they work.
My current understanding of LLMs is that the prompt, along with the previous chat and other contextual information, forms the context. Based on this context, the model generates the token that is most likely to follow the context. It will then append this token to the context and generate the next token and so on.
Where in this process does the negative prompt come in?
If negative prompts are simply inserted into the context, they seem redundant, since we could just include them directly in the prompt.