MCPcopy Create free account
hub / github.com/SooLab/CGFormer / prepare_inputs_for_generation

Method prepare_inputs_for_generation

bert/modeling_bert.py:994–1001  ·  view source on GitHub ↗
(self, input_ids, attention_mask=None, **model_kwargs)

Source from the content-addressed store, hash-verified

992 return outputs # (ltr_lm_loss), prediction_scores, (hidden_states), (attentions)
993
994 def prepare_inputs_for_generation(self, input_ids, attention_mask=None, **model_kwargs):
995 input_shape = input_ids.shape
996
997 # if model is used as a decoder in encoder-decoder model, the decoder attention mask is created on the fly
998 if attention_mask is None:
999 attention_mask = input_ids.new_ones(input_shape)
1000
1001 return {"input_ids": input_ids, "attention_mask": attention_mask}
1002
1003
1004@add_start_docstrings("""Bert Model with a `language modeling` head on top. """, BERT_START_DOCSTRING)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected