pub struct ModelConfig {
pub model: EmbeddingModel,
pub output_dim: Option<usize>,
}Expand description
Runtime configuration pairing a model with an optional MRL truncation dimension.
Two ModelConfig values with different output_dim produce different embedding spaces
and must be stored in separate vector index namespaces.
Fields§
§model: EmbeddingModelThe underlying embedding model.
output_dim: Option<usize>MRL truncation dimension. None uses the model’s native dimension.
Implementations§
Source§impl ModelConfig
impl ModelConfig
Sourcepub const fn new(model: EmbeddingModel) -> Self
pub const fn new(model: EmbeddingModel) -> Self
Create a config with no MRL truncation (native model dimension).
Sourcepub fn try_new(
model: EmbeddingModel,
output_dim: Option<usize>,
) -> Result<Self, EmbedError>
pub fn try_new( model: EmbeddingModel, output_dim: Option<usize>, ) -> Result<Self, EmbedError>
Create and validate a config with an optional MRL truncation dimension.
Sourcepub fn validate(&self) -> Result<(), EmbedError>
pub fn validate(&self) -> Result<(), EmbedError>
Validate that the output dimension is consistent with the model.
Sourcepub fn dimensions(&self) -> usize
pub fn dimensions(&self) -> usize
Active output dimension: configured truncation if set, otherwise the model’s native dimension.
Trait Implementations§
Source§impl Clone for ModelConfig
impl Clone for ModelConfig
Source§fn clone(&self) -> ModelConfig
fn clone(&self) -> ModelConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ModelConfig
impl Debug for ModelConfig
Source§impl Default for ModelConfig
impl Default for ModelConfig
Source§impl<'de> Deserialize<'de> for ModelConfig
impl<'de> Deserialize<'de> for ModelConfig
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 Hash for ModelConfig
impl Hash for ModelConfig
Source§impl PartialEq for ModelConfig
impl PartialEq for ModelConfig
Source§fn eq(&self, other: &ModelConfig) -> bool
fn eq(&self, other: &ModelConfig) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for ModelConfig
impl Serialize for ModelConfig
impl Copy for ModelConfig
impl Eq for ModelConfig
impl StructuralPartialEq for ModelConfig
Auto Trait Implementations§
impl Freeze for ModelConfig
impl RefUnwindSafe for ModelConfig
impl Send for ModelConfig
impl Sync for ModelConfig
impl Unpin for ModelConfig
impl UnsafeUnpin for ModelConfig
impl UnwindSafe for ModelConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.