Skip to content

Conversation

@peter-gy
Copy link

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

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",

text_projector = _project_text_with_sentence_transformers

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

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

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 donghaoren requested a review from domoritz October 28, 2025 20:19
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.

2 participants