# Create and Deploy custom ML models for NLP

**URL:** <https://discuss.elastic.co/t/create-and-deploy-custom-ml-models-for-nlp/326777>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-machine-learning\
**Created:** [March 1, 2023, 3:27pm UTC](https://discuss.elastic.co/t/create-and-deploy-custom-ml-models-for-nlp/326777 "2023-03-01T15:27:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastianboelling](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@sebastianboelling](https://discuss.elastic.co/u/sebastianboelling)\
**Post date:** [March 1, 2023, 3:27pm UTC](https://discuss.elastic.co/t/create-and-deploy-custom-ml-models-for-nlp/326777/1 "2023-03-01T15:27:32Z")

</div>

Hello,

I've read the documentation on ML and deploying ML models [Overview | Machine Learning in the Elastic Stack [8.6] | Elastic](https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-overview.html).

Does anyone have examples of how to do the following:

1. Create a custom ML model that fits the needs (pytorch, TorchScript representation, etc.)
2. Deploy an local ML model not hosted on [huggingface.co](http://huggingface.co)

Best regards

Sebastian

---

<div class="post-metadata">

**Author:** ![dkyle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkyle/32/59114_2.png) [@dkyle](https://discuss.elastic.co/u/dkyle)\
**Post date:** [March 1, 2023, 4:42pm UTC](https://discuss.elastic.co/t/create-and-deploy-custom-ml-models-for-nlp/326777/2 "2023-03-01T16:42:19Z")

</div>

Hi Sebastian

> [@sebastianboelling](#):
>
> Create a custom ML model that fits the needs (pytorch, TorchScript representation, etc.)

One example would be to fine tune a text embedding model for your specific needs. Using one of the compatible models listed [here](https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-model-ref.html#ml-nlp-model-ref-text-embedding) as the base model.

> [@sebastianboelling](#):
>
> Deploy an local ML model not hosted on [huggingface.co](http://huggingface.co)

Use the Eland `eland_import_hub_model` script with the `--hub-model-id` argument set to the the path to the model.

See the example in [Deploy trained model offline environment · Issue #502 · elastic/eland · GitHub](https://github.com/elastic/eland/issues/502)

---

<div class="post-metadata">

**Author:** ![sebastianboelling](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@sebastianboelling](https://discuss.elastic.co/u/sebastianboelling)\
**Post date:** [March 2, 2023, 7:48am UTC](https://discuss.elastic.co/t/create-and-deploy-custom-ml-models-for-nlp/326777/3 "2023-03-02T07:48:38Z")

</div>

Hi @dkyle,

Thank you for your quick response. The offline example seems feasible. I will test that - thank you very much.

Do you have examples of creating your own ML models that meet Elastic requirements? I have the language requirement to provide NER, fill-mask, Q&A, text classification and embedding and also similarity in German language. So I'm afraid deriving a model from an existing one from Huggingface (most are English) would not be sufficient for our needs.

Thanks and best regards

Sebastian

---

<div class="post-metadata">

**Author:** ![dkyle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkyle/32/59114_2.png) [@dkyle](https://discuss.elastic.co/u/dkyle)\
**Post date:** [March 2, 2023, 12:57pm UTC](https://discuss.elastic.co/t/create-and-deploy-custom-ml-models-for-nlp/326777/4 "2023-03-02T12:57:22Z")

</div>

Creating and training a transformer model is quite an advanced task and beyond the scope of this forum sorry.

There are a number of German language models on HuggingFace, simply searching for [German](https://huggingface.co/models?search=german) returns 404 models.

Here's a German Bert base: [bert-base-german-cased · Hugging Face](https://huggingface.co/bert-base-german-cased)  
A model for sentiment analysis: [oliverguhr/german-sentiment-bert · Hugging Face](https://huggingface.co/oliverguhr/german-sentiment-bert)  
Q and A: [deepset/gbert-base-germandpr-question\_encoder · Hugging Face](https://huggingface.co/deepset/gbert-base-germandpr-question_encoder)

And many more...

Not all of the models will be compatible with Elastic, in general most BERT based models will be compatible and are a good place to start. See also the list of known [compatible models](https://www.elastic.co/guide/en/machine-learning/master/ml-nlp-model-ref.html) (this is a small sample there will be many more models that are compatible).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 30, 2023, 12:57pm UTC](https://discuss.elastic.co/t/create-and-deploy-custom-ml-models-for-nlp/326777/5 "2023-03-30T12:57:25Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
