Add expansion_type parameter to API call from eland_import_hub_model#802
Open
daixque wants to merge 4 commits intoelastic:mainfrom
Open
Add expansion_type parameter to API call from eland_import_hub_model#802daixque wants to merge 4 commits intoelastic:mainfrom
daixque wants to merge 4 commits intoelastic:mainfrom
Conversation
…ate inference logic for text expansion task
davidkyle
reviewed
Jul 22, 2025
| elif self._task_type == "text_expansion": | ||
| sample_embedding = self._traceable_model.sample_output() | ||
| if type(sample_embedding) is tuple: | ||
| text_embedding = sample_embedding[0] |
Member
There was a problem hiding this comment.
Please rename text_embedding to sparse_embedding
Contributor
Author
There was a problem hiding this comment.
In the current codebase, text_expansion is used in anywhere. (No sparse_embedding)
https://github.com/search?q=repo%3Aelastic%2Feland%20text_expansion&type=code
% grep -inR "text_expansion" eland tests | grep -v "Binary file"
eland/ml/pytorch/transformers.py:76: "text_expansion",
eland/ml/pytorch/transformers.py:97: "text_expansion": TextExpansionInferenceOptions,
eland/ml/pytorch/transformers.py:557: elif self._task_type == "text_expansion":
eland/ml/pytorch/transformers.py:747: if self._task_type == "text_expansion":
eland/ml/pytorch/nlp_ml_model.py:320: super().__init__(configuration_type="text_expansion")
tests/ml/pytorch/test_pytorch_model_config_pytest.py:149: "text_expansion",
tests/ml/pytorch/test_pytorch_model_config_pytest.py:217: if task_type == "text_expansion":
Should I rename everything? It will cause CLI interface change. Should we keep --task-type=text_expansion for the compatibility? (I feel that renaming should be another PR)
Member
There was a problem hiding this comment.
Ah ok thanks. Yes the rename is not necessary in this PR
Co-authored-by: David Kyle <david.kyle@elastic.co>
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.
Overview
This PR is related to the Elasticsearch change: elastic/elasticsearch#131679
In the above PR, Elasticsearch supports sparse embeddings including non-ELSER models. A significant example of a sparse vector model is the SPLADE model, which is a reference model for ELSER.
To inform Elasticsearch that the target model is for a SPLADE type one, this PR introduces a new
expansion_typeparameter when it calls the create trained model API.How Eland detects the SPLADE model
Eland identifies the model as a SPLADE model by checking the dimention of the output tensor. If the second dimension of the output tensor is over 1, it is considered a SPLADE model. This is because SPLADE models typically output embeddings per token, which is different from ELSER.
Related