Open
Conversation
Contributor
There was a problem hiding this comment.
Additional Comments (1)
-
helix-db/src/helix_gateway/tests/embedding_providers.rs, line 150 (link)style: the returned
modelvalue is not being asserted. The test should verify the model string matches the defaultthen add after line 156:
3 files reviewed, 1 comment
Member
|
@vrn21 resolve conflicts please |
Author
|
Sorry for the delay, have resolved the conflicts! |
Member
|
please fix clippy check @vrn21 |
Author
|
Clippy fixed @xav-db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add model2vec-rs as 4th embedding provider
Closes #721
Summary
Adds
model2vec-rsas a new embedding provider for free, local, offline embedding generation without API keys or external servers.Changes
Dependencies
model2vec-rs = { version = "0.1", optional = true }to Cargo.tomlmodel2vec = ["model2vec-rs"]feature flagImplementation (115 lines across 3 files)
helix-db/src/helix_gateway/embedding_providers/mod.rs:
Model2Vec { model_name: String }variant toEmbeddingProviderenummodel2vec: Option<StaticModel>field to EmbeddingModelImpl (feature-gated)StaticModel::from_pretrained()tokio::task::spawn_blocking()for sync→async conversion"model2vec:{model}"prefix (default:minishlab/potion-base-32M)helix-db/src/helix_gateway/tests/embedding_providers.rs:
Technical Details
Model Loading:
~/.cache/huggingface/StaticModelisClone(Arc-based, cheap)Async Handling:
encode_single()is sync/CPU-boundtokio::task::spawn_blocking()to avoid blocking async runtimeVec<f64>like other providersAvailable Models:
minishlab/potion-base-2M(2MB, 256 dims)minishlab/potion-base-8M(8MB, 256 dims)minishlab/potion-base-32M(32MB, 768 dims) [default]minishlab/potion-retrieval-32M(32MB, 768 dims)Testing
Configuration (config.hx.json):
{ "embedding_model": "model2vec:minishlab/potion-base-32M" }HelixQL:
Breaking Changes
None. All changes are additive:
New feature flag (opt-in)
New enum variant (non-breaking)
New optional field (feature-gated)
Existing providers unchanged
Checklist when merging to main
rustfmthelix-cli/Cargo.tomlandhelixdb/Cargo.tomlAdditional Notes
Greptile Summary
This PR successfully adds
model2vec-rsas a fourth embedding provider, enabling free, local, offline embedding generation without API keys. The implementation follows existing patterns for other providers with proper feature gating, comprehensive documentation, and async handling.Key Changes:
model2vec-rsdependency with feature flag inhelix-db/Cargo.tomlModel2Vecvariant inEmbeddingProviderenum with model loading viaStaticModel::from_pretrained()tokio::task::spawn_blocking()to handle synchronousencode_single()without blocking async runtime"model2vec:{model}"format with defaultminishlab/potion-base-32M#[ignore])Minor Issues Found:
test_parse_model2vec_default) doesn't fully assert the returned model value, though this is a minor style issueImportant Files Changed
model2vec-rsdependency andmodel2vecfeature flagSequence Diagram
sequenceDiagram participant User participant Config participant EmbeddingModelImpl participant StaticModel participant TokenioRuntime participant ThreadPool User->>Config: configure model2vec provider User->>EmbeddingModelImpl: new(api_key, model, url) EmbeddingModelImpl->>EmbeddingModelImpl: parse_provider_and_model() EmbeddingModelImpl->>EmbeddingModelImpl: extract model name EmbeddingModelImpl->>StaticModel: from_pretrained(model_name) Note over StaticModel: Downloads from HuggingFace<br/>Cached locally StaticModel-->>EmbeddingModelImpl: StaticModel instance EmbeddingModelImpl-->>User: EmbeddingModelImpl ready User->>EmbeddingModelImpl: fetch_embedding_async(text) EmbeddingModelImpl->>EmbeddingModelImpl: match Model2Vec provider EmbeddingModelImpl->>EmbeddingModelImpl: clone text and model EmbeddingModelImpl->>TokenioRuntime: spawn_blocking(encode_single) TokenioRuntime->>ThreadPool: schedule blocking task ThreadPool->>StaticModel: encode_single(text) StaticModel-->>ThreadPool: Vec f32 embedding ThreadPool->>ThreadPool: convert f32 to f64 ThreadPool-->>TokenioRuntime: Vec f64 embedding TokenioRuntime-->>EmbeddingModelImpl: Result with embedding EmbeddingModelImpl-->>User: Vec f64 embedding