# DeBERTa use for NLI tasks - Missing contradiction score

**URL:** <https://discuss.huggingface.co/t/deberta-use-for-nli-tasks-missing-contradiction-score/3379>\
**Category:** Models\
**Created:** [January 25, 2021, 8:42pm UTC](https://discuss.huggingface.co/t/deberta-use-for-nli-tasks-missing-contradiction-score/3379 "2021-01-25T20:42:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![metah](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/metah/32/954_2.png) [@metah](https://discuss.huggingface.co/u/metah)\
**Post date:** [January 25, 2021, 8:42pm UTC](https://discuss.huggingface.co/t/deberta-use-for-nli-tasks-missing-contradiction-score/3379/1 "2021-01-25T20:42:55Z")

</div>

Hi all,  
I was wondering if someone got to make [DeBERTa](https://huggingface.co/transformers/model_doc/deberta.html) work on NLI task using the pre-trained model available in Hugging Face?

When running this code, the contradiction is always empty (although entailment and neutral score are populated).

```
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

if __name__ == ' __main__':
    max_length = 256

    premise = "Two women are embracing while holding to go packages."
    hypothesis = "The men are fighting outside a deli."

    hg_model_hub_name = "microsoft/deberta-large"
    # hg_model_hub_name = "microsoft/deberta-base"

    tokenizer = AutoTokenizer.from_pretrained(hg_model_hub_name)
    model = AutoModelForSequenceClassification.from_pretrained(hg_model_hub_name)
    tokenized_input_seq_pair = tokenizer.encode_plus(premise, hypothesis,
                                                     max_length=max_length,
                                                     return_token_type_ids=True, truncation=True)

    input_ids = torch.Tensor(tokenized_input_seq_pair['input_ids']).long().unsqueeze(0)
    # remember bart doesn't have 'token_type_ids', remove the line below if you are using bart.
    token_type_ids = torch.Tensor(tokenized_input_seq_pair['token_type_ids']).long().unsqueeze(0)
    attention_mask = torch.Tensor(tokenized_input_seq_pair['attention_mask']).long().unsqueeze(0)

    outputs = model(input_ids,
                    attention_mask=attention_mask,
                    token_type_ids=token_type_ids,
                    labels=None)
    # Note:
    # "id2label": {
    # "0": "entailment",
    # "1": "neutral",
    # "2": "contradiction"
    # },

    predicted_probability = torch.softmax(outputs[0], dim=1)[0].tolist() # batch_size only one

    print("Premise:", premise)
    print("Hypothesis:", hypothesis)
    print("Entailment:", predicted_probability[0])
    print("Neutral:", predicted_probability[1])
    print("Contradiction:", predicted_probability[2])
```

---

<div class="post-metadata">

**Author:** ![DeBERTa](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@DeBERTa](https://discuss.huggingface.co/u/DeBERTa)\
**Post date:** [January 25, 2021, 9:31pm UTC](https://discuss.huggingface.co/t/deberta-use-for-nli-tasks-missing-contradiction-score/3379/2 "2021-01-25T21:31:39Z")

</div>

The model is not tuned on MNLI task. To inference with MNLI, you need to fine-tuning with MNLI task.
