redis-vl-dotnet
Cohere Reranker
RedisVL.Rerankers.Cohere provides CohereTextReranker, an ITextReranker implementation backed by Cohere’s rerank API.
Package contents
-
CohereTextRerankerfor remote reranking requests -
CohereRerankerOptionsfor request shaping and endpoint selection -
CohereRerankerPackageas the package marker type
Request options
CohereRerankerOptions currently supports:
-
MaxTokensPerDocumentto cap per-document token usage -
Priorityto set the provider request priority -
ClientNameto send anX-Client-Nameheader -
EndpointOverridewhen the application needs a non-default rerank endpoint
The default provider endpoint is https://api.cohere.com/v2/rerank.
Required environment variables
The runnable sample reads:
-
COHERE_API_KEYas the required provider credential -
COHERE_RERANK_MODELas an optional model override -
REDIS_VL_REDIS_URLas the Redis connection string override
If COHERE_API_KEY is missing, /examples/CohereRerankerExample throws an InvalidOperationException before it attempts the provider request.
Example workflow
/examples/CohereRerankerExample shows the expected integration pattern:
-
load a Redis index with candidate documents
-
collect an initial candidate set through
TextQuery -
build
RerankDocumentvalues from those Redis hits -
rerank the candidates with
CohereTextReranker -
print both the Redis order and the reranked provider order
Run it from the repository root:
dotnet run --project examples/CohereRerankerExample/CohereRerankerExample.csproj