cliprs 0.2.1

Rust bindings to CLIP.cpp
Documentation
  • Coverage
  • 87.5%
    7 out of 8 items documented6 out of 7 items with examples
  • Size
  • Source code size: 13.65 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 317.05 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 50s Average build duration of successful builds.
  • all releases: 49s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • simon0302010 FoxMoss

Cliprs

clip.cpp bindings to rust.

Grabing a model file

I've been using huggingface.co/mys/ggml_clip-vit-large-patch14 two tower models for testing. All quantization levels have worked great!

Install

To add to your project:

cargo add cliprs

Usage

For a detailed example, see src/main.rs.

But basic usage looks like

use cliprs::ClipModel;

fn main() {
    // Loading model
    let model = ClipModel::new("/path/to/model.gguf");

    // Embedding text
    let text_embedding = model.embed_text("text").unwrap();

    // Embedding an image
    let image_embedding = model.embed_image("/path/to/image.jpg").unwrap();

    // Comparing image and text. You can also compare embeddings of the same type.
    let similarity = model.embed_compare(&text_embedding, &image_embedding);
    println!("Similarity: {}", similarity);

    // Prints all warnings during processing
    for warning in cliprs::poll_warnings() {
        eprintln!("Warning: {}", warning);
    }
}