15 unstable releases (3 breaking)
0.4.1 | Apr 26, 2024 |
---|---|
0.4.0 | Apr 26, 2024 |
0.3.0 | Apr 22, 2024 |
0.2.2 | Apr 22, 2024 |
0.1.9 | Apr 16, 2024 |
#858 in Machine learning
34KB
658 lines
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 accelerationcuda
: Compile with CUDA accelerationaccelerate
: 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.
Dependencies
~30–48MB
~873K SLoC