Spaces:
Runtime error
Runtime error
Cuda support?
Browse files
app.py
CHANGED
@@ -16,10 +16,7 @@ from nltk.tokenize import sent_tokenize
|
|
16 |
import nltk
|
17 |
nltk.download('punkt')
|
18 |
|
19 |
-
|
20 |
-
if not torch.cuda.is_available():
|
21 |
-
print("Warning: No GPU found. Please add GPU to your notebook")
|
22 |
-
|
23 |
|
24 |
import pandas as pd
|
25 |
st.title('Sociology Paragraph Search')
|
@@ -82,7 +79,7 @@ def search(query, top_k=40):
|
|
82 |
|
83 |
##### Sematic Search #####
|
84 |
# Encode the query using the bi-encoder and find potentially relevant passages
|
85 |
-
question_embedding = bi_encoder.encode(query, convert_to_tensor=True)
|
86 |
|
87 |
|
88 |
hits = util.semantic_search(question_embedding, corpus_embeddings, top_k=top_k)
|
|
|
16 |
import nltk
|
17 |
nltk.download('punkt')
|
18 |
|
19 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
|
|
|
|
20 |
|
21 |
import pandas as pd
|
22 |
st.title('Sociology Paragraph Search')
|
|
|
79 |
|
80 |
##### Sematic Search #####
|
81 |
# Encode the query using the bi-encoder and find potentially relevant passages
|
82 |
+
question_embedding = bi_encoder.encode(query, convert_to_tensor=True).to(device)
|
83 |
|
84 |
|
85 |
hits = util.semantic_search(question_embedding, corpus_embeddings, top_k=top_k)
|