Spaces:
Runtime error
Runtime error
Update app.py
Browse filesUncommenting data embedding stage
app.py
CHANGED
|
@@ -22,8 +22,8 @@ import os
|
|
| 22 |
huggingfacehub_api_token = os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
| 23 |
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
|
| 28 |
|
| 29 |
|
|
@@ -36,11 +36,11 @@ model_norm = HuggingFaceBgeEmbeddings(
|
|
| 36 |
model_kwargs={'device': 'cpu'},
|
| 37 |
encode_kwargs=encode_kwargs
|
| 38 |
)
|
| 39 |
-
|
| 40 |
# job_done = object() # signals the processing is done
|
| 41 |
|
| 42 |
## saving the embeddings locally
|
| 43 |
-
|
| 44 |
|
| 45 |
##loading
|
| 46 |
vector_store = FAISS.load_local("cdssagent_database", model_norm, allow_dangerous_deserialization=True)
|
|
|
|
| 22 |
huggingfacehub_api_token = os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
| 23 |
|
| 24 |
|
| 25 |
+
loader = PyPDFLoader("stg.pdf")
|
| 26 |
+
documents = loader.load_and_split()
|
| 27 |
|
| 28 |
|
| 29 |
|
|
|
|
| 36 |
model_kwargs={'device': 'cpu'},
|
| 37 |
encode_kwargs=encode_kwargs
|
| 38 |
)
|
| 39 |
+
vector_store = FAISS.from_documents(documents, model_norm)
|
| 40 |
# job_done = object() # signals the processing is done
|
| 41 |
|
| 42 |
## saving the embeddings locally
|
| 43 |
+
vector_store.save_local("cdssagent_database")
|
| 44 |
|
| 45 |
##loading
|
| 46 |
vector_store = FAISS.load_local("cdssagent_database", model_norm, allow_dangerous_deserialization=True)
|