Ranker Parameters

Check the init and runtime parameters you can configure for the rankers available in deepset Cloud.

YAML Init Parameters

These are the parameters you can specify in pipeline YAML:


CohereRanker Parameters

ParameterTypePossible ValuesDescription
api_keyStringThe Cohere API key so that you can use Cohere models.
Required.
model_name_or_pathStringThe name of the Cohere model you want to use for reranking. Check the list of supported models in the Cohere documentation.
Required.
top_kIntegerDefault: 10The maximum number of documents to return.
Required.
max_chunks_per_docIntegerDefault: NoneSpecifies the maximum number of chunks your document is split into if the document exceeds 512 tokens. (This is because Cohere models break documents into chunks of 512 tokens.)
The default None setting splits your documents into a maximum of 10 chunks. Note that this parameter counts in the length of the query as well. So if your query is 32 tokens, the split will be:
First chunk: 32 tokens from query + first 480 tokens from the document
Second chunk: 32 tokens from the query + tokens 481 to 961 from the document,
and so on. If after splitting into 10 chunks there are still some tokens from the document left, they're disregarded.
Optional.
embed_meta_fieldsList of stringsConcatenates the provided metadata fields into the text passage that is then used in reranking. The concatenated metadata are not included in the documents that are returned. (Original documents are returned.)

DeepsetMetaFieldRanker Parameters

ParameterTypePossible ValuesDescription
meta_fieldStringThe name of the document's metadata field you want to rank by.
Required.
weightFloatValues in range [0,1].
Default: 1.0
Specifies how documents are ranked:
0 - disables ranking by a metadata field.
0.5 - means both ranking done by a previous component and ranking by a metadata field have the same impact.
1 - ranks by a metadata field only.
Required.
top_kIntegerDefault: noneThe maximum number of documents to return per query. If not specified, the ranker returns all documents it received but reranked.
Optional.
ranking_modeLiteralreciprocal_rank_fusion
descending
Default: descending
The mode used to combine the retriever's and ranker's scores.
Use linear_score only with retrievers or rankers that return a score in the range [0,1].
Required.
sort_orderLiteralascending
descending
Default: descending
Defines whether to sort the documents in the ascending or descending order.
Required.
meta_value_typeLiteralfloat
int
date
Default: none
Parses the metadata field value into the data type specified before ranking. This only works if all metadata values stored under meta_field in the provided documents are strings.
For example, if you specify meta_value_type="date" and then for the metadata field value: "date": "2015-02-01", the ranker parses the string into a datetime object and sorts the documents by date.
Possible values are:
float: parses the values into floats.
int: parses the values into integers
date: parses the values into datetime objects.
none: doesn't parse.
Optional.

DiversityRanker Parameters

ParameterTypePossible ValuesDescription
model_name_or_pathUnion[String, Path]Model path
Default: all-MiniLM-L6-v2
The path to the directory of a saved sentence transformers model.
Mandatory.
top_kIntegerDefault: NoneThe maximum number of documents the Ranker should return.
Optional.
use_gpuBooleanTrue
False
Default: True
Specifies whether to use all available GPUs or a CPU. Falls back on a CPU if no GPU is available.
Optional.
devicesString, torch.deviceDefault: NoneA list of devices to use for inference.
Optional.
similarityLiteraldot_product
cosine
Default: dot_product
Specifies the function to apply for calculating the similarity of query and passage embeddings.
Required.

EmbeddingRanker Parameters

ParametersTypePossible ValuesDescription
embedding_modelUnion[String, Path]Model pathThe path to the directory of a saved model or the name of a public model, for example: sentence-transformers/all-mpnet-base-v2.
Required.
top_kIntegerDefault: 10The maximum number of documents the Ranker should return.
Required.
use_gpuBooleanTrue
False
Default: True
Specifies whether to use all available GPUs or a CPU. Falls back on a CPU if no GPU is available.
Required.
devicesString, torch.deviceDefault: NoneA list of devices to use for inference.
Optional.
batch_sizeIntegerDefault: 16The number of documents you want the ranker to process at a time.
Required.
scale_scoreBooleanTrue
False
Default: True
Scales the similarity score to a unit interval in the range of 0 to 1, where 1 means extremely relevant.
True - Scales similarity scores that naturally have a different value range, such as cosine or dot_product.
False - Uses raw similarity scores.
Required.
max_seq_lenIntegerDefault: 512Specifies the maximum number of tokens the document text can have. Longer documents are truncated.
Required.
similarityStringdot-product
cosine
Default: dot-product
Specifies the function to apply for calculating the similarity of query and passage embeddings.
Required.
embedding_dimIntegerDefault: 768Specifies the dimensionality of the embedding vector.
return_embeddingBooleanTrue
False
Default:False
Returns document embeddings.
use_auth_tokenUnion[string, Boolean]Default: NoneIf you're using a private model from Hugging Face, pass the API token used to download the model in this parameter.
If this parameter is set to True, then the token generated when running transformers-cli login (stored in ~/.huggingface) is used.
Optional.
raise_for_missing_embeddingsBooleanTrue
False
Default: True
Raises an error if there are embeddings missing.

