mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-29 09:54:06 -04:00
66 lines
No EOL
2.4 KiB
Text
66 lines
No EOL
2.4 KiB
Text
// tag::cohere[]
|
|
|
|
[source,console]
|
|
------------------------------------------------------------
|
|
PUT _inference/text_embedding/cohere_embeddings <1>
|
|
{
|
|
"service": "cohere",
|
|
"service_settings": {
|
|
"api_key": "<api_key>", <2>
|
|
"model_id": "embed-english-v3.0", <3>
|
|
"embedding_type": "byte"
|
|
}
|
|
}
|
|
------------------------------------------------------------
|
|
// TEST[skip:TBD]
|
|
<1> The task type is `text_embedding` in the path and the `inference_id` which
|
|
is the unique identifier of the {infer} endpoint is `cohere_embeddings`.
|
|
<2> The API key of your Cohere account. You can find your API keys in your
|
|
Cohere dashboard under the
|
|
https://dashboard.cohere.com/api-keys[API keys section]. You need to provide
|
|
your API key only once. The <<get-inference-api>> does not return your API
|
|
key.
|
|
<3> The name of the embedding model to use. You can find the list of Cohere
|
|
embedding models https://docs.cohere.com/reference/embed[here].
|
|
|
|
NOTE: When using this model the recommended similarity measure to use in the
|
|
`dense_vector` field mapping is `dot_product`. In the case of Cohere models, the
|
|
embeddings are normalized to unit length in which case the `dot_product` and
|
|
the `cosine` measures are equivalent.
|
|
|
|
|
|
|
|
// end::cohere[]
|
|
|
|
|
|
// tag::openai[]
|
|
|
|
[source,console]
|
|
------------------------------------------------------------
|
|
PUT _inference/text_embedding/openai_embeddings <1>
|
|
{
|
|
"service": "openai",
|
|
"service_settings": {
|
|
"api_key": "<api_key>", <2>
|
|
"model_id": "text-embedding-ada-002" <3>
|
|
}
|
|
}
|
|
------------------------------------------------------------
|
|
// TEST[skip:TBD]
|
|
<1> The task type is `text_embedding` in the path and the `inference_id` which
|
|
is the unique identifier of the {infer} endpoint is `openai_embeddings`.
|
|
<2> The API key of your OpenAI account. You can find your OpenAI API keys in
|
|
your OpenAI account under the
|
|
https://platform.openai.com/api-keys[API keys section]. You need to provide
|
|
your API key only once. The <<get-inference-api>> does not return your API
|
|
key.
|
|
<3> The name of the embedding model to use. You can find the list of OpenAI
|
|
embedding models
|
|
https://platform.openai.com/docs/guides/embeddings/embedding-models[here].
|
|
|
|
NOTE: When using this model the recommended similarity measure to use in the
|
|
`dense_vector` field mapping is `dot_product`. In the case of OpenAI models, the
|
|
embeddings are normalized to unit length in which case the `dot_product` and
|
|
the `cosine` measures are equivalent.
|
|
|
|
// end::openai[] |