rxnn 0.1.71__py3-none-any.whl → 0.1.73__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rxnn/training/dataset.py
CHANGED
@@ -32,11 +32,13 @@ class BaseDataset(Dataset):
|
|
32
32
|
def __len__(self):
|
33
33
|
return len(self.texts if not self.is_pre_tokenized else self.inputs)
|
34
34
|
|
35
|
-
def get_tokenized_text(self, idx: int):
|
35
|
+
def get_tokenized_text(self, idx: int, txt: str = None):
|
36
36
|
if self.is_pre_tokenized:
|
37
37
|
return self.inputs[idx]
|
38
38
|
else:
|
39
|
-
if
|
39
|
+
if txt:
|
40
|
+
text = txt
|
41
|
+
elif isinstance(self.texts, list):
|
40
42
|
text = self.texts[idx]
|
41
43
|
else:
|
42
44
|
text = self.texts[idx][self.hf_field]
|
@@ -75,16 +77,31 @@ class BaseDataset(Dataset):
|
|
75
77
|
return self.__class__(subset, self.tokenizer, max_seq_len=self.max_seq_len, hf_field=self.hf_field, **kwargs)
|
76
78
|
|
77
79
|
def pre_tokenize(self, verbose: bool = False, log_interval: int = 10_000):
|
80
|
+
"""
|
81
|
+
Pre-tokenizes all the items in the dataset, for faster training. Training with pre-tokenized
|
82
|
+
dataset could be even 2x faster.
|
83
|
+
|
84
|
+
!! This method has extremely high memory usage, when used with HuggingFace datasets,
|
85
|
+
because of converting it to list. Additionally, for the most optimal performance,
|
86
|
+
pre-tokenized items are in reversed order - it shouldn't matter for training, as
|
87
|
+
items are shuffled then by DataLoader, but you should keep that in mind in case
|
88
|
+
of reproducibility.
|
89
|
+
|
90
|
+
:param(bool) verbose:
|
91
|
+
:param(int) log_interval: Interval of verbose logs
|
92
|
+
"""
|
78
93
|
if not self.is_pre_tokenized:
|
79
94
|
num_texts = len(self.texts)
|
80
95
|
txts = self.texts if isinstance(self.texts, list) else self.texts.to_list()
|
81
96
|
del self.texts
|
97
|
+
self.texts = None
|
82
98
|
for index in range(num_texts):
|
83
|
-
|
99
|
+
item = txts.pop() if isinstance(txts, list) else txts.pop()[self.hf_field]
|
100
|
+
self.inputs.append(self.get_tokenized_text(index, txt=item))
|
84
101
|
if verbose and index % log_interval == 0:
|
85
102
|
print(f'Processed {index + 1}/{num_texts}')
|
86
103
|
self.is_pre_tokenized = True
|
87
|
-
|
104
|
+
|
88
105
|
|
89
106
|
@classmethod
|
90
107
|
def from_hf_hub(
|
@@ -12,7 +12,7 @@ rxnn/training/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
rxnn/training/base.py,sha256=xPMA2Bg9-oUZvSZg67ls2p7Gk9pZ9IHUiIJwUzSe2K8,11766
|
13
13
|
rxnn/training/bml.py,sha256=S1ZaXTybzeJH7uVFamCr4TPl2bLyZ5xmn_lSsjThTiM,19162
|
14
14
|
rxnn/training/callbacks.py,sha256=_YfMKY_eFdc-tubhO9nYH2PXDZDQwlSI74FVOoCXpQg,22108
|
15
|
-
rxnn/training/dataset.py,sha256=
|
15
|
+
rxnn/training/dataset.py,sha256=Vak29XMVGOnu7okim_6Lo0E9Jz95U-scOPi-5d8alHg,12477
|
16
16
|
rxnn/training/scheduler.py,sha256=ow6oALzWjWQmHSpcJEjv6tg4g4CDMvr73TypxfcefMc,712
|
17
17
|
rxnn/training/tokenizer.py,sha256=umaLByMBx_NMrQElA45HLm9gkuzyKWDTFaKVd-CjXl0,8344
|
18
18
|
rxnn/transformers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -25,7 +25,7 @@ rxnn/transformers/moe.py,sha256=j6jEx6Ip0zttlUZKKn82azxo95lkLZs-H2GLSMD88hY,5859
|
|
25
25
|
rxnn/transformers/positional.py,sha256=2l38RS0Dini3f6Z3LUHr3XwWzg1UK7fO2C6wazWDAYU,4292
|
26
26
|
rxnn/transformers/sampler.py,sha256=poWBpxg1iuK5gEJtxHkk5VVfS9V48hs2Olqdhy_Gw8c,6548
|
27
27
|
rxnn/utils.py,sha256=d5U8i5ukovgDyqiycc2AoxObTz_eF_bgo2MKvdtJ98s,467
|
28
|
-
rxnn-0.1.
|
29
|
-
rxnn-0.1.
|
30
|
-
rxnn-0.1.
|
31
|
-
rxnn-0.1.
|
28
|
+
rxnn-0.1.73.dist-info/LICENSE,sha256=C8coDFIUYuOcke4JLPwTqahQUCyXyGq6WOaigOkx8tY,11275
|
29
|
+
rxnn-0.1.73.dist-info/METADATA,sha256=lo-8t4WHBKlvoBFoEzqebdCdZUWhheLsPu-v-pW8CIU,16579
|
30
|
+
rxnn-0.1.73.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
31
|
+
rxnn-0.1.73.dist-info/RECORD,,
|
File without changes
|
File without changes
|