Rerank¶
Rerank candidate content by query intent and return ranked results.
POST https://token.moi.matrixorigin.cn/v1/rerank
Before you call¶
Prepare credentials with Genesis access, a model ID that supports Rerank, and a mapping between candidate content and business IDs.
Request body¶
Replace $GENESIS_ACCESS_TOKEN with an access token or service-account API key, and $MODEL_ID with the model ID to call.
curl -X POST \
"https://token.moi.matrixorigin.cn/v1/rerank" \
-H "Authorization: Bearer $GENESIS_ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"model": "'"$MODEL_ID"'",
"query": "What is retrieval-augmented generation?",
"documents": [
"RAG augments model answers by retrieving an external knowledge base.",
"Deep learning is a branch of machine learning.",
"A vector database can store and retrieve high-dimensional vectors."
],
"top_n": 2,
"return_documents": true
}'
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Rerank model ID to call. |
|
string |
Yes |
Query text used to determine candidate relevance. |
|
array of string |
Yes |
Text candidates to rerank. |
|
integer |
No |
Number of highest-relevance results to return. |
|
boolean |
No |
Whether to return original candidate content in the results. |
Successful response¶
The service returns reranked candidate content.
{
"id": "<REQUEST_ID>",
"model": "<MODEL_ID>",
"results": [
{ "index": 0, "relevance_score": 0.987, "document": "RAG augments model answers by retrieving an external knowledge base." }
]
}
Field |
Type |
Description |
|---|---|---|
|
string |
Identifier for this rerank request. |
|
string |
Model ID that processed the request. |
|
array of object |
Result list ordered by relevance. |
The following table expands each item in the example results array.
Field |
Type |
Description |
|---|---|---|
|
integer |
Index in the original |
|
number |
Relevance score assigned by the current model; compare it only within the same model and business context. |
|
string or object |
Original candidate content returned when |
The following table expands the results[].document object.
Field |
Type |
Description |
|---|---|---|
|
string |
Text candidate content when |
Error response¶
{
"error": {
"message": "<human-readable error message>",
"type": "<error type; may be omitted>",
"code": "<error code; may be omitted>"
}
}
Field |
Type |
Description |
|---|---|---|
|
object |
Error object. |
The following table expands the example error object.
Field |
Type |
Description |
|---|---|---|
|
string |
Human-readable error message. |
|
string |
Error category; it may be omitted. |
|
string or null |
Error code; it may be omitted. |