You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a somewhat silly use case. I'm running retriever.retrieve, with a queries dict with only 1 entry. However, this causes an IndexError with pytorch due to how pytorch indexes 2D arrays where the first dim is of size 1:
File "<dir>/script.py", line 83, in <module>
results = retriever.retrieve(para_d, one_query_d)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<env>/beir/retrieval/evaluation.py", line 20, in retrieve
return self.retriever.search(corpus, queries, self.top_k, self.score_function, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<env>/beir/retrieval/search/dense/exact_search.py", line 73, in search
scores_dim = cos_scores[1]
~~~~~~~~~~^^^
IndexError: index 1 is out of bounds for dimension 0 with size 1
I was able to fix this by changing the below line:
I have a somewhat silly use case. I'm running
retriever.retrieve
, with aqueries
dict with only 1 entry. However, this causes an IndexError with pytorch due to how pytorch indexes 2D arrays where the first dim is of size 1:I was able to fix this by changing the below line:
beir/beir/retrieval/search/dense/exact_search.py
Line 73 in f062f03
And swapping out
cos_scores[1]
withscores_dim
:This monkey patch works for me, but I'm just curious if there's a more appropriate way to retrieve given only 1 query. Thanks!
The text was updated successfully, but these errors were encountered: