(self, input: torch.Tensor, labels: torch.Tensor)
| 48 | ) |
| 49 | |
| 50 | def forward(self, input: torch.Tensor, labels: torch.Tensor) -> torch.Tensor: |
| 51 | # Output is of the shape (seq_len, vocab_size). |
| 52 | logits = self.model(input) |
| 53 | labels = torch.hstack( |
| 54 | (labels[..., 1:], self.ignore_labels_cache[: labels.shape[0]]) |
| 55 | ) |
| 56 | if not isinstance(logits, list): |
| 57 | labels = labels.reshape(-1) |
| 58 | logits = logits.reshape(-1, logits.size(-1)) |
| 59 | return self.loss(logits, labels) |
| 60 | |
| 61 | |
| 62 | def python_code_instructions_alpaca(tokenizer: ModelTokenizer) -> PackedDataset: |
no outgoing calls
no test coverage detected