From 44286b94d3376f56ee7ef039790d40798d5f9e7d Mon Sep 17 00:00:00 2001 From: Lysandre Date: Tue, 22 Oct 2019 13:46:48 -0400 Subject: [PATCH] RoBERTa doesn't print a warning when no special tokens are passed. --- transformers/modeling_roberta.py | 12 ------------ transformers/modeling_tf_roberta.py | 16 ---------------- 2 files changed, 28 deletions(-) diff --git a/transformers/modeling_roberta.py b/transformers/modeling_roberta.py index eb340dc7fb..e15663d017 100644 --- a/transformers/modeling_roberta.py +++ b/transformers/modeling_roberta.py @@ -169,18 +169,6 @@ class RobertaModel(BertModel): self.embeddings = RobertaEmbeddings(config) self.init_weights() - def forward(self, input_ids, attention_mask=None, token_type_ids=None, position_ids=None, head_mask=None): - if input_ids[:, 0].sum().item() != 0: - logger.warning("A sequence with no special tokens has been passed to the RoBERTa model. " - "This model requires special tokens in order to work. " - "Please specify add_special_tokens=True in your tokenize.encode()" - "or tokenizer.convert_tokens_to_ids().") - return super(RobertaModel, self).forward(input_ids, - attention_mask=attention_mask, - token_type_ids=token_type_ids, - position_ids=position_ids, - head_mask=head_mask) - @add_start_docstrings("""RoBERTa Model with a `language modeling` head on top. """, ROBERTA_START_DOCSTRING, ROBERTA_INPUTS_DOCSTRING) diff --git a/transformers/modeling_tf_roberta.py b/transformers/modeling_tf_roberta.py index 244c83f2b3..b734f056ab 100644 --- a/transformers/modeling_tf_roberta.py +++ b/transformers/modeling_tf_roberta.py @@ -65,22 +65,6 @@ class TFRobertaMainLayer(TFBertMainLayer): super(TFRobertaMainLayer, self).__init__(config, **kwargs) self.embeddings = TFRobertaEmbeddings(config, name='embeddings') - def call(self, inputs, **kwargs): - # Check that input_ids starts with control token - if isinstance(inputs, (tuple, list)): - input_ids = inputs[0] - elif isinstance(inputs, dict): - input_ids = inputs.get('input_ids') - else: - input_ids = inputs - - if tf.not_equal(tf.reduce_sum(input_ids[:, 0]), 0): - tf.print("A sequence with no special tokens has been passed to the RoBERTa model. " - "This model requires special tokens in order to work. " - "Please specify add_special_tokens=True in your encoding.") - - return super(TFRobertaMainLayer, self).call(inputs, **kwargs) - class TFRobertaPreTrainedModel(TFPreTrainedModel): """ An abstract class to handle weights initialization and