rerank
Rank precomputed document embeddings against a query embedding using deterministic similarity metrics to return the most relevant documents first.
Instructions
Rank caller-supplied document embeddings against a query embedding with a supported deterministic similarity metric (default embeddings.cosine_similarity), most relevant first. This tool does not embed text — call embeddings first to produce the query and document vectors. Every document embedding must share the query's dimension or the call fails with invalid_embedding_dimensions. Read-only and deterministic. Returns ranked items with rank (starting at 1) and score, plus total_documents and returned_documents counts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | Similarity model id from list_models; selects the metric. | embeddings.cosine_similarity |
| top_n | No | Optional cap on how many top-ranked documents are returned; omit to return all documents ranked. | |
| documents | Yes | Candidate documents to rank against the query vector. | |
| query_embedding | Yes | Query vector every document embedding is scored against. |