cohere.rerank
Conduit processor for Cohere's rerank model.
Description
Conduit processor for Cohere's rerank model.
Configuration parameters
- YAML
- Table
version: 2.2
pipelines:
- id: example
status: running
connectors:
# define source and destination ...
processors:
- id: example
plugin: "cohere.rerank"
settings:
# APIKey is the API key for Cohere api calls.
# Type: string
apiKey: ""
# Maximum number of retries for an individual record when backing off
# following an error.
# Type: float
backoffRetry.count: "0"
# The multiplying factor for each increment step.
# Type: float
backoffRetry.factor: "2"
# The maximum waiting time before retrying.
# Type: duration
backoffRetry.max: "5s"
# The minimum waiting time before retrying.
# Type: duration
backoffRetry.min: "100ms"
# Model is one of the name of a compatible rerank model version.
# Type: string
model: "rerank-v3.5"
# Query is the search query.
# Type: string
query: ""
# RequestBodyRef specifies the api request field.
# Type: string
request.body: ".Payload.After"
# ResponseBodyRef specifies in which field should the response body be
# saved.
# Type: string
response.body: ".Payload.After"
# Whether to decode the record key using its corresponding schema from
# the schema registry.
# Type: bool
sdk.schema.decode.key.enabled: "true"
# Whether to decode the record payload using its corresponding schema
# from the schema registry.
# Type: bool
sdk.schema.decode.payload.enabled: "true"
# Whether to encode the record key using its corresponding schema from
# the schema registry.
# Type: bool
sdk.schema.encode.key.enabled: "true"
# Whether to encode the record payload using its corresponding schema
# from the schema registry.
# Type: bool
sdk.schema.encode.payload.enabled: "true"
Name | Type | Default | Description |
---|---|---|---|
apiKey | string | null | APIKey is the API key for Cohere api calls. |
backoffRetry.count | float | 0 | Maximum number of retries for an individual record when backing off following an error. |
backoffRetry.factor | float | 2 | The multiplying factor for each increment step. |
backoffRetry.max | duration | 5s | The maximum waiting time before retrying. |
backoffRetry.min | duration | 100ms | The minimum waiting time before retrying. |
model | string | rerank-v3.5 | Model is one of the name of a compatible rerank model version. |
query | string | null | Query is the search query. |
request.body | string | .Payload.After | RequestBodyRef specifies the api request field. |
response.body | string | .Payload.After | ResponseBodyRef specifies in which field should the response body be saved. |
sdk.schema.decode.key.enabled | bool | true | Whether to decode the record key using its corresponding schema from the schema registry. |
sdk.schema.decode.payload.enabled | bool | true | Whether to decode the record payload using its corresponding schema from the schema registry. |
sdk.schema.encode.key.enabled | bool | true | Whether to encode the record key using its corresponding schema from the schema registry. |
sdk.schema.encode.payload.enabled | bool | true | Whether to encode the record payload using its corresponding schema from the schema registry. |
Examples
Generate responses using Cohere's rerank model
This example demonstrates how to use the Cohere rerank processor.This takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score. The processor extracts text from the specified input field (default: ".Payload.After"), sends it to the Cohere API, and stores the response in the record's ".Payload.After" field.
In this example, the processor is configured with a mock client and an API key. The input record's metadata is updated to include the rerank model used ("rerank-v3.5").
Configuration parameters
- YAML
- Table
version: 2.2
pipelines:
- id: example
status: running
connectors:
# define source and destination ...
processors:
- id: example
plugin: "cohere.rerank"
settings:
apiKey: "fakeapiKey"
backoffRetry.count: "0"
backoffRetry.factor: "2"
backoffRetry.max: "5s"
backoffRetry.min: "100ms"
model: "rerank-v3.5"
query: "What is the capital of the United States?"
request.body: ".Payload.After"
response.body: ".Payload.After"
Name | Value |
---|---|
apiKey | fakeapiKey |
backoffRetry.count | 0 |
backoffRetry.factor | 2 |
backoffRetry.max | 5s |
backoffRetry.min | 100ms |
model | rerank-v3.5 |
query | What is the capital of the United States? |
request.body | .Payload.After |
response.body | .Payload.After |
Record difference
Before | After | ||||
1 | { | 1 | { | ||
2 | "position": "cG9zLTE=", | 2 | "position": "cG9zLTE=", | ||
3 | "operation": "update", | 3 | "operation": "update", | ||
4 | "metadata": null, | 4 | "metadata": null, | ||
5 | "key": null, | 5 | "key": null, | ||
6 | "payload": { | 6 | "payload": { | ||
7 | "before": null, | 7 | "before": null, | ||
8 | - | "after": "Carson City is the capital city of the American state of Nevada." | 8 | + | "after": "{\"document\":{\"text\":\"Carson City is the capital city of the American state of Nevada.\"},\"index\":0,\"relevance_score\":0.9}" |
9 | } | 9 | } | ||
10 | } | 10 | } |