infer-api-task.asciidoc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // tag::cohere[]
  2. [source,console]
  3. ------------------------------------------------------------
  4. PUT _inference/text_embedding/cohere_embeddings <1>
  5. {
  6. "service": "cohere",
  7. "service_settings": {
  8. "api_key": "<api_key>", <2>
  9. "model_id": "embed-english-v3.0", <3>
  10. "embedding_type": "byte"
  11. }
  12. }
  13. ------------------------------------------------------------
  14. // TEST[skip:TBD]
  15. <1> The task type is `text_embedding` in the path and the `inference_id` which
  16. is the unique identifier of the {infer} endpoint is `cohere_embeddings`.
  17. <2> The API key of your Cohere account. You can find your API keys in your
  18. Cohere dashboard under the
  19. https://dashboard.cohere.com/api-keys[API keys section]. You need to provide
  20. your API key only once. The <<get-inference-api>> does not return your API
  21. key.
  22. <3> The name of the embedding model to use. You can find the list of Cohere
  23. embedding models https://docs.cohere.com/reference/embed[here].
  24. NOTE: When using this model the recommended similarity measure to use in the
  25. `dense_vector` field mapping is `dot_product`. In the case of Cohere models, the
  26. embeddings are normalized to unit length in which case the `dot_product` and
  27. the `cosine` measures are equivalent.
  28. // end::cohere[]
  29. // tag::openai[]
  30. [source,console]
  31. ------------------------------------------------------------
  32. PUT _inference/text_embedding/openai_embeddings <1>
  33. {
  34. "service": "openai",
  35. "service_settings": {
  36. "api_key": "<api_key>", <2>
  37. "model_id": "text-embedding-ada-002" <3>
  38. }
  39. }
  40. ------------------------------------------------------------
  41. // TEST[skip:TBD]
  42. <1> The task type is `text_embedding` in the path and the `inference_id` which
  43. is the unique identifier of the {infer} endpoint is `openai_embeddings`.
  44. <2> The API key of your OpenAI account. You can find your OpenAI API keys in
  45. your OpenAI account under the
  46. https://platform.openai.com/api-keys[API keys section]. You need to provide
  47. your API key only once. The <<get-inference-api>> does not return your API
  48. key.
  49. <3> The name of the embedding model to use. You can find the list of OpenAI
  50. embedding models
  51. https://platform.openai.com/docs/guides/embeddings/embedding-models[here].
  52. NOTE: When using this model the recommended similarity measure to use in the
  53. `dense_vector` field mapping is `dot_product`. In the case of OpenAI models, the
  54. embeddings are normalized to unit length in which case the `dot_product` and
  55. the `cosine` measures are equivalent.
  56. // end::openai[]