(self, batch)
| 111 | return data, attn_mask, label |
| 112 | |
| 113 | def collate_fn(self, batch): |
| 114 | batch_input_ids, batch_attn_mask, batch_labels = [], [], [] |
| 115 | for input_ids, attn_mask, label in batch: |
| 116 | batch_input_ids.append(input_ids) |
| 117 | batch_attn_mask.append(attn_mask) |
| 118 | batch_labels.append(label) |
| 119 | |
| 120 | batch_input_ids = torch.nn.utils.rnn.pad_sequence(batch_input_ids, batch_first=True, padding_value=self.tokenizer.eos_token_id) |
| 121 | batch_attn_mask = torch.nn.utils.rnn.pad_sequence(batch_attn_mask, batch_first=True, padding_value=0).to(torch.bool) |
| 122 | batch_labels = torch.nn.utils.rnn.pad_sequence(batch_labels, batch_first=True, padding_value=-100) |
| 123 | |
| 124 | return batch_input_ids, batch_attn_mask, batch_labels |
| 125 | |
| 126 | |
| 127 | class SFTMetric: |
nothing calls this directly
no outgoing calls
no test coverage detected