Refactor/embedding service cleanup - #44
Merged
Merged
Conversation
hinxcode
force-pushed
the
refactor/embedding-service-cleanup
branch
from
May 8, 2026 09:38
cd7b10d to
3f4cb14
Compare
Collaborator
|
@hinxcode Thank you for making these updates, everything looks good. I was able to generate new embeddings and run the unit tests successfully. |
ktamaral
approved these changes
May 28, 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.
Description
Make the offline embedding script use the new
BaseEmbeddingService(it was bypassing it), stop the factoryfrom loading a model at import time, and fix SigLIP's scoring formula.
Motivation and Context
Abstraction not used in the offline path.
generate_embeddings.pyreached intoservice.model/.processordirectly, so adding a new model would require touching the batch script. Now it callsservice.encode_image().Module-level singleton in
embedding_service_factory. Importing the module triggered model download and collided with the existing vector-storeembedding_servicesingleton.SigLIP scoring used CLIP's formula (
logit_scale * sim) instead of SigLIP's (sigmoid(logit_scale * sim + logit_bias)).transformers>=5.0.0forced CLIP-only users to upgrade. SigLIP needs only>=4.42.0.Type of Change
Component(s) Affected
Changes Made
BaseEmbeddingService.encode_image()in offline pipeline; dropsrc/models/clip/layersearch.pyowns its instancetransform_scoreabstract method; SigLIP appliessigmoid(logit_scale * sim + logit_bias)EmbeddingService.search()takes optionalscore_transformcallable instead of scalarlogit_scaleembedding_servicefromservices/__init__.py(avoids name collision)transformers>=4.42.0; restoreconfig.jsondefault toclip+cudapyproject.tomlwith black + isort configor "clip"fallback in factorytest_search_with_logit_scale→test_search_with_score_transformto match new callable APIcontinue-on-errorfrom the pytest job (was masking failures)Testing
How Has This Been Tested?
pytest tests/passesTest Configuration
Screenshots (if applicable)
Checklist
Code Quality
black .andisort .on Python codenpm run linton frontend code (if applicable)Testing
Documentation
config.jsondocumentation if config changes were madeDependencies
requirements.txt(if Python dependencies changed)package.json(if Node dependencies changed)Research (if applicable)
Breaking Changes
Two internal-API changes; both updated in this PR:
EmbeddingService.search(): parameterlogit_scale: Optional[float]replaced withscore_transform: Optional[Callable[[Tensor], Tensor]].services/__init__.py: no longer re-exportsembedding_service(it pointed to the factory's encoder, conflicting with the vector-store singleton). Import fromembedding_service_factorydirectly.Additional Notes
The
transform_scoreabstraction makes explicit that absolute scores differ across models. Benchmarking should rely on rank-based metrics rather than score thresholds.Reviewers Checklist (for maintainers)