Skip to content

Commit

Permalink
Fixed invalid MMR argsort
Browse files Browse the repository at this point in the history
  • Loading branch information
whitead committed Mar 8, 2024
1 parent 0d63f6f commit 01304f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions paperqa/llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,9 @@ async def similarity_search(
)[0]
similarity_scores = np.nan_to_num(similarity_scores, nan=-np.inf)
# minus so descending
if k == len(self.texts):
sorted_indices = np.argsort(-similarity_scores)
else:
sorted_indices = np.argpartition(-similarity_scores, k)
# we could use arg-partition here
# but a lot of algorithms expect a sorted list
sorted_indices = np.argsort(-similarity_scores)
return (
[self.texts[i] for i in sorted_indices[:k]],
[similarity_scores[i] for i in sorted_indices[:k]],
Expand Down
2 changes: 1 addition & 1 deletion paperqa/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.1.0"
__version__ = "4.1.1"

0 comments on commit 01304f1

Please sign in to comment.