fix for empty initial string (#665)

This commit is contained in:
Awni Hannun 2024-04-08 10:40:05 -07:00 committed by GitHub
parent c386dd5f5a
commit 1e2f7f50b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -249,7 +249,9 @@ def generate(
if verbose: if verbose:
s = tokenizer.decode(tokens) s = tokenizer.decode(tokens)
if formatter: if not s:
continue
elif formatter:
formatter(s[skip:], prob.item()) formatter(s[skip:], prob.item())
skip = len(s) skip = len(s)
elif s[-1] != REPLACEMENT_CHAR: elif s[-1] != REPLACEMENT_CHAR: