Skip to content

FastembedRanker doesn't automatically warm_up on first run #2833

@bogdankostic

Description

@bogdankostic

Describe the bug
From my understanding, #2678 should have added the functionality to FastembedRanker to automatically warm_up on the first run of the component instead of raising an error. However, this functionality was only implemented for the FastEmbed Embedder components, not the Ranker components.

Therefore, we still get the following error when running the component without having explicitly called warm_up:

Traceback (most recent call last):
  File "<python-input-13>", line 1, in <module>
    reranked_documents = ranker.run(query=query, documents=documents)["documents"]
                         ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bogdan.kostic/Repositories/haystack-core-integrations/integrations/fastembed/src/haystack_integrations/components/rankers/fastembed/ranker.py", line 181, in run
    raise RuntimeError(msg)
RuntimeError: The ranker model has not been loaded. Please call warm_up() before running.

To Reproduce

from haystack import Document

from haystack_integrations.components.rankers.fastembed import FastembedRanker

query = "Who is maintaining Qdrant?"
documents = [
    Document(
        content="This is built to be faster and lighter than other embedding libraries e.g. Transformers, Sentence-Transformers, etc."
    ),
    Document(content="fastembed is supported by and maintained by Qdrant."),
]

ranker = FastembedRanker(model_name="Xenova/ms-marco-MiniLM-L-6-v2")
reranked_documents = ranker.run(query=query, documents=documents)["documents"]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions