YagiASAFAS
commited on
Commit
•
b32b464
1
Parent(s):
f787eb8
Update README.md
Browse files
README.md
CHANGED
@@ -13,7 +13,31 @@ The model was evaluated on a held-out test set, and its performance was measured
|
|
13 |
As with any machine learning model, it is important to recognize potential limitations and biases. The translation step could introduce errors or nuances that affect the labeling accuracy. Additionally, the ManiBERT model used for initial labeling was trained on political texts, which may limit its effectiveness on non-political news or introduce political bias.
|
14 |
|
15 |
## How to Use the Model
|
16 |
-
To classify an Indonesian news article, you can use the
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
# Label Mapping
|
19 |
| Label ID | Label Text |
|
|
|
13 |
As with any machine learning model, it is important to recognize potential limitations and biases. The translation step could introduce errors or nuances that affect the labeling accuracy. Additionally, the ManiBERT model used for initial labeling was trained on political texts, which may limit its effectiveness on non-political news or introduce political bias.
|
14 |
|
15 |
## How to Use the Model
|
16 |
+
To classify an Indonesian news article, you can use the script below:
|
17 |
+
|
18 |
+
```python
|
19 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
20 |
+
|
21 |
+
model_name = "YagiASAFAS/indonesia-news-classification-bert"
|
22 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
23 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
24 |
+
|
25 |
+
# Write Indonesian Text
|
26 |
+
inputs = tokenizer("[Indonesian Text]", return_tensors="pt")
|
27 |
+
|
28 |
+
outputs = model(**inputs)
|
29 |
+
predictions = torch.nn.functional.softmax(outputs.logits, dim=1)
|
30 |
+
|
31 |
+
id2label = model.config.id2label
|
32 |
+
|
33 |
+
predicted_class_index = torch.argmax(predictions, dim=1).item()
|
34 |
+
|
35 |
+
predicted_class_index
|
36 |
+
|
37 |
+
predicted_category = id2label.get(predicted_class_index)
|
38 |
+
|
39 |
+
print("Predicted Category:", predicted_category)
|
40 |
+
```
|
41 |
|
42 |
# Label Mapping
|
43 |
| Label ID | Label Text |
|