From c89791f268b7efb119ccbca64b8aa62932f07a60 Mon Sep 17 00:00:00 2001 From: nickprock Date: Wed, 19 Jul 2023 12:55:33 +0200 Subject: [PATCH 1/2] added shard number --- core/cat/memory/vector_memory.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/cat/memory/vector_memory.py b/core/cat/memory/vector_memory.py index 69d8b16b..fc7c0737 100644 --- a/core/cat/memory/vector_memory.py +++ b/core/cat/memory/vector_memory.py @@ -114,6 +114,7 @@ def __init__(self, cat, client: Any, collection_name: str, embeddings: Embedding # Check if memory collection exists, otherwise create it self.create_collection_if_not_exists() + def create_collection_if_not_exists(self): # create collection if it does not exist try: @@ -130,6 +131,7 @@ def create_collection_if_not_exists(self): else: log(f'Collection "{self.collection_name}" has different embedder', "WARNING") # TODO: dump collection on disk before deleting, so it can be recovered + self.client.delete_collection(self.collection_name) log(f'Collection "{self.collection_name}" deleted', "WARNING") self.create_collection() @@ -155,8 +157,10 @@ def create_collection(self): quantile=0.75, always_ram=False ) - ) + ), + shard_number=3, ) + self.client.update_collection_aliases( change_aliases_operations=[ CreateAliasOperation( From e96642d944d63193b8286d699f84f5192c745dd7 Mon Sep 17 00:00:00 2001 From: nickprock Date: Wed, 19 Jul 2023 14:34:32 +0200 Subject: [PATCH 2/2] added memmap_threshold --- core/cat/memory/vector_memory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/cat/memory/vector_memory.py b/core/cat/memory/vector_memory.py index fc7c0737..c5dcb496 100644 --- a/core/cat/memory/vector_memory.py +++ b/core/cat/memory/vector_memory.py @@ -9,7 +9,7 @@ from langchain.vectorstores import Qdrant from qdrant_client.http.models import (Distance, VectorParams, SearchParams, ScalarQuantization, ScalarQuantizationConfig, ScalarType, QuantizationSearchParams, - CreateAliasOperation, CreateAlias) + CreateAliasOperation, CreateAlias, OptimizersConfigDiff) class VectorMemory: @@ -151,6 +151,7 @@ def create_collection(self): collection_name=self.collection_name, vectors_config=VectorParams( size=self.embedder_size, distance=Distance.COSINE), + optimizers_config=OptimizersConfigDiff(memmap_threshold=20000), quantization_config=ScalarQuantization( scalar=ScalarQuantizationConfig( type=ScalarType.INT8,