boryana commited on
Commit
1568361
·
verified ·
1 Parent(s): 192a014

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +25 -4
README.md CHANGED
@@ -62,14 +62,35 @@ pip install transformers torch accelerate
62
 
63
  Then the model can be downloaded and used for inference:
64
  ```py
 
65
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
66
 
67
- model = AutoModelForSequenceClassification.from_pretrained("identrics/wasper_propaganda_classifier_bg", num_labels=5)
 
 
 
 
 
 
 
 
 
 
68
  tokenizer = AutoTokenizer.from_pretrained("identrics/wasper_propaganda_classifier_bg")
69
 
70
- tokens = tokenizer("Газа евтин, американското ядрено гориво евтино, пълно с фотоволтаици а пък тока с 30% нагоре. Защо ?", return_tensors="pt")
71
- output = model(**tokens)
72
- print(output.logits)
 
 
 
 
 
 
 
 
 
 
73
  ```
74
 
75
 
 
62
 
63
  Then the model can be downloaded and used for inference:
64
  ```py
65
+ import torch
66
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
67
 
68
+ labels = [
69
+ "Legitimisation Techniques",
70
+ "Rhetorical Devices",
71
+ "Logical Fallacies",
72
+ "Self-Identification Techniques",
73
+ "Defamation Techniques",
74
+ ]
75
+
76
+ model = AutoModelForSequenceClassification.from_pretrained(
77
+ "identrics/wasper_propaganda_classifier_bg", num_labels=5
78
+ )
79
  tokenizer = AutoTokenizer.from_pretrained("identrics/wasper_propaganda_classifier_bg")
80
 
81
+ text = "Газа евтин, американското ядрено гориво евтино, пълно с фотоволтаици а пък тока с 30% нагоре. Защо ?"
82
+
83
+ inputs = tokenizer(text, padding=True, truncation=True, return_tensors="pt")
84
+
85
+ with torch.no_grad():
86
+ outputs = model(**inputs)
87
+ logits = outputs.logits
88
+
89
+ probabilities = torch.sigmoid(logits).cpu().numpy().flatten()
90
+
91
+ # Format predictions
92
+ formatted_predictions = {labels[i]: probabilities[i] for i in range(len(labels))}
93
+ print(formatted_predictions)
94
  ```
95
 
96