Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmartrencharpro committed Nov 13, 2024
1 parent 286ae8a commit 2256d7f
Showing 1 changed file with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
@component
class FastembedRanker:
"""
Ranks Documents based on their similarity to the query using [Fastembed models](https://qdrant.github.io/fastembed/examples/Supported_Models/).
Ranks Documents based on their similarity to the query using [Fastembed models](https://qdrant.github.io/fastembed/examples/Supported_Models/).
Documents are indexed from most to least semantically relevant to the query.
Documents are indexed from most to least semantically relevant to the query.
Usage example:
```python
from haystack import Document
from haystack_integrations.components.rankers.fastembed import FastembedRanker
Usage example:
```python
from haystack import Document
from haystack_integrations.components.rankers.fastembed import FastembedRanker
ranker = FastembedRanker(model_name="Xenova/ms-marco-MiniLM-L-6-v2", top_k=2)
ranker = FastembedRanker(model_name="Xenova/ms-marco-MiniLM-L-6-v2", top_k=2)
docs = [Document(content="Paris"), Document(content="Berlin")]
query = "What is the capital of germany?"
output = ranker.run(query=query, documents=docs)
print(output["documents"][0].content)
# Berlin
```
docs = [Document(content="Paris"), Document(content="Berlin")]
query = "What is the capital of germany?"
output = ranker.run(query=query, documents=docs)
print(output["documents"][0].content)
# Berlin
```
"""

def __init__(
Expand Down Expand Up @@ -63,8 +63,9 @@ def __init__(
to the Document content.
"""
if top_k <= 0:
raise ValueError(f"top_k must be > 0, but got {top_k}")

msg = f"top_k must be > 0, but got {top_k}"
raise ValueError(msg)

self.model_name = model_name
self.top_k = top_k
self.cache_dir = cache_dir
Expand Down

0 comments on commit 2256d7f

Please sign in to comment.