Skip to content

Commit

Permalink
Model: Add fallback if negative prompt is empty
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bdashore3 committed Jan 2, 2024
1 parent b378773 commit bbd4ee5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion model.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,11 @@ def generate_gen(self, prompt: str, **kwargs):
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. "
Expand Down

0 comments on commit bbd4ee5

Please sign in to comment.