Skip to content

Commit edfbd5d

Browse files
authored
[DOCS] Adds elser service to the inference tutorial (#111406) (#111450)
* [DOCS] Adds elser service to the inference tutorial. * [DOCS] Amends search intro text. * [DOCS] Addresses feedback.
1 parent fd02519 commit edfbd5d

13 files changed

+274
-10
lines changed

docs/reference/search/search-your-data/semantic-search-inference.asciidoc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ IMPORTANT: For the easiest way to perform semantic search in the {stack}, refer
1111

1212
The following examples use Cohere's `embed-english-v3.0` model, the `all-mpnet-base-v2` model from HuggingFace, and OpenAI's `text-embedding-ada-002` second generation embedding model.
1313
You can use any Cohere and OpenAI models, they are all supported by the {infer} API.
14-
For a list of supported models available on HuggingFace, refer to
15-
<<inference-example-hugging-face-supported-models, the supported model list>>.
14+
For a list of recommended models available on HuggingFace, refer to <<inference-example-hugging-face-supported-models, the supported model list>>.
1615

1716
Azure based examples use models available through https://ai.azure.com/explore/models?selectedTask=embeddings[Azure AI Studio]
1817
or https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models[Azure OpenAI].
@@ -40,17 +39,15 @@ include::{es-ref-dir}/tab-widgets/inference-api/infer-api-task-widget.asciidoc[]
4039
==== Create the index mapping
4140

4241
The mapping of the destination index - the index that contains the embeddings that the model will create based on your input text - must be created.
43-
The destination index must have a field with the <<dense-vector, `dense_vector`>>
44-
field type to index the output of the used model.
42+
The destination index must have a field with the <<dense-vector, `dense_vector`>> field type for most models and the <<sparse-vector, `sparse_vector`>> field type for the sparse vector models like in the case of the `elser` service to index the output of the used model.
4543

4644
include::{es-ref-dir}/tab-widgets/inference-api/infer-api-mapping-widget.asciidoc[]
4745

4846
[discrete]
4947
[[infer-service-inference-ingest-pipeline]]
5048
==== Create an ingest pipeline with an inference processor
5149

52-
Create an <<ingest,ingest pipeline>> with an
53-
<<inference-processor,{infer} processor>> and use the model you created above to infer against the data that is being ingested in the pipeline.
50+
Create an <<ingest,ingest pipeline>> with an <<inference-processor,{infer} processor>> and use the model you created above to infer against the data that is being ingested in the pipeline.
5451

5552
include::{es-ref-dir}/tab-widgets/inference-api/infer-api-ingest-pipeline-widget.asciidoc[]
5653

@@ -103,8 +100,8 @@ POST _tasks/<task_id>/_cancel
103100
==== Semantic search
104101

105102
After the data set has been enriched with the embeddings, you can query the data using {ref}/knn-search.html#knn-semantic-search[semantic search].
106-
Pass a
107-
`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 the embeddings.
103+
In case of dense vector models, 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 the embeddings.
104+
In case of a sparse vector model like ELSER, use a `sparse_vector` query, and provide the query text with the model you have used to create the embeddings.
108105

109106
NOTE: If you cancelled the reindexing process, you run the query only a part of the data which affects the quality of your results.
110107

docs/reference/tab-widgets/inference-api/infer-api-ingest-pipeline-widget.asciidoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
id="infer-api-ingest-cohere">
88
Cohere
99
</button>
10+
<button role="tab"
11+
aria-selected="false"
12+
aria-controls="infer-api-ingest-elser-tab"
13+
id="infer-api-ingest-elser">
14+
ELSER
15+
</button>
1016
<button role="tab"
1117
aria-selected="false"
1218
aria-controls="infer-api-ingest-hf-tab"
@@ -52,6 +58,17 @@
5258

5359
include::infer-api-ingest-pipeline.asciidoc[tag=cohere]
5460

61+
++++
62+
</div>
63+
<div tabindex="0"
64+
role="tabpanel"
65+
id="infer-api-ingest-elser-tab"
66+
aria-labelledby="infer-api-ingest-elser"
67+
hidden="">
68+
++++
69+
70+
include::infer-api-ingest-pipeline.asciidoc[tag=elser]
71+
5572
++++
5673
</div>
5774
<div tabindex="0"

docs/reference/tab-widgets/inference-api/infer-api-ingest-pipeline.asciidoc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,32 @@ and the `output_field` that will contain the {infer} results.
3535

3636
// end::cohere[]
3737

38+
// tag::elser[]
39+
40+
[source,console]
41+
--------------------------------------------------
42+
PUT _ingest/pipeline/elser_embeddings
43+
{
44+
"processors": [
45+
{
46+
"inference": {
47+
"model_id": "elser_embeddings", <1>
48+
"input_output": { <2>
49+
"input_field": "content",
50+
"output_field": "content_embedding"
51+
}
52+
}
53+
}
54+
]
55+
}
56+
--------------------------------------------------
57+
<1> The name of the inference endpoint you created by using the
58+
<<put-inference-api>>, it's referred to as `inference_id` in that step.
59+
<2> Configuration object that defines the `input_field` for the {infer} process
60+
and the `output_field` that will contain the {infer} results.
61+
62+
// end::elser[]
63+
3864
// tag::hugging-face[]
3965

4066
[source,console]

docs/reference/tab-widgets/inference-api/infer-api-mapping-widget.asciidoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
id="infer-api-mapping-cohere">
88
Cohere
99
</button>
10+
<button role="tab"
11+
aria-selected="false"
12+
aria-controls="infer-api-mapping-elser-tab"
13+
id="infer-api-mapping-elser">
14+
ELSER
15+
</button>
1016
<button role="tab"
1117
aria-selected="false"
1218
aria-controls="infer-api-mapping-hf-tab"
@@ -52,6 +58,17 @@
5258

5359
include::infer-api-mapping.asciidoc[tag=cohere]
5460

61+
++++
62+
</div>
63+
<div tabindex="0"
64+
role="tabpanel"
65+
id="infer-api-mapping-elser-tab"
66+
aria-labelledby="infer-api-mapping-elser"
67+
hidden="">
68+
++++
69+
70+
include::infer-api-mapping.asciidoc[tag=elser]
71+
5572
++++
5673
</div>
5774
<div tabindex="0"

docs/reference/tab-widgets/inference-api/infer-api-mapping.asciidoc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,34 @@ the {infer} pipeline configuration in the next step.
3131

3232
// end::cohere[]
3333

34+
// tag::elser[]
35+
36+
[source,console]
37+
--------------------------------------------------
38+
PUT elser-embeddings
39+
{
40+
"mappings": {
41+
"properties": {
42+
"content_embedding": { <1>
43+
"type": "sparse_vector" <2>
44+
},
45+
"content": { <3>
46+
"type": "text" <4>
47+
}
48+
}
49+
}
50+
}
51+
--------------------------------------------------
52+
<1> The name of the field to contain the generated tokens. It must be refrenced
53+
in the {infer} pipeline configuration in the next step.
54+
<2> The field to contain the tokens is a `sparse_vector` field for ELSER.
55+
<3> The name of the field from which to create the dense vector representation.
56+
In this example, the name of the field is `content`. It must be referenced in
57+
the {infer} pipeline configuration in the next step.
58+
<4> The field type which is text in this example.
59+
60+
// end::elser[]
61+
3462
// tag::hugging-face[]
3563

3664
[source,console]

docs/reference/tab-widgets/inference-api/infer-api-reindex-widget.asciidoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
id="infer-api-reindex-cohere">
88
Cohere
99
</button>
10+
<button role="tab"
11+
aria-selected="false"
12+
aria-controls="infer-api-reindex-elser-tab"
13+
id="infer-api-reindex-elser">
14+
ELSER
15+
</button>
1016
<button role="tab"
1117
aria-selected="false"
1218
aria-controls="infer-api-reindex-hf-tab"
@@ -52,6 +58,17 @@
5258

5359
include::infer-api-reindex.asciidoc[tag=cohere]
5460

61+
++++
62+
</div>
63+
<div tabindex="0"
64+
role="tabpanel"
65+
id="infer-api-reindex-elser-tab"
66+
aria-labelledby="infer-api-reindex-elser"
67+
hidden="">
68+
++++
69+
70+
include::infer-api-reindex.asciidoc[tag=elser]
71+
5572
++++
5673
</div>
5774
<div tabindex="0"

docs/reference/tab-widgets/inference-api/infer-api-reindex.asciidoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,29 @@ may affect the throughput of the reindexing process.
2525

2626
// end::cohere[]
2727

28+
// tag::elser[]
29+
30+
[source,console]
31+
----
32+
POST _reindex?wait_for_completion=false
33+
{
34+
"source": {
35+
"index": "test-data",
36+
"size": 50 <1>
37+
},
38+
"dest": {
39+
"index": "elser-embeddings",
40+
"pipeline": "elser_embeddings"
41+
}
42+
}
43+
----
44+
// TEST[skip:TBD]
45+
<1> The default batch size for reindexing is 1000. Reducing `size` to a smaller
46+
number makes the update of the reindexing process quicker which enables you to
47+
follow the progress closely and detect errors early.
48+
49+
// end::elser[]
50+
2851
// tag::hugging-face[]
2952

3053
[source,console]

docs/reference/tab-widgets/inference-api/infer-api-requirements-widget.asciidoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
id="infer-api-requirements-cohere">
88
Cohere
99
</button>
10+
<button role="tab"
11+
aria-selected="false"
12+
aria-controls="infer-api-requirements-elser-tab"
13+
id="infer-api-requirements-elser">
14+
ELSER
15+
</button>
1016
<button role="tab"
1117
aria-selected="false"
1218
aria-controls="infer-api-requirements-hf-tab"
@@ -52,6 +58,17 @@
5258

5359
include::infer-api-requirements.asciidoc[tag=cohere]
5460

61+
++++
62+
</div>
63+
<div tabindex="0"
64+
role="tabpanel"
65+
id="infer-api-requirements-elser-tab"
66+
aria-labelledby="infer-api-requirements-elser"
67+
hidden="">
68+
++++
69+
70+
include::infer-api-requirements.asciidoc[tag=elser]
71+
5572
++++
5673
</div>
5774
<div tabindex="0"

docs/reference/tab-widgets/inference-api/infer-api-requirements.asciidoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ the Cohere service.
55

66
// end::cohere[]
77

8+
// tag::elser[]
9+
10+
ELSER is a model trained by Elastic. If you have an {es} deployment, there is no
11+
further requirement for using the {infer} API with the `elser` service.
12+
13+
// end::elser[]
14+
815
// tag::hugging-face[]
916

1017
A https://huggingface.co/[HuggingFace account] is required to use the {infer}

docs/reference/tab-widgets/inference-api/infer-api-search-widget.asciidoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
id="infer-api-search-cohere">
88
Cohere
99
</button>
10+
<button role="tab"
11+
aria-selected="false"
12+
aria-controls="infer-api-search-elser-tab"
13+
id="infer-api-search-elser">
14+
ELSER
15+
</button>
1016
<button role="tab"
1117
aria-selected="false"
1218
aria-controls="infer-api-search-hf-tab"
@@ -52,6 +58,17 @@
5258

5359
include::infer-api-search.asciidoc[tag=cohere]
5460

61+
++++
62+
</div>
63+
<div tabindex="0"
64+
role="tabpanel"
65+
id="infer-api-search-elser-tab"
66+
aria-labelledby="infer-api-search-elser"
67+
hidden="">
68+
++++
69+
70+
include::infer-api-search.asciidoc[tag=elser]
71+
5572
++++
5673
</div>
5774
<div tabindex="0"

0 commit comments

Comments
 (0)