Skip to content

Commit 2d41927

Browse files
authored
Updates Watsonx inference integration with rerank feature (elastic#125565)
1 parent 274b59a commit 2d41927

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

docs/reference/inference/service-watsonx-ai.asciidoc

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ include::inference-shared.asciidoc[tag=task-type]
3434
--
3535
Available task types:
3636

37-
* `text_embedding`.
37+
* `text_embedding`,
38+
* `rerank`.
3839
--
3940

4041
[discrete]
@@ -91,6 +92,26 @@ To modify this, set the `requests_per_minute` setting of this object in your ser
9192
include::inference-shared.asciidoc[tag=request-per-minute-example]
9293
--
9394

95+
`task_settings`::
96+
(Optional, object)
97+
include::inference-shared.asciidoc[tag=task-settings]
98+
+
99+
.`task_settings` for the `rerank` task type
100+
[%collapsible%closed]
101+
=====
102+
`truncate_input_tokens`:::
103+
(Optional, integer)
104+
Specifies the maximum number of tokens per input document before truncation.
105+
106+
`return_documents`:::
107+
(Optional, boolean)
108+
Specify whether to return doc text within the results.
109+
110+
`top_n`:::
111+
(Optional, integer)
112+
The number of most relevant documents to return. Defaults to the number of input documents.
113+
=====
114+
94115

95116
[discrete]
96117
[[inference-example-watsonx-ai]]
@@ -118,4 +139,35 @@ PUT _inference/text_embedding/watsonx-embeddings
118139
You can find on the https://cloud.ibm.com/iam/apikeys[API keys page of your account].
119140
<2> The {infer} endpoint URL you created on Watsonx.
120141
<3> The ID of your IBM Cloud project.
121-
<4> A valid API version parameter. You can find the active version data parameters https://cloud.ibm.com/apidocs/watsonx-ai#active-version-dates[here].
142+
<4> A valid API version parameter. You can find the active version data parameters https://cloud.ibm.com/apidocs/watsonx-ai#active-version-dates[here].
143+
144+
The following example shows how to create an {infer} endpoint called `watsonx-rerank` to perform a `rerank` task type.
145+
146+
[source,console]
147+
------------------------------------------------------------
148+
PUT _inference/rerank/watsonx-rerank
149+
{
150+
"service": "watsonxai",
151+
"service_settings": {
152+
"api_key": "<api_key>", <1>
153+
"url": "<url>", <2>
154+
"model_id": "cross-encoder/ms-marco-minilm-l-12-v2",
155+
"project_id": "<project_id>", <3>
156+
"api_version": "2024-05-02" <4>
157+
},
158+
"task_settings": {
159+
"truncate_input_tokens": 50, <5>
160+
"return_documents": true, <6>
161+
"top_n": 3 <7>
162+
}
163+
}
164+
------------------------------------------------------------
165+
// TEST[skip:TBD]
166+
<1> A valid Watsonx API key.
167+
You can find on the https://cloud.ibm.com/iam/apikeys[API keys page of your account].
168+
<2> The {infer} endpoint URL you created on Watsonx.
169+
<3> The ID of your IBM Cloud project.
170+
<4> A valid API version parameter. You can find the active version data parameters https://cloud.ibm.com/apidocs/watsonx-ai#active-version-dates[here].
171+
<5> The maximum number of tokens per document before truncation.
172+
<6> Whether to return the document text in the results.
173+
<7> The number of top relevant documents to return.

0 commit comments

Comments
 (0)