File size: 626 Bytes
f5d46f6 138bca0 f5d46f6 138bca0 4f8ccb0 138bca0 f5d46f6 138bca0 f5d46f6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from typing import Any, Dict
from haystack import Document
from fastrag.rankers import IPEXBiEncoderSimilarityRanker
class EndpointHandler:
def __init__(self, path=""):
model_id = "Intel/bge-large-en-v1.5-rag-int8-static"
self.ranker = IPEXBiEncoderSimilarityRanker(model=model_id)
self.ranker.warm_up()
def __call__(self, data: Dict[str, Any]):
query = data.get("query")
documents = data.get("documents")
top_k = data.get("top_k", None)
documents = [Document.from_dict(doc) for doc in documents]
return self.ranker.run(query, documents, top_k)
|