huggingface/transformers · error · ValueError

`min_eos_p` has to be a positive float, but is {min_eos_p}

Error message

`min_eos_p` has to be a positive float, but is {min_eos_p}

What it means

Error "`min_eos_p` has to be a positive float, but is {min_eos_p}" thrown in huggingface/transformers.

Source

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

    Args:
        eos_token_id (`Union[int, list[int], torch.Tensor]`):
            The id(s) of the *end-of-sequence* token.
        min_eos_p (`float`, *optional*):
            Minimum end of speech threshold.
    """

    def __init__(self, eos_token_id: int | list[int] | torch.Tensor, min_eos_p: float, device: str = "cpu"):
        if not isinstance(eos_token_id, torch.Tensor):
            if isinstance(eos_token_id, int):
                eos_token_id = [eos_token_id]
            eos_token_id = torch.tensor(eos_token_id, device=device)
        self.eos_token_id = eos_token_id

        if torch.is_floating_point(eos_token_id) or (eos_token_id < 0).any():
            raise ValueError(f"`eos_token_id` has to be a list of positive integers, but is {eos_token_id}")

        if min_eos_p is not None and min_eos_p <= 0:
            raise ValueError(f"`min_eos_p` has to be a positive float, but is {min_eos_p}")
        self.min_eos_p = min_eos_p

    @add_start_docstrings(LOGITS_PROCESSOR_INPUTS_DOCSTRING)
    def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
        scores_processed = scores
        if self.min_eos_p:
            probs = torch.nn.functional.softmax(scores.float(), dim=-1)
            # create scores full of -inf except for the eos_token_id
            early_stop_scores = torch.ones_like(scores) * -float("inf")
            early_stop_scores[:, self.eos_token_id] = scores[:, self.eos_token_id]

            do_early_stop = probs[:, self.eos_token_id] > self.min_eos_p
            do_early_stop = torch.any(do_early_stop, dim=1, keepdim=True)
            scores_processed = torch.where(do_early_stop, early_stop_scores, scores)

        return scores_processed

View on GitHub (pinned to a597f97485)

Solutions

  1. Set `min_eos_p` to a positive float (e.g. 0.1).
  2. Remove `min_eos_p` if you do not want probability-based early stopping.

When it happens

Trigger: Raised in MinEosProbabilityLogitsProcessor (or equivalent early-stop processor) when min_eos_p is not a positive float.

Common situations: Setting min_eos_p to 0, a negative number, or a non-float when configuring early stopping on EOS probability.


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