Update filtered_search_engine.py
Browse files
filtered_search_engine.py
CHANGED
|
@@ -55,8 +55,8 @@ class SmartRecommender:
|
|
| 55 |
vec = np.array(vec, dtype="float32").reshape(1, -1)
|
| 56 |
|
| 57 |
# Search in full FAISS with wider net (NO HARD FILTERING)
|
| 58 |
-
#
|
| 59 |
-
scores, ids = self.index.search(vec, k=
|
| 60 |
|
| 61 |
results = []
|
| 62 |
for i, score in zip(ids[0], scores[0]):
|
|
@@ -71,8 +71,10 @@ class SmartRecommender:
|
|
| 71 |
"intent": intent # Pass intent for boosting later
|
| 72 |
})
|
| 73 |
|
| 74 |
-
#
|
| 75 |
-
|
|
|
|
|
|
|
| 76 |
break
|
| 77 |
|
| 78 |
print("\n🎯 Top Recommendations (Pre-Rerank):")
|
|
|
|
| 55 |
vec = np.array(vec, dtype="float32").reshape(1, -1)
|
| 56 |
|
| 57 |
# Search in full FAISS with wider net (NO HARD FILTERING)
|
| 58 |
+
# SPEED OPTIMIZATION: Retrieve 200 candidates (Deep enough to capture key items)
|
| 59 |
+
scores, ids = self.index.search(vec, k=200)
|
| 60 |
|
| 61 |
results = []
|
| 62 |
for i, score in zip(ids[0], scores[0]):
|
|
|
|
| 71 |
"intent": intent # Pass intent for boosting later
|
| 72 |
})
|
| 73 |
|
| 74 |
+
# LIMIT RERANKING POOL: Only rerank top 60 candidates.
|
| 75 |
+
# Reranking 500+ items with BGE-Base on CPU takes 5-10 seconds.
|
| 76 |
+
# 60 is the sweet spot for Accuracy vs Speed (<1 sec).
|
| 77 |
+
if len(results) >= 60:
|
| 78 |
break
|
| 79 |
|
| 80 |
print("\n🎯 Top Recommendations (Pre-Rerank):")
|