You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/.../.venv/lib/python3.10/site-packages/pydantic/main.py", line 596, in model_validate
return cls.__pydantic_validator__.validate_python(
pydantic_core._pydantic_core.ValidationError: 1 validation error for ChatCompletionRequest
Value error, when using `top_logprobs`, `logprobs` must be set to true. [type=value_error, input_value={'messages': [{'content':...ogits_processors': None}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.9/v/value_error
This becomes a problem when an instance of the class is instantiated at some point (and consequently filled with its defaults if no values for logprobs and top_logprobs are given), then converted to json/ a dict and later reinstantiated from this dump. (Also just generally: Either the defaults are valid or they are not (in which case it should not be possible to create an instance that has the default values by not passing the values explicitly).)
To fix this the validator should change as follows:
@model_validator(mode="before")@classmethoddefcheck_logprobs(cls, data):
if (prompt_logprobs:=data.get("prompt_logprobs")) isnotNone:
ifdata.get("stream") andprompt_logprobs>0:
raiseValueError(
"`prompt_logprobs` are not available when `stream=True`.")
ifprompt_logprobs<0:
raiseValueError("`prompt_logprobs` must be a positive value.")
if (top_logprobs:=data.get("top_logprobs")) isnotNone:
iftop_logprobs<0:
raiseValueError("`top_logprobs` must be a positive value.")
iftop_logprobs>0andnotdata.get("logprobs"):
raiseValueError(
"when using `top_logprobs`, `logprobs` must be set to true."
)
returndata
Where the line if top_logprobs > 0 and not data.get("logprobs"): contains the relevant fix. I.e. logprobs must only be set to True if we actually request any top_logprobs.
Before submitting a new issue...
Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.
The text was updated successfully, but these errors were encountered:
Your current environment
The output of `python collect_env.py`
🐛 Describe the bug
The pydantic model
ChatCompletionRequest
found invllm.entrypoints.openai.protocol
rejects its own default configuration oflogprobs
andtop_logprobs
.Example to reproduce the problem:
Output:
This becomes a problem when an instance of the class is instantiated at some point (and consequently filled with its defaults if no values for
logprobs
andtop_logprobs
are given), then converted to json/ a dict and later reinstantiated from this dump. (Also just generally: Either the defaults are valid or they are not (in which case it should not be possible to create an instance that has the default values by not passing the values explicitly).)To fix this the validator should change as follows:
Where the line
if top_logprobs > 0 and not data.get("logprobs"):
contains the relevant fix. I.e.logprobs
must only be set toTrue
if we actually request anytop_logprobs
.Before submitting a new issue...
The text was updated successfully, but these errors were encountered: