"applications/Chat/coati/vscode:/vscode.git/clone" did not exist on "da4f7b855f0074b374bbd26837c036f2cdfa9564"
SentencesDataset.py 708 Bytes
Newer Older
Rayyyyy's avatar
Rayyyyy committed
1
from typing import List
Rayyyyy's avatar
Rayyyyy committed
2
3
4
5
6

from torch.utils.data import Dataset

from sentence_transformers import SentenceTransformer
from sentence_transformers.readers.InputExample import InputExample
Rayyyyy's avatar
Rayyyyy committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22


class SentencesDataset(Dataset):
    """
    DEPRECATED: This class is no longer used. Instead of wrapping your List of InputExamples in a SentencesDataset
    and then passing it to the DataLoader, you can pass the list of InputExamples directly to the dataset loader.
    """

    def __init__(self, examples: List[InputExample], model: SentenceTransformer):
        self.examples = examples

    def __getitem__(self, item):
        return self.examples[item]

    def __len__(self):
        return len(self.examples)