PavanDeepak commited on
Commit
36b5802
·
verified ·
1 Parent(s): a18f7a3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +17 -18
README.md CHANGED
@@ -34,28 +34,27 @@ The model leverages the BertForSequenceClassification architecture, It has been
34
  ## Example
35
 
36
  ```python
37
- >>> from transformers import AutoModelForSequenceClassification, AutoTokenizer
38
- >>> import numpy as np
39
- >>> from scipy.special import expit
40
 
41
- >>> MODEL = "PavanDeepak/Topic_Classification"
42
- >>> tokenizer = AutoTokenizer.from_pretrained(MODEL)
43
- >>> model = AutoModelForSequenceClassification.from_pretrained(MODEL)
44
- >>> class_mapping = model.config.id2label
45
 
46
- >>> text = "I love chicken manchuria"
47
- >>> tokens = tokenizer(text, return_tensors="pt")
48
- >>> output = model(**tokens)
49
 
50
- >>> scores = output.logits[0][0].detach().numpy()
51
- >>> scores = expit(scores)
52
- >>> predictions = (scores >= 0.5) * 1
53
-
54
- >>> for i in range(len(predictions)):
55
- >>> if predictions[i]:
56
- >>> print(class_mapping[i])
57
- ```python
58
 
 
 
 
 
59
 
60
  ## Output:
61
 
 
34
  ## Example
35
 
36
  ```python
37
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
38
+ import numpy as np
39
+ from scipy.special import expit
40
 
41
+ MODEL = "PavanDeepak/Topic_Classification"
42
+ tokenizer = AutoTokenizer.from_pretrained(MODEL)
43
+ model = AutoModelForSequenceClassification.from_pretrained(MODEL)
44
+ class_mapping = model.config.id2label
45
 
46
+ text = "I love chicken manchuria"
47
+ tokens = tokenizer(text, return_tensors="pt")
48
+ output = model(**tokens)
49
 
50
+ scores = output.logits[0][0].detach().numpy()
51
+ scores = expit(scores)
52
+ predictions = (scores >= 0.5) * 1
 
 
 
 
 
53
 
54
+ for i in range(len(predictions)):
55
+ if predictions[i]:
56
+ print(class_mapping[i])
57
+ ```
58
 
59
  ## Output:
60