Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,12 +10,17 @@ def load_sbert():
|
|
10 |
|
11 |
model = load_sbert()
|
12 |
|
|
|
13 |
def calculate_similarity(word1, word2):
|
14 |
embeddings1 = model.encode(word1)
|
15 |
embeddings2 = model.encode(word2)
|
|
|
|
|
|
|
|
|
|
|
16 |
cos_sim = torch.nn.functional.cosine_similarity(embeddings1, embeddings2, dim=0)
|
17 |
return cos_sim.item()
|
18 |
-
|
19 |
# Streamlit interface
|
20 |
st.title("Word Similarity Checker")
|
21 |
|
|
|
10 |
|
11 |
model = load_sbert()
|
12 |
|
13 |
+
|
14 |
def calculate_similarity(word1, word2):
|
15 |
embeddings1 = model.encode(word1)
|
16 |
embeddings2 = model.encode(word2)
|
17 |
+
|
18 |
+
# Convert NumPy arrays to tensors
|
19 |
+
embeddings1 = torch.tensor(embeddings1)
|
20 |
+
embeddings2 = torch.tensor(embeddings2)
|
21 |
+
|
22 |
cos_sim = torch.nn.functional.cosine_similarity(embeddings1, embeddings2, dim=0)
|
23 |
return cos_sim.item()
|
|
|
24 |
# Streamlit interface
|
25 |
st.title("Word Similarity Checker")
|
26 |
|