huggingface/transformers · error · ValueError

greenlist_ratio has be in range between 0.0 and 1.0, exclusi

Error message

greenlist_ratio has be in range between 0.0 and 1.0, exclusively. but found {greenlist_ratio}

What it means

Error "greenlist_ratio has be in range between 0.0 and 1.0, exclusively. but found {greenlist_ratio}" thrown in huggingface/transformers.

Source

Thrown at src/transformers/generation/logits_process.py:2464

    >>> detection_preds
    array([ True])
    ```
    """

    def __init__(
        self,
        vocab_size,
        device,
        greenlist_ratio: float = 0.25,
        bias: float = 2.0,
        hashing_key: int = 15485863,
        seeding_scheme: str = "lefthash",
        context_width: int = 1,
    ):
        if seeding_scheme not in ["selfhash", "lefthash"]:
            raise ValueError(f"seeding_scheme has to be one of [`selfhash`, `lefthash`], but found {seeding_scheme}")
        if greenlist_ratio >= 1.0 or greenlist_ratio <= 0.0:
            raise ValueError(
                f"greenlist_ratio has be in range between 0.0 and 1.0, exclusively. but found {greenlist_ratio}"
            )

        self.vocab_size = vocab_size
        self.greenlist_size = int(self.vocab_size * greenlist_ratio)
        self.bias = bias
        self.seeding_scheme = seeding_scheme
        self.rng = torch.Generator(device=device)
        self.hash_key = hashing_key
        self.context_width = context_width

        self.rng.manual_seed(hashing_key)
        self.table_size = 1_000_003
        self.fixed_table = torch.randperm(self.table_size, generator=self.rng, device=device)

    def set_seed(self, input_seq: torch.LongTensor):
        input_seq = input_seq[-self.context_width :]
        if self.seeding_scheme == "selfhash":

View on GitHub (pinned to a597f97485)

Solutions

  1. Set `greenlist_ratio` to a float strictly between 0.0 and 1.0 (default 0.25).

When it happens

Trigger: Raised in WatermarkLogitsProcessor.__init__ when greenlist_ratio is outside the exclusive range (0.0, 1.0).

Common situations: WatermarkingConfig.greenlist_ratio set to 0, 1, or a value outside (0,1).


AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14). Data as JSON: /api/errors/f0c0344385a5f5c7. Report an issue: GitHub.