Spaces:
Sleeping
Sleeping
dinhquangson
commited on
Commit
•
9fade90
1
Parent(s):
86bde80
Update app.py
Browse files
app.py
CHANGED
@@ -159,6 +159,9 @@ def search(prompt: str):
|
|
159 |
FastembedTextEmbedder,
|
160 |
FastembedSparseTextEmbedder
|
161 |
)
|
|
|
|
|
|
|
162 |
start_time = time.time()
|
163 |
|
164 |
# Querying
|
@@ -169,10 +172,12 @@ def search(prompt: str):
|
|
169 |
model="BAAI/bge-small-en-v1.5", prefix="Represent this sentence for searching relevant passages: ")
|
170 |
)
|
171 |
querying.add_component("retriever", QdrantHybridRetriever(document_store=document_store))
|
172 |
-
|
|
|
173 |
querying.connect("sparse_text_embedder.sparse_embedding", "retriever.query_sparse_embedding")
|
174 |
querying.connect("dense_text_embedder.embedding", "retriever.query_embedding")
|
175 |
-
|
|
|
176 |
question = "Cosa sono i marker tumorali?"
|
177 |
|
178 |
results = querying.run(
|
|
|
159 |
FastembedTextEmbedder,
|
160 |
FastembedSparseTextEmbedder
|
161 |
)
|
162 |
+
from haystack.components.rankers import TransformersSimilarityRanker
|
163 |
+
from haystack.components.joiners import DocumentJoiner
|
164 |
+
|
165 |
start_time = time.time()
|
166 |
|
167 |
# Querying
|
|
|
172 |
model="BAAI/bge-small-en-v1.5", prefix="Represent this sentence for searching relevant passages: ")
|
173 |
)
|
174 |
querying.add_component("retriever", QdrantHybridRetriever(document_store=document_store))
|
175 |
+
querying.add_component("document_joiner", DocumentJoiner())
|
176 |
+
querying.add_component("ranker", TransformersSimilarityRanker(model="BAAI/bge-reranker-base"))
|
177 |
querying.connect("sparse_text_embedder.sparse_embedding", "retriever.query_sparse_embedding")
|
178 |
querying.connect("dense_text_embedder.embedding", "retriever.query_embedding")
|
179 |
+
querying.connect("retriever", "document_joiner")
|
180 |
+
querying.connect("document_joiner", "ranker")
|
181 |
question = "Cosa sono i marker tumorali?"
|
182 |
|
183 |
results = querying.run(
|