Ajaykanth Maddi commited on
Commit ·
e8268f4
1
Parent(s): d13d918
Code Refactoring
Browse files- ragbench.py +10 -7
ragbench.py
CHANGED
|
@@ -162,14 +162,20 @@ class RAGSystem:
|
|
| 162 |
self._load_embeddings()
|
| 163 |
|
| 164 |
|
| 165 |
-
folder_path = f"{self.subset}/embeddings/{self.retriever_model_name.replace('/', ':')}/{self.strategy}"
|
| 166 |
-
print(f"Folder path: {folder_path}")
|
| 167 |
-
|
| 168 |
chunkFilePath = f"{self.subset}/chunks/chunks_{self.strategy}.pkl"
|
| 169 |
print(f"Chunk File Path: {chunkFilePath} for strategy {self.strategy}")
|
| 170 |
|
| 171 |
chunkFile = self._download_file(chunkFilePath, "")
|
| 172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
# # 1. Try to download the chunk file
|
| 174 |
# chunk_path = hf_hub_download(
|
| 175 |
# repo_id=HF_DATASET_REPO_NAME,
|
|
@@ -178,10 +184,7 @@ class RAGSystem:
|
|
| 178 |
# token=os.getenv("HF_TOKEN")
|
| 179 |
# )
|
| 180 |
|
| 181 |
-
|
| 182 |
-
with open(chunkFile, "rb") as f:
|
| 183 |
-
langchain_docs = pickle.load(f)
|
| 184 |
-
print(f"Successfully loaded chunks from {chunkFile}, length: {len(langchain_docs)}")
|
| 185 |
|
| 186 |
|
| 187 |
# # 1. Define all required files
|
|
|
|
| 162 |
self._load_embeddings()
|
| 163 |
|
| 164 |
|
|
|
|
|
|
|
|
|
|
| 165 |
chunkFilePath = f"{self.subset}/chunks/chunks_{self.strategy}.pkl"
|
| 166 |
print(f"Chunk File Path: {chunkFilePath} for strategy {self.strategy}")
|
| 167 |
|
| 168 |
chunkFile = self._download_file(chunkFilePath, "")
|
| 169 |
|
| 170 |
+
if os.path.exists(chunkFile):
|
| 171 |
+
with open(chunkFile, "rb") as f:
|
| 172 |
+
langchain_docs = pickle.load(f)
|
| 173 |
+
print(f"Successfully loaded chunks from {chunkFile}, length: {len(langchain_docs)}")
|
| 174 |
+
|
| 175 |
+
# Check for FAISS index files (index.faiss, index.pkl )
|
| 176 |
+
folderPath = f"{self.subset}/embeddings/{self.retriever_model_name.replace('/', ':')}/{self.strategy}"
|
| 177 |
+
print(f"Folder path: {folderPath}")
|
| 178 |
+
|
| 179 |
# # 1. Try to download the chunk file
|
| 180 |
# chunk_path = hf_hub_download(
|
| 181 |
# repo_id=HF_DATASET_REPO_NAME,
|
|
|
|
| 184 |
# token=os.getenv("HF_TOKEN")
|
| 185 |
# )
|
| 186 |
|
| 187 |
+
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
|
| 190 |
# # 1. Define all required files
|