glowrs

Crates.ioglowrs
lib.rsglowrs
version0.4.1
sourcesrc
created_at2024-04-09 13:20:13.611671
updated_at2024-04-26 13:56:28.664724
descriptionSentenceTransformers for candle-rs
homepagehttps://github.com/wdoppenberg/glowrs
repositoryhttps://github.com/wdoppenberg/glowrs
max_upload_size
id1202363
size106,886
Wouter Doppenberg (wdoppenberg)

documentation

https://docs.rs/glowrs/

README

glowrs

The glowrs library provides an easy and familiar interface to use pre-trained models for embeddings and sentence similarity.

Example

use glowrs::{SentenceTransformer, Device, PoolingStrategy, Error};

fn main() -> Result<(), Error> {
    let encoder = SentenceTransformer::from_repo_string("sentence-transformers/all-MiniLM-L6-v2", &Device::Cpu)?;

    let sentences = vec![
        "Hello, how are you?",
        "Hey, how are you doing?"
    ];

    let embeddings = encoder.encode_batch(sentences, true, PoolingStrategy::Mean)?;

    println!("{:?}", embeddings);
    
    Ok(())
}

Features

  • Load models from Hugging Face Hub
  • Use hardware acceleration (Metal, CUDA)
  • More to come!

Build features

  • metal: Compile with Metal acceleration
  • cuda: Compile with CUDA acceleration
  • accelerate: Compile with Accelerate framework acceleration (CPU)

Disclaimer

This is still a work-in-progress. The embedding performance is decent but can probably do with some benchmarking.

Do not use this in a production environment.

Commit count: 71

cargo fmt