Add support for spaces_between_special_tokens

This commit is contained in:
Dan Lord
2023-10-30 16:52:56 -07:00
committed by GitHub
parent 79a30912b8
commit 7013a80170
5 changed files with 28 additions and 7 deletions

View File

@@ -71,6 +71,8 @@ class SamplingParams:
`logprobs+1` elements in the response.
prompt_logprobs: Number of log probabilities to return per prompt token.
skip_special_tokens: Whether to skip special tokens in the output.
spaces_between_special_tokens: Whether to add spaces between special
tokens in the output. Defaults to True.
"""
def __init__(
@@ -93,6 +95,7 @@ class SamplingParams:
logprobs: Optional[int] = None,
prompt_logprobs: Optional[int] = None,
skip_special_tokens: bool = True,
spaces_between_special_tokens: bool = True,
) -> None:
self.n = n
self.best_of = best_of if best_of is not None else n
@@ -120,6 +123,7 @@ class SamplingParams:
self.logprobs = logprobs
self.prompt_logprobs = prompt_logprobs
self.skip_special_tokens = skip_special_tokens
self.spaces_between_special_tokens = spaces_between_special_tokens
self._verify_args()
if self.use_beam_search:
@@ -222,4 +226,6 @@ class SamplingParams:
f"max_tokens={self.max_tokens}, "
f"logprobs={self.logprobs}, "
f"prompt_logprobs={self.prompt_logprobs}, "
f"skip_special_tokens={self.skip_special_tokens})")
f"skip_special_tokens={self.skip_special_tokens}, "
"spaces_between_special_tokens="
f"{self.spaces_between_special_tokens})")