enhance: change autoindex default metric type (#34277)

issue: #34304 
pr: #34261

Signed-off-by: chasingegg <chao.gao@zilliz.com>
This commit is contained in:
Gao 2024-07-08 10:52:14 +08:00 committed by GitHub
parent 014820e9d2
commit a60e2a65ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 10 deletions

View File

@ -64,7 +64,7 @@ var (
)
const (
FloatVectorDefaultMetricType = metric.IP
FloatVectorDefaultMetricType = metric.COSINE
SparseFloatVectorDefaultMetricType = metric.IP
BinaryVectorDefaultMetricType = metric.JACCARD
BinaryVectorDefaultMetricType = metric.HAMMING
)

View File

@ -180,15 +180,15 @@ func Test_hnswChecker_SetDefaultMetricType(t *testing.T) {
}{
{
dType: schemapb.DataType_FloatVector,
metricType: metric.IP,
metricType: metric.COSINE,
},
{
dType: schemapb.DataType_Float16Vector,
metricType: metric.IP,
metricType: metric.COSINE,
},
{
dType: schemapb.DataType_BFloat16Vector,
metricType: metric.IP,
metricType: metric.COSINE,
},
{
dType: schemapb.DataType_SparseFloatVector,
@ -196,7 +196,7 @@ func Test_hnswChecker_SetDefaultMetricType(t *testing.T) {
},
{
dType: schemapb.DataType_BinaryVector,
metricType: metric.JACCARD,
metricType: metric.HAMMING,
},
}

View File

@ -70,7 +70,7 @@ func (p *autoIndexConfig) init(base *BaseTable) {
p.IndexParams = ParamItem{
Key: "autoIndex.params.build",
Version: "2.2.0",
DefaultValue: `{"M": 18,"efConstruction": 240,"index_type": "HNSW", "metric_type": "IP"}`,
DefaultValue: `{"M": 18,"efConstruction": 240,"index_type": "HNSW", "metric_type": "COSINE"}`,
Export: true,
}
p.IndexParams.Init(base.mgr)
@ -86,7 +86,7 @@ func (p *autoIndexConfig) init(base *BaseTable) {
p.BinaryIndexParams = ParamItem{
Key: "autoIndex.params.binary.build",
Version: "2.4.5",
DefaultValue: `{"nlist": 1024, "index_type": "BIN_IVF_FLAT", "metric_type": "JACCARD"}`,
DefaultValue: `{"nlist": 1024, "index_type": "BIN_IVF_FLAT", "metric_type": "HAMMING"}`,
Export: true,
}
p.BinaryIndexParams.Init(base.mgr)

View File

@ -22,7 +22,8 @@ prefix = "index"
default_schema = cf.gen_default_collection_schema()
default_field_name = ct.default_float_vec_field_name
default_index_params = ct.default_index
default_autoindex_params = {"index_type": "AUTOINDEX", "metric_type": "IP"}
default_autoindex_params = {"index_type": "AUTOINDEX", "metric_type": "COSINE"}
default_sparse_autoindex_params = {"index_type": "AUTOINDEX", "metric_type": "IP"}
# copied from pymilvus
uid = "test_index"
@ -2125,7 +2126,7 @@ class TestAutoIndex(TestcaseBase):
"""
collection_w = self.init_collection_general(prefix, is_binary=True, is_index=False)[0]
collection_w.create_index(binary_field_name, {})
assert collection_w.index()[0].params == {'index_type': 'AUTOINDEX', 'metric_type': 'JACCARD'}
assert collection_w.index()[0].params == {'index_type': 'AUTOINDEX', 'metric_type': 'HAMMING'}
@pytest.mark.tags(CaseLabel.GPU)