PaddlePaddle/PaddleOCR · error · InvalidRequestError
repetition_penalty must be greater than 0.
Error message
repetition_penalty must be greater than 0.
What it means
InvalidRequestError raised by _validate_vl_options when PaddleOCRVLOptions.repetition_penalty is <= 0. The penalty multiplies token logits, so zero or negative values are invalid; the client enforces positivity before sending.
Source
Thrown at paddleocr/_api_client/models.py:192
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
- Set repetition_penalty to a positive value; use 1.0 for no penalty
- Omit it (None) to accept the server default
Example fix
# before options = PaddleOCRVLOptions(repetition_penalty=0.0) # intended 'off' # after options = PaddleOCRVLOptions(repetition_penalty=1.0)
Defensive patterns
Strategy: validation
Validate before calling
if options.repetition_penalty is not None and options.repetition_penalty <= 0:
options.repetition_penalty = 1.0 # neutral value Try / catch
from paddleocr._api_client.errors import InvalidRequestError
try:
run(options)
except InvalidRequestError as e:
if 'repetition_penalty' in str(e):
options.repetition_penalty = 1.0
else:
raise Prevention
- Use 1.0 to disable repetition penalty, never 0
- Keep sampling params in a dataclass validated at construction
When it happens
Trigger: PaddleOCRVLOptions(repetition_penalty=0) or a negative value; confusing repetition_penalty (typically ~1.0) with a 0-1 penalty fraction.
Common situations: Assuming penalty is a probability-like 0..1 knob and setting 0.0 to 'disable' it (use 1.0 for no penalty instead).
Related errors
- top_p must be greater than 0 and less than or equal to 1.
- temperature must be greater than or equal to 0.
- Resource filename must not be empty.
- min_pixels must be greater than 0.
- max_pixels must be greater than 0.
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/9cbf5ab029c15946.
Report an issue: GitHub.