chore(python): refactor legacy code in WatsonxEmbeddings component#3660
Conversation
|
Hi @jackye1995 @wjones127 @u70b3 Could you please take a look into this changes? |
|
Thanks for tagging me. I’m not a core maintainer of this project, but since you asked for a review, I took a careful look at the compatibility and configuration behavior. The overall direction makes sense, especially adding 1. Existing tables may silently switch embedding modelsLanceDB persists only the arguments explicitly passed to def create(cls, **kwargs):
instance = cls(**resolved_kwargs)
instance._original_args = kwargsdef safe_model_dump(self):
return self._original_argsThe function is later reconstructed from this metadata: function=self.get(obj["name"]).create(**obj["model"])Therefore, After this PR changes the default: name: str = "ibm/granite-embedding-278m-multilingual"an existing table whose vectors were generated with the previous Slate default will use Granite for new query embeddings. Both models produce 768-dimensional vectors, so this will not raise a dimension error. It may instead silently degrade retrieval correctness. Suggestion: Preserve the legacy default when reading old metadata, or introduce explicit versioning/migration for the stored embedding configuration. 2. The new supported-model list needs verificationIBM’s current SaaS documentation states:
This seems inconsistent with presenting these models as the new current supported set. Could you clarify the targeted watsonx deployment/version and verify the list accordingly? 3. Explicit scope arguments can conflict with environment variablesThe current resolution logic is: project_id = self.project_id or os.environ.get("WATSONX_PROJECT_ID")
space_id = self.space_id or os.environ.get("WATSONX_SPACE_ID")For example, explicitly passing It may be more predictable for an explicitly selected scope to take precedence over the opposite environment variable. Environment fallback could be applied only when neither scope was explicitly provided. 4. Missing testsThis PR changes:
However, it does not add tests for these behaviors. It would be helpful to add mocked tests covering:
ConclusionThe Because of that risk, I’m not sure this change is fully backward-compatible or best classified as a |
|
@u70b3 I responded to your review., Could you please take a look again? |
|
Thanks for the update. The explicit Two items remain:
Could you address these two points before merging? |
|
@u70b3 Thanks for your comments. I believe all of the issues you pointed out have now been addressed. |
|
Thanks for the update. The scope precedence issue is fixed, and restoring the
original = create()
reloaded = create(**original.safe_model_dump())
assert reloaded.name == original.nameBoth instances use the current class default, so the test still passes if both assert reloaded.name == "ibm/slate-125m-english-rtrvr"
return list(MODELS_DIMS.keys())This mixes currently available, deprecated, and compatibility-only model IDs, IBM documents regional availability and withdrawal dates of June 8, 2026 for Please separate models advertised to new users from legacy IDs retained only Non-blocking: since this adds |
|
@u70b3 Done, thanks for comment |
Co-authored-by: Will Jones <[email protected]>
Co-authored-by: Will Jones <[email protected]>
|
@wjones127 Done, thanks! |
|
Hi @wjones127 @jackye1995 |
|
Hi @wjones127 @Xuanwo @u70b3 @AyushExel @jackye1995 |
|
LGTM. I don't have write permission to formally approve this PR. |
What
WatsonxEmbeddingswith the current supported set:ibm/granite-embedding-278m-multilingual(new default, 768-dim)ibm/slate-125m-english-rtrvr-v2(768-dim)ibm/slate-30m-english-rtrvr-v2(384-dim)intfloat/multilingual-e5-large(1024-dim)sentence-transformers/all-minilm-l6-v2(384-dim)space_idfield — mutually exclusive withproject_id, mirrors theexisting pattern in
WatsonxRerankerproject_id/space_idresolution now falls back toWATSONX_PROJECT_ID/WATSONX_SPACE_IDenv vars; exactly one must be suppliedWhy
The previously hardcoded models (
ibm/slate-125m-english-rtrvr,sentence-transformers/all-minilm-l12-v2) are legacy and no longer listed assupported by the watsonx.ai platform.
space_idscoping was already supportedby
WatsonxRerankerbut was missing from the embeddings counterpart.