pub struct SemanticModel { /* private fields */ }Expand description
Wrapper around an embedding model backend.
Supports multiple backends selected at compile time via feature flags. When multiple backends are available, ORT is preferred (higher quality); model2vec is used as a fallback.
Implementations§
Source§impl SemanticModel
impl SemanticModel
Sourcepub fn load() -> Result<Self>
pub fn load() -> Result<Self>
Load the model from the OS cache directory.
Tries backends in priority order: ORT (highest quality), then model2vec (no ONNX dependency, Windows-friendly).
§Errors
Returns an error if no backend is available or loading fails.
Sourcepub fn model_cache_path() -> Result<PathBuf>
pub fn model_cache_path() -> Result<PathBuf>
Return the OS-appropriate cache path for the ORT model file.
Uses dirs::cache_dir() / bones / models / minilm-l6-v2-int8.onnx.
§Errors
Returns an error if the OS cache directory cannot be determined.
Sourcepub fn model_cache_root() -> Result<PathBuf>
pub fn model_cache_root() -> Result<PathBuf>
Return the OS-appropriate cache root for model files.
§Errors
Returns an error if the OS cache directory cannot be determined.
Sourcepub fn is_cached_valid(path: &Path) -> bool
pub fn is_cached_valid(path: &Path) -> bool
Check if cached model matches expected SHA256.
Sourcepub fn extract_to_cache(path: &Path) -> Result<()>
pub fn extract_to_cache(path: &Path) -> Result<()>
Extract bundled model bytes to cache directory.
§Errors
Returns an error if no bundled bytes are available, or if the file system operations fail, or if the extracted model fails SHA256 verification.
Sourcepub fn dimensions(&self) -> usize
pub fn dimensions(&self) -> usize
The dimensionality of embedding vectors this model produces.
Sourcepub fn backend_id(&self) -> &'static str
pub fn backend_id(&self) -> &'static str
A stable identifier for the active backend, used to detect backend switches that require re-embedding stored vectors.