Spaces:
Sleeping
Sleeping
Update FAISS index.py
Browse files- FAISS index.py +9 -0
FAISS index.py
CHANGED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain_community.vectorstores import FAISS
|
2 |
+
from langchain.embeddings import SentenceTransformerEmbeddings
|
3 |
+
|
4 |
+
embedding_model = SentenceTransformerEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
|
5 |
+
documents = ["Mathematical modeling is used in AI, finance, and physics.", "Differential equations are part of modeling."]
|
6 |
+
vectorstore = FAISS.from_texts(documents, embedding_model)
|
7 |
+
|
8 |
+
# Save FAISS index
|
9 |
+
vectorstore.save_local("faiss_index")
|