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
| Parameter | Type | Default | Description |
|---|---|---|---|
| query | str | Query string. | |
| documents | List[Document] | List of Documents. | |
| top_k | Optional[int] | None | The maximum number of Documents you want the Ranker to return. |
| score_threshold | Optional[float] | None | If provided only returns documents with a score above this threshold. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | List[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:
| Parameter | Type | Default | Description |
|---|---|---|---|
| api_key | Secret | Secret.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). |
| model | str | jina-reranker-v1-base-en | The name of the Jina model to use. Check the list of available models on https://jina.ai/reranker/ |
| top_k | Optional[int] | None | The maximum number of Documents to return per query. If None, all documents are returned |
| score_threshold | Optional[float] | None | If 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| query | str | Query string. | |
| documents | List[Document] | List of Documents. | |
| top_k | Optional[int] | None | The maximum number of Documents you want the Ranker to return. |
| score_threshold | Optional[float] | None | If provided only returns documents with a score above this threshold. |
Was this page helpful?