Update app.py
Browse files
app.py
CHANGED
@@ -184,8 +184,18 @@ def file_Upload():
|
|
184 |
print("All chunk List END ***********************\n\n")
|
185 |
|
186 |
#embeddings = OpenAIEmbeddings()
|
187 |
-
from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings
|
188 |
-
embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
global vectordb
|
190 |
#vectordb = Chroma.from_documents(texts,embeddings)
|
191 |
vectordb=Chroma.from_documents(documents=texts, embedding=embeddings, collection_metadata={"hnsw:space": "cosine"})
|
|
|
184 |
print("All chunk List END ***********************\n\n")
|
185 |
|
186 |
#embeddings = OpenAIEmbeddings()
|
187 |
+
#from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings
|
188 |
+
#embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
|
189 |
+
from langchain.embeddings import HuggingFaceEmbeddings
|
190 |
+
|
191 |
+
model_name = "sentence-transformers/all-MiniLM-L6-v2"
|
192 |
+
model_kwargs = {'device': 'cpu'}
|
193 |
+
encode_kwargs = {'normalize_embeddings': False}
|
194 |
+
embeddings = HuggingFaceEmbeddings(
|
195 |
+
model_name=model_name,
|
196 |
+
model_kwargs=model_kwargs,
|
197 |
+
encode_kwargs=encode_kwargs
|
198 |
+
)
|
199 |
global vectordb
|
200 |
#vectordb = Chroma.from_documents(texts,embeddings)
|
201 |
vectordb=Chroma.from_documents(documents=texts, embedding=embeddings, collection_metadata={"hnsw:space": "cosine"})
|