Collate
bert_padding_collate_fn(batch, padding_value, min_length=None, max_length=None)
Padding collate function for BERT dataloaders.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch
|
list
|
List of samples. |
required |
padding_value
|
int
|
The tokenizer's pad token ID. |
required |
min_length
|
int | None
|
Minimum length of the output batch; tensors will be padded to this length. If not provided, no extra padding beyond the max_length will be added. |
None
|
max_length
|
int | None
|
Maximum length of the sequence. If not provided, tensors will be padded to the longest sequence in the batch. |
None
|
Source code in bionemo/llm/data/collate.py
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 |
|
padding_collate_fn(batch, padding_values, min_length=None, max_length=None)
Collate function with padding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch
|
Sequence[_T]
|
List of samples, each of which is a dictionary of tensors. |
required |
padding_values
|
dict[str, int]
|
A dictionary of padding values for each tensor key. |
required |
min_length
|
int | None
|
Minimum length of the output batch; tensors will be padded to this length. If not provided, no extra padding beyond the max_length will be added. |
None
|
max_length
|
int | None
|
Maximum length of the sequence. If not provided, tensors will be padded to the longest sequence in the batch. |
None
|
Returns:
Type | Description |
---|---|
_T
|
A collated batch with the same dictionary input structure. |
Source code in bionemo/llm/data/collate.py
31 32 33 34 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 |
|