Unverified Commit b1198a84 authored by Will Frey's avatar Will Frey Committed by GitHub
Browse files

Update generation_logits_process.py (#12671)

If you're using type hints, then passing an `int` where a `float` is annotated is acceptable as per [PEP 484](https://www.python.org/dev/peps/pep-0484/#the-numeric-tower).

This makes life a little nicer.
parent 0245cee4
...@@ -184,7 +184,8 @@ class TopPLogitsWarper(LogitsWarper): ...@@ -184,7 +184,8 @@ class TopPLogitsWarper(LogitsWarper):
""" """
def __init__(self, top_p: float, filter_value: float = -float("Inf"), min_tokens_to_keep: int = 1): def __init__(self, top_p: float, filter_value: float = -float("Inf"), min_tokens_to_keep: int = 1):
if not isinstance(top_p, float) or (top_p < 0 or top_p > 1.0): top_p = float(top_p)
if top_p < 0 or top_p > 1.0:
raise ValueError(f"`top_p` has to be a float > 0 and < 1, but is {top_p}") raise ValueError(f"`top_p` has to be a float > 0 and < 1, but is {top_p}")
self.top_p = top_p self.top_p = top_p
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment