Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions explore-analyze/machine-learning/nlp/ml-nlp-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ mapped_pages:

The following pages contain end-to-end examples of how to use the different {{nlp}} tasks in the {{stack}}.

* [An NLP end-to-end tutorial](nlp-end-to-end-tutorial.md)
* [Multilingual semantic search - notebook example](https://colab.research.google.com/github/elastic/elasticsearch-labs/blob/main/notebooks/search/04-multilingual.ipynb)
* [Named entity recognition](ml-nlp-ner-example.md)
* [Text embedding and semantic search](ml-nlp-text-emb-vector-search-example.md)



7 changes: 2 additions & 5 deletions explore-analyze/machine-learning/nlp/ml-nlp-limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ mapped_pages:

The following limitations and known problems apply to the 9.0.0-beta1 release of the Elastic {{nlp}} trained models feature.


## Document size limitations when using `semantic_text` fields [ml-nlp-large-documents-limit-10k-10mb]
## Document size limitations when using `semantic_text` fields [ml-nlp-large-documents-limit-10k-10mb]

When using semantic text to ingest documents, chunking takes place automatically. The number of chunks is limited by the [`index.mapping.nested_objects.limit`](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-settings-limit.html) cluster setting, which defaults to 10k. Documents that are too large will cause errors during ingestion. To avoid this issue, please split your documents into roughly 1MB parts before ingestion.


## ELSER semantic search is limited to 512 tokens per field that inference is applied to [ml-nlp-elser-v1-limit-512]
## ELSER semantic search is limited to 512 tokens per field that inference is applied to [ml-nlp-elser-v1-limit-512]

When you use ELSER for semantic search, only the first 512 extracted tokens from each field of the ingested documents that ELSER is applied to are taken into account for the search process. If your data set contains long documents, divide them into smaller segments before ingestion if you need the full text to be searchable.

10 changes: 0 additions & 10 deletions explore-analyze/machine-learning/nlp/ml-nlp-ner-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ mapped_pages:
- https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-ner-example.html
---



# Named entity recognition [ml-nlp-ner-example]


You can use these instructions to deploy a [named entity recognition (NER)](ml-nlp-extract-info.md#ml-nlp-ner) model in {{es}}, test the model, and add it to an {{infer}} ingest pipeline. The model that is used in the example is publicly available on [HuggingFace](https://huggingface.co/).


## Requirements [ex-ner-requirements]

To follow along the process on this page, you must have:
Expand All @@ -20,7 +16,6 @@ To follow along the process on this page, you must have:
* The [appropriate subscription](https://www.elastic.co/subscriptions) level or the free trial period activated.
* [Docker](https://docs.docker.com/get-docker/) installed.


## Deploy a NER model [ex-ner-deploy]

You can use the [Eland client](https://www.elastic.co/guide/en/elasticsearch/client/eland/current) to install the {{nlp}} model. Use the prebuilt Docker image to run the Eland install model commands. Pull the latest image with:
Expand Down Expand Up @@ -51,7 +46,6 @@ Since the `--start` option is used at the end of the Eland import command, {{es}

Go to the **{{ml-app}} > Trained Models** page and synchronize your trained models. A warning message is displayed at the top of the page that says *"ML job and trained model synchronization required"*. Follow the link to *"Synchronize your jobs and trained models."* Then click **Synchronize**. You can also wait for the automatic synchronization that occurs in every hour, or use the [sync {{ml}} objects API](https://www.elastic.co/guide/en/kibana/current/ml-sync.html).


## Test the NER model [ex-ner-test]

Deployed models can be evaluated in {{kib}} under **{{ml-app}}** > **Trained Models** by selecting the **Test model** action for the respective model.
Expand Down Expand Up @@ -112,10 +106,8 @@ The API returns a response similar to the following:

::::


Using the example text "Elastic is headquartered in Mountain View, California.", the model finds three entities: an organization "Elastic", and two locations "Mountain View" and "California".


## Add the NER model to an {{infer}} ingest pipeline [ex-ner-ingest]

You can perform bulk {{infer}} on documents as they are ingested by using an [{{infer}} processor](https://www.elastic.co/guide/en/elasticsearch/reference/current/inference-processor.html) in your ingest pipeline. The novel *Les Misérables* by Victor Hugo is used as an example for {{infer}} in the following example. [Download](https://github.com/elastic/stack-docs/blob/8.5/docs/en/stack/ml/nlp/data/les-miserables-nd.json) the novel text split by paragraph as a JSON file, then upload it by using the [Data Visualizer](../../../manage-data/ingest.md#upload-data-kibana). Give the new index the name `les-miserables` when uploading the file.
Expand Down Expand Up @@ -187,7 +179,6 @@ POST _reindex

1. The default batch size for reindexing is 1000. Reducing `size` to a smaller number makes the update of the reindexing process quicker which enables you to follow the progress closely and detect errors early.


Take a random paragraph from the source document as an example:

```js
Expand Down Expand Up @@ -240,7 +231,6 @@ The request returns the document marked up with one identified person:
(...)
```


## Visualize results [ex-ner-visual]

You can create a tag cloud to visualize your data processed by the {{infer}} pipeline. A tag cloud is a visualization that scales words by the frequency at which they occur. It is a handy tool for viewing the entities found in the data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ mapped_pages:
- https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-text-emb-vector-search-example.html
---



# Text embedding and semantic search [ml-nlp-text-emb-vector-search-example]


You can use these instructions to deploy a [text embedding](ml-nlp-search-compare.md#ml-nlp-text-embedding) model in {{es}}, test the model, and add it to an {{infer}} ingest pipeline. It enables you to generate vector representations of text and perform vector similarity search on the generated vectors. The model that is used in the example is publicly available on [HuggingFace](https://huggingface.co/).

The example uses a public data set from the [MS MARCO Passage Ranking Task](https://microsoft.github.io/msmarco/#ranking). It consists of real questions from the Microsoft Bing search engine and human generated answers for them. The example works with a sample of this data set, uses a model to produce text embeddings, and then runs vector search on it.

You can find [this example as a Jupyter notebook](https://github.com/elastic/elasticsearch-labs/blob/main/notebooks/integrations/hugging-face/loading-model-from-hugging-face.ipynb) using the Python client in the `elasticsearch-labs` repo.


## Requirements [ex-te-vs-requirements]

To follow along the process on this page, you must have:
Expand All @@ -24,7 +20,6 @@ To follow along the process on this page, you must have:
* The [appropriate subscription](https://www.elastic.co/subscriptions) level or the free trial period activated.
* [Docker](https://docs.docker.com/get-docker/) installed.


## Deploy a text embedding model [ex-te-vs-deploy]

You can use the [Eland client](https://www.elastic.co/guide/en/elasticsearch/client/eland/current) to install the {{nlp}} model. Use the prebuilt Docker image to run the Eland install model commands. Pull the latest image with:
Expand Down Expand Up @@ -55,7 +50,6 @@ Since the `--start` option is used at the end of the Eland import command, {{es}

Go to the **{{ml-app}} > Trained Models** page and synchronize your trained models. A warning message is displayed at the top of the page that says *"ML job and trained model synchronization required"*. Follow the link to *"Synchronize your jobs and trained models."* Then click **Synchronize**. You can also wait for the automatic synchronization that occurs in every hour, or use the [sync {{ml}} objects API](https://www.elastic.co/guide/en/kibana/current/ml-sync.html).


## Test the text embedding model [ex-text-emb-test]

Deployed models can be evaluated in {{kib}} under **{{ml-app}}** > **Trained Models** by selecting the **Test model** action for the respective model.
Expand Down Expand Up @@ -98,10 +92,8 @@ The API returns a response similar to the following:

::::


The result is the predicted dense vector transformed from the example text.


## Load data [ex-text-emb-data]

In this step, you load the data that you later use in an ingest pipeline to get the embeddings.
Expand All @@ -115,7 +107,6 @@ Upload the file by using the [Data Visualizer](../../../manage-data/ingest.md#up
:class: screenshot
:::


## Add the text embedding model to an {{infer}} ingest pipeline [ex-text-emb-ingest]

Process the initial data with an [{{infer}} processor](https://www.elastic.co/guide/en/elasticsearch/reference/current/inference-processor.html). It adds an embedding for each passage. For this, create a text embedding ingest pipeline and then reindex the initial data with this pipeline.
Expand Down Expand Up @@ -195,7 +186,6 @@ POST _reindex?wait_for_completion=false

1. The default batch size for reindexing is 1000. Reducing `size` to a smaller number makes the update of the reindexing process quicker which enables you to follow the progress closely and detect errors early.


The API call returns a task ID that can be used to monitor the progress:

```js
Expand All @@ -211,7 +201,6 @@ You can also open the model stat UI to follow the progress.

After the reindexing is finished, the documents in the new index contain the {{infer}} results – the vector embeddings.


## Semantic search [ex-text-emb-vect-search]

After the dataset has been enriched with vector embeddings, you can query the data using [semantic search](../../../solutions/search/vector/knn.md#knn-semantic-search). Pass a `query_vector_builder` to the k-nearest neighbor (kNN) vector search API, and provide the query text and the model you have used to create vector embeddings. This example searches for "How is the weather in Jamaica?":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
navigation_title: "NLP tutorial"
navigation_title: "End-to-end tutorial"
mapped_pages:
- https://www.elastic.co/guide/en/elasticsearch/reference/current/nlp-example.html
---

# NLP example [nlp-example]
# An NLP end-to-end tutorial [nlp-example]

This guide focuses on a concrete task: getting a machine learning trained model loaded into Elasticsearch and set up to enrich your documents.

Expand Down Expand Up @@ -41,7 +41,7 @@ Follow the steps to **Create** a new deployment. Make sure to add capacity to th

Enriching documents using machine learning was introduced in Enterprise Search **8.5.0**, so be sure to use version **8.5.0 or later**.

## Clone Eland [nlp-example-clone-eland]
## Clone Eland [nlp-example-clone-eland]

Elastic’s [Eland](https://github.com/elastic/eland) tool makes it easy to upload trained models to your deployment via Docker.

Expand Down Expand Up @@ -188,9 +188,9 @@ In this guide, we covered how to:

## Learn more [nlp-example-learn-more]

* [Compatible third party models^](ml-nlp-model-ref.md)
* [NLP Overview^](ml-nlp-overview.md)
* [Compatible third party models](ml-nlp-model-ref.md)
* [NLP Overview](ml-nlp-overview.md)
* [Docker section of Eland readme](https://github.com/elastic/eland#docker)
* [Deploying a model ML guide^](ml-nlp-deploy-models.md)
* [Eland Authentication methods^](ml-nlp-import-model.md#ml-nlp-authentication)
* [Adding inference pipelines](inference-processing.md#ingest-pipeline-search-inference-add-inference-processors)
* [Deploying a model ML guide](ml-nlp-deploy-models.md)
* [Eland Authentication methods](ml-nlp-import-model.md#ml-nlp-authentication)
* [Adding inference pipelines](../machine-learning-in-kibana/inference-processing.md#ingest-pipeline-search-inference-add-inference-processors)
5 changes: 2 additions & 3 deletions explore-analyze/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,16 @@ toc:
- file: machine-learning/nlp/ml-nlp-model-ref.md
- file: machine-learning/nlp/ml-nlp-examples.md
children:
- file: machine-learning/nlp/nlp-end-to-end-tutorial.md
- file: machine-learning/nlp/ml-nlp-ner-example.md
- file: machine-learning/nlp/ml-nlp-text-emb-vector-search-example.md
- file: machine-learning/nlp/ml-nlp-limitations.md
- file: machine-learning/nlp/inference-processing.md
children:
- file: machine-learning/nlp/nlp-example.md
- file: machine-learning/machine-learning-in-kibana.md
children:
- file: machine-learning/machine-learning-in-kibana/xpack-ml-anomalies.md
- file: machine-learning/machine-learning-in-kibana/xpack-ml-dfanalytics.md
- file: machine-learning/machine-learning-in-kibana/xpack-ml-aiops.md
- file: machine-learning/machine-learning-in-kibana/inference-processing.md
- file: machine-learning/aiops-labs.md
children:
- file: machine-learning/aiops-labs/observability-aiops-detect-anomalies.md
Expand Down
Loading