22# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
33"""Sampling parameters for text generation."""
44import copy
5+ import warnings
56from dataclasses import field
67from enum import Enum , IntEnum
78from functools import cached_property
@@ -59,6 +60,19 @@ def __post_init__(self):
5960 f"but multiple are specified: { self .__dict__ } " )
6061
6162
63+ @dataclass
64+ class GuidedDecodingParams (StructuredOutputsParams ):
65+
66+ def __post_init__ (self ):
67+ warnings .warn (
68+ "GuidedDecodingParams is deprecated. This will be removed in "
69+ "v0.12.0 or v1.0.0, which ever is soonest. Please use "
70+ "StructuredOutputsParams instead." ,
71+ DeprecationWarning ,
72+ stacklevel = 2 )
73+ return super ().__post_init__ ()
74+
75+
6276class RequestOutputKind (Enum ):
6377 # Return entire output so far in every RequestOutput
6478 CUMULATIVE = 0
@@ -179,6 +193,8 @@ class SamplingParams(
179193 # Fields used to construct logits processors
180194 structured_outputs : Optional [StructuredOutputsParams ] = None
181195 """Parameters for configuring structured outputs."""
196+ guided_decoding : Optional [GuidedDecodingParams ] = None
197+ """Deprecated alias for structured_outputs."""
182198 logit_bias : Optional [dict [int , float ]] = None
183199 """If provided, the engine will construct a logits processor that applies
184200 these logit biases."""
@@ -227,6 +243,7 @@ def from_optional(
227243 ge = - 1 )]] = None ,
228244 output_kind : RequestOutputKind = RequestOutputKind .CUMULATIVE ,
229245 structured_outputs : Optional [StructuredOutputsParams ] = None ,
246+ guided_decoding : Optional [GuidedDecodingParams ] = None ,
230247 logit_bias : Optional [Union [dict [int , float ], dict [str , float ]]] = None ,
231248 allowed_token_ids : Optional [list [int ]] = None ,
232249 extra_args : Optional [dict [str , Any ]] = None ,
@@ -238,6 +255,15 @@ def from_optional(
238255 int (token ): min (100.0 , max (- 100.0 , bias ))
239256 for token , bias in logit_bias .items ()
240257 }
258+ if guided_decoding is not None :
259+ warnings .warn (
260+ "guided_decoding is deprecated. This will be removed in "
261+ "v0.12.0 or v1.0.0, which ever is soonest. Please use "
262+ "structured_outputs instead." ,
263+ DeprecationWarning ,
264+ stacklevel = 2 )
265+ structured_outputs = guided_decoding
266+ guided_decoding = None
241267
242268 return SamplingParams (
243269 n = 1 if n is None else n ,
@@ -334,6 +360,16 @@ def __post_init__(self) -> None:
334360 # eos_token_id is added to this by the engine
335361 self ._all_stop_token_ids .update (self .stop_token_ids )
336362
363+ if self .guided_decoding is not None :
364+ warnings .warn (
365+ "guided_decoding is deprecated. This will be removed in "
366+ "v0.12.0 or v1.0.0, which ever is soonest. Please use "
367+ "structured_outputs instead." ,
368+ DeprecationWarning ,
369+ stacklevel = 2 )
370+ self .structured_outputs = self .guided_decoding
371+ self .guided_decoding = None
372+
337373 def _verify_args (self ) -> None :
338374 if not isinstance (self .n , int ):
339375 raise ValueError (f"n must be an int, but is of "
0 commit comments