Spaces:
Runtime error
Runtime error
Shroogawh24
commited on
Commit
•
f3ce899
1
Parent(s):
08438e8
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,16 @@ from langchain.embeddings.openai import OpenAIEmbeddings
|
|
11 |
|
12 |
from sentence_transformers import SentenceTransformer
|
13 |
|
14 |
-
embeddings = OpenAIEmbeddings()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
embedder = SentenceTransformer('all-mpnet-base-v2')
|
17 |
|
@@ -19,7 +28,7 @@ embedder = SentenceTransformer('all-mpnet-base-v2')
|
|
19 |
#openai.api_key = os.getenv("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")
|
20 |
|
21 |
# Load the FAISS index using LangChain's FAISS implementation
|
22 |
-
db = FAISS.load_local("Faiss_index",
|
23 |
parser = StrOutputParser()
|
24 |
|
25 |
# Load your data (e.g., a DataFrame)
|
|
|
11 |
|
12 |
from sentence_transformers import SentenceTransformer
|
13 |
|
14 |
+
#embeddings = OpenAIEmbeddings()
|
15 |
+
model_name = "BAAI/bge-large-en-v1.5"
|
16 |
+
model_kwargs = {'device':'cuda'}
|
17 |
+
encode_kwargs = {'normalize_embeddings':True}
|
18 |
+
|
19 |
+
embedding_function = HuggingFaceBgeEmbeddings(
|
20 |
+
model_name = model_name,
|
21 |
+
model_kwargs = model_kwargs,
|
22 |
+
encode_kwargs = encode_kwargs
|
23 |
+
)
|
24 |
|
25 |
embedder = SentenceTransformer('all-mpnet-base-v2')
|
26 |
|
|
|
28 |
#openai.api_key = os.getenv("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")
|
29 |
|
30 |
# Load the FAISS index using LangChain's FAISS implementation
|
31 |
+
db = FAISS.load_local("Faiss_index", embedding_function, allow_dangerous_deserialization=True)
|
32 |
parser = StrOutputParser()
|
33 |
|
34 |
# Load your data (e.g., a DataFrame)
|