Downloads · 30 days
4
2% of all-time downloads
alsubari/bert-base-multilingual-cased-dytr
bert-base-multilingual-cased-dytr is a token classification model from alsubari. Use it when you need labels on individual words, such as names. It is set up for dytr. The card lists the license as apache-2.0.
This model performs Part-of-Speech (POS) tagging for Arabic text using a character-level BIO tagging scheme. It is specifically trained on the Holy Quran and built with the dytr (Dynamic Transformer) library, enabling…
Downloads · 30 days
4
2% of all-time downloads
All-time downloads
199
Public
Parameters
177M
14 GB on disk
Likes
0
Public
Click a slice to open those files.
.pt10.9 GB · 94%
From the Hugging Face model README
This model performs Part-of-Speech (POS) tagging for Arabic text using a character-level BIO tagging scheme. It is specifically trained on the Holy Quran and built with the dytr (Dynamic Transformer) library, enabling continual learning and multi-task capabilities.
google-bert/bert-base-multilingual-cased| Metric | Score |
|---|---|
| Token Accuracy | 95.68% |
| F1 Macro | 89.59% |
| F1 Weighted | 95.41% |
| Validation Loss | 0.8816 |
pip install torch pyarabic huggingface_hub dytr -q
import torch
import json
import pyarabic.araby as araby
from huggingface_hub import hf_hub_download
from dytr import DynamicTransformer
# Download and load model
model_path = hf_hub_download(
repo_id="alsubari/bert-base-multilingual-cased-dytr",
filename="dytr.pt"
)
config_path = hf_hub_download(
repo_id="alsubari/bert-base-multilingual-cased-dytr",
filename="config.json"
)
model = DynamicTransformer.load_model(model_path)
model.eval()
with open(config_path) as f:
config = json.load(f)
id2label = config['id2label']
tokenizer = model.tokenizer
def tag_arabic(text):
# Simple tagging function
chars = []
for word in text.split():
for i, c in enumerate(list(word)):
if i == 0:
chars.append(c)
else:
chars.append(f'##{c}')
input_ids = [tokenizer.cls_token_id] + tokenizer.convert_tokens_to_ids(chars) + [tokenizer.sep_token_id]
input_tensor = torch.tensor([input_ids])
with torch.no_grad():
outputs = model.forward(input_ids=input_tensor, task_name='ar_pos_tagging')
preds = outputs['logits'].argmax(-1).squeeze().tolist()
tags = [id2label[str(p)] for p in preds[1:len(chars)+1]]
# Format output
result = []
idx = 0
for word in text.split():
word_tags = tags[idx:idx+len(word)]
pos = '+'.join([t[2:] for t in word_tags if t.startswith('B-')])
result.append(f"{word}/{pos if pos else 'O'}")
idx += len(word)
return '\n'.join(result)
# Test
print(tag_arabic("بسم الله الرحمن الرحيم"))
[More Information Needed]
[More Information Needed]
[More Information Needed]
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
Use the code below to get started with the model.
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]