A state-of-the-art Named Entity Recognition (NER) system specifically designed for the Azerbaijani language, featuring multiple fine-tuned transformer models and a production-ready FastAPI deployment with an intuitive web interface.
Note: The server runs on a free tier and may take 1-2 minutes to initialize if inactive. Please be patient during startup.
🏗️ System Architecture
mermaid
1graph TD
2 A[User Input]--> B[FastAPI Server]3 B --> C[XLM-RoBERTa Model]4 C --> D[Token Classification]5 D --> E[Entity Aggregation]6 E --> F[Label Mapping]7 F --> G[JSON Response]8 G --> H[Frontend Visualization]910subgraph"Model Pipeline"11 C --> C1[Tokenization]12 C1 --> C2[BERT Encoding]13 C2 --> C3[Classification Head]14 C3 --> D
15end1617subgraph"Entity Categories"18 I[Person]19 J[Location]20 K[Organization]21 L[Date/Time]22 M[Government]23 N[25 Total Categories]24end2526 F --> I
27 F --> J
28 F --> K
29 F --> L
30 F --> M
31 F --> N
🤖 Model Training Pipeline
mermaid
1flowchart LR
2 A[Azerbaijani NER Dataset]--> B[Data Preprocessing]3 B --> C[Tokenization]4 C --> D[Label Alignment]56subgraph"Model Training"7 E[mBERT]--> F[Fine-tuning]8 G[XLM-RoBERTa]--> F
9 H[XLM-RoBERTa Large]--> F
10 I[Azeri-Turkish BERT]--> F
11 F --> J[Model Evaluation]12end1314 D --> E
15 D --> G
16 D --> H
17 D --> I
1819 J --> K[Best Model Selection]20 K --> L[Hugging Face Hub]21 L --> M[Production Deployment]2223subgraph"Performance Metrics"24 N[Precision: 76.44%]25 O[Recall: 74.05%]26 P[F1-Score: 75.22%]27end2829 J --> N
30 J --> O
31 J --> P
🔄 Data Flow Architecture
mermaid
1sequenceDiagram2participant U as User
3participant F as Frontend
4participant API as FastAPI
5participant M as XLM-RoBERTa
6participant HF as Hugging Face
78 U->>F: Enter Azerbaijani text
9 F->>API: POST /predict/
10 API->>M: Process text
11 M->>M: Tokenize input
12 M->>M: Generate predictions
13 M->>API: Return entity predictions
14 API->>API: Apply label mapping
15 API->>API: Group entities by type
16 API->>F: JSON response with entities
17 F->>U: Display highlighted entities
1819Note over M,HF: Model loaded from<br/>IsmatS/xlm-roberta-az-ner
Project Structure
.
├── Dockerfile # Docker image configuration
├── README.md # Project documentation
├── fly.toml # Fly.io deployment configuration
├── main.py # FastAPI application entry point
├── models/ # Model-related files
│ ├── NER_from_scratch.ipynb # Custom NER implementation notebook
│ ├── README.md # Models documentation
│ ├── XLM-RoBERTa.ipynb # XLM-RoBERTa training notebook
│ ├── azeri-turkish-bert-ner.ipynb # Azeri-Turkish BERT training
│ ├── mBERT.ipynb # mBERT training notebook
│ ├── push_to_HF.py # Hugging Face upload script
│ ├── train-00000-of-00001.parquet # Training data
│ └── xlm_roberta_large.ipynb # XLM-RoBERTa Large training
├── requirements.txt # Python dependencies
├── static/ # Frontend assets
│ ├── app.js # Frontend logic
│ └── style.css # UI styling
└── templates/ # HTML templates
└── index.html # Main UI template
Size: High-quality annotated Azerbaijani text corpus
Language: Azerbaijani (az)
Annotation: IOB2 format with 25 entity categories
Training Infrastructure: A100 GPU on Google Colab Pro+
📊 Model Performance Comparison
Model
F1-Score
mBERT
67.70%
XLM-RoBERTa Base
75.22%
XLM-RoBERTa Large
75.48%
Azeri-Turkish-BERT
73.55%
📈 Detailed Performance Metrics
mBERT Performance
Epoch
Training Loss
Validation Loss
Precision
Recall
F1
Accuracy
1
0.2952
0.2657
0.7154
0.6229
0.6659
0.9191
2
0.2486
0.2521
0.7210
0.6380
0.6770
0.9214
3
0.2068
0.2534
0.7049
0.6507
0.6767
0.9209
XLM-RoBERTa Base Performance
Epoch
Training Loss
Validation Loss
Precision
Recall
F1
1
0.3231
0.2755
0.7758
0.6949
0.7331
3
0.2486
0.2525
0.7515
0.7412
0.7463
5
0.2238
0.2522
0.7644
0.7405
0.7522
7
0.2097
0.2507
0.7607
0.7394
0.7499
XLM-RoBERTa Large Performance
Epoch
Training Loss
Validation Loss
Precision
Recall
F1
1
0.4075
0.2538
0.7689
0.7214
0.7444
3
0.2144
0.2488
0.7509
0.7489
0.7499
6
0.1526
0.2881
0.7831
0.7284
0.7548
9
0.1194
0.3316
0.7393
0.7495
0.7444
Azeri-Turkish-BERT Performance
Epoch
Training Loss
Validation Loss
Precision
Recall
F1
1
0.4331
0.3067
0.7390
0.6933
0.7154
3
0.2506
0.2751
0.7583
0.7094
0.7330
6
0.1992
0.2861
0.7551
0.7170
0.7355
9
0.1717
0.3138
0.7431
0.7255
0.7342
⚡ Key Features
🎯 State-of-the-art Accuracy: 75.22% F1-score on Azerbaijani NER
🌐 25 Entity Categories: Comprehensive coverage including Person, Location, Organization, Government, and more
🚀 Production Ready: Deployed on Fly.io with FastAPI backend
🎨 Interactive UI: Real-time entity highlighting with confidence scores
🔄 Multiple Models: Four different transformer models to choose from
📊 Confidence Scoring: Each prediction includes confidence metrics
🌍 Multilingual Foundation: Built on XLM-RoBERTa for cross-lingual understanding
📱 Responsive Design: Works seamlessly across desktop and mobile devices
🛠️ Technology Stack
mermaid
1graph LR
2subgraph"Frontend"3 A[HTML5]--> B[CSS3]4 B --> C[JavaScript]5end67subgraph"Backend"8 D[FastAPI]--> E[Python 3.8+]9 E --> F[Uvicorn]10end1112subgraph"ML Stack"13 G[Transformers]--> H[PyTorch]14 H --> I[Hugging Face]15end1617subgraph"Deployment"18 J[Docker]--> K[Fly.io]19 K --> L[Production]20end2122 C --> D
23 F --> G
24 I --> J
View results with entities highlighted by category and confidence scores
Example Usage
python
1# Example API request2import requests
34response = requests.post(5"https://named-entity-recognition.fly.dev/predict/",6 data={"text":"2014-cü ildə Azərbaycan Respublikasının prezidenti İlham Əliyev Salyanda olub."}7)89print(response.json())10# Output: {11# "entities": {12# "Date": ["2014"],13# "Government": ["Azərbaycan"],14# "Organization": ["Respublikasının"],15# "Position": ["prezidenti"],16# "Person": ["İlham Əliyev"],17# "Location": ["Salyanda"]18# }19# }
🎯 Model Capabilities
Person Names: İlham Əliyev, Heydər Əliyev, Nizami Gəncəvi
Locations: Bakı, Salyanda, Azərbaycan, Gəncə
Organizations: Respublika, Universitet, Şirkət
Dates & Times: 2014-cü il, sentyabr ayı, səhər saatları
Government Entities: prezident, nazir, məclis
And 20+ more categories...
🤝 Contributing
We welcome contributions! Here's how you can help:
🍴 Fork the repository
🌿 Create your feature branch (git checkout -b feature/AmazingFeature)
💍 Commit your changes (git commit -m 'Add some AmazingFeature')
📤 Push to the branch (git push origin feature/AmazingFeature)
🔀 Open a Pull Request
Development Areas
🧠 Model improvements and fine-tuning
🎨 UI/UX enhancements
📊 Performance optimizations
🧪 Additional test cases
📖 Documentation improvements
📄 License
This project is open source and available under the MIT License.
🙏 Acknowledgments
Hugging Face team for the transformer models and infrastructure
Google Colab for providing A100 GPU access
Fly.io for hosting the production deployment
The Azerbaijani NLP community for dataset contributions