reranker-cohere
Introduction
- The
reranker-cohere
module enables reranking search results using Cohere reranking. - This module uses a third-party API and may incur costs. Make sure to check the Cohere pricing page before applying reranking to large amounts of data.
- You will need a Cohere API key. You can request one here.
How to enable
Weaviate Cloud Services
This module is enabled by default on the WCS.
Weaviate open source
Add reranker-cohere
to the ENABLE_MODULES
environment variable.
Below is an example Docker Compose file, which will spin up Weaviate with the reranker-cohere
module (as well as text2vec-cohere
).
---
version: '3.4'
services:
weaviate:
command:
- --host
- 0.0.0.0
- --port
- '8080'
- --scheme
- http
image: semitechnologies/weaviate:1.21.4
restart: on-failure:0
ports:
- "8080:8080"
environment:
QUERY_DEFAULTS_LIMIT: 20
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: "./data"
DEFAULT_VECTORIZER_MODULE: text2vec-cohere
ENABLE_MODULES: text2vec-cohere,reranker-cohere
COHERE_APIKEY: $COHERE_APIKEY
CLUSTER_HOSTNAME: 'node1'
...
- You can also use the Weaviate configuration tool to create a Weaviate setup with this module.
- The
COHERE_APIKEY
environment variable is optional and the client can instead provide the key at insert/query time as an HTTP header (see the 'usage' section for instructions)
Schema configuration
The reranker-cohere
module can be configured for any class in the schema. You can also specify options such as the model
to use.
This example configures the Document
class to use the reranker-cohere
module, with the rerank-multilingual-v2.0
model, and to return the documents in the response.
{
"classes": [
{
"class": "Document",
...,
"moduleConfig": {
"reranker-cohere": {
"model": "rerank-multilingual-v2.0",
},
}
}
]
}
Reranker selection
If there is only one reranker
module enabled, you don't need to do anything. The reranker
module will be used by default.
Where multiple reranker
modules are enabled, you must specify the reranker module to be used for each class. You can do this by adding the desired reranker in the moduleConfig
section of the schema, even without any further settings.
Set reranker for a class
{
"classes": [
{
"class": "Document",
...,
"moduleConfig": {
"reranker-cohere": {}, // This will configure the 'Document' class to use the 'reranker-cohere' module
}
}
]
}
Model selection
The reranker-cohere
module supports the following models:
rerank-english-v2.0
rerank-multilingual-v2.0
Usage
API key
- If the
COHERE_APIKEY
environment variable is not set, clients can set the API key at query time by adding this HTTP header:X-Cohere-Api-Key: YOUR-COHERE-API-KEY
.
Queries
- Using this module will enable the
rerank
GraphQL _additional property. - For usage examples, see the Howto: Search - Reranking page.
More resources
For additional information, try these sources.