{"record":{"id":"79097e90ad057b1d","repo":"PaddlePaddle/PaddleOCR","slug":"temperature-must-be-greater-than-or-equal-to-0","errorCode":null,"errorMessage":"temperature must be greater than or equal to 0.","messagePattern":"temperature must be greater than or equal to 0\\.","errorType":"validation","errorClass":"InvalidRequestError","httpStatus":null,"severity":"error","filePath":"paddleocr/_api_client/models.py","lineNumber":190,"sourceCode":"    payload = {}\n    for field in fields(options):\n        value = getattr(options, field.name)\n        if value is None:\n            continue\n        if field.name == \"extra_options\":\n            payload.update(value)\n        else:\n            payload[snake_to_camel(field.name)] = value\n    return payload\n\n\ndef _validate_vl_options(options: PaddleOCRVLOptions) -> None:\n    if options.top_p is not None and not (0 < options.top_p <= 1):\n        raise InvalidRequestError(\n            \"top_p must be greater than 0 and less than or equal to 1.\"\n        )\n    if options.temperature is not None and options.temperature < 0:\n        raise InvalidRequestError(\"temperature must be greater than or equal to 0.\")\n    if options.repetition_penalty is not None and options.repetition_penalty <= 0:\n        raise InvalidRequestError(\"repetition_penalty must be greater than 0.\")\n    if options.min_pixels is not None and options.min_pixels <= 0:\n        raise InvalidRequestError(\"min_pixels must be greater than 0.\")\n    if options.max_pixels is not None and options.max_pixels <= 0:\n        raise InvalidRequestError(\"max_pixels must be greater than 0.\")\n    if (\n        options.min_pixels is not None\n        and options.max_pixels is not None\n        and options.min_pixels > options.max_pixels\n    ):\n        raise InvalidRequestError(\"min_pixels cannot be greater than max_pixels.\")\n","sourceCodeStart":172,"sourceCodeEnd":203,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_api_client/models.py#L172-L203","documentation":"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.","triggerScenarios":"PaddleOCRVLOptions(temperature=-0.5); computing temperature arithmetically (e.g. base - delta) that underflows below zero.","commonSituations":"Dynamic temperature schedules that subtract too much; sign errors when porting configs from other frameworks.","solutions":["Use temperature=0.0 or a positive float","Clamp computed values: max(0.0, t) before constructing options"],"exampleFix":"# before\noptions = PaddleOCRVLOptions(temperature=t_base - t_delta)\n# after\noptions = PaddleOCRVLOptions(temperature=max(0.0, t_base - t_delta))","handlingStrategy":"validation","validationCode":"if options.temperature is not None:\n    options.temperature = max(0.0, float(options.temperature))","typeGuard":null,"tryCatchPattern":"from paddleocr._api_client.errors import InvalidRequestError\n\ntry:\n    run(options)\nexcept InvalidRequestError as e:\n    if 'temperature' in str(e):\n        options.temperature = 0.0\n        run(options)\n    else:\n        raise","preventionTips":["Clamp dynamic temperature schedules to >= 0","Validate hyperparameters once at config load"],"tags":["validation","api-client","sampling"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}