From 5c8097c2de27df8f3ee087a5b187b804bc1509ce Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 28 Jan 2025 08:39:20 +0100 Subject: [PATCH] Document VADD EF option. --- README.md | 5 ++++- vset.c | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 910023a95d..382471ca3e 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ The execute the tests with: **VADD: add items into a vector set** VADD key [REDUCE dim] FP32|VALUES vector element [CAS] [NOQUANT] [BIN] + [EF build-exploration-factor] Add a new element into the vector set specified by the key. The vector can be provided as FP32 blob of values, or as floating point @@ -43,9 +44,11 @@ The `NOQUANT` option forces the vector to be created (in the first VADD call to The `BIN` option forces the vector to use binary quantization instead of int8. This is much faster and uses less memory, but has impacts on the recall quality. +The `EF` option plays a role in the effort made to find good candidates when connecting the new node to the existing HNSW graph. The default is 200. Using a larger value, may help to have a better recall. To improve the recall it is also possible to increase `EF` during `VSIM` searches. + **VSIM: return elements by vector similarity** - VSIM key [ELE|FP32|VALUES] [WITHSCORES] [COUNT num] [EF exploration-factor] + VSIM key [ELE|FP32|VALUES] [WITHSCORES] [COUNT num] [EF search-exploration-factor] The command returns similar vectors, in the example instead of providing a vector using FP32 or VALUES (like in `VADD`), we will ask for elements associated with a vector similar to a given element already in the sorted set: diff --git a/vset.c b/vset.c index f8963058ac..47a8ea1623 100644 --- a/vset.c +++ b/vset.c @@ -1086,8 +1086,7 @@ size_t VectorSetMemUsage(const void *value) { size += sizeof(*node) * vset->hnsw->node_count; /* Vector storage. */ - uint64_t vec_storage = vset->hnsw->vector_dim; - if (vset->hnsw->quant_type == HNSW_QUANT_NONE) vec_storage *= 4; + uint64_t vec_storage = hnsw_quants_bytes(vset->hnsw); size += vec_storage * vset->hnsw->node_count; /* Layers array. We use 1.33 as average nodes layers count. */