rerank_documents
Rerank documents by relevance to a query using a Cross-Encoder, returning sorted scores for better RAG and AI agent responses.
Instructions
Reranks a list of documents based on their relevance to a given query.
Args: query: The core intent or query string to compare against. documents: A list of document descriptions/strings to be ranked. model_name: The HuggingFace model name for the CrossEncoder. Default is from env RERANKER_MODEL_NAME or 'BAAI/bge-reranker-v2-m3'.
Returns: A JSON string representing a sorted list of dictionaries containing 'document' and 'score'.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| documents | Yes | ||
| model_name | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |