Rabbitt-AI commited on
Commit
0a6da3b
·
verified ·
1 Parent(s): 26869b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -168,10 +168,17 @@ class MistralRAGChatbot:
168
  0.3 * bm25_scores.get(idx, 0) +
169
  0.2 * pagerank_scores[idx]
170
  )
171
-
 
 
 
 
 
 
 
172
  sorted_indices = sorted(combined_scores, key=combined_scores.get, reverse=True)
173
 
174
- return [{'text': self.texts[i], 'method': 'advanced_fusion', 'score': combined_scores[i], 'index': i} for i in sorted_indices[:5]]
175
 
176
  def create_embeddings(self, text_list: List[str]) -> np.ndarray:
177
  expected_dim = 1024
 
168
  0.3 * bm25_scores.get(idx, 0) +
169
  0.2 * pagerank_scores[idx]
170
  )
171
+ # Step 1: Calculate min and max scores
172
+ min_score = min(combined_scores.values())
173
+ max_score = max(combined_scores.values())
174
+
175
+ # Step 2: Normalize the scores
176
+ normalized_scores = {idx: (score - min_score) / (max_score - min_score) for idx, score in combined_scores.items()}
177
+
178
+
179
  sorted_indices = sorted(combined_scores, key=combined_scores.get, reverse=True)
180
 
181
+ return [{'text': self.texts[i], 'method': 'advanced_fusion', 'score': normalized_scores[i], 'index': i} for i in sorted_indices[:5]]
182
 
183
  def create_embeddings(self, text_list: List[str]) -> np.ndarray:
184
  expected_dim = 1024