omni_search
omni_search is a Rust SDK for multimodal embedding and similarity search.
Current scope:
- load a local model bundle with
manifest.json; - compute text embeddings;
- compute image embeddings;
- compare embeddings with cosine similarity;
- manually unload ONNX Runtime sessions.
The SDK currently targets local ONNX bundles through the ort crate.
The published crate does not bundle ONNX models or sample images. Point it at your own local assets with OMNI_BUNDLE_DIR and OMNI_SAMPLES_DIR.
Quickstart:
- set
OMNI_BUNDLE_DIRto a local bundle directory that containsmanifest.json, tokenizer assets, and ONNX files; - set
OMNI_SAMPLES_DIRto a directory containing one or more.jpg,.jpeg,.png,.webp, or.bmpimages; - build SDK instances with
OmniSearch::builder()when you only want to override part of the runtime config and keep the rest at defaults; - run
cargo run --bin omni_search --releaseto scan all images inOMNI_SAMPLES_DIRwith the default query"山"; main.rsprints bothtext_to_imageandimage_to_imagetop-k examples using the same public SDK API;- run
cargo run --bin omni_search --release -- "海边"to scan all images inOMNI_SAMPLES_DIRwith a custom query; - run
cargo run --bin omni_search --release -- "海边" 20to scan all images inOMNI_SAMPLES_DIRand print top 20; - run
cargo run --bin omni_search --release -- "海边" "/absolute/path/to/query.jpg"to keep the default top-k and use a specific query image forimage_to_image; - run
cargo run --bin omni_search --release -- "海边" 20 "/absolute/path/to/query.jpg"to set both top-k and query image; - set
OMNI_INTRA_THREADS/OMNI_INTER_THREADSto override ONNX Runtime thread counts when benchmarking or tuning; - set
OMNI_FGCLIP_MAX_PATCHESto cap FG-CLIP2 image preprocessing at a smaller bucket without changing the ONNX bundle; - recommended
OMNI_FGCLIP_MAX_PATCHESvalues are128,256,576,784, or1024; Chinese CLIP ignores this override because it uses fixed224x224inputs; - see
docs/model-performance.mdfor the current Chinese CLIP vs FGCLIP2 performance and memory comparison; - run
cargo test --test quickstart -- --ignored --nocaptureto execute the smoke test after settingOMNI_TEST_BUNDLE_DIRandOMNI_TEST_SAMPLE_IMAGE.
Builder example:
use ;
let sdk = builder
.from_local_model_dir
.intra_threads
.fgclip_max_patches
.session_policy
.graph_optimization_level
.build?;