Skip to content

HNSW Search: Changing ef Has No Effect on Recall (Milvus C++ SDK) #276

@AdeelAslamSoton

Description

@AdeelAslamSoton

Hi all,

I'm using the Milvus C++ SDK with an HNSW index and testing different ef values during search:

int total_efs[] = {20, 40, 60, 100, 200, 300, 400, 500, 600,
800, 1000, 1200, 1500, 1700, 1900, 2100};

In each search:

ef is set via AddExtraParam("ef", total_efs[i])

I'm using ParallelFor with 40 threads

TopK is 10, metric is L2

Each result is saved per query

❗ Problem
No matter how high I set ef, recall stays the same. I expected higher ef to improve recall (at the cost of speed), but that’s not happening, I already use HNSW for collection construction

❓ Questions
Does ef work at search time for HNSW in Milvus C++ SDK?

Code snippt for search is here
milvus::SearchArguments arguments;
arguments.SetCollectionName(collection_name);
arguments.SetTopK(10);
arguments.SetMetricType(milvus::MetricType::L2);
arguments.AddExtraParam("ef", total_efs[i]);

if (!data_vectors.first.empty()) {
arguments.SetExpression(data_vectors.first[row]);
}
arguments.AddTargetVector(vector_field_name, data_vectors.second[row]);
arguments.AddOutputField(filter_field_name);
arguments.AddOutputField("id");

milvus::SearchResults results;
status = client->Search(arguments, results);

Thanks 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions