pub struct GenParams {Show 14 fields
pub max_tokens: Option<u32>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub top_k: Option<usize>,
pub seed: Option<u64>,
pub presence_penalty: Option<f32>,
pub frequency_penalty: Option<f32>,
pub repeat_penalty: Option<f32>,
pub min_p: Option<f32>,
pub logit_bias: Vec<(u32, f32)>,
pub logprobs: bool,
pub top_logprobs: usize,
pub stop: Vec<String>,
pub response_format: Option<ResponseFormat>,
}Expand description
The validated, per-request generation config handed to ChatGenerator::chat. None fields
mean “the request didn’t say” — the generator leaves the process default (INFR_TEMP /
INFR_TOP_K / INFR_TOP_P / INFR_MAX_NEW) in charge for exactly those.
Fields§
§max_tokens: Option<u32>§temperature: Option<f32>§top_p: Option<f32>§top_k: Option<usize>§seed: Option<u64>§presence_penalty: Option<f32>§frequency_penalty: Option<f32>§repeat_penalty: Option<f32>§min_p: Option<f32>§logit_bias: Vec<(u32, f32)>(token id, bias) pairs in ascending id order. Ids are checked against the model’s
vocabulary by check_vocab, which needs the routed generator.
logprobs: boolOpenAI logprobs: include each generated token’s log probability in the reply.
top_logprobs: usizeHow many most likely alternatives to include per token. 0 with logprobs on reports
only the chosen token. Defaults to 20, OpenAI’s upper bound, when top_logprobs is
absent, matching llama.cpp.
stop: Vec<String>Already normalised: empty strings dropped (an empty stop would fire on the first token).
response_format: Option<ResponseFormat>None for free text. Not sampling, but the same “what this request asked for” the rest of
this struct carries to the generator.
Implementations§
Source§impl GenParams
impl GenParams
Sourcepub fn from_request(req: &ChatRequest) -> Result<Self, ParamError>
pub fn from_request(req: &ChatRequest) -> Result<Self, ParamError>
Validate + normalise the request’s sampling fields. Out-of-range values are a 400, NEVER a
silent clamp and never a panic (OpenAI’s own ranges: temperature 0..2, top_p 0..1,
presence/frequency -2..2, logit_bias -100..100, at most 4 stop sequences; min_p 0..1).
n > 1 is a 400 too: the server returns one choice, and a reply shaped as if it had more
would be wrong.
Sourcepub fn check_vocab(&self, vocab: usize) -> Result<(), ParamError>
pub fn check_vocab(&self, vocab: usize) -> Result<(), ParamError>
The logit_bias ids against the routed model’s vocabulary: an id at or past vocab names
no token, so the request is a 400 rather than a bias that silently does nothing.
Trait Implementations§
impl StructuralPartialEq for GenParams
Auto Trait Implementations§
impl Forget for GenParams
impl Freeze for GenParamswhere
*const u8 is !null: Freeze,
PhantomData<(u32, f32)>: Freeze,
PhantomData<String>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Value>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<Bucket<String, Value>>: Freeze,
impl Move for GenParams
impl RefUnwindSafe for GenParams
impl Send for GenParams
impl Sync for GenParams
impl Unpin for GenParams
impl UnsafeUnpin for GenParamswhere
*const u8 is !null: UnsafeUnpin,
PhantomData<(u32, f32)>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Bucket<String, Value>>: UnsafeUnpin,
impl UnwindSafe for GenParams
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more