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.
- 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 |
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.