feat: pluggable embedding provider registry#87
Merged
Conversation
Add an EmbeddingProvider protocol and registry so Context auto-embeds
text at write time and string queries at search time, eliminating the
need for each caller to maintain their own embedding pipeline.
Built-in providers for OpenAI and sentence-transformers ship as optional
extras (lance-context[openai] / lance-context[sentence-transformers]);
the registry accepts any object satisfying the EmbeddingProvider protocol
for custom backends.
- EmbeddingProvider: runtime-checkable Protocol (dims, embed_texts)
- Context.create/AsyncContext.create: new embedding_provider kwarg
(instance or {"provider": "openai", "model": ...} dict)
- add() / upsert(): auto-embed text payloads when no manual embedding
given; manual embedding= always takes precedence
- add_many(): batch-embeds all uneembedded text records in one call
- search(): accepts a plain string query and auto-embeds it via the
provider; existing vector queries are unaffected
- fork() propagates the provider to the child context
- EmbeddingProvider exported from the top-level package
Closes #85
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
beinan
approved these changes
Jun 13, 2026
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
EmbeddingProviderprotocol and registry soContextauto-embeds text at write time and auto-embeds string queries at search time — eliminating the per-caller embedding glue described in Proposal: pluggable embedding provider registry (OpenAI / Jina / local) for auto-embedding on ingest #85OpenAIProvider,SentenceTransformersProvider) behind optional extras; accepts any object satisfying the protocol for custom backendsembedding=always takes precedence; existing callers are unaffectedAPI
Changes
lance_context/embeddings.pyEmbeddingProviderprotocol,OpenAIProvider,SentenceTransformersProvider,_build_providerregistrylance_context/api.pyembedding_providerkwarg on__init__/create; auto-embed inadd,upsert,add_many,search; provider propagated throughforklance_context/__init__.pyEmbeddingProviderpyproject.toml[openai]and[sentence-transformers]optional extrastests/test_embeddings.pyNotes
retrieve()is intentionally not wired: itstextarg feeds BM25 (not the vector index), so a separatevector=kwarg is already the right surface if hybrid retrieval with auto-embedding is wanted in a follow-upadd_many()sends all un-embedded text records in one provider call — batching is preserved end-to-endTest plan
python/tests/test_embeddings.py— 15 unit tests, zero external depstest_search.py,test_add_many.py,test_delete.py,test_async.py— all pass (85 total across these suites)Closes #85
🤖 Generated with Claude Code