Spaces:
Sleeping
Sleeping
Ajaykanth Maddi commited on
Commit ·
affdfdf
1
Parent(s): c9b1554
Code Changes - Added the time taken to build FAISS
Browse files- ragbench.py +7 -2
ragbench.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import pickle
|
| 3 |
from typing import List
|
| 4 |
-
import re, json
|
| 5 |
from dataclasses import dataclass
|
| 6 |
from nltk.tokenize import sent_tokenize
|
| 7 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
|
@@ -268,8 +268,13 @@ class RAGSystem:
|
|
| 268 |
print(f"Failed to load FAISS index from {faissFolderPath}, so load from documents")
|
| 269 |
if bChunkFileAvailable:
|
| 270 |
print(f"Building FAISS index from downloaded chunks")
|
|
|
|
| 271 |
self.vector_store = FAISS.from_documents(langchain_docs, self.embedder)
|
| 272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
self._store_faiss_files(faissFolderPath)
|
| 274 |
|
| 275 |
|
|
|
|
| 1 |
import os
|
| 2 |
import pickle
|
| 3 |
from typing import List
|
| 4 |
+
import re, json, time
|
| 5 |
from dataclasses import dataclass
|
| 6 |
from nltk.tokenize import sent_tokenize
|
| 7 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
|
|
|
| 268 |
print(f"Failed to load FAISS index from {faissFolderPath}, so load from documents")
|
| 269 |
if bChunkFileAvailable:
|
| 270 |
print(f"Building FAISS index from downloaded chunks")
|
| 271 |
+
start = time.time()
|
| 272 |
self.vector_store = FAISS.from_documents(langchain_docs, self.embedder)
|
| 273 |
+
duration = time.time() - start
|
| 274 |
+
# Convert to minutes and seconds
|
| 275 |
+
minutes = int(duration // 60)
|
| 276 |
+
seconds = int(duration % 60)
|
| 277 |
+
print(f"FAISS index built successfully from chunks in {minutes} minutes and {seconds} seconds, saving to {faissFolderPath}")
|
| 278 |
self._store_faiss_files(faissFolderPath)
|
| 279 |
|
| 280 |
|