예제 #1
0
    def create_and_check_dpr_reader(
        self, config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
    ):
        model = TFDPRReader(config=config)
        result = model(input_ids, attention_mask=input_mask)

        self.parent.assertEqual(result.start_logits.shape, (self.batch_size, self.seq_length))
        self.parent.assertEqual(result.end_logits.shape, (self.batch_size, self.seq_length))
        self.parent.assertEqual(result.relevance_logits.shape, (self.batch_size,))
예제 #2
0
    def test_model_from_pretrained(self):
        for model_name in TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
            model = TFDPRContextEncoder.from_pretrained(model_name)
            self.assertIsNotNone(model)

        for model_name in TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
            model = TFDPRContextEncoder.from_pretrained(model_name)
            self.assertIsNotNone(model)

        for model_name in TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
            model = TFDPRQuestionEncoder.from_pretrained(model_name)
            self.assertIsNotNone(model)

        for model_name in TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
            model = TFDPRReader.from_pretrained(model_name)
            self.assertIsNotNone(model)