SentencesDataset.py 719 B

12345678910111213141516171819202122
  1. from __future__ import annotations
  2. from torch.utils.data import Dataset
  3. from sentence_transformers import SentenceTransformer
  4. from sentence_transformers.readers.InputExample import InputExample
  5. class SentencesDataset(Dataset):
  6. """
  7. DEPRECATED: This class is no longer used. Instead of wrapping your List of InputExamples in a SentencesDataset
  8. and then passing it to the DataLoader, you can pass the list of InputExamples directly to the dataset loader.
  9. """
  10. def __init__(self, examples: list[InputExample], model: SentenceTransformer):
  11. self.examples = examples
  12. def __getitem__(self, item):
  13. return self.examples[item]
  14. def __len__(self):
  15. return len(self.examples)