Skip to content

Commit

Permalink
add alibaba cloud ai search inference docs
Browse files Browse the repository at this point in the history
  • Loading branch information
weizijun committed Aug 28, 2024
1 parent 09617e3 commit 9c1fdca
Show file tree
Hide file tree
Showing 16 changed files with 479 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/reference/inference/inference-apis.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ include::delete-inference.asciidoc[]
include::get-inference.asciidoc[]
include::post-inference.asciidoc[]
include::put-inference.asciidoc[]
include::service-alibabacloud-ai-search.asciidoc[]
include::service-amazon-bedrock.asciidoc[]
include::service-anthropic.asciidoc[]
include::service-azure-ai-studio.asciidoc[]
Expand Down
1 change: 1 addition & 0 deletions docs/reference/inference/put-inference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The create {infer} API enables you to create an {infer} endpoint and configure a

The following services are available through the {infer} API, click the links to review the configuration details of the services:

* <<infer-service-alibabacloud-ai-search,AlibabaCloud AI Search>>
* <<infer-service-amazon-bedrock,Amazon Bedrock>>
* <<infer-service-anthropic,Anthropic>>
* <<infer-service-azure-ai-studio,Azure AI Studio>>
Expand Down
193 changes: 193 additions & 0 deletions docs/reference/inference/service-alibabacloud-ai-search.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
[[infer-service-alibabacloud-ai-search]]
=== AlibabaCloud AI Search {infer} service

Creates an {infer} endpoint to perform an {infer} task with the `alibabacloud-ai-search` service.

[discrete]
[[infer-service-alibabacloud-ai-search-api-request]]
==== {api-request-title}

`PUT /_inference/<task_type>/<inference_id>`

[discrete]
[[infer-service-alibabacloud-ai-search-api-path-params]]
==== {api-path-parms-title}

`<inference_id>`::
(Required, string)
include::inference-shared.asciidoc[tag=inference-id]

`<task_type>`::
(Required, string)
include::inference-shared.asciidoc[tag=task-type]
+
--
Available task types:

* `text_embedding`,
* `sparse_embedding`.
* `rerank`.
--

[discrete]
[[infer-service-alibabacloud-ai-search-api-request-body]]
==== {api-request-body-title}

`service`::
(Required, string) The type of service supported for the specified task type.
In this case,
`alibabacloud-ai-search`.

`service_settings`::
(Required, object)
include::inference-shared.asciidoc[tag=service-settings]
+
--
These settings are specific to the `alibabacloud-ai-search` service.
--

`api_key`:::
(Required, string)
A valid API key for the AlibabaCloud AI Search API.

`service_id`:::
(Required, string)
The name of the model service to use for the {infer} task.

The service_id available for the `text_embedding` task are:

* `ops-text-embedding-001`
* `ops-text-embedding-zh-001`
* `ops-text-embedding-en-001`
* `ops-text-embedding-002`

You can find the supported `text_embedding` service_id at https://help.aliyun.com/zh/open-search/search-platform/developer-reference/text-embedding-api-details[embedding detail]

for the `sparse_embedding` task are:

* `ops-text-sparse-embedding-001`

You can find the supported `sparse_embedding` service_id at https://help.aliyun.com/zh/open-search/search-platform/developer-reference/text-sparse-embedding-api-details[sparse embedding detail]

for the `rerank` task are:

* `ops-bge-reranker-larger`

You can find the supported `rerank` service_id at https://help.aliyun.com/zh/open-search/search-platform/developer-reference/ranker-api-details[rerank detail]

`host`:::
(Required, string)
The name of the host address use for the {infer} task. You can find the host address at https://opensearch.console.aliyun.com/cn-shanghai/rag/api-key[API keys section]

`workspace`:::
(Required, string)
The name of the workspace use for the {infer} task.

`rate_limit`:::
(Optional, object)
By default, the `alibabacloud-ai-search` service sets the number of requests allowed per minute to `1000`.
This helps to minimize the number of rate limit errors returned from Amazon Bedrock.
To modify this, set the `requests_per_minute` setting of this object in your service settings:
+
--
include::inference-shared.asciidoc[tag=request-per-minute-example]
--

