relax faiss type dependency as its optional; breaking when faiss is not installed by thakur-nandan · Pull Request #200 · beir-cellar/beir (original) (raw)

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.

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

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.