RerankResultItem
Describes one reranked item.
For the list of response object types, see Response Objects.
Use RerankResultItem to map a rerank score back to the zero-based position of the input document.
Attributes
| Attribute | Type | Description |
|---|---|---|
index |
int |
Zero-based position of the input document. |
score |
int or float |
Rerank score for the input document. |
Methods
| Method | Return Type | Description |
|---|---|---|
model_dump() |
dict[str, Any] |
Returns a Pydantic dictionary representation of the object. |
model_dump_json() |
str |
Returns a Pydantic JSON string representation of the object. |
to_dict() |
dict[str, Any] |
Returns a dictionary representation compatible with earlier SDK response handling. |
to_json() |
str |
Returns a JSON string representation compatible with earlier SDK response handling. |
to_str() |
str |
Returns a readable string representation compatible with earlier SDK response handling. |
Iterate Attributes
Use the item serialization helper to iterate every public attribute on the rerank result item.
response = client.rerank(
model_name="reranker_model",
query="best trail shoes",
documents=["Trail running shoes with durable grip.", "Formal leather shoes."],
)
for item in response.items:
item_payload = item.to_dict()
for attribute, value in item_payload.items():
print(attribute, value)
Sample Response
{
"index": 0,
"score": 0.9821
}
Contained By
Contained by: RerankResponse.