Skip to content

Conversation

@thakur-nandan
Copy link
Member

Solves the issue stated in #198. Allows direct usage without installing the faiss-cpu dependency.

@thakur-nandan thakur-nandan requested a review from Copilot June 3, 2025 05:45
@thakur-nandan thakur-nandan self-assigned this Jun 3, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR relaxes the dependency on faiss by making the similarity_metric parameter optional so that the library can be used without installing the faiss-cpu dependency.

  • Updated several constructors in faiss_search.py to accept an optional similarity_metric argument.
  • Added conditional assignments for similarity_metric in most constructors to default to faiss.METRIC_INNER_PRODUCT when None is provided.
  • In one constructor (the one with quantizer_type), the assignment for similarity_metric was removed, which may lead to an uninitialized attribute.

if similarity_metric is None:
self.similarity_metric = faiss.METRIC_INNER_PRODUCT
else:
self.similarity_metric = similarity_metric
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constructor with quantizer_type no longer assigns the similarity_metric argument, unlike the other constructors. Consider adding the conditional assignment (if similarity_metric is None then assign faiss.METRIC_INNER_PRODUCT) to ensure similarity_metric is consistently initialized.

Copilot uses AI. Check for mistakes.
@thakur-nandan thakur-nandan merged commit 3e2d56d into main Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants