pub struct EngineConfig {
pub model_path: String,
pub tokenizer_path: Option<String>,
pub temperature: f32,
pub top_k: usize,
pub top_p: f32,
pub repeat_penalty: f32,
pub max_tokens: usize,
pub seed: Option<u64>,
pub use_gpu: bool,
pub max_context_len: Option<usize>,
pub kv_cache_type: KVCacheType,
}Expand description
Configuration for creating an Engine.
Can be constructed manually, from a Config TOML file,
or with Default::default().
Fields§
§model_path: StringPath to the model file (GGUF or ONNX).
tokenizer_path: Option<String>Optional path to a tokenizer file.
For ONNX models, this defaults to tokenizer.json in the same directory.
Can also point to a GGUF file to extract just the tokenizer.
temperature: f32Temperature for sampling (0.0 = greedy, higher = more random).
top_k: usizeTop-K sampling: only consider the K most likely tokens (0 = disabled).
top_p: f32Top-P (nucleus) sampling: only consider tokens with cumulative probability <= p.
repeat_penalty: f32Repetition penalty (1.0 = no penalty).
max_tokens: usizeDefault maximum tokens to generate.
seed: Option<u64>Random seed for reproducible generation (None = random).
use_gpu: boolUse GPU acceleration (requires cuda feature).
max_context_len: Option<usize>Maximum context length override.
If set, caps the model’s context length (and thus KV cache size).
The model’s native max_seq_len from GGUF metadata can be very large
(e.g. 32768) which may exhaust GPU memory for the KV cache alone.
Set this to a smaller value (e.g. 2048) to reduce VRAM usage.
If None or 0, uses the model’s native max_seq_len.
kv_cache_type: KVCacheTypeKV cache type for memory-efficient inference.
Implementations§
Source§impl EngineConfig
impl EngineConfig
Sourcepub fn from_config_file(path: impl AsRef<Path>) -> Result<Self, ConfigError>
pub fn from_config_file(path: impl AsRef<Path>) -> Result<Self, ConfigError>
Load an EngineConfig from a Config TOML file.
This is a convenience method that loads the full config and extracts the engine-relevant sections.
Sourcepub fn from_config(
config_path: Option<impl AsRef<Path>>,
) -> Result<Self, ConfigError>
pub fn from_config( config_path: Option<impl AsRef<Path>>, ) -> Result<Self, ConfigError>
Load an EngineConfig using the full config precedence chain.
Searches default config file locations, then applies environment variable overrides.
Trait Implementations§
Source§impl Clone for EngineConfig
impl Clone for EngineConfig
Source§fn clone(&self) -> EngineConfig
fn clone(&self) -> EngineConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EngineConfig
impl Debug for EngineConfig
Source§impl Default for EngineConfig
impl Default for EngineConfig
Source§impl<'de> Deserialize<'de> for EngineConfigwhere
EngineConfig: Default,
impl<'de> Deserialize<'de> for EngineConfigwhere
EngineConfig: Default,
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>,
Auto Trait Implementations§
impl Freeze for EngineConfig
impl RefUnwindSafe for EngineConfig
impl Send for EngineConfig
impl Sync for EngineConfig
impl Unpin for EngineConfig
impl UnsafeUnpin for EngineConfig
impl UnwindSafe for EngineConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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