Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only save top-k #209

Merged
merged 8 commits into from
Feb 2, 2024
Merged

only save top-k #209

merged 8 commits into from
Feb 2, 2024

Conversation

hongjin-su
Copy link
Contributor

No description provided.

Comment on lines 89 to 97
top_k = kwargs.get('top_k', 10)
all_qids = []
for k in results:
all_qids.append(k)
for qid in all_qids:
doc_ids = sorted(results[qid].items(), key=lambda x: x[1], reverse=True)
remove_doc_ids = [d[0] for d in doc_ids[top_k:]]
for a_doc_id in remove_doc_ids:
results[qid].pop(a_doc_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels like this could be simpler with fewer lines of code 🤔

@Muennighoff Muennighoff merged commit f58888d into embeddings-benchmark:main Feb 2, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants