-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Open
Description
Should soft_negatives defined as follow instead?
def deranged_shuffle(original):
while True:
shuffled = original.copy()
random.shuffle(shuffled)
if all(o != s for o, s in zip(original, shuffled)):
return shuffled
mnli = mnli.filter(lambda x: True if x["label"] == 0 else False)
# Prepare data and add a soft negative
train_dataset = {"anchor": [], "positive": [], "negative": []}
# soft_negatives = mnli["hypothesis"]
# random.shuffle(soft_negatives)
soft_negatives = deranged_shuffle(mnli["hypothesis"])
for row, soft_negative in tqdm(zip(mnli, soft_negatives)):
train_dataset["anchor"].append(row["premise"])
train_dataset["positive"].append(row["hypothesis"])
train_dataset["negative"].append(soft_negative)
train_dataset = Dataset.from_dict(train_dataset)
Metadata
Metadata
Assignees
Labels
No labels