Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: support multiple text embedding providers #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
peter-gy wants to merge 11 commits into apple:main
base: main
Choose a base branch
Loading
from peter-gy:peter-gy/support-multiple-embedding-providers

Conversation

@peter-gy
Copy link

@peter-gy peter-gy commented Oct 22, 2025

Summary

Adds support for multiple text embedding providers through LiteLLM integration, enabling users to leverage API-based models (OpenAI, Cohere, Azure, Ollama, etc.) alongside the existing local SentenceTransformers approach. compute_text_projection() API remains 100% backward compatible; new parameters are optional.

Changes

  • New CLI Options: Added --text-projector to route between litellm and sentence_transformers, and exposed --api-key, --api-base, --dimensions, and --sync flags for LiteLLM-specific configuration
  • Provider Abstraction: Introduced TextProjectorCallback type and provider-specific implementations (_project_text_with_sentence_transformers, _project_text_with_litellm) so that we can keep benefitting from the existing caching approach regardless of the model used to compute the projections
  • Examples: Added notebook cells demonstrating Ollama (locally-served API) and OpenAI (remote API) embedding workflows

Testing

Verified in packages/backend/examples/notebook.ipynb with:

  • SentenceTransformers (default, backward compatibility)
  • Ollama API (nomic-embed-text)
  • OpenAI API (text-embedding-3-small)

Copy link
Collaborator

@donghaoren donghaoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the new addition! A couple of comments.

"llvmlite >= 0.43.0",
"accelerate >= 1.5.0",
"tqdm >= 4.60.0",
"litellm>=1.78.5",
Copy link
Collaborator

@donghaoren donghaoren Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"litellm>=1.78.5",
"litellm >= 1.78.5",

peter-gy reacted with thumbs up emoji
text_projector = _project_text_with_sentence_transformers

hasher = Hasher()
hasher.update(
Copy link
Collaborator

@donghaoren donghaoren Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In _projection_for_texts, we have a caching mechanism that computes a hash from the parameters and use the hash as a cache filename. It seems like we are not taking into account all text projector parameters (e.g., the text projector type, dimensions). Could you update the code to include the text projector type (as string) and args into the hasher, and increment the "version" number?

Copy link
Author

@peter-gy peter-gy Oct 28, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course. Thanks for pointing it out. Addressed this in 823a82b.

donghaoren reacted with thumbs up emoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@donghaoren donghaoren donghaoren left review comments

@domoritz domoritz Awaiting requested review from domoritz

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /