bharatverse11 commited on
Commit
1205b3f
·
verified ·
1 Parent(s): 4f07b64

Update filtered_search_engine.py

Browse files
Files changed (1) hide show
  1. filtered_search_engine.py +6 -4
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
- # MAX ACCURACY: Retrieve 1000 candidates to ensure we don't miss anything relevant
59
- scores, ids = self.index.search(vec, k=1000)
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
- # Pass more candidates to the reranker for better precision
75
- if len(results) >= 500:
 
 
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):")