Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Typed decisions

libmir::decision loads Laya checkpoints independently of Library and the generation scheduler. Its ModernBERT encoder answers option, boolean, and scale questions about text or conversation state.

libmir = { version = "0.6.2", default-features = false, features = ["cpu"] }
serde_json = "1"
use libmir::decision::{DecisionBackend, DecisionModel, DecisionSchema, DecisionState};

let model = DecisionModel::load("/models/laya-multilingual", DecisionBackend::Cpu)?;
let schema = DecisionSchema::from_json_schema(&serde_json::json!({
    "type": "object",
    "properties": {"refund": {"type": "boolean"}}
}))?;
let values = model.decide_schema(&DecisionState::text("We were billed twice."), &schema)?;
println!("{}", serde_json::Value::Object(values));
Ok::<(), libmir::Error>(())

Select DecisionBackend::Metal with the metal feature for Apple GPUs, or DecisionBackend::Cuda(DecisionPrecision::F32) / Bf16 with cuda for NVIDIA GPUs. CPU and Metal evaluate in FP32; CUDA offers FP32 or BF16 matrix products with FP32 normalization, softmax, and residuals. These precisions have separate numerical tolerances in the reference tests.

decide returns typed Answer values with option probabilities and verdicts; decide_schema projects them into a JSON object. rows and logits expose tokenized questions and raw option logits for validation.

The CPU backend uses mircup: Apple Accelerate on macOS and multithreaded GEMM elsewhere. Enabling cpu does not provide general-purpose text generation, embeddings, or reranking through Library.