Spaces:
Runtime error
Runtime error
mcarthuradal
commited on
Commit
•
74ee2e4
1
Parent(s):
30e4578
Update app.py
Browse files
app.py
CHANGED
@@ -28,11 +28,19 @@ def get_text_chunks(text):
|
|
28 |
)
|
29 |
chunks = text_splitter.split_text(text)
|
30 |
return chunks
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
def get_vectorstore(text_chunks):
|
34 |
-
|
35 |
-
embeddings = HuggingFaceInstructEmbeddings(model_name="hkunlp/instructor-xl")
|
36 |
vectorstore = FAISS.from_texts(texts=text_chunks, embedding=embeddings)
|
37 |
return vectorstore
|
38 |
|
|
|
28 |
)
|
29 |
chunks = text_splitter.split_text(text)
|
30 |
return chunks
|
31 |
+
def get_embeddings():
|
32 |
+
model_name = "sentence-transformers/all-mpnet-base-v2"
|
33 |
+
model_kwargs = {'device': 'cpu'}
|
34 |
+
encode_kwargs = {'normalize_embeddings': False}
|
35 |
+
|
36 |
+
return HuggingFaceEmbeddings(
|
37 |
+
model_name=model_name,
|
38 |
+
model_kwargs=model_kwargs,
|
39 |
+
encode_kwargs=encode_kwargs
|
40 |
|
41 |
def get_vectorstore(text_chunks):
|
42 |
+
embeddings = get_embeddings()
|
43 |
+
# embeddings = HuggingFaceInstructEmbeddings(model_name="hkunlp/instructor-xl")
|
44 |
vectorstore = FAISS.from_texts(texts=text_chunks, embedding=embeddings)
|
45 |
return vectorstore
|
46 |
|