Example #1
0
    def test_inference_no_head(self):
        model = TFDebertaV2Model.from_pretrained("kamalkraj/deberta-v2-xlarge")
        input_ids = tf.constant(
            [[0, 31414, 232, 328, 740, 1140, 12695, 69, 46078, 1588, 2]])
        attention_mask = tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]])
        output = model(input_ids, attention_mask=attention_mask)[0]

        expected_slice = tf.constant([[[0.2356, 0.1948, 0.0369],
                                       [-0.1063, 0.3586, -0.5152],
                                       [-0.6399, -0.0259, -0.2525]]])
        tf.debugging.assert_near(output[:, 1:4, 1:4],
                                 expected_slice,
                                 atol=1e-4)
Example #2
0
    def create_and_check_model(self, config, input_ids, token_type_ids,
                               input_mask, sequence_labels, token_labels,
                               choice_labels):
        model = TFDebertaV2Model(config=config)
        inputs = {
            "input_ids": input_ids,
            "attention_mask": input_mask,
            "token_type_ids": token_type_ids
        }

        inputs = [input_ids, input_mask]
        result = model(inputs)

        result = model(input_ids)

        self.parent.assertEqual(
            result.last_hidden_state.shape,
            (self.batch_size, self.seq_length, self.hidden_size))
Example #3
0
 def test_model_from_pretrained(self):
     model = TFDebertaV2Model.from_pretrained("kamalkraj/deberta-v2-xlarge")
     self.assertIsNotNone(model)