pub struct GenerationConfig {
pub temperature: Option<f32>,
pub max_tokens: Option<u32>,
pub stop: Vec<String>,
pub top_p: Option<f32>,
pub top_k: Option<u32>,
pub presence_penalty: Option<f32>,
pub frequency_penalty: Option<f32>,
pub stream: bool,
pub extra: HashMap<String, Value>,
}
Expand description
Configuration for language model generation
Fields§
§temperature: Option<f32>
Temperature for generation (0.0 to 1.0)
max_tokens: Option<u32>
Maximum number of tokens to generate
stop: Vec<String>
Stop sequences
top_p: Option<f32>
Top-p sampling parameter
top_k: Option<u32>
Top-k sampling parameter
presence_penalty: Option<f32>
Presence penalty
frequency_penalty: Option<f32>
Frequency penalty
stream: bool
Whether to stream the response
extra: HashMap<String, Value>
Additional parameters
Implementations§
Source§impl GenerationConfig
impl GenerationConfig
Sourcepub fn with_temperature(self, temperature: f32) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
Set the temperature
Sourcepub fn with_max_tokens(self, max_tokens: u32) -> Self
pub fn with_max_tokens(self, max_tokens: u32) -> Self
Set the maximum tokens
Sourcepub fn with_streaming(self, stream: bool) -> Self
pub fn with_streaming(self, stream: bool) -> Self
Enable streaming
Sourcepub fn with_extra(self, key: impl Into<String>, value: Value) -> Self
pub fn with_extra(self, key: impl Into<String>, value: Value) -> Self
Add an extra parameter
Trait Implementations§
Source§impl Clone for GenerationConfig
impl Clone for GenerationConfig
Source§fn clone(&self) -> GenerationConfig
fn clone(&self) -> GenerationConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for GenerationConfig
impl Debug for GenerationConfig
Source§impl Default for GenerationConfig
impl Default for GenerationConfig
Source§impl<'de> Deserialize<'de> for GenerationConfig
impl<'de> Deserialize<'de> for GenerationConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for GenerationConfig
impl PartialEq for GenerationConfig
Source§impl Serializable for GenerationConfig
impl Serializable for GenerationConfig
Source§fn is_serializable() -> bool
fn is_serializable() -> bool
Check if this object is serializable Read more
Source§fn to_json_pretty(&self) -> Result<String>
fn to_json_pretty(&self) -> Result<String>
Serialize this object to a pretty-printed JSON string
Source§fn to_dict(&self) -> Result<HashMap<String, Value>>
fn to_dict(&self) -> Result<HashMap<String, Value>>
Serialize this object to a dictionary (HashMap)
Source§impl Serialize for GenerationConfig
impl Serialize for GenerationConfig
impl StructuralPartialEq for GenerationConfig
Auto Trait Implementations§
impl Freeze for GenerationConfig
impl RefUnwindSafe for GenerationConfig
impl Send for GenerationConfig
impl Sync for GenerationConfig
impl Unpin for GenerationConfig
impl UnwindSafe for GenerationConfig
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
Mutably borrows from an owned value. Read more