Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions explore-analyze/machine-learning/nlp.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ You can use {{stack-ml-features}} to analyze natural language data and make pred
* [Add NLP {{infer}} to ingest pipelines](nlp/ml-nlp-inference.md)
* [API quick reference](nlp/ml-nlp-apis.md)
* [ELSER](nlp/ml-nlp-elser.md)
* [Elastic Rerank](nlp/ml-nlp-rerank.md)
* [E5](nlp/ml-nlp-e5.md)
* [Language identification](nlp/ml-nlp-lang-ident.md)
* [Examples](nlp/ml-nlp-examples.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ There are {{nlp}} models that are available for use in every cluster out-of-the-
* [ELSER](ml-nlp-elser.md) trained by Elastic
* [E5](ml-nlp-e5.md)
* [{{lang-ident-cap}}](ml-nlp-lang-ident.md)





46 changes: 15 additions & 31 deletions explore-analyze/machine-learning/nlp/ml-nlp-e5.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ mapped_pages:
- https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-e5.html
---



# E5 [ml-nlp-e5]


EmbEddings from bidirEctional Encoder rEpresentations - or E5 - is a {{nlp}} model that enables you to perform multi-lingual semantic search by using dense vector representations. This model is recommended for non-English language documents and queries. If you want to perform semantic search on English language documents, use the [ELSER](ml-nlp-elser.md) model.

[Semantic search](../../../solutions/search/semantic-search.md) provides you search results based on contextual meaning and user intent, rather than exact keyword matches.
Expand All @@ -17,23 +14,21 @@ E5 has two versions: one cross-platform version which runs on any hardware and o

Refer to the model cards of the [multilingual-e5-small](https://huggingface.co/elastic/multilingual-e5-small) and the [multilingual-e5-small-optimized](https://huggingface.co/elastic/multilingual-e5-small-optimized) models on HuggingFace for further information including licensing.


## Requirements [e5-req]

To use E5, you must have the [appropriate subscription](https://www.elastic.co/subscriptions) level for semantic search or the trial period activated.

Enabling trained model autoscaling for your E5 deployment is recommended. Refer to [*Trained model autoscaling*](ml-nlp-auto-scale.md) to learn more.


## Download and deploy E5 [download-deploy-e5]

The easiest and recommended way to download and deploy E5 is to use the [{{infer}} API](https://www.elastic.co/guide/en/elasticsearch/reference/current/inference-apis.html).

1. In {{kib}}, navigate to the **Dev Console**.
2. Create an {{infer}} endpoint with the `elasticsearch` service by running the following API request:

```console
PUT _inference/text_embedding/my-e5-model
```console
PUT _inference/text_embedding/my-e5-model
{
"service": "elasticsearch",
"service_settings": {
Expand All @@ -42,16 +37,14 @@ The easiest and recommended way to download and deploy E5 is to use the [{{infer
"model_id": ".multilingual-e5-small"
}
}
```
```

The API request automatically initiates the model download and then deploy the model.


Refer to the [`elasticsearch` {{infer}} service documentation](../../../solutions/search/inference-api/elasticsearch-inference-integration.md) to learn more about the available settings.

After you created the E5 {{infer}} endpoint, it’s ready to be used for semantic search. The easiest way to perform semantic search in the {{stack}} is to [follow the `semantic_text` workflow](../../../solutions/search/semantic-search/semantic-search-semantic-text.md).


### Alternative methods to download and deploy E5 [alternative-download-deploy-e5]

You can also download and deploy the E5 model either from **{{ml-app}}** > **Trained Models**, from **Search** > **Indices**, or by using the trained models API in Dev Console.
Expand All @@ -60,7 +53,6 @@ You can also download and deploy the E5 model either from **{{ml-app}}** > **Tra
For most cases, the preferred version is the **Intel and Linux optimized** model, it is recommended to download and deploy that version.
::::


::::{dropdown} Using the Trained Models page

#### Using the Trained Models page [trained-model-e5]
Expand All @@ -87,7 +79,6 @@ For most cases, the preferred version is the **Intel and Linux optimized** model

::::


::::{dropdown} Using the search indices UI

#### Using the search indices UI [elasticsearch-e5]
Expand All @@ -111,65 +102,61 @@ Alternatively, you can download and deploy the E5 model to an {{infer}} pipeline
:class: screenshot
:::


When your E5 model is deployed and started, it is ready to be used in a pipeline.

::::


::::{dropdown} Using the trained models API in Dev Console

#### Using the trained models API in Dev Console [dev-console-e5]

1. In {{kib}}, navigate to the **Dev Console**.
2. Create the E5 model configuration by running the following API call:

```console
PUT _ml/trained_models/.multilingual-e5-small
```console
PUT _ml/trained_models/.multilingual-e5-small
{
"input": {
"field_names": ["text_field"]
}
}
```
```

The API call automatically initiates the model download if the model is not downloaded yet.

3. Deploy the model by using the [start trained model deployment API](https://www.elastic.co/guide/en/elasticsearch/reference/current/start-trained-model-deployment.html) with a delpoyment ID:

```console
POST _ml/trained_models/.multilingual-e5-small/deployment/_start?deployment_id=for_search
```

```console
POST _ml/trained_models/.multilingual-e5-small/deployment/_start?deployment_id=for_search
```

::::



## Deploy the E5 model in an air-gapped environment [air-gapped-install-e5]

If you want to install E5 in an air-gapped environment, you have the following options: * put the model artifacts into a directory inside the config directory on all master-eligible nodes (for `multilingual-e5-small` and `multilingual-e5-small-linux-x86-64`) * install the model by using HuggingFace (for `multilingual-e5-small` model only).
If you want to install E5 in an air-gapped environment, you have the following options:

* put the model artifacts into a directory inside the config directory on all master-eligible nodes (for `multilingual-e5-small` and `multilingual-e5-small-linux-x86-64`)
* install the model by using HuggingFace (for `multilingual-e5-small` model only).

### Model artifact files [e5-model-artifacts]

For the `multilingual-e5-small` model, you need the following files in your system:

```
```url
https://ml-models.elastic.co/multilingual-e5-small.metadata.json
https://ml-models.elastic.co/multilingual-e5-small.pt
https://ml-models.elastic.co/multilingual-e5-small.vocab.json
```

For the optimized version, you need the following files in your system:

```
```url
https://ml-models.elastic.co/multilingual-e5-small_linux-x86_64.metadata.json
https://ml-models.elastic.co/multilingual-e5-small_linux-x86_64.pt
https://ml-models.elastic.co/multilingual-e5-small_linux-x86_64.vocab.json
```


### Using file-based access [_using_file_based_access_3]

For a file-based access, follow these steps:
Expand All @@ -178,7 +165,7 @@ For a file-based access, follow these steps:
2. Put the files into a `models` subdirectory inside the `config` directory of your {{es}} deployment.
3. Point your {{es}} deployment to the model directory by adding the following line to the `config/elasticsearch.yml` file:

```
```yml
xpack.ml.model_repository: file://${path.home}/config/models/`
```

Expand All @@ -190,7 +177,6 @@ For a file-based access, follow these steps:
9. Provide a deployment ID, select the priority, and set the number of allocations and threads per allocation values.
10. Click **Start**.


### Using the HuggingFace repository [_using_the_huggingface_repository]

You can install the `multilingual-e5-small` model in a restricted or closed network by pointing the `eland_import_hub_model` script to the model’s local files.
Expand Down Expand Up @@ -230,8 +216,6 @@ For an offline install, the model first needs to be cloned locally, Git and [Git

Once it’s uploaded to {{es}}, the model will have the ID specified by `--es-model-id`. If it is not set, the model ID is derived from `--hub-model-id`; spaces and path delimiters are converted to double underscores `__`.



## Disclaimer [terms-of-use-e5]

Customers may add third party trained models for management in Elastic. These models are not owned by Elastic. While Elastic will support the integration with these models in the performance according to the documentation, you understand and agree that Elastic has no control over, or liability for, the third party models or the underlying training data they may utilize.
Expand Down
Loading
Loading