Spaces:
Runtime error
Runtime error
Update recommend.py
Browse files- recommend.py +1 -1
recommend.py
CHANGED
|
@@ -13,7 +13,7 @@ def recommend(query, n=5):
|
|
| 13 |
# Encode the query
|
| 14 |
q_embedding = model.encode(query)
|
| 15 |
# Calculate the cosine similarity
|
| 16 |
-
cos_sim = np.array([1 - cosine(q_embedding, emb) for emb in a_embeddings)
|
| 17 |
# Get the top n recommendations
|
| 18 |
top_n = np.argsort(cos_sim)[-n:]
|
| 19 |
return data.iloc[top_n]['title']
|
|
|
|
| 13 |
# Encode the query
|
| 14 |
q_embedding = model.encode(query)
|
| 15 |
# Calculate the cosine similarity
|
| 16 |
+
cos_sim = np.array([1 - cosine(q_embedding, emb) for emb in a_embeddings])
|
| 17 |
# Get the top n recommendations
|
| 18 |
top_n = np.argsort(cos_sim)[-n:]
|
| 19 |
return data.iloc[top_n]['title']
|