oneai-vector 0.1.0

OneAI default retrieval backend stack — sqlite-vec / usearch / tantivy BM25 / BGE-M3 embedder / BGE reranker + RRF StandardRetrievalPipeline
Documentation

OneAI default retrieval backend stack.

Implements the retrieval-backend traits declared in [oneai-core::traits] (VectorBackend, KeywordBackend, RetrievalBackend, RerankerProvider) using the P0-spike-verified library set (2026-07-26):

Backend Crate Feature Role
[InMemoryVectorBackend] (std only) always brute-force cosine, tests/tiny sets
[SqliteVecBackend] sqlite-vec sqlite exact KNN via vec0, mobile/small
[UsearchBackend] usearch usearch HNSW + mmap + pre-filter
[TantivyBm25Backend] tantivy + tantivy-jieba tantivy CJK BM25
[BgeM3Embedder] ort ort local BGE-M3 dense embeddings
[BgeRerankerOnnx] ort ort local bge-reranker-v2-m3 cross-encoder
[StandardRetrievalPipeline] (composes the above) default BM25+dense → RRF → rerank

The non-negotiable default pipeline

[StandardRetrievalPipeline] runs BM25 + dense → RRF(k=60) → rerank (top-150 → top-K), which Anthropic's "Contextual Retrieval" evaluation showed cuts top-20 retrieval failure rate by 67%. An app that implements its own [RetrievalBackend] (e.g. Qdrant, which does hybrid natively) bypasses this pipeline — the trait docs in oneai-core say explicitly that skipping the keyword/sparse leg degrades Chinese short queries and unique-identifier lookups, so dropping BM25 is an informed decision.

Feature flags

  • default = ["sqlite", "usearch", "tantivy"] — the storage backends + BM25 + the pipeline all build without network access. The pipeline can take any EmbeddingService (the ones in oneai-rag, or BgeM3Embedder when ort is on).
  • ort — local ONNX embedder + reranker. Off by default because ort-sys downloads a prebuilt libonnxruntime blob and the embedder needs ONNX model files at runtime. Enable with --features ort.

Design principle

These implementations must NOT leak storage-internal types — an app that brings Qdrant/Milvus/pgvector/Elasticsearch implements against the public oneai-core trait surface, not against these internals. Backends here are the reference embedded stack.

unsafe is confined to the sqlite-vec static-registration shim (a single FFI transmute required to register sqlite3_vec_init as a SQLite auto extension; every other backend is pure safe Rust over its crate's API).