Spaces:
Runtime error
Runtime error
syedmudassir16
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -41,14 +41,20 @@ class DocumentRetrievalAndGeneration:
|
|
41 |
|
42 |
def create_faiss_index(self):
|
43 |
all_texts = [split.page_content for split in self.all_splits]
|
44 |
-
embeddings = self.embeddings.encode(all_texts
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
)
|
51 |
-
return vectordb
|
52 |
|
53 |
def initialize_llm(self, model_id):
|
54 |
quantization_config = BitsAndBytesConfig(
|
|
|
41 |
|
42 |
def create_faiss_index(self):
|
43 |
all_texts = [split.page_content for split in self.all_splits]
|
44 |
+
embeddings = self.embeddings.encode(all_texts)
|
45 |
+
|
46 |
+
# Create FAISS index
|
47 |
+
vector_dimension = embeddings.shape[1]
|
48 |
+
index = faiss.IndexFlatL2(vector_dimension)
|
49 |
+
index.add(embeddings)
|
50 |
+
|
51 |
+
# Create and return FAISS object
|
52 |
+
return FAISS(
|
53 |
+
embedding_function=self.embeddings.encode,
|
54 |
+
index=index,
|
55 |
+
docstore=self.all_splits,
|
56 |
+
index_to_docstore_id={i: i for i in range(len(self.all_splits))}
|
57 |
)
|
|
|
58 |
|
59 |
def initialize_llm(self, model_id):
|
60 |
quantization_config = BitsAndBytesConfig(
|