feat: Add faiss cache backend#3402
Conversation
# Conflicts: # mteb/models/cache_wrappers/cache_wrapper.py
KennethEnevoldsen
left a comment
There was a problem hiding this comment.
great changes - only a few minor things
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class VectorCacheMap: |
There was a problem hiding this comment.
Should we rename this to NumpyCache?
|
|
||
|
|
||
| @runtime_checkable | ||
| class CacheBackendProtocol(Protocol): |
There was a problem hiding this comment.
Loving it - this makes it very easy to change + test
| self.cache_dict[task_name] = _VectorCacheMap( | ||
| self.cache_path / task_name | ||
| ) | ||
| self.cache_dict[task_name] = self.backend(self.cache_path / task_name) |
There was a problem hiding this comment.
So, a whole new cache PR task - I am fine with this, but it prevents re-use across
There was a problem hiding this comment.
Yes, agree. Can remove it
There was a problem hiding this comment.
does the check include prompt (if not we probably have to handle that)
There was a problem hiding this comment.
Yes, maybe this is the reason behind different indexes for different tasks. I think the simplest solution would be to keep cache per task to ensure that prompts will apply correctly, because they can change in model.encode
There was a problem hiding this comment.
yeah propably the best choice
Co-authored-by: Kenneth Enevoldsen <kennethcenevoldsen@gmail.com>
orionw
left a comment
There was a problem hiding this comment.
Looks great! Excited to have this in 🙌
| xet = ["huggingface_hub>=0.32.0"] | ||
| youtu = ["tencentcloud-sdk-python-common>=3.0.1454", "tencentcloud-sdk-python-lkeap>=3.0.1451"] | ||
| faiss-cpu = ["faiss-cpu>=1.12.0"] | ||
| faiss-gpu = ["faiss-gpu>=1.12.0"] |
There was a problem hiding this comment.
Did you test with cpu and gpu? It's been a minute since I used them, but IIRC the gpu one has some quirks.
There was a problem hiding this comment.
I faiss-gpu is deprecated on pypi, but exists only on conda. I'll leave only cpu version then
|
|
||
|
|
||
| @runtime_checkable | ||
| class CacheBackendProtocol(Protocol): |
|
@KennethEnevoldsen Is it good to merge? |
Co-authored-by: Kenneth Enevoldsen <kennethcenevoldsen@gmail.com>
# Conflicts: # pyproject.toml
Close #3192
Added
FAISSto cache backend. NowCacheEmbeddingsWrappercan support multiple backends that can be passed directly.Probably something similar can be done for
Retrievaltasks