Spaces:
Running
Running
ivyblossom
commited on
Commit
•
7723d60
1
Parent(s):
81c1037
Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ def semantic_search(query, documents, top_k=5):
|
|
25 |
document_embeddings = model.encode([text for _, text in documents], convert_to_tensor=True)
|
26 |
|
27 |
# Compute cosine similarity scores of query with documents
|
28 |
-
cosine_scores = util.pytorch_cos_sim(query_embedding, document_embeddings)
|
29 |
|
30 |
# Sort the results in decreasing order
|
31 |
results = []
|
@@ -36,7 +36,7 @@ def semantic_search(query, documents, top_k=5):
|
|
36 |
return results[:top_k]
|
37 |
|
38 |
def main():
|
39 |
-
st.title("Semantic Search on
|
40 |
|
41 |
pdf_file = st.file_uploader("Upload a PDF file:", type=["pdf"])
|
42 |
query = st.text_input("Enter your query:")
|
|
|
25 |
document_embeddings = model.encode([text for _, text in documents], convert_to_tensor=True)
|
26 |
|
27 |
# Compute cosine similarity scores of query with documents
|
28 |
+
cosine_scores = util.pytorch_cos_sim(query_embedding.unsqueeze(0), document_embeddings)[0]
|
29 |
|
30 |
# Sort the results in decreasing order
|
31 |
results = []
|
|
|
36 |
return results[:top_k]
|
37 |
|
38 |
def main():
|
39 |
+
st.title("Semantic Search on PDF Documents")
|
40 |
|
41 |
pdf_file = st.file_uploader("Upload a PDF file:", type=["pdf"])
|
42 |
query = st.text_input("Enter your query:")
|