Model: Add fallback if negative prompt is empty

Fallback to the BOS token since an empty string won't do anything.
Ideally, an empty negative prompt should not be used, but it's not
the end of the world.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2024-01-02 01:38:03 -05:00 committed by Brian Dashore
parent b378773d0a
commit bbd4ee54ca

View file

@ -585,7 +585,11 @@ class ModelContainer:
if cfg_scale not in [None, 1.0]:
if self.use_cfg:
gen_settings.cfg_scale = cfg_scale
negative_prompt = kwargs.get("negative_prompt")
# If the negative prompt is empty, use the BOS token
negative_prompt = unwrap(
kwargs.get("negative_prompt"), self.tokenizer.bos_token
)
else:
logger.warn(
"CFG is currently disabled. "