mirror of
https://github.com/deepseek-ai/DeepInfer.git
synced 2026-11-09 22:59:44 +08:00
Merge f97e82bdb61377eaa10b992296ccd45f9e58286f into 553741557a57df44a46fb3ab72b6aafeaf945337
This commit is contained in:
commit
700230447c
@ -62,6 +62,9 @@ class SamplingParams:
|
|||||||
) -> None:
|
) -> None:
|
||||||
del logprobs
|
del logprobs
|
||||||
|
|
||||||
|
if so_args is not None and golden_token_ids is not None:
|
||||||
|
raise ValueError("golden_token_ids cannot be combined with structured output constraints (so_args)")
|
||||||
|
|
||||||
self.temperature = temperature
|
self.temperature = temperature
|
||||||
self.top_p = top_p
|
self.top_p = top_p
|
||||||
self.top_k = top_k
|
self.top_k = top_k
|
||||||
|
|||||||
28
tests/engine/test_sampling_params_golden_so.py
Normal file
28
tests/engine/test_sampling_params_golden_so.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from deepinfer.sampling_params import SamplingParams
|
||||||
|
|
||||||
|
|
||||||
|
def test_golden_tokens_conflict_with_structured_output() -> None:
|
||||||
|
with pytest.raises(ValueError, match="cannot be combined"):
|
||||||
|
SamplingParams(
|
||||||
|
golden_token_ids=[2],
|
||||||
|
so_args={
|
||||||
|
"schema_type": "regex",
|
||||||
|
"schema": "[0-9]+",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_golden_tokens_without_structured_output() -> None:
|
||||||
|
params = SamplingParams(golden_token_ids=[2])
|
||||||
|
assert params.golden_token_ids == [2]
|
||||||
|
|
||||||
|
|
||||||
|
def test_structured_output_without_golden_tokens() -> None:
|
||||||
|
so_args = {
|
||||||
|
"schema_type": "regex",
|
||||||
|
"schema": "[0-9]+",
|
||||||
|
}
|
||||||
|
params = SamplingParams(so_args=so_args)
|
||||||
|
assert params.so_args == so_args
|
||||||
Loading…
x
Reference in New Issue
Block a user