r/StableDiffusion • u/Wiskkey • Aug 10 '22
Discussion The maximum usable length of a Stable Diffusion text prompt is purportedly 77 tokens. Here is what that means, and how to test how many tokens are in your text prompt.
According to this document "Your prompt must be 77 75 tokens or less, anything above will be silently ignored". I don't know offhand what tokenizer Stable Diffusion uses, but perhaps it's the same as this tokenizer, which also counts the number of tokens for a given text string. If that is the same tokenizer (?), then see my comments in this post for a method of probing the token limit, and also more information about what tokens are.
EDIT: According to another user's comment, the tokenizer used by Stable Diffusion is different from the tokenizer I mentioned above.
8
u/greykher Sep 22 '22
I know this thread is a bit old, but I was having trouble recreating some of my old images to test out upscaling on them, and a change to the max token length has resulted in not being able to recreate the images anymore. The max token size was reduced from 77 to 75, making it impossible to recreate older creations if they happen to now exceed the new token size.
Just thought I'd pass this along, in case anyone else has run into the inability to reproduce any of their old works.
3
u/Caffdy Sep 26 '22
so, can I then stop using commas?
2
u/VaporWaveChillaxer Sep 26 '22
GPT tokenizer (which is not the SD tokenizer, but...) seems to imply that maybe the "diffuse, masterpiece, highly detailed, intricate, sense of scale, 4k, 8k, Octane render, volumetric lighting, Unreal Engine, <by 12 different artists>" prompt stuffing is basically useless since the first "stunning beautiful symetrical portraint (yes, with the mispellings) greg rutkowski, greg_rutkowski, of a gorgeous young anime girl, full body, beautiful face", parts may have already blown the token limit if tokens aren't full_words or whatever.
Curious how that works for negative prompts as well. Do they come "last" in the order and generally get truncated\ignored by tokens already being maxed out?
1
u/ts4m8r Aug 20 '22
Does that mean 77 letters?
2
u/Ok_Marionberry_9932 Aug 31 '22
Super helpful link, thanks!
0
u/[deleted] Mar 02 '24
[deleted] — view deleted comment