Skip to content

Commit

Permalink
API: Fix banned_tokens string when empty
Browse files Browse the repository at this point in the history
The string should not be parsed and any non-string elements should
be removed as well.

Signed-off-by: kingbri <[email protected]>
  • Loading branch information
bdashore3 committed Apr 28, 2024
1 parent 72dff0b commit 6114bfd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions common/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,14 @@ def to_gen_params(self, **kwargs):
self.validate_params()

# Convert stop to an array of strings
if isinstance(self.stop, str):
if self.stop and isinstance(self.stop, str):
self.stop = [self.stop]

if isinstance(self.banned_tokens, str):
self.banned_tokens = list(map(int, self.banned_tokens.split(",")))
# Convert string banned tokens to an integer list
if self.banned_tokens and isinstance(self.banned_tokens, str):
self.banned_tokens = [
int(x) for x in self.banned_tokens.split(",") if x.isdigit()
]

gen_params = {
"max_tokens": self.max_tokens,
Expand Down

0 comments on commit 6114bfd

Please sign in to comment.