LostInTheMiddleRanker Parameters

ParameterTypePossible ValuesDescription
word_count_thresholdIntegerDefault: NoneThe maximum total number of words across all documents the ranker selects. If you specify this parameter, the ranker includes all documents up to the point where adding another document would exceed the word_count_threshold. The last document that exceeds the threshold is included in the resulting list of documents, but all subsequent documents are discarded.
Optional.
top_kIntegerDefault: NoneThe maximum number you want the ranker to return.
Optional.

RecentnessRanker Parameters

ParameterTypePossible ValuesDescription
date_meta_fieldStringThe name of the metadata field in your documents that contains the date, for example updated_at. This is a required parameter, as dates are needed for sorting documents from newest to oldest.
Required.
top_kIntegerDefault: None (all documents are returned)Specifies how many documents to return. You may want to set larger top_k for the Retriever and then use the RecentnessRanker top_k to filter the documents down.
Optional.
weightFloatValues in range [0,1]
Default: 0.5
Specifies how documents are sorted.
0 means sorting by document age is disabled.
0.5 means both document content and its age have the same impact.
1 means documents are sorted by age only. The most recent documents come first.
Optional.
ranking_modeStringscore
reciprocal_rank_fusion
Default: reciprocal_rank_fusion
Specifies the method used to combine the documents fetched by the Retriever with recentness ranking.
reciprocal_rank_fusion - combines individual document rankings and uses the outcome to rank the documents.
score - uses the document's score returned by the Retriever.
Make sure you use score only with Retrievers or Rankers that return properly distributed scores in the range [0,1]
If your Retriever doesn't return properly distributed scores (like BM25Retriever), you can either set the method to reciprocal_rank_fusion or combine RecentnessRanker with a model-based Ranker, such as SentenceTransfomersRanker.

SentenceTransformersRanker Parameters

ParameterTypePossible ValuesDescription
model_name_or_pathStringExample: cross-encoder/ms-marco-MiniLM-L-12-v2The path to a saved model or the name of a public model from Hugging Face.
For a list of available models, see cross encoders.
Required.
model_versionStringDefault: NoneThe version of the model from Hugging Face. This can be a tag name, a branch name, or a commit hash.
Optional.
top_kIntegerDefault: 10The maximum number of documents to return.
Required.
use_gpuBooleanTrue
False
Default: True
Specifies whether to use all available GPUs or a CPU. Falls back on a CPU if no GPU is available.
Required
batch_sizeIntegerDefault: 16The number of documents you want the ranker to process at a time.
Required
scale_scoreBooleanTrue
False
Default: True
If the model only predicts a single label, the raw predictions are transformed using a Sigmoid activation function.
No scaling is applied to multi-label predictions.
If you don't want to scale raw predictions, set this value to False.
Required.
progress_barBooleanTrue
False
Default: True
Shows a progress bar when processing the documents.
Required.
use_auth_tokenUnion[string, Boolean]Default: NoneIf you're using a private model from Hugging Face, pass the API token used to download the model in this parameter.
If this parameter is set to True, then the token generated when running transformers-cli login (stored in ~/.huggingface) is used.
Optional.
embed_meta_fieldsList of stringsDefault: NoneConcatenates the provided meta fields to a text passage that is then used in reranking. The concatenated metadata are not included in the returned documents.
model_kwargsDictionary.Default: NoneAdditional keyword arguments passed to AutoModelForSequenceClassification.from_pretrained
when loading the model specified in model_name_or_path. See the model's documentation for details on what kwargs you can pass.

CNSentenceTransformersRanker Parameters

This ranker uses the same parameters as SentenceTransformersRanker with an additional tokenizer_kwargs parameter:

ParameterTypePossible ValuesDescription
tokenizer_kwargsDictionaryDefault: NoneAdditional keyword arguments you can pass to the tokenizer. For details, check the model documentation.
Optional.

REST API Runtime Parameters

For all Rankers, you can pass the following parameters at runtime:

ParameterTypeDescription
top_kIntegerThe maximum number of ranked documents to return.
For default values, see the top_k parameter description in the YAML Parameters section for each ranker.