ragarwal commited on
Commit
55d6665
1 Parent(s): 1e300e7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -3
README.md CHANGED
@@ -5,9 +5,35 @@ license: mit
5
 
6
  ### Usage
7
 
8
- First, install [Sentence-Transformers](https://www.sbert.net/)
9
 
10
- Then,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  ```python
13
  from sentence_transformers import CrossEncoder
@@ -15,7 +41,6 @@ from sentence_transformers import CrossEncoder
15
  model_name="ragarwal/deberta-v3-base-nli-mixer"
16
  model = CrossEncoder(model_name, max_length=256)
17
 
18
-
19
  sentence = "During its monthly call, the National Oceanic and Atmospheric Administration warned of \
20
  increased temperatures and low precipitation"
21
  labels = ["Computer", "Climate Change", "Tablet", "Football", "Artificial Intelligence", "Global Warming"]
 
5
 
6
  ### Usage
7
 
8
+ In Transformers
9
 
10
+ ```python
11
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
12
+ import torch
13
+ from scipy.special import softmax, expit
14
+
15
+ device = "cuda" if torch.cuda.is_available() else "cpu"
16
+
17
+ model_name="ragarwal/deberta-v3-base-nli-mixer"
18
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
19
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
20
+
21
+ sentence = "During its monthly call, the National Oceanic and Atmospheric Administration warned of \
22
+ increased temperatures and low precipitation"
23
+ labels = ["Computer", "Climate Change", "Tablet", "Football", "Artificial Intelligence", "Global Warming"]
24
+
25
+ features = tokenizer([[sentence, l] for l in labels], padding=True, truncation=True, return_tensors="pt")
26
+
27
+ model.eval()
28
+ with torch.no_grad():
29
+ scores = model(**features).logits
30
+ print(expit(scores)) #Multi-Label Classification
31
+ print(softmax(scores)) #Single-Label Classification
32
+
33
+ ```
34
+
35
+
36
+ In [Sentence-Transformers](https://www.sbert.net/)
37
 
38
  ```python
39
  from sentence_transformers import CrossEncoder
 
41
  model_name="ragarwal/deberta-v3-base-nli-mixer"
42
  model = CrossEncoder(model_name, max_length=256)
43
 
 
44
  sentence = "During its monthly call, the National Oceanic and Atmospheric Administration warned of \
45
  increased temperatures and low precipitation"
46
  labels = ["Computer", "Climate Change", "Tablet", "Football", "Artificial Intelligence", "Global Warming"]