Azerbaijani Named Entity Recognition with XLM-RoBERTa Large
Fine-tuned version of xlm-roberta-large for Named Entity Recognition (NER) on Azerbaijani text. Recognizes 12 entity types including persons, locations, organizations, dates, and more.
1from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
2import torch
34model_name ="IsmatS/xlm_roberta_large_az_ner"5tokenizer = AutoTokenizer.from_pretrained(model_name)6model = AutoModelForTokenClassification.from_pretrained(model_name)78device =0if torch.cuda.is_available()else-19ner = pipeline("ner", model=model, tokenizer=tokenizer,10 aggregation_strategy="simple", device=device)1112# Single text13text ="Bakı şəhərində Azərbaycan Respublikasının prezidenti İlham Əliyev."14results = ner(text)15for e in results:16print(f"[{e['entity_group']}] {e['word']} (score: {e['score']:.3f})")
Batch Inference
python
1texts =[2"Bakı şəhərində İlham Əliyev çıxış etdi.",3"SOCAR şirkəti 2024-cü ildə rekord gəlir əldə etdi.",4"Heydər Əliyev Beynəlxalq Hava Limanı yeni terminalı açıldı.",5]67results = ner(texts)8for text, entities inzip(texts, results):9print(f"\nText: {text}")10for e in entities:11print(f" [{e['entity_group']}] {e['word']}")