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

NoDuplicatesDataLoader Compatability with Asymmetric models #3220

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sentence_transformers/datasets/NoDuplicatesDataLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ def __iter__(self):

valid_example = True
for text in example.texts:
if not isinstance(text, str):
text = str(text)
if text.strip().lower() in texts_in_batch:
valid_example = False
break

if valid_example:
batch.append(example)
for text in example.texts:
if not isinstance(text, str):
text = str(text)
texts_in_batch.add(text.strip().lower())

self.data_pointer += 1
Expand Down
2 changes: 1 addition & 1 deletion sentence_transformers/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def __iter__(self) -> Iterator[list[int]]:
batch_indices = []
for index in remaining_indices:
sample_values = {
value
str(value)
for key, value in self.dataset[index].items()
if not key.endswith("_prompt_length") and key != "dataset_name"
}
Expand Down