trusty-embedder 0.1.5

Shared embedding abstraction + fastembed-backed implementation for trusty-* projects
Documentation

trusty-embedder

Shared text-embedding abstraction for the trusty-* family of projects.

Provides a single async Embedder trait and a production-ready FastEmbedder implementation backed by fastembed-rs (all-MiniLM-L6-v2, 384-dimensional output, INT8-quantized ONNX) with LRU caching and ORT warmup. A MockEmbedder test double is available behind the test-support feature.

Installation

cargo add trusty-embedder

For tests/benches that want a deterministic stand-in:

cargo add trusty-embedder --features test-support

Quick Example

use trusty_embedder::{Embedder, FastEmbedder};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let embedder = FastEmbedder::new()?;
    let vectors = embedder
        .embed_batch(&["hello world".into(), "trusty".into()])
        .await?;
    assert_eq!(vectors[0].len(), trusty_embedder::EMBEDDING_DIM);
    Ok(())
}

Feature Flags

  • test-support (optional) — exposes MockEmbedder, a deterministic hash-based embedder for unit tests that don't want to load an ONNX model.

Notes

  • Model files are downloaded by fastembed on first use and cached in the standard fastembed cache location.
  • The crate falls back from AllMiniLML6V2Q (INT8) to AllMiniLML6V2 (FP32) when the quantized variant is unavailable in the host fastembed build.
  • embed_batch is the single primitive — single-text embedding is a thin helper that wraps a one-element batch.

License

Licensed under the Elastic License 2.0.

Repository

https://github.com/bobmatnyc/trusty-common