Skip to content

Commit 8f6f8a3

Browse files
authored
[DOCS] Dense vector element type should be float for OpenAI (#104966) (#104967)
1 parent 6bf2c71 commit 8f6f8a3

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

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

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
<titleabbrev>Semantic search with the {infer} API</titleabbrev>
55
++++
66

7-
The instructions in this tutorial shows you how to use the {infer} API with the
8-
Open AI service to perform semantic search on your data. The following example
9-
uses OpenAI's `text-embedding-ada-002` second generation embedding model. You
7+
The instructions in this tutorial shows you how to use the {infer} API with the
8+
Open AI service to perform semantic search on your data. The following example
9+
uses OpenAI's `text-embedding-ada-002` second generation embedding model. You
1010
can use any OpenAI models, they are all supported by the {infer} API.
1111

1212

1313
[discrete]
1414
[[infer-openai-requirements]]
1515
==== Requirements
1616

17-
An https://openai.com/[OpenAI account] is required to use the {infer} API with
18-
the OpenAI service.
17+
An https://openai.com/[OpenAI account] is required to use the {infer} API with
18+
the OpenAI service.
1919

2020

2121
[discrete]
@@ -39,23 +39,23 @@ PUT _inference/text_embedding/openai_embeddings <1>
3939
------------------------------------------------------------
4040
// TEST[skip:TBD]
4141
<1> The task type is `text_embedding` in the path.
42-
<2> The API key of your OpenAI account. You can find your OpenAI API keys in
43-
your OpenAI account under the
44-
https://platform.openai.com/api-keys[API keys section]. You need to provide
45-
your API key only once. The <<get-inference-api>> does not return your API
42+
<2> The API key of your OpenAI account. You can find your OpenAI API keys in
43+
your OpenAI account under the
44+
https://platform.openai.com/api-keys[API keys section]. You need to provide
45+
your API key only once. The <<get-inference-api>> does not return your API
4646
key.
47-
<3> The name of the embedding model to use. You can find the list of OpenAI
48-
embedding models
47+
<3> The name of the embedding model to use. You can find the list of OpenAI
48+
embedding models
4949
https://platform.openai.com/docs/guides/embeddings/embedding-models[here].
5050

5151

5252
[discrete]
5353
[[infer-openai-mappings]]
5454
==== Create the index mapping
5555

56-
The mapping of the destination index - the index that contains the embeddings
57-
that the model will create based on your input text - must be created. The
58-
destination index must have a field with the <<dense-vector, `dense_vector`>>
56+
The mapping of the destination index - the index that contains the embeddings
57+
that the model will create based on your input text - must be created. The
58+
destination index must have a field with the <<dense-vector, `dense_vector`>>
5959
field type to index the output of the OpenAI model.
6060

6161
[source,console]
@@ -67,7 +67,7 @@ PUT openai-embeddings
6767
"content_embedding": { <1>
6868
"type": "dense_vector", <2>
6969
"dims": 1536, <3>
70-
"element_type": "byte",
70+
"element_type": "float",
7171
"similarity": "dot_product" <4>
7272
},
7373
"content": { <5>
@@ -80,15 +80,15 @@ PUT openai-embeddings
8080
<1> The name of the field to contain the generated tokens. It must be refrenced
8181
in the {infer} pipeline configuration in the next step.
8282
<2> The field to contain the tokens is a `dense_vector` field.
83-
<3> The output dimensions of the model. Find this value in the
84-
https://platform.openai.com/docs/guides/embeddings/embedding-models[OpenAI documentation]
83+
<3> The output dimensions of the model. Find this value in the
84+
https://platform.openai.com/docs/guides/embeddings/embedding-models[OpenAI documentation]
8585
of the model you use.
86-
<4> The faster` dot_product` function can be used to calculate similarity
87-
because OpenAI embeddings are normalised to unit length. You can check the
86+
<4> The faster` dot_product` function can be used to calculate similarity
87+
because OpenAI embeddings are normalised to unit length. You can check the
8888
https://platform.openai.com/docs/guides/embeddings/which-distance-function-should-i-use[OpenAI docs]
89-
about which similarity function to use.
89+
about which similarity function to use.
9090
<5> The name of the field from which to create the sparse vector representation.
91-
In this example, the name of the field is `content`. It must be referenced in
91+
In this example, the name of the field is `content`. It must be referenced in
9292
the {infer} pipeline configuration in the next step.
9393
<6> The field type which is text in this example.
9494

@@ -98,8 +98,8 @@ the {infer} pipeline configuration in the next step.
9898
==== Create an ingest pipeline with an inference processor
9999

100100
Create an <<ingest,ingest pipeline>> with an
101-
<<inference-processor,{infer} processor>> and use the OpenAI model you created
102-
above to infer against the data that is being ingested in the
101+
<<inference-processor,{infer} processor>> and use the OpenAI model you created
102+
above to infer against the data that is being ingested in the
103103
pipeline.
104104

105105
[source,console]
@@ -119,8 +119,8 @@ PUT _ingest/pipeline/openai_embeddings
119119
]
120120
}
121121
--------------------------------------------------
122-
<1> The name of the inference model you created by using the
123-
<<put-inference-api>>.
122+
<1> The name of the inference model you created by using the
123+
<<put-inference-api>>.
124124
<2> Configuration object that defines the `input_field` for the {infer} process
125125
and the `output_field` that will contain the {infer} results.
126126

@@ -179,9 +179,9 @@ POST _reindex?wait_for_completion=false
179179
number makes the update of the reindexing process quicker which enables you to
180180
follow the progress closely and detect errors early.
181181

182-
NOTE: The
183-
https://platform.openai.com/account/limits[rate limit of your OpenAI account]
184-
may affect the throughput of the reindexing process. If this happens, change
182+
NOTE: The
183+
https://platform.openai.com/account/limits[rate limit of your OpenAI account]
184+
may affect the throughput of the reindexing process. If this happens, change
185185
`size` to `3` or a similar value in magnitude.
186186

187187
The call returns a task ID to monitor the progress:
@@ -192,7 +192,7 @@ GET _tasks/<task_id>
192192
----
193193
// TEST[skip:TBD]
194194

195-
You can also cancel the reindexing process if you don't want to wait until the
195+
You can also cancel the reindexing process if you don't want to wait until the
196196
reindexing process is fully complete which might take hours:
197197

198198
[source,console]
@@ -206,12 +206,12 @@ POST _tasks/<task_id>/_cancel
206206
[[infer-semantic-search]]
207207
==== Semantic search
208208

209-
After the dataset has been enriched with the embeddings, you can query the data
209+
After the dataset has been enriched with the embeddings, you can query the data
210210
using {ref}/knn-search.html#knn-semantic-search[semantic search]. Pass a
211211
`query_vector_builder` to the k-nearest neighbor (kNN) vector search API, and
212212
provide the query text and the model you have used to create the embeddings.
213213

214-
NOTE: If you cancelled the reindexing process, you run the query only a part of
214+
NOTE: If you cancelled the reindexing process, you run the query only a part of
215215
the data which affects the quality of your results.
216216

217217
[source,console]
@@ -237,7 +237,7 @@ GET openai-embeddings/_search
237237
--------------------------------------------------
238238
// TEST[skip:TBD]
239239

240-
As a result, you receive the top 10 documents that are closest in meaning to the
240+
As a result, you receive the top 10 documents that are closest in meaning to the
241241
query from the `openai-embeddings` index sorted by their proximity to the query:
242242

243243
[source,consol-result]

0 commit comments

Comments
 (0)