File size: 1,185 Bytes
f7ccce6
 
 
 
 
 
 
 
 
bdc5368
 
 
 
 
abfb268
 
 
 
 
 
 
 
 
 
 
0f0c375
 
abfb268
 
 
0f0c375
abfb268
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
language: 
  - en
datasets:
- SNLI
- MNLI
---


This is a small cross attention entailment model trained for zero-shot and few-shot text classification experiments.

The base model is [mpnet-base](https://huggingface.co/microsoft/mpnet-base) and it has been trained with the code from [here](https://github.com/facebookresearch/anli).

The model has been trained using [SNLI](https://nlp.stanford.edu/projects/snli/) and [MNLI](https://cims.nyu.edu/~sbowman/multinli/).

Usage:

```python
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
import numpy as np

model = AutoModelForSequenceClassification.from_pretrained("symanto/mpnet-base-snli-mnli")
tokenizer = AutoTokenizer.from_pretrained("symanto/mpnet-base-snli-mnli")

input_pairs = [("I like this pizza.", "The sentence is positive."), ("I like this pizza.", "The sentence is negative.")]
inputs = tokenizer(["</s></s>".join(input_pair) for input_pair in input_pairs], return_tensors="pt")
logits = model(**inputs).logits
probs =  torch.softmax(logits, dim=1).tolist()
print("probs", probs)
np.testing.assert_almost_equal(probs, [[0.86, 0.14, 0.00], [0.16, 0.15, 0.69]], decimal=2)
```