diff --git a/requirements.txt b/requirements.txt index 399521b..b5cd996 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,7 +18,7 @@ starlette~=0.27.0 unstructured[all-docs]==0.11.0 python-magic-bin; sys_platform == 'win32' SQLAlchemy==2.0.19 -faiss-cpu +faiss-cpu # `conda install faiss-gpu -c conda-forge` if you want to accelerate with gpus accelerate>=0.24.1 spacy>=3.7.2 PyMuPDF @@ -64,7 +64,7 @@ metaphor-python>=0.1.23 # WebUI requirements -streamlit>=1.29.0 +streamlit>=1.29.0 # do remember to add streamlit to environment variables if you use windows streamlit-option-menu>=0.3.6 streamlit-antd-components>=0.2.3 streamlit-chatbox>=1.1.11 diff --git a/server/knowledge_base/kb_cache/faiss_cache.py b/server/knowledge_base/kb_cache/faiss_cache.py index 6823536..68b5494 100644 --- a/server/knowledge_base/kb_cache/faiss_cache.py +++ b/server/knowledge_base/kb_cache/faiss_cache.py @@ -45,7 +45,7 @@ class _FaissPool(CachePool): # create an empty vector store embeddings = EmbeddingsFunAdapter(embed_model) doc = Document(page_content="init", metadata={}) - vector_store = FAISS.from_documents([doc], embeddings, normalize_L2=True) + vector_store = FAISS.from_documents([doc], embeddings, normalize_L2=True,distance_strategy="METRIC_INNER_PRODUCT") ids = list(vector_store.docstore._dict.keys()) vector_store.delete(ids) return vector_store @@ -82,7 +82,7 @@ class KBFaissPool(_FaissPool): if os.path.isfile(os.path.join(vs_path, "index.faiss")): embeddings = self.load_kb_embeddings(kb_name=kb_name, embed_device=embed_device, default_embed_model=embed_model) - vector_store = FAISS.load_local(vs_path, embeddings, normalize_L2=True) + vector_store = FAISS.load_local(vs_path, embeddings, normalize_L2=True,distance_strategy="METRIC_INNER_PRODUCT") elif create: # create an empty vector store if not os.path.exists(vs_path):