Skip to content

feat(ruvector-core): Add OnnxEmbedding for real semantic embeddings#265

Merged
ruvnet merged 1 commit intomainfrom
feature/ruvllm-embedding-provider
Mar 16, 2026
Merged

feat(ruvector-core): Add OnnxEmbedding for real semantic embeddings#265
ruvnet merged 1 commit intomainfrom
feature/ruvllm-embedding-provider

Conversation

@ruvnet
Copy link
Owner

@ruvnet ruvnet commented Mar 16, 2026

Summary

  • Add native ONNX Runtime integration for production-ready semantic embeddings
  • Implement OnnxEmbedding with auto-download from HuggingFace Hub
  • Thread-safe inference via RwLock<Session>

Changes

File Description
Cargo.toml Add ort, tokenizers, hf-hub deps + onnx-embeddings feature
embeddings.rs Implement OnnxEmbedding struct (~350 lines)
lib.rs Export OnnxEmbedding, update deprecation warning
ADR-114 Update implementation status

Usage

use ruvector_core::embeddings::{EmbeddingProvider, OnnxEmbedding};

let provider = OnnxEmbedding::from_pretrained("sentence-transformers/all-MiniLM-L6-v2")?;
let embedding = provider.embed("hello world")?;
assert_eq!(embedding.len(), 384);

Test plan

  • cargo check -p ruvector-core --features onnx-embeddings
  • cargo test -p ruvector-core (123 tests pass)
  • cargo clippy -p ruvector-core --features onnx-embeddings
  • cargo publish --dry-run -p ruvector-core

Breaking Changes

None - This is an additive feature behind an optional feature flag.

Closes #264

🤖 Generated with claude-flow

Add native ONNX Runtime integration for production-ready semantic embeddings.

## New Features
- `OnnxEmbedding` struct with `from_pretrained()` and `from_files()` methods
- Feature flag: `onnx-embeddings` (optional, not default)
- Auto-downloads models from HuggingFace Hub (~90MB for all-MiniLM-L6-v2)
- Supports sentence-transformers, BGE, E5 model families
- Thread-safe inference via RwLock<Session>
- Mean pooling and L2 normalization for sentence transformers

## Dependencies (optional)
- ort 2.0.0-rc.9 (ONNX Runtime)
- tokenizers 0.20 (HuggingFace tokenizers)
- hf-hub 0.3 (model downloads)

## Documentation
- Updated ADR-114 with implementation details
- Updated lib.rs deprecation warning to reference OnnxEmbedding

Closes #263

Co-Authored-By: claude-flow <ruv@ruv.net>
@ruvnet ruvnet merged commit 2b6c9c5 into main Mar 16, 2026
18 checks passed
@ruvnet ruvnet deleted the feature/ruvllm-embedding-provider branch March 16, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(ruvector-core): Add OnnxEmbedding for real semantic embeddings

1 participant