Skip to main content

JinaRanker

Ranks Documents based on their similarity to the query using Jina AI models.

Basic Information

  • Type: haystack_integrations.components.rankers.jina.ranker.JinaRanker

Inputs

ParameterTypeDefaultDescription
querystrQuery string.
documentsList[Document]List of Documents.
top_kOptional[int]NoneThe maximum number of Documents you want the Ranker to return.
score_thresholdOptional[float]NoneIf provided only returns documents with a score above this threshold.

Outputs

ParameterTypeDefaultDescription
documentsList[Document]A dictionary with the following keys: - documents: List of Documents most similar to the given query in descending order of similarity.

Overview

Work in Progress

Bear with us while we're working on adding pipeline examples and most common components connections.

Ranks Documents based on their similarity to the query using Jina AI models.

Usage example:

from haystack import Document
from haystack_integrations.components.rankers.jina import JinaRanker

ranker = JinaRanker()
docs = [Document(content="Paris"), Document(content="Berlin")]
query = "City in Germany"
result = ranker.run(query=query, documents=docs)
docs = result["documents"]
print(docs[0].content)

Usage Example

components:
JinaRanker:
type: jina.src.haystack_integrations.components.rankers.jina.ranker.JinaRanker
init_parameters:

Parameters

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
api_keySecretSecret.from_env_var('JINA_API_KEY')The Jina API key. It can be explicitly provided or automatically read from the environment variable JINA_API_KEY (recommended).
modelstrjina-reranker-v1-base-enThe name of the Jina model to use. Check the list of available models on https://jina.ai/reranker/
top_kOptional[int]NoneThe maximum number of Documents to return per query. If None, all documents are returned
score_thresholdOptional[float]NoneIf provided only returns documents with a score above this threshold.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
querystrQuery string.
documentsList[Document]List of Documents.
top_kOptional[int]NoneThe maximum number of Documents you want the Ranker to return.
score_thresholdOptional[float]NoneIf provided only returns documents with a score above this threshold.