Update README.md
Browse files
README.md
CHANGED
|
@@ -8,6 +8,17 @@ licenses:
|
|
| 8 |
## Using this model as a discriminator in `transformers` (tested on 4.11.0.dev0)
|
| 9 |
|
| 10 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
```
|
| 13 |
|
|
|
|
| 8 |
## Using this model as a discriminator in `transformers` (tested on 4.11.0.dev0)
|
| 9 |
|
| 10 |
```python
|
| 11 |
+
# Load model directly
|
| 12 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 13 |
+
|
| 14 |
+
tokenizer = AutoTokenizer.from_pretrained("shawon95/BengaliFakeReviewDetection")
|
| 15 |
+
model = AutoModelForSequenceClassification.from_pretrained("shawon95/BengaliFakeReviewDetection")
|
| 16 |
+
review = "টাকা ইয়ে এই বিরিয়ানি কে খায় ভাই আর এটাকে বিরিয়ানি বলে? কার কাছে কেমন লাগে এই বোবার বিরিয়ানি?"
|
| 17 |
+
|
| 18 |
+
review_tokens = tokenizer.tokenize(review)
|
| 19 |
+
review_inputs = tokenizer.encode(review, return_tensors="pt")
|
| 20 |
+
discriminator_outputs = model(review_inputs).logits
|
| 21 |
+
predictions = torch.round((torch.sign(discriminator_outputs) + 1) / 2)
|
| 22 |
|
| 23 |
```
|
| 24 |
|