Spaces:
Running
Running
from langchain_community.vectorstores import FAISS | |
from langchain_huggingface import HuggingFaceEmbeddings | |
def get_embeddings_model(): | |
embeddings = HuggingFaceEmbeddings( | |
model_name="sentence-transformers/all-MiniLM-L6-v2", | |
model_kwargs={"device": "cuda"}, | |
encode_kwargs={"normalize_embeddings": True}, | |
show_progress=True, | |
) | |
print("Loaded embeddings model") | |
return embeddings | |
def get_vector_store(): | |
return FAISS.load_local( | |
folder_path="vector_store", | |
embeddings=get_embeddings_model(), | |
index_name="object_detection_models_faiss_index", | |
allow_dangerous_deserialization=True, | |
) | |