Exemple #1
0
    def test_esnli_drop_explanations(self):
        input_data = {
            'premise': 'It is hot.',
            'hypothesis': 'It is sunny.',
            'label': 0,
            'explanation_1': 'hot implies that it is sunny.',
        }

        og_dataset = tf.data.Dataset.from_tensors(input_data)
        dataset = preprocessors.esnli(og_dataset,
                                      prefix='nli',
                                      drop_explanations=True)

        test_utils.assert_dataset(
            dataset, {
                'inputs': 'nli hypothesis: It is sunny. premise: It is hot.',
                'targets': 'entailment'
            })
    def test_esnli(self):
        input_data = {
            'premise': 'It is hot.',
            'hypothesis': 'It is sunny.',
            'label': 0,
            'explanation_1': 'hot implies that it is sunny.'
        }

        og_dataset = tf.data.Dataset.from_tensors(input_data)
        dataset = preprocessors.esnli(og_dataset)

        t5.data.assert_dataset(
            dataset, {
                'inputs':
                'explain nli hypothesis: It is sunny. premise: It is hot.',
                'targets':
                'entailment explanation: hot implies that it is sunny.'
            })
Exemple #3
0
    def test_esnli_multiple_explanations(self):
        input_data = {
            'premise': 'It is hot.',
            'hypothesis': 'It is sunny.',
            'label': 0,
            'explanation_1': 'hot implies that it is sunny.',
            'explanation_2': 'sunny equals hot.',
            'explanation_3': 'hot means sunny.',
        }

        og_dataset = tf.data.Dataset.from_tensors(input_data)
        dataset = preprocessors.esnli(og_dataset)

        test_utils.assert_dataset(
            dataset, {
                'inputs':
                'explain nli hypothesis: It is sunny. premise: It is hot.',
                'targets':
                'entailment explanation: hot implies that it is sunny. '
                'explanation: sunny equals hot. '
                'explanation: hot means sunny.'
            })