Skip to content

Commit

Permalink
Feature/safe random negatives (#161)
Browse files Browse the repository at this point in the history
* bugfix

* updated RAGTrainer data handling

* remove unnec changes

* add back 02 example notebook

* only select as many negatives as you can

* remove old changes

* remove unnecessary changes

---------

Co-authored-by: Benjamin Clavié <ben@clavie.eu>
  • Loading branch information
JoshuaPurtell and bclavie authored Feb 27, 2024
1 parent 845a54f commit 671241c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ragatouille/data/training_data_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _get_new_negatives(self, query, passages, mine_hard_negatives, n_new_negativ
else:
new_negatives = [
x
for x in random.sample(self.collection, n_new_negatives)
for x in random.sample(self.collection, min(n_new_negatives, len(self.collection)))
if x not in passages["positives"] and x not in passages["negatives"]
]

Expand Down

0 comments on commit 671241c

Please sign in to comment.