pub struct ClipModel { /* private fields */ }Expand description
Represents a CLIP model loaded from a GGUF file.
§Example
let model = cliprs::ClipModel::new("path/to/model.gguf");
let text_embedding = model.embed_text("A sample text").unwrap();
let image_embedding = model.embed_image("path/to/image.png").unwrap();
let similarity = model.embed_compare(&text_embedding, &image_embedding);
println!("Similarity: {}", similarity);Implementations§
Source§impl ClipModel
impl ClipModel
Sourcepub fn new(model_path: impl Into<String>) -> Self
pub fn new(model_path: impl Into<String>) -> Self
Initializes ClipModel with a model path.
§Example
let model = cliprs::ClipModel::new("path/to/model.gguf");Sourcepub fn embed_compare(&self, p1: &Vec<f32>, p2: &Vec<f32>) -> f32
pub fn embed_compare(&self, p1: &Vec<f32>, p2: &Vec<f32>) -> f32
Compares two embeddings and returns the similarity.
§Example
let similarity = model.embed_compare(&text_embedding, &image_embedding);Trait Implementations§
Auto Trait Implementations§
impl Freeze for ClipModel
impl RefUnwindSafe for ClipModel
impl Unpin for ClipModel
impl UnsafeUnpin for ClipModel
impl UnwindSafe for ClipModel
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