(self, input_ids, attention_mask=None, **model_kwargs)
| 1096 | return outputs # (masked_lm_loss), prediction_scores, (hidden_states), (attentions) |
| 1097 | |
| 1098 | def prepare_inputs_for_generation(self, input_ids, attention_mask=None, **model_kwargs): |
| 1099 | input_shape = input_ids.shape |
| 1100 | effective_batch_size = input_shape[0] |
| 1101 | |
| 1102 | # add a dummy token |
| 1103 | assert self.config.pad_token_id is not None, "The PAD token should be defined for generation" |
| 1104 | attention_mask = torch.cat([attention_mask, attention_mask.new_zeros((attention_mask.shape[0], 1))], dim=-1) |
| 1105 | dummy_token = torch.full( |
| 1106 | (effective_batch_size, 1), self.config.pad_token_id, dtype=torch.long, device=input_ids.device |
| 1107 | ) |
| 1108 | input_ids = torch.cat([input_ids, dummy_token], dim=1) |
| 1109 | |
| 1110 | return {"input_ids": input_ids, "attention_mask": attention_mask} |
| 1111 | |
| 1112 | |
| 1113 | @add_start_docstrings( |
nothing calls this directly
no outgoing calls
no test coverage detected