trainer.causal_language_model_trainer.fwd_bwd_functions
create_casual_language_model_evaluation_step(partition_spec=PartitionSpec(('dp', 'fsdp'), 'sp'))
The create_casual_language_model_evaluation_step function is used to create a function that calculates the loss and accuracy of a model. It takes in a set of parameters, which are then passed into the state.apply_fn function to generate logits for each token in the batch. The cross entropy loss and accuracy are then calculated from these logits.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
partition_spec |
Specify the partitioning of the model parameters |
PartitionSpec(('dp', 'fsdp'), 'sp')
|
Returns:
Type | Description |
---|---|
A function that can be used to calculate the loss and accuracy of a model |
Source code in src/python/easydel/trainer/causal_language_model_trainer/fwd_bwd_functions.py
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 |
|
create_casual_language_model_train_step(partition_spec=PartitionSpec(('dp', 'fsdp'), 'sp'), label_smoothing_factor=0.0, z_loss=0.0, gradient_accumulation_steps=1)
The create_casual_language_model_train_step function is a training step function that takes in the current state of the model,and a batch of data. It then calculates the loss and accuracy for this batch, and returns an updated state with new parameters based on these gradients.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
partition_spec |
Specify which devices the model will be split across |
PartitionSpec(('dp', 'fsdp'), 'sp')
|
|
label_smoothing_factor |
A float in [0, 1] specifying the amount of label smoothing to apply, where 0 means no smoothing. |
0.0
|
|
z_loss |
A regularization term that adds a penalty for large weights, where 0 means no regularization. |
0.0
|
|
gradient_accumulation_steps |
int
|
int : gradient accumulation step size from arguments |
1
|
Returns:
Type | Description |
---|---|
A casual_language_model_train_step function that takes in the current state of the model, |
Source code in src/python/easydel/trainer/causal_language_model_trainer/fwd_bwd_functions.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|