`task_settings`::
(Optional, object)
include::inference-shared.asciidoc[tag=task-settings]
+
.`task_settings` for the `text_embedding` task type
[%collapsible%closed]
=====
`input_type`:::
(Optional, string)
Specifies the type of input passed to the model.
Valid values are:
* `ingest`: use it for storing document embeddings in a vector database.
* `search`: use it for storing embeddings of search queries run against a vector database to find relevant documents.
+
=====
+
.`task_settings` for the `sparse_embedding` task type
[%collapsible%closed]
=====
`input_type`:::
(Optional, string)
Specifies the type of input passed to the model.
Valid values are:
* `ingest`: use it for storing document embeddings in a vector database.
* `search`: use it for storing embeddings of search queries run against a vector database to find relevant documents.
+
`return_token`:::
(Optional, boolean)
Specify Whether to return the token name, the default value is false, it means that it will return the token id.
=====
+
.`task_settings` for the `rerank` task type
[%collapsible%closed]
=====
There are no `task_settings` available for the `rerank` task type.
=====

[discrete]
[[inference-example-alibabacloud-ai-search]]
==== AlibabaCloud AI Search service example

The following example shows how to create an {infer} endpoint called `alibabacloud_ai_search_embeddings` to perform a `text_embedding` task type.

[source,console]
------------------------------------------------------------
PUT _inference/text_embedding/alibabacloud_ai_search_embeddings
{
"service": "alibabacloud-ai-search",
"service_settings": {
"api_key": "<api_key>",
"service_id": "ops-text-embedding-001",
"host": "default-j01.platform-cn-shanghai.opensearch.aliyuncs.com",
"workspace": "default"
}
}
------------------------------------------------------------
// TEST[skip:TBD]

The following example shows how to create an {infer} endpoint called
`alibabacloud_ai_search_sparse` to perform a `sparse_embedding` task type.

[source,console]
------------------------------------------------------------
PUT _inference/sparse_embedding/alibabacloud_ai_search_sparse
{
"service": "alibabacloud-ai-search",
"service_settings": {
"api_key": "<api_key>",
"service_id": "ops-text-sparse-embedding-001",
"host": "default-j01.platform-cn-shanghai.opensearch.aliyuncs.com",
"workspace": "default"
}
}
------------------------------------------------------------
// TEST[skip:TBD]

The next example shows how to create an {infer} endpoint called
`alibabacloud_ai_search_rerank` to perform a `rerank` task type.

[source,console]
------------------------------------------------------------
PUT _inference/rerank/alibabacloud_ai_search_rerank
{
"service": "alibabacloud-ai-search",
"service_settings": {
"api_key": "<api_key>",
"service_id": "ops-bge-reranker-larger",
"host": "default-j01.platform-cn-shanghai.opensearch.aliyuncs.com",
"workspace": "default"
}
}
------------------------------------------------------------
// TEST[skip:TBD]
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Azure based examples use models available through https://ai.azure.com/explore/m
or https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models[Azure OpenAI].
Mistral examples use the `mistral-embed` model from https://docs.mistral.ai/getting-started/models/[the Mistral API].
Amazon Bedrock examples use the `amazon.titan-embed-text-v1` model from https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html[the Amazon Bedrock base models].
AlibabaCloud AI Search examples use the `ops-text-embedding-zh-001` model from https://help.aliyun.com/zh/open-search/search-platform/developer-reference/text-embedding-api-details[the AlibabaCloud AI Search base models].

Click the name of the service you want to use on any of the widgets below to review the corresponding instructions.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
id="infer-api-ingest-amazon-bedrock">
Amazon Bedrock
</button>
<button role="tab"
aria-selected="false"
aria-controls="infer-api-ingest-alibabacloud-ai-search-tab"
id="infer-api-ingest-alibabacloud-ai-search">
AlibabaCloud AI Search
</button>
</div>
<div tabindex="0"
role="tabpanel"
Expand Down Expand Up @@ -135,6 +141,17 @@ include::infer-api-ingest-pipeline.asciidoc[tag=mistral]

include::infer-api-ingest-pipeline.asciidoc[tag=amazon-bedrock]

