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
impl Parameters
Sourcepub fn temperature(self, value: f32) -> Self
pub fn temperature(self, value: f32) -> Self
Sets the parameter value using a builder pattern.
§Arguments
value
- The value to set for this parameter
Sourcepub fn top_p(self, value: f32) -> Self
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
Sourcepub fn top_k(self, value: u32) -> Self
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
Sourcepub fn frequency_penalty(self, value: f32) -> Self
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
Sourcepub fn presence_penalty(self, value: f32) -> Self
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
Sourcepub fn repetition_penalty(self, value: f32) -> Self
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
Sourcepub fn min_p(self, value: f32) -> Self
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
Sourcepub fn top_a(self, value: f32) -> Self
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
Sourcepub fn seed(self, value: u32) -> Self
pub fn seed(self, value: u32) -> Self
Sets the parameter value using a builder pattern.
§Arguments
value
- The value to set for this parameter
Sourcepub fn max_tokens(self, value: u32) -> Self
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
Sourcepub fn logit_bias(self, value: Vec<(String, f32)>) -> Self
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
Sourcepub fn logprobs(self, value: bool) -> Self
pub fn logprobs(self, value: bool) -> Self
Sets the parameter value using a builder pattern.
§Arguments
value
- The value to set for this parameter
Sourcepub fn top_logprobs(self, value: u8) -> Self
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