feat(extensions): add LatticeWasmEmbeddings provider#651
Open
ohdearquant wants to merge 1 commit into
Open
Conversation
Adds LatticeWasmEmbeddings, a local embeddings provider backed by the published @khive-ai/lattice-embed-wasm package (a pure-Rust BERT-family text embedder compiled to WebAssembly). It plugs into the existing EmbeddingProvider seam alongside OpenAI/Cohere/Anthropic/HuggingFace, giving a native-Rust local embedder option with no @xenova/transformers dependency. - getMaxBatchSize() honestly returns 1: the wasm package has no batch API, so this does not simulate a larger batch. - getDimension() returns 384 for both supported models (minilm, bge-small). - embedTexts() dynamic-imports the optional peer dependency (mirrors the existing HuggingFaceEmbeddings pattern) and treats a null result from the wasm layer as a real error for an explicitly-selected provider, never a silent skip. - Added as an optional peerDependency (peerDependenciesMeta.optional), matching the existing openai/cohere-ai convention. - Tests mirror the existing per-provider style: construction, dimension, batch size, and a live-embed assertion (exact 384 dim, L2 norm) gated behind package/model-weight availability.
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.
Summary
Adds LatticeWasmEmbeddings, a local embeddings provider for ruvector-extensions backed by @khive-ai/lattice-embed-wasm, a pure-Rust BERT-family text embedder compiled to WebAssembly (source: ohdearquant/lattice/npm/lattice-embed-wasm). It plugs into the existing EmbeddingProvider seam next to the OpenAI, Cohere, Anthropic, and HuggingFace providers, giving a native-Rust local-embedding option that does not depend on @xenova/transformers. Offered as a convenience alternative at parity with the existing HuggingFaceEmbeddings local path, not a faster or higher-quality replacement.
What it does
Test plan
Note (limitation of the underlying package, not this PR): the wasm package's release-asset weight-fetch tier is not live yet, so a user with no local model cache and no model-dir override currently gets a thrown error on first embed. Local-cache and env-override paths work today.