Rust · Quickstart

Quickstart

4.0.0-rc.1 · 3ee5e534

use uform::*;

let executor = Executor::for_ram(&[], None, 0)?;           // the threads every receiver names
let mut arena = Arena::new_in(&executor)?;                    // the memory outputs land in
let model = Model::load_ram("model.safetensors")?;            // BFloat16 blocks, as the checkpoint stores them

let texts = ["a cat on a mat", "a dog in the fog"];
let encoded = model.on(&executor).text_encode(&texts, Outputs::EMBEDDINGS, Scalar::F32, &mut arena)?;
if let Some(embeddings) = encoded.embeddings {
    let values: &[f32] = embeddings.values()?;                // count × columns, zero-copy from the arena
    assert_eq!(values.len(), texts.len() * model.describe()?.dimensions);
}