Ajaykanth Maddi commited on
Commit ·
68f5761
1
Parent(s): 6cd14c4
Changes to use RAG26-Demo as dataset
Browse files- ragbench.py +28 -29
ragbench.py
CHANGED
|
@@ -140,40 +140,39 @@ class RAGSystem:
|
|
| 140 |
# 1. Define all required files
|
| 141 |
REQUIRED_FILES = [
|
| 142 |
"index.faiss",
|
| 143 |
-
"index.pkl"
|
| 144 |
-
"langchain_docs.pkl" # Include if needed
|
| 145 |
]
|
| 146 |
|
| 147 |
folder_path = f"{self.subset}/embeddings/{self.retriever_model_name.replace('/', ':')}"
|
| 148 |
print(f"Folder path: {folder_path}")
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
|
| 175 |
-
|
| 176 |
-
|
| 177 |
|
| 178 |
# # Load langchain_docs for BM25
|
| 179 |
# docs_path = os.path.join(index_dir, f"chunks_{self.strategy}.pkl")
|
|
|
|
| 140 |
# 1. Define all required files
|
| 141 |
REQUIRED_FILES = [
|
| 142 |
"index.faiss",
|
| 143 |
+
"index.pkl"
|
|
|
|
| 144 |
]
|
| 145 |
|
| 146 |
folder_path = f"{self.subset}/embeddings/{self.retriever_model_name.replace('/', ':')}"
|
| 147 |
print(f"Folder path: {folder_path}")
|
| 148 |
+
try:
|
| 149 |
+
# 2. Download the embeddings files to cache
|
| 150 |
+
downloaded_files = []
|
| 151 |
+
for filename in REQUIRED_FILES:
|
| 152 |
+
file_path = hf_hub_download(
|
| 153 |
+
repo_id=repo_id,
|
| 154 |
+
filename=f"{folder_path}/{filename}",
|
| 155 |
+
repo_type=HF_REPO_TYPE,
|
| 156 |
+
local_dir=folder_path,
|
| 157 |
+
token=os.getenv("HF_TOKEN")
|
| 158 |
+
)
|
| 159 |
+
downloaded_files.append(file_path)
|
| 160 |
+
print(f"Downloaded: {filename} → {file_path}")
|
| 161 |
+
|
| 162 |
+
# 3. Get the common directory
|
| 163 |
+
index_dir = os.path.dirname(downloaded_files[0])
|
| 164 |
+
print(f"Final index directory: {index_dir}")
|
| 165 |
+
print(f"Files in directory: {os.listdir(index_dir)}")
|
| 166 |
+
|
| 167 |
+
# 4. Load FAISS
|
| 168 |
+
self.vector_store = FAISS.load_local(
|
| 169 |
+
folder_path=index_dir,
|
| 170 |
+
embeddings=self.embedder,
|
| 171 |
+
allow_dangerous_deserialization=True
|
| 172 |
+
)
|
| 173 |
|
| 174 |
+
except Exception as e:
|
| 175 |
+
print(f"Error loading index: {e}")
|
| 176 |
|
| 177 |
# # Load langchain_docs for BM25
|
| 178 |
# docs_path = os.path.join(index_dir, f"chunks_{self.strategy}.pkl")
|