Song commited on
Commit
65a3c09
·
1 Parent(s): 4fcb155
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -208,11 +208,16 @@ class RagPipeline:
208
  self.state.sentences = data["sentences"]
209
  self.state.meta = data["meta"]
210
 
 
 
211
  log.info("載入 BM25 索引...")
212
  with open(BM25_PKL, "rb") as f:
213
- self.state.bm25 = pickle.load(f)
 
 
214
  if not isinstance(self.state.bm25, BM25Okapi):
215
  raise ValueError("Loaded BM25 is not a BM25Okapi instance.")
 
216
  except (FileNotFoundError, KeyError) as e:
217
  log.exception(f"資料或索引檔案載入失敗: {e}")
218
  raise RuntimeError(f"資料初始化失敗,請檢查檔案路徑與內容: {e}")
 
208
  self.state.sentences = data["sentences"]
209
  self.state.meta = data["meta"]
210
 
211
+ log.info("載入 BM25 索引...")
212
+
213
  log.info("載入 BM25 索引...")
214
  with open(BM25_PKL, "rb") as f:
215
+ # 載入整個字典,然後取 'bm25' 這個鍵
216
+ bm25_data = pickle.load(f)
217
+ self.state.bm25 = bm25_data["bm25"]
218
  if not isinstance(self.state.bm25, BM25Okapi):
219
  raise ValueError("Loaded BM25 is not a BM25Okapi instance.")
220
+
221
  except (FileNotFoundError, KeyError) as e:
222
  log.exception(f"資料或索引檔案載入失敗: {e}")
223
  raise RuntimeError(f"資料初始化失敗,請檢查檔案路徑與內容: {e}")