Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ model = CrossEncoder("jinaai/jina-reranker-v2-base-multilingual", trust_remote_c
|
|
6 |
|
7 |
# Function to rerank documents
|
8 |
def rerank(query, documents):
|
9 |
-
documents = documents.split("
|
10 |
scores = model.predict([[query, doc] for doc in documents if doc.strip()])
|
11 |
ranked_docs = sorted(zip(documents, scores), key=lambda x: x[1], reverse=True)
|
12 |
return [{"document": doc, "score": round(score, 4)} for doc, score in ranked_docs]
|
@@ -14,10 +14,10 @@ def rerank(query, documents):
|
|
14 |
# Gradio Interface
|
15 |
iface = gr.Interface(
|
16 |
fn=rerank,
|
17 |
-
inputs=["text", gr.Textbox(label="Documents (Separate with
|
18 |
outputs="json",
|
19 |
title="JinaAI v2 Reranker API",
|
20 |
-
description="Enter a query and documents (separated by '
|
21 |
)
|
22 |
|
23 |
iface.launch()
|
|
|
6 |
|
7 |
# Function to rerank documents
|
8 |
def rerank(query, documents):
|
9 |
+
documents = documents.split("&&") # Use custom delimiter to split documents correctly
|
10 |
scores = model.predict([[query, doc] for doc in documents if doc.strip()])
|
11 |
ranked_docs = sorted(zip(documents, scores), key=lambda x: x[1], reverse=True)
|
12 |
return [{"document": doc, "score": round(score, 4)} for doc, score in ranked_docs]
|
|
|
14 |
# Gradio Interface
|
15 |
iface = gr.Interface(
|
16 |
fn=rerank,
|
17 |
+
inputs=["text", gr.Textbox(label="Documents (Separate with &&)", placeholder="Doc1 ||| Doc2 ||| Doc3")],
|
18 |
outputs="json",
|
19 |
title="JinaAI v2 Reranker API",
|
20 |
+
description="Enter a query and documents (separated by '&&'). The model will rank them based on relevance.",
|
21 |
)
|
22 |
|
23 |
iface.launch()
|