Repository navigation
Embed MiniLM through the Delosis embedding service, beside E5 - #37
Merged
Merged
Conversation
The Delosis embedding service (delosis-embedding-api 1.2.0) now serves several models from one container, Harmony's default MiniLM among them. A deployment can have it embed MiniLM as well as E5, so the API process no longer loads its own copy at start-up. - delosis_e5_embeddings.py becomes delosis_embeddings.py, a client for any model the service serves for Harmony (REMOTE_MODELS: e5, minilm). HARMONY_EMBEDDER_URL / _TOKEN / _MODELS configure it. The old HARMONY_E5_EMBEDDER_URL / _TOKEN still work and mean E5 only, asked for without a model name, as before. - Requests name the model, and a reply must name the same model and have its dimension: a service that predates model names answers with E5, which must never be taken for MiniLM. - hugging_face_embeddings.py loads at start-up only the models the service does not serve. If the service fails, MiniLM is loaded in-process on first use and used for 60 s before the service is tried again. That fallback normalises, so every MiniLM vector in a process has the service's unit scale (k-means and HDBSCAN use raw vectors; everything else is cosine). E5 has no in-process fallback. - With none of the settings, nothing changes. The service's MiniLM vectors match the in-process ones to cosine 0.9999999 on 498 MHC catalogue items (2 Dec 2026). Unit tests with a fake service and stand-in models: tests/unit_tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
woodthom2
approved these changes
Dec 3, 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
With this change, a deployment can have the Delosis embedding service embed Harmony's default model,
paraphrase-multilingual-MiniLM-L12-v2, as well as E5 (#34). The API process then no longer loads its own copy of MiniLM at start-up. With none of the new settings, nothing changes.delosis_e5_embeddings.pybecomesdelosis_embeddings.py, which works with any model the service serves for Harmony (REMOTE_MODELS: e5 and minilm).HARMONY_EMBEDDER_URL,HARMONY_EMBEDDER_TOKENandHARMONY_EMBEDDER_MODELS(for examplee5,minilm) configure it.HARMONY_E5_EMBEDDER_URLand_TOKEN, still work. On their own they mean E5 only, as before.hugging_face_embeddings.pyloads at start-up only the models the service doesn't serve. If the service fails, MiniLM is loaded in-process on first use and used for 60 seconds before the service is tried again. E5 still has no in-process fallback.The service's MiniLM vectors match the in-process model's to cosine 0.9999999 on 498 Mental Health Catalogue items.
No dependencies added. No file in common with #36.
Type of change
Testing
pytest tests/unit_tests/test_delosis_embeddings.py: 15 tests with a fake service and stand-in models, so no weights load and nothing is sent anywhere. They cover:Test Configuration
mainChecklist
hugging_face_embeddings.pykeeps its CRLF line endings.)delosis_embeddings.py; the README is unchanged)🤖 Generated with Claude Code