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.
Key Features
✅ Character-level BIO tagging for handling complex Arabic morphology
✅ Trained on Quranic Arabic - high accuracy on classical texts
✅ Continual Learning ready - add new tasks without forgetting
✅ Multi-task capable - extend to NER, error detection, or generation
Model Details
Model Description
Developed by: [Akram Alsubari]
Model type: Token Classification (Character-level POS tagging)
Language(s): Arabic (Modern Standard & Quranic)
License: Apache 2.0
Base Model:google-bert/bert-base-multilingual-cased
Framework: dytr (Dynamic Transformer)
Training Data: Holy Quran with morphological annotations
1import torch
2import json
3import pyarabic.araby as araby
4from huggingface_hub import hf_hub_download
5from dytr import DynamicTransformer
67# Download and load model8model_path = hf_hub_download(9 repo_id="alsubari/bert-base-multilingual-cased-dytr",10 filename="dytr.pt"11)12config_path = hf_hub_download(13 repo_id="alsubari/bert-base-multilingual-cased-dytr",14 filename="config.json"15)1617model = DynamicTransformer.load_model(model_path)18model.eval()1920withopen(config_path)as f:21 config = json.load(f)22 id2label = config['id2label']2324tokenizer = model.tokenizer
2526def tag_arabic(text):27# Simple tagging function28 chars =[]29for word in text.split():30for i, c inenumerate(list(word)):31if i ==0:32 chars.append(c)33else:34 chars.append(f'##{c}')3536 input_ids =[tokenizer.cls_token_id]+ tokenizer.convert_tokens_to_ids(chars)+[tokenizer.sep_token_id]37 input_tensor = torch.tensor([input_ids])3839with torch.no_grad():40 outputs = model.forward(input_ids=input_tensor, task_name='ar_pos_tagging')41 preds = outputs['logits'].argmax(-1).squeeze().tolist()4243 tags =[id2label[str(p)]for p in preds[1:len(chars)+1]]4445# Format output46 result =[]47 idx =048for word in text.split():49 word_tags = tags[idx:idx+len(word)]50 pos ='+'.join([t[2:]for t in word_tags if t.startswith('B-')])51 result.append(f"{word}/{pos if pos else'O'}")52 idx +=len(word)5354return'\n'.join(result)5556# Test57print(tag_arabic("بسم الله الرحمن الرحيم"))
Downstream Use [optional]
[More Information Needed]
Out-of-Scope Use
[More Information Needed]
Bias, Risks, and Limitations
[More Information Needed]
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.