++++
</div>
<div tabindex="0"
role="tabpanel"
id="infer-api-ingest-alibabacloud-ai-search-tab"
aria-labelledby="infer-api-ingest-alibabacloud-ai-search"
hidden="">
++++

include::infer-api-ingest-pipeline.asciidoc[tag=alibabacloud-ai-search]

++++
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,29 @@ PUT _ingest/pipeline/amazon_bedrock_embeddings
and the `output_field` that will contain the {infer} results.

// end::amazon-bedrock[]

// tag::alibabacloud-ai-search[]

[source,console]
--------------------------------------------------
PUT _ingest/pipeline/alibabacloud_ai_search_embeddings
{
"processors": [
{
"inference": {
"model_id": "alibabacloud_ai_search_embeddings", <1>
"input_output": { <2>
"input_field": "content",
"output_field": "content_embedding"
}
}
}
]
}
--------------------------------------------------
<1> The name of the inference endpoint you created by using the
<<put-inference-api>>, it's referred to as `inference_id` in that step.
<2> Configuration object that defines the `input_field` for the {infer} process
and the `output_field` that will contain the {infer} results.

// end::alibabacloud-ai-search[]
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
id="infer-api-mapping-amazon-bedrock">
Amazon Bedrock
</button>
<button role="tab"
aria-selected="false"
aria-controls="infer-api-mapping-alibabacloud-ai-search-tab"
id="infer-api-mapping-alibabacloud-ai-search">
AlibabaCloud AI Search
</button>
</div>
<div tabindex="0"
role="tabpanel"
Expand Down Expand Up @@ -135,6 +141,17 @@ include::infer-api-mapping.asciidoc[tag=mistral]

include::infer-api-mapping.asciidoc[tag=amazon-bedrock]

++++
</div>
<div tabindex="0"
role="tabpanel"
id="infer-api-mapping-alibabacloud-ai-search-tab"
aria-labelledby="infer-api-mapping-alibabacloud-ai-search"
hidden="">
++++

include::infer-api-mapping.asciidoc[tag=alibabacloud-ai-search]

++++
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,35 @@ the {infer} pipeline configuration in the next step.
<6> The field type which is text in this example.

// end::amazon-bedrock[]

// tag::alibabacloud-ai-search[]

[source,console]
--------------------------------------------------
PUT alibabacloud-ai-search-embeddings
{
"mappings": {
"properties": {
"content_embedding": { <1>
"type": "dense_vector", <2>
"dims": 1024, <3>
"element_type": "float"
},
"content": { <4>
"type": "text" <5>
}
}
}
}
--------------------------------------------------
<1> The name of the field to contain the generated tokens. It must be referenced
in the {infer} pipeline configuration in the next step.
<2> The field to contain the tokens is a `dense_vector` field.
<3> The output dimensions of the model. This value may be different depending on the underlying model used.
See the https://help.aliyun.com/zh/open-search/search-platform/developer-reference/text-embedding-api-details[AlibabaCloud AI Search embedding model] documentation.
<4> The name of the field from which to create the dense vector representation.
In this example, the name of the field is `content`. It must be referenced in
the {infer} pipeline configuration in the next step.
<5> The field type which is text in this example.

// end::alibabacloud-ai-search[]
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
id="infer-api-reindex-amazon-bedrock">
Amazon Bedrock
</button>
<button role="tab"
aria-selected="false"
aria-controls="infer-api-reindex-alibabacloud-ai-search-tab"
id="infer-api-reindex-alibabacloud-ai-search">
AlibabaCloud AI Search
</button>
</div>
<div tabindex="0"
role="tabpanel"
Expand Down Expand Up @@ -135,6 +141,17 @@ include::infer-api-reindex.asciidoc[tag=mistral]

include::infer-api-reindex.asciidoc[tag=amazon-bedrock]

++++
</div>
<div tabindex="0"
role="tabpanel"
id="infer-api-reindex-alibabacloud-ai-search-tab"
aria-labelledby="infer-api-reindex-alibabacloud-ai-search"
hidden="">
++++

include::infer-api-reindex.asciidoc[tag=alibabacloud-ai-search]

++++
</div>
</div>
Expand Down
Loading

0 comments on commit 9c1fdca

Please sign in to comment.