Views
No views yet
FacebookAI/xlm-roberta-base on the Balochi CoNLL-U dataset.| Metric | Score |
|---|---|
| Accuracy | 0.7207 |
| Precision | 0.6215 |
| Recall | 0.5488 |
| F1 Macro | 0.5588 |
| F1 Weighted | 0.6853 |
1from transformers import AutoTokenizer, AutoModelForTokenClassification
2import torch
3
4tokenizer = AutoTokenizer.from_pretrained("shahbakhsh/balochi-pos-tagger-v1")
5model = AutoModelForTokenClassification.from_pretrained("shahbakhsh/balochi-pos-tagger-v1")
6
7sentence = 'ایش انت ملّاہانی حکومت ءِ سوگات'
8words = sentence.split()
9inputs = tokenizer(words, is_split_into_words=True, return_tensors='pt')
10
11with torch.no_grad():
12 outputs = model(**inputs)
13
14predictions = outputs.logits.argmax(-1)[0]
15word_ids = inputs.word_ids()
16
17for idx, word_id in enumerate(word_ids):
18 if word_id is not None:
19 print(words[word_id], model.config.id2label[predictions[idx].item()])