PaddlePaddle/PaddleOCR · error · InvalidRequestError

temperature must be greater than or equal to 0.

Error message

temperature must be greater than or equal to 0.

What it means

InvalidRequestError raised by _validate_vl_options when PaddleOCRVLOptions.temperature is negative. Temperature controls sampling randomness and must be >= 0; negative values are rejected before the request leaves the client.

Source

Thrown at paddleocr/_api_client/models.py:190

    payload = {}
    for field in fields(options):
        value = getattr(options, field.name)
        if value is None:
            continue
        if field.name == "extra_options":
            payload.update(value)
        else:
            payload[snake_to_camel(field.name)] = value
    return payload


def _validate_vl_options(options: PaddleOCRVLOptions) -> None:
    if options.top_p is not None and not (0 < options.top_p <= 1):
        raise InvalidRequestError(
            "top_p must be greater than 0 and less than or equal to 1."
        )
    if options.temperature is not None and options.temperature < 0:
        raise InvalidRequestError("temperature must be greater than or equal to 0.")
    if options.repetition_penalty is not None and options.repetition_penalty <= 0:
        raise InvalidRequestError("repetition_penalty must be greater than 0.")
    if options.min_pixels is not None and options.min_pixels <= 0:
        raise InvalidRequestError("min_pixels must be greater than 0.")
    if options.max_pixels is not None and options.max_pixels <= 0:
        raise InvalidRequestError("max_pixels must be greater than 0.")
    if (
        options.min_pixels is not None
        and options.max_pixels is not None
        and options.min_pixels > options.max_pixels
    ):
        raise InvalidRequestError("min_pixels cannot be greater than max_pixels.")

View on GitHub (pinned to 2661c7c0ef)

Solutions

  1. Use temperature=0.0 or a positive float
  2. Clamp computed values: max(0.0, t) before constructing options

Example fix

# before
options = PaddleOCRVLOptions(temperature=t_base - t_delta)
# after
options = PaddleOCRVLOptions(temperature=max(0.0, t_base - t_delta))
Defensive patterns

Strategy: validation

Validate before calling

if options.temperature is not None:
    options.temperature = max(0.0, float(options.temperature))

Try / catch

from paddleocr._api_client.errors import InvalidRequestError

try:
    run(options)
except InvalidRequestError as e:
    if 'temperature' in str(e):
        options.temperature = 0.0
        run(options)
    else:
        raise

Prevention

When it happens

Trigger: PaddleOCRVLOptions(temperature=-0.5); computing temperature arithmetically (e.g. base - delta) that underflows below zero.

Common situations: Dynamic temperature schedules that subtract too much; sign errors when porting configs from other frameworks.

Related errors


AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14). Data as JSON: /api/errors/79097e90ad057b1d. Report an issue: GitHub.