Instructions to use hamidsalimi/persian-gliner-ner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER
How to use hamidsalimi/persian-gliner-ner with GLiNER:
from gliner import GLiNER model = GLiNER.from_pretrained("hamidsalimi/persian-gliner-ner") - Notebooks
- Google Colab
- Kaggle
Persian GLiNER NER
Model type: Token Classification / Named Entity Recognition
Language: Persian (fa)
Base model: microsoft/mdeberta-v3-base
GLiNER version: v0.2.28
License: Apache 2.0
Model Description
This is a fine-tuned GLiNER model for Persian Named Entity Recognition (NER) with 22 entity types. It was trained on 100,000 synthetic Persian NER samples generated from diverse templates covering news, legal, medical, and technical domains.
Intended Uses & Limitations
Intended Uses
- Named Entity Recognition in Persian text
- Information extraction from Persian documents
- Processing Persian news articles, legal documents, and medical texts
- Research and commercial applications requiring Persian NER
Limitations
- Weak categories: NARCOTICS, WEAPON, ALCOHOLIC_BEVERAGES, and CULTURAL_CONCEPT have low F1 scores due to limited synthetic training data diversity
- Generalization: Model was trained on synthetic Persian text and may not generalize well to all real-world text distributions
- Misclassification: Some entities may be misclassified due to overlapping contexts (e.g., PERCENT vs LOCATION)
- Recommended threshold: 0.3-0.5 (lower for high-recall scenarios)
Entity Types (22)
| # | Label | Description |
|---|---|---|
| 1 | PERSON |
People names |
| 2 | ORGANIZATION |
Companies, institutions |
| 3 | LOCATION |
General locations |
| 4 | DATE |
Dates, years |
| 5 | TIME |
Times, durations |
| 6 | MONEY |
Monetary values |
| 7 | PERCENT |
Percentage values |
| 8 | PROVINCE |
Iranian provinces |
| 9 | CITY |
Cities and towns |
| 10 | COUNTY |
Counties (شهرستان) |
| 11 | FACILITY |
Buildings, venues |
| 12 | EVENT |
Events, incidents |
| 13 | LAW |
Laws, regulations |
| 14 | LANGUAGE |
Languages |
| 15 | NATIONALITY |
Nationalities |
| 16 | RELIGION |
Religious concepts |
| 17 | POLITICAL_PARTY |
Political parties |
| 18 | CULTURAL_CONCEPT |
Cultural concepts |
| 19 | PRODUCT |
Products, goods |
| 20 | NARCOTICS |
Drugs, narcotics |
| 21 | WEAPON |
Weapons, arms |
| 22 | ALCOHOLIC_BEVERAGES |
Alcoholic beverages |
Training Details
Training Hyperparameters
- Steps: 20,000
- Batch size: 8
- Learning rate: 1e-5 (encoder), 5e-5 (others)
- Scheduler: Cosine with 3,000 warmup steps
- Precision: BF16
- Hardware: NVIDIA RTX 4050
- Training time: ~2 hours
Training Data
- 100,000 synthetic Persian NER samples
- Diverse templates covering news, legal, medical, and technical domains
Evaluation Results
Evaluated on 5,000 validation samples using seqeval:
| Metric | Score |
|---|---|
| Micro F1 | 0.79 |
| Micro Precision | 0.90 |
| Micro Recall | 0.70 |
| Macro F1 | 0.64 |
| Weighted F1 | 0.74 |
Per-Entity Results
| Label | Precision | Recall | F1 | Support |
|---|---|---|---|---|
| PERSON | 0.80 | 0.90 | 0.85 | 323 |
| ORGANIZATION | 1.00 | 0.71 | 0.83 | 617 |
| LOCATION | 0.86 | 0.86 | 0.86 | 652 |
| DATE | 0.91 | 0.88 | 0.90 | 1214 |
| TIME | 1.00 | 0.83 | 0.91 | 597 |
| MONEY | 1.00 | 0.76 | 0.87 | 320 |
| PERCENT | 1.00 | 0.02 | 0.03 | 322 |
| PROVINCE | 0.97 | 0.99 | 0.98 | 619 |
| CITY | 1.00 | 0.72 | 0.83 | 2528 |
| COUNTY | 1.00 | 0.83 | 0.91 | 300 |
| FACILITY | 1.00 | 0.87 | 0.93 | 623 |
| EVENT | 0.72 | 1.00 | 0.84 | 663 |
| LAW | 1.00 | 0.94 | 0.97 | 646 |
| LANGUAGE | 0.58 | 0.85 | 0.69 | 306 |
| NATIONALITY | 1.00 | 0.27 | 0.42 | 317 |
| RELIGION | 1.00 | 1.00 | 1.00 | 338 |
| POLITICAL_PARTY | 1.00 | 0.98 | 0.99 | 263 |
| CULTURAL_CONCEPT | 0.00 | 0.00 | 0.00 | 309 |
| PRODUCT | 1.00 | 0.02 | 0.03 | 322 |
| NARCOTICS | 0.00 | 0.00 | 0.00 | 316 |
| WEAPON | 0.00 | 0.00 | 0.00 | 316 |
| ALCOHOLIC_BEVERAGES | 0.14 | 0.14 | 0.14 | 316 |
How to Use
from gliner import GLiNER
# Load the model
model = GLiNER.from_pretrained("your-username/persian-gliner-ner")
model.eval()
# Define entity labels
labels = [
"PERSON", "ORGANIZATION", "LOCATION", "DATE", "TIME", "MONEY", "PERCENT",
"PROVINCE", "CITY", "COUNTY", "FACILITY", "EVENT", "LAW", "LANGUAGE",
"NATIONALITY", "RELIGION", "POLITICAL_PARTY", "CULTURAL_CONCEPT", "PRODUCT",
"NARCOTICS", "WEAPON", "ALCOHOLIC_BEVERAGES",
]
# Example text
text = "دانشگاه تهران یکی از بزرگترین دانشگاههای ایران است که در منطقه فنآوری اطلاعات تهران قرار دارد."
# Predict entities
entities = model.predict_entities(text, labels, threshold=0.5)
# Display results
for e in entities:
print(f"{e['label']}: {e['text']} (score: {e['score']:.3f})")
- Downloads last month
- -
Model tree for hamidsalimi/persian-gliner-ner
Base model
microsoft/mdeberta-v3-base