Thomas Müller commited on
Commit
abfb268
1 Parent(s): e4012f8

Adds usage example.

Browse files
Files changed (1) hide show
  1. README.md +17 -0
README.md CHANGED
@@ -3,3 +3,20 @@ This is a small cross attention entailment model trained for zero-shot and few-s
3
  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).
4
 
5
  The model has been trained using [SNLI](https://nlp.stanford.edu/projects/snli/) and [MNLI](https://cims.nyu.edu/~sbowman/multinli/).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  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).
4
 
5
  The model has been trained using [SNLI](https://nlp.stanford.edu/projects/snli/) and [MNLI](https://cims.nyu.edu/~sbowman/multinli/).
6
+
7
+ Usage:
8
+
9
+ ```python
10
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
11
+ import torch
12
+ import numpy as np
13
+
14
+ model = AutoModelForSequenceClassification.from_pretrained("symanto/mpnet-base-snli-mnli")
15
+ tokenizer = AutoTokenizer.from_pretrained("symanto/mpnet-base-snli-mnli")
16
+
17
+ inputs = tokenizer(["I like this pizza. [SEP] The sentence is positive.", "I like this pizza. [SEP] The sentence is negative."], return_tensors="pt")
18
+ logits = model(**inputs).logits
19
+ probs = torch.softmax(logits, dim=1).tolist()
20
+ print("probs", probs)
21
+ np.testing.assert_almost_equal(probs, [[0.66, 0.33, 0.01], [0.08, 0.22, 0.70]], decimal=2)
22
+ ```