Struct Parameters

Source
pub struct Parameters {
Show 16 fields pub temperature: Option<f32>, pub top_p: Option<f32>, pub top_k: Option<u32>, pub frequency_penalty: Option<f32>, pub presence_penalty: Option<f32>, pub repetition_penalty: Option<f32>, pub min_p: Option<f32>, pub top_a: Option<f32>, pub seed: Option<u32>, pub max_tokens: Option<u32>, pub logit_bias: Option<Vec<(String, f32)>>, pub logprobs: Option<bool>, pub top_logprobs: Option<u8>, pub stop: Option<Vec<String>>, pub tools: Tools, pub tool_choice: Option<Vec<String>>,
}
Expand description

Parameters for configuring the behavior of a language model.

This struct contains various parameters that can be used to control how a language model generates responses. All parameters are optional and use the builder pattern for easy configuration.

§Examples

use ai_types::llm::model::Parameters;

let params = Parameters::default()
    .temperature(0.7)
    .top_p(0.9)
    .max_tokens(1000)
    .seed(42);

Fields§

§temperature: Option<f32>

Sampling temperature.

Controls randomness in generation. Higher values (e.g., 1.0) make output more random, lower values (e.g., 0.1) make it more deterministic.

§top_p: Option<f32>

Nucleus sampling probability.

Only consider tokens with cumulative probability up to this value. Typical values are between 0.9 and 1.0.

§top_k: Option<u32>

Top-k sampling parameter.

Only consider the k most likely tokens at each step.

§frequency_penalty: Option<f32>

Frequency penalty to reduce repetition.

Positive values penalize tokens that have already appeared.

§presence_penalty: Option<f32>

Presence penalty to encourage new tokens.

Positive values encourage the model to talk about new topics.

§repetition_penalty: Option<f32>

Repetition penalty to penalize repeated tokens.

Values > 1.0 discourage repetition, values < 1.0 encourage it.

§min_p: Option<f32>

Minimum probability for nucleus sampling.

Alternative to top_p that sets a minimum threshold for token probabilities.

§top_a: Option<f32>

Top-a sampling parameter.

Adaptive sampling that adjusts the number of considered tokens.

§seed: Option<u32>

Random seed for reproducibility.

Use the same seed to get deterministic outputs.

§max_tokens: Option<u32>

Maximum number of tokens to generate.

Limits the length of the generated response.

§logit_bias: Option<Vec<(String, f32)>>

Biases for specific logits.

Each tuple contains a token string and its bias value.

§logprobs: Option<bool>

Whether to return log probabilities.

When true, the model returns probability information for tokens.

§top_logprobs: Option<u8>

Number of top log probabilities to return.

Only used when logprobs is true.

§stop: Option<Vec<String>>

Stop sequences to end generation.

Generation stops when any of these strings are encountered.

§tools: Tools

Tools available to the model.

Defines what external functions the model can call.

§tool_choice: Option<Vec<String>>

Tool choices available to the model.

Specifies which tools the model is allowed to use.

Implementations§

Source§

impl Parameters

Source

pub fn temperature(self, value: f32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn top_p(self, value: f32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn top_k(self, value: u32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn frequency_penalty(self, value: f32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn presence_penalty(self, value: f32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn repetition_penalty(self, value: f32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn min_p(self, value: f32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn top_a(self, value: f32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn seed(self, value: u32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn max_tokens(self, value: u32) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn logit_bias(self, value: Vec<(String, f32)>) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn logprobs(self, value: bool) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn top_logprobs(self, value: u8) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter
Source

pub fn stop(self, value: Vec<String>) -> Self

Sets the parameter value using a builder pattern.

§Arguments
  • value - The value to set for this parameter

Trait Implementations§

Source§

impl Debug for Parameters

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Parameters

Source§

fn default() -> Parameters

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,