Datamodule
ESMDataModule
Bases: MegatronDataModule
LightningDataModule wrapper of ESMDataset
.
Source code in bionemo/esm2/data/datamodule.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
tokenizer: tokenizer.BioNeMoESMTokenizer
property
Returns the tokenizer.
__init__(train_cluster_path, train_database_path, valid_cluster_path, valid_database_path, seed=42, min_seq_length=None, max_seq_length=1024, micro_batch_size=4, global_batch_size=8, num_workers=10, persistent_workers=True, pin_memory=True, rampup_batch_size=None, mask_prob=0.15, mask_token_prob=0.8, mask_random_prob=0.1, random_mask_strategy=dataset.RandomMaskStrategy.ALL_TOKENS, tokenizer=tokenizer.get_tokenizer(), dataloader_type='single')
Initialize the ESMDataModule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
train_cluster_path
|
str | PathLike
|
A path to the parquet files containing UniRef90 training clusters. |
required |
train_database_path
|
str | PathLike
|
A path to the sqlite file mapping UniRef90 cluster IDs to sequences. |
required |
valid_cluster_path
|
str | PathLike
|
A path to the parquet files containing UniRef50 validation clusters. |
required |
valid_database_path
|
str | PathLike
|
A path to the sqlite file mapping UniRef50 cluster IDs to sequences. |
required |
seed
|
int | None
|
Input random seed. If None, initializes randomly. Defaults to 42. |
42
|
min_seq_length
|
int | None
|
Whether to pad sequences to a minimum length. If None, no extra padding is added. Defaults to None. |
None
|
max_seq_length
|
int
|
The maximum context length for the ESM transformer. Defaults to 1024. |
1024
|
micro_batch_size
|
int
|
Passed to MegatronDataSampler. Defaults to 4. |
4
|
global_batch_size
|
int
|
Passed to MegatronDataSampler.. Defaults to 8. |
8
|
num_workers
|
int
|
The number of workers for the pytorch Dataloaders. Defaults to 10. |
10
|
persistent_workers
|
bool
|
Whether to keep the workers alive between epochs. Defaults to True. |
True
|
pin_memory
|
bool
|
Whether to pin GPU memory in the pytorch Dataloaders. Defaults to True. |
True
|
rampup_batch_size
|
list[int] | None
|
Passed to MegatronDataSampler. Defaults to None. |
None
|
mask_prob
|
float
|
The overall chance of masking a token and having it appear in the loss fn. Defaults to 0.15. |
0.15
|
mask_token_prob
|
float
|
Percentage of masked tokens that get assigned the |
0.8
|
mask_random_prob
|
float
|
Percentage of masked tokens assigned to a random amino acid. Defaults to 0.1. |
0.1
|
random_mask_strategy
|
RandomMaskStrategy
|
Whether to replace random masked tokens with all tokens or amino acids only. Defaults to RandomMaskStrategy.ALL_TOKENS. |
ALL_TOKENS
|
tokenizer
|
BioNeMoESMTokenizer
|
The ESM2 tokenizer. Defaults to the one returned by |
get_tokenizer()
|
dataloader_type
|
Literal['single', 'cyclic']
|
The type of dataloader to use. Defaults to "single". |
'single'
|
Source code in bionemo/esm2/data/datamodule.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
setup(stage='')
Setup the ESMDataModule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stage
|
str
|
Unused. |
''
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If the trainer is not attached, or if the trainer's max_steps is not set. |
Source code in bionemo/esm2/data/datamodule.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
test_dataloader()
Raises a not implemented error.
Source code in bionemo/esm2/data/datamodule.py
216 217 218 |
|
train_dataloader()
Returns the dataloader for training data.
Source code in bionemo/esm2/data/datamodule.py
208 209 210 |
|
val_dataloader()
Returns the dataloader for validation data.
Source code in bionemo/esm2/data/datamodule.py
212 213 214 |
|