rlx-embed
Text + image embedding runtime for RLX. This is the crate that turns the encoder graph builders (rlx-bert, rlx-nomic, rlx-vision) into a working pipeline: tokenize → compile → run → pool → normalize → vectors. (Migrated from burnembed.)
Quickstart
use ;
let tok = from_dir?;
let mut model = load?;
let vecs = embed_with_rlx?;
// vecs: Vec<Vec<f32>> — one embedding per input
# Ok
Supported models
Auto-detected via detect_arch (from config.json / GGUF metadata) into one of three architectures — Bert, NomicBert, NomicVision:
| Model | Arch | Notes |
|---|---|---|
sentence-transformers/all-MiniLM-L6-v2, -L12-v2 |
Bert | mean pooling |
BAAI/bge-{small,base,large}-en-v1.5, bge-small-zh-v1.5 |
Bert | CLS pooling |
nomic-ai/nomic-embed-text-v1.5 |
NomicBert | 768-dim, RoPE + SwiGLU, mean pooling |
nomic-ai/nomic-embed-vision-v1.5 |
NomicVision | 768-dim ViT, 224px, CLS pooling |
EmbeddingModel::list_supported() / models_map() enumerate the built-in registry (HF repo + weight file + pooling).
How it works
- Tokenize —
BertTokenizer::encode_batch→input_ids/attention_mask/token_type_ids(TokenizedBatch). - Compile —
RlxBertModel/RlxNomicModel/RlxVisionModelbuild the encoder graph (via the sibling builder crate) and compile it for aDevice; the compiled graph is cached perbatch×seq(recompileon a new shape). - Run — inputs are marshaled to
f32and fed to the compiled graph →hidden_states[B, S, H]. - Pool —
Pooling::{Mean, Cls, None}(pool_embeddings), then optionall2_normalize_in_place.
Lower-level entry points: RlxEmbed, compile_model / compile_model_cpu, assemble_vision_hidden.
Features
embed (tokenizers, default) · hf-download (Hub fetch) · backends metal / mlx / cuda / rocm / gpu / vulkan / coreml (+ all-backends, apple-silicon, …).
License
GPL-3.0-only. © 2026 Eugene Hauptmann, Nataliya Kosmyna.