use candding::TextEmbedding;
fn main() -> candding::Result<()> {
let model = TextEmbedding::builder("BAAI/bge-small-en-v1.5").build()?;
let text = "what is a matryoshka embedding";
let raw = model.embed(&[text], None)?;
let query = model.query_embed(&[text], None)?;
let cosine: f32 = raw[0].iter().zip(&query[0]).map(|(a, b)| a * b).sum();
println!("query template: {:?}", model.descriptor().query_template);
println!(
"tokens without the template: {:?}",
model.token_count(&[text])?
);
println!("cosine(raw, query) = {cosine:.4}");
Ok(())
}