Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify model import code #618

Open
jeffvestal opened this issue Oct 10, 2023 · 0 comments
Open

Simplify model import code #618

jeffvestal opened this issue Oct 10, 2023 · 0 comments
Labels
enhancement New feature or request topic:NLP Issue or PR about NLP model support and eland_import_hub_model

Comments

@jeffvestal
Copy link

Feature Request

As a Python user, I would like to simplify the code required to load an inference model from Hugging Face (or private source) into Elasticsearch.

Use Case

Today eland is the way we load inference models into Elasticsearch. Many users will only use eland to load models, making it as simple to use will help the end-user experience.

Currently, in python, it requires several lines of code
eg:

hf_model_id='sentence-transformers/msmarco-MiniLM-L-12-v3'
tm = TransformerModel(hf_model_id, "text_embedding")
es_model_id = tm.elasticsearch_model_id()
tmp_path = "models"
Path(tmp_path).mkdir(parents=True, exist_ok=True)
model_path, config, vocab_path = tm.save(tmp_path)
ptm = PyTorchModel(es, es_model_id)
ptm.import_model(model_path=model_path, config_path=None, vocab_path=vocab_path, config=config) 

This could be abstracted into a simple function call such as eland.ml.pytorch.import_model and take in the minimum required parameters. Something like

def import_model(
    es: Elasticsearch,
    model_id: str,
    task_type: str = 'text_embedding',
    access_token: Union[str, bool] = False
) -> str:

where it would return the model_id as it is known in Elasticsearch so it can be used later in the code to call inference

cc: @joshdevins

@jeffvestal jeffvestal added the enhancement New feature or request label Oct 10, 2023
@joshdevins joshdevins added the topic:NLP Issue or PR about NLP model support and eland_import_hub_model label Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request topic:NLP Issue or PR about NLP model support and eland_import_hub_model
Projects
None yet
Development

No branches or pull requests

2 participants