Spaces:
Sleeping
Sleeping
andykr1k commited on
Commit ·
d693ac3
1
Parent(s): 54acd78
added scheduler, logging and optimization updates
Browse files
app.py
CHANGED
|
@@ -184,7 +184,10 @@ def get_recommendations(user_id, model, data, G, user_nodes, post_nodes, node2id
|
|
| 184 |
|
| 185 |
scores = torch.matmul(user_embed, post_embeds.T).squeeze(0)
|
| 186 |
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
| 188 |
post_scores = sorted(post_scores, key=lambda x: x[1], reverse=True)
|
| 189 |
|
| 190 |
logger.info(f"Generated {len(post_scores)} recommendations for user {user_id}")
|
|
|
|
| 184 |
|
| 185 |
scores = torch.matmul(user_embed, post_embeds.T).squeeze(0)
|
| 186 |
|
| 187 |
+
# Create an inverse mapping from index to post ID
|
| 188 |
+
idx2node = {idx: node for node, idx in node2idx.items()}
|
| 189 |
+
# Map post_indices back to original post IDs
|
| 190 |
+
post_scores = [(idx2node[i], score.item()) for i, score in zip(post_indices, scores)]
|
| 191 |
post_scores = sorted(post_scores, key=lambda x: x[1], reverse=True)
|
| 192 |
|
| 193 |
logger.info(f"Generated {len(post_scores)} recommendations for user {user_id}")
|