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 337e668 commit 9cdfb3d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion model.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,12 @@ 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 9cdfb3d

Please sign in to comment.