Skip to main content
View source

Cohere Rerank

View as Markdown

A RocketRide rerank node that reorders retrieved documents by relevance to the query using Cohere's Rerank API.

What it does

Takes questions that already carry retrieved documents and reorders those documents by how well they match the query. Cohere scores each document, results are sorted by relevance, cut to the top N, and anything below the minimum score threshold is dropped. Put it downstream of a retrieval or vector-store node so it can rerank the documents attached to each question.

Uses the cohere Python SDK (ClientV2). Supports the rerank-english-v3.0 (default) and rerank-v3.5 models, or any custom model name.

Key behavior to know:

  • The incoming question is deep-copied before processing, so shared question objects in fan-out pipelines are never mutated.
  • The query text is taken from the question's first question entry; a missing or whitespace-only query raises an error.
  • Documents whose page_content is missing, non-string, or whitespace-only are silently skipped (Cohere rejects whitespace-only documents). If no usable document content remains, the node raises an error.
  • Reranked documents preserve the original document metadata; the score field is replaced with Cohere's relevance_score.
  • The min_score filter is applied after the top-N cut, so you can receive fewer than top_n results.
  • Config validation only checks presence and format of required fields. It does not make a live API call, so a Cohere outage or rate limit at config time cannot surface a misleading error.

Configuration

Lanes

Lane inLane outDescription
questionsdocumentsReranked documents ordered by relevance score
questionsanswersAn answer with the reranked documents

The documents lane is written only when at least one document survives the min_score filter. The answers lane is always written, so downstream nodes receive a result even when every document was filtered out: the answer text is the surviving documents' content joined by blank lines (empty string if none survived).

Fields

FieldTypeDescription
modelstringDefault "rerank-english-v3.0". Cohere rerank model name
top_nnumberNumber of top results to return
min_scorenumberMinimum relevance score threshold (0.0-1.0)
profilestringDefault "rerank-english-v3.0". Rerank model

top_n must be a whole number >= 1 (whole-number floats like 5.0 are accepted; booleans and fractional values are rejected). min_score must be a number between 0.0 and 1.0.

Profiles

The Model dropdown selects a preconfigured profile:

ProfileTitleModel
rerank-english-v3.0Rerank v3.0rerank-english-v3.0 (default)
rerank-v3.5Rerank v3.5rerank-v3.5
customCustomfree-form model field

All profiles expose top_n, min_score, and the API key. The Custom profile additionally exposes the model field.


Authentication

A Cohere API key is required. Set it in the node's API Key field. The node fails to initialize (with a warning) if the key is missing or blank.

The built-in pipeline test cases require the ROCKETRIDE_RERANK_COHERE_KEY environment variable to run against the live API.


Error handling

Cohere API errors are mapped to a custom exception hierarchy whose class names let retry/circuit-breaker heuristics classify them correctly:

Cohere errorRaised asRetryable
UnauthorizedErrorRerankAuthenticationErrorNo
BadRequestErrorRerankBadRequestErrorNo
TooManyRequestsErrorRerankRateLimitErrorYes
InternalServerErrorRerankServerErrorYes
Any other exceptionRerankServerErrorYes

Schema

FieldTypeDescriptionDefault
min_scorenumberMin Score
Minimum relevance score threshold (0.0-1.0)
modelstringModel
Cohere rerank model name
"rerank-english-v3.0"
rerank_cohere.profilestringModel
Rerank model
"rerank-english-v3.0"
top_nnumberTop N
Number of top results to return

Dependencies

  • cohere >=6.1.0,<7.0.0