Crates.io | glowrs |
lib.rs | glowrs |
version | 0.4.1 |
source | src |
created_at | 2024-04-09 13:20:13.611671 |
updated_at | 2024-04-26 13:56:28.664724 |
description | SentenceTransformers for candle-rs |
homepage | https://github.com/wdoppenberg/glowrs |
repository | https://github.com/wdoppenberg/glowrs |
max_upload_size | |
id | 1202363 |
size | 106,886 |
glowrs
The glowrs
library provides an easy and familiar interface to use pre-trained models for embeddings and sentence similarity.
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(())
}
metal
: Compile with Metal accelerationcuda
: Compile with CUDA accelerationaccelerate
: Compile with Accelerate framework acceleration (CPU)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.