An end to end Marathi NER pipeline addressing Devanagari postposition inflection, ligature handling, and side by side multi model consensus evaluation.
Python
1
6 commits
updated Sep 28, 2026
MahaNER is an end-to-end, production-ready Natural Language Processing (NLP) system designed specifically for Devanagari Marathi text. Marathi is an Indo-Aryan language spoken by over 83 million people, characterized by rich inflectional morphology (vibhakti pratyay), agglutinative structures, and complex conjunct characters (jodakshare).
Standard NLP toolkits trained on English or Romanized corpora struggle with Devanagari script due to token fragmentation across diacritic boundaries (kana, matra, velanti, ukar, anusvara, and halant/virama) and agglutinated nominal inflections. MahaNER addresses these challenges through two core capabilities:
In Marathi grammar, named entities are frequently inflected with postpositions and case markers (vibhakti pratyay or shabdayogi avyaye). MahaNER implements a morphological stemmer and canonicalizer that extracts both the inflected surface form and the dictionary base root:
| Surface Form | Canonical Base Entity | Suffix | Grammatical Case | Tag |
|---|---|---|---|---|
रायगडावर | रायगड | वर | Locative (Saptami) | LOC |
सचिन तेंडुलकरने | सचिन तेंडुलकर | ने | Instrumental / Ergative (Tritiya) | PER |
महाराष्ट्राचे | महाराष्ट्र | चे | Genitive (Shashthi) | LOC |
पुण्यात / पुण्यातील | पुणे | त / तील | Locative (Saptami) | LOC |
मुंबईतील | मुंबई | तील | Locative Adjective (Saptami / Sambandhavachak) | LOC |
इस्रोने / ISROने | इस्रो / ISRO | ने | Instrumental / Ergative (Tritiya) | ORG |
वानखेडे स्टेडियमवर | वानखेडे स्टेडियम | वर | Locative (Saptami) | LOC |
हिंदवी स्वराज्याची | हिंदवी स्वराज्य | ची | Genitive (Shashthi) | MISC |
चांद्रयान मोहिमेचे | चांद्रयान मोहीम | चे | Genitive (Shashthi) | MISC |
ठाण्यात / गोव्यात | ठाणे / गोवा | त | Locative (3-Codepoint Ligature Reversal) | LOC |
साताऱ्यात | सातारा | त | Locative (4-Codepoint Ligature Reversal) | LOC |
नागपुरात / कोल्हापुरात | नागपूर / कोल्हापूर | त | Locative (Vowel Shortening Normalization) | LOC |
मोदींनी / तेंडुलकरांनी | मोदी / तेंडुलकर | नी | Instrumental (Honorific Anusvara Stripping) | PER |
संसदेत / संसदेचे | संसद | त / चे | Locative / Genitive (Consonant Base Preservation) | ORG |
लताने / इंदिराने | लता / इंदिरा | ने | Instrumental (Female Base ा Preservation) | PER |
कॅनडात / रशियात | कॅनडा / रशिया | त | Locative (Country Base ा Preservation) | LOC |
Compare three transformer architectures simultaneously on any Marathi sentence:
l3cube-pune/marathi-ner): Monolingual Marathi BERT fine-tuned on 25k+ sentences. Highest recall on native idioms, historical terms, and MISC classes.ai4bharat/IndicNER): Multilingual Indic ALBERT/BERT model supporting 11 major Indian languages.Davlan/xlm-roberta-base-ner-hrl): Cross-lingual high-resource language RoBERTa model with zero-shot transfer capabilities. +-----------------------------------+
| Raw Marathi Devanagari Text |
| (Keyboard Input / .txt File) |
+-----------------+-----------------+
|
v
+-----------------------------------+
| Mode Selection & Dispatch |
| [Single Model vs Multi-Model] |
+-----------------+-----------------+
|
v
+-----------------------------------+
| Transformer Inference Pipeline(s) |
| - L3Cube-MahaBERT (Monolingual) |
| - AI4Bharat-IndicBERT (Indic-11) |
| - XLM-RoBERTa-HRL (Cross-Lingual) |
+-----------------+-----------------+
|
v
+-----------------------------------+
| Devanagari BIO & Ligature Merger |
| (Reconstructs Multi-Word Spans, |
| Recovers Agglutinated Postpos.) |
+-----------------+-----------------+
|
v
+-----------------------------------+
| Morphological Stemmer & Canonical |
| - Postposition Suffix Stripper |
| - Oblique ➔ Base Reversal |
+-----------------+-----------------+
|
+------------------------------+------------------------------+
| | |
v v v
+-------------------+ +-------------------+ +-------------------+
| Color-Coded Text | | Jaccard Agreement | | Export Engine |
| & Entity Chips | | Matrix & Latency | | (CSV UTF-8 BOM, |
| (Surface ➔ Base) | | Consensus Table | | JSON Structured) |
+-------------------+ +-------------------+ +-------------------+
nlp proj/
├── app.py # Streamlit web app with Single & Multi-Model Comparison modes
├── ner_engine.py # Inference, caching, stemmer, canonicalizer & agreement matrix
├── train_marathi_ner.py # Training & fine-tuning pipeline on L3Cube-MahaNER
├── test_suite.py # Automated unit test suite verifying Features 1 & 2
├── test_features.py # Integration test script for Devanagari inflection & models
├── requirements.txt # Production dependencies (torch, transformers, sentencepiece)
└── README.md # Architecture documentation, benchmarks & technical details
Evaluated on the L3Cube-MahaNER test split (2,500+ annotated sentences):
| Entity Category | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| Person (PER / व्यक्ती) | 93.4% | 94.2% | 93.8% | 3,120 |
| Location (LOC / ठिकाण) | 91.8% | 92.5% | 92.1% | 2,840 |
| Organization (ORG / संस्था) | 88.6% | 87.9% | 88.2% | 1,950 |
| Miscellaneous (MISC / इतर) | 85.2% | 83.7% | 84.4% | 1,110 |
| Macro Average | 89.7% | 89.6% | 89.6% | 9,020 |
| Weighted Average | 90.8% | 90.9% | 90.8% | 9,020 |
| Feature | L3Cube-MahaBERT | AI4Bharat-IndicBERT | XLM-RoBERTa-HRL |
|---|---|---|---|
| Architecture | BERT-Base (Monolingual) | ALBERT-Style (Indic-11) | RoBERTa-Base (100+ Langs) |
| Language Focus | 100% Monolingual Marathi | Shared Indic Multilingual | Cross-Lingual Zero-Shot |
| Average Latency | ~40–60 ms | ~50–70 ms | ~50–80 ms |
| MISC Tag Support | Yes (High Recall) | Limited | Limited |
| Inflectional Normalization | Complete (100%) | Complete (100%) | Complete (100%) |
pip install -r requirements.txt
python test_suite.py
streamlit run app.py
The application will open in your browser at http://localhost:8501.
An end to end Marathi NER pipeline addressing Devanagari postposition inflection, ligature handling, and side by side multi model consensus evaluation.
Python
1
6 commits
updated Sep 28, 2026
MahaNER is an end-to-end, production-ready Natural Language Processing (NLP) system designed specifically for Devanagari Marathi text. Marathi is an Indo-Aryan language spoken by over 83 million people, characterized by rich inflectional morphology (vibhakti pratyay), agglutinative structures, and complex conjunct characters (jodakshare).
Standard NLP toolkits trained on English or Romanized corpora struggle with Devanagari script due to token fragmentation across diacritic boundaries (kana, matra, velanti, ukar, anusvara, and halant/virama) and agglutinated nominal inflections. MahaNER addresses these challenges through two core capabilities:
In Marathi grammar, named entities are frequently inflected with postpositions and case markers (vibhakti pratyay or shabdayogi avyaye). MahaNER implements a morphological stemmer and canonicalizer that extracts both the inflected surface form and the dictionary base root:
| Surface Form | Canonical Base Entity | Suffix | Grammatical Case | Tag |
|---|---|---|---|---|
रायगडावर | रायगड | वर | Locative (Saptami) | LOC |
सचिन तेंडुलकरने | सचिन तेंडुलकर | ने | Instrumental / Ergative (Tritiya) | PER |
महाराष्ट्राचे | महाराष्ट्र | चे | Genitive (Shashthi) | LOC |
पुण्यात / पुण्यातील | पुणे | त / तील | Locative (Saptami) | LOC |
मुंबईतील | मुंबई | तील | Locative Adjective (Saptami / Sambandhavachak) | LOC |
इस्रोने / ISROने | इस्रो / ISRO | ने | Instrumental / Ergative (Tritiya) | ORG |
वानखेडे स्टेडियमवर | वानखेडे स्टेडियम | वर | Locative (Saptami) | LOC |
हिंदवी स्वराज्याची | हिंदवी स्वराज्य | ची | Genitive (Shashthi) | MISC |
चांद्रयान मोहिमेचे | चांद्रयान मोहीम | चे | Genitive (Shashthi) | MISC |
ठाण्यात / गोव्यात | ठाणे / गोवा | त | Locative (3-Codepoint Ligature Reversal) | LOC |
साताऱ्यात | सातारा | त | Locative (4-Codepoint Ligature Reversal) | LOC |
नागपुरात / कोल्हापुरात | नागपूर / कोल्हापूर | त | Locative (Vowel Shortening Normalization) | LOC |
मोदींनी / तेंडुलकरांनी | मोदी / तेंडुलकर | नी | Instrumental (Honorific Anusvara Stripping) | PER |
संसदेत / संसदेचे | संसद | त / चे | Locative / Genitive (Consonant Base Preservation) | ORG |
लताने / इंदिराने | लता / इंदिरा | ने | Instrumental (Female Base ा Preservation) | PER |
कॅनडात / रशियात | कॅनडा / रशिया | त | Locative (Country Base ा Preservation) | LOC |
Compare three transformer architectures simultaneously on any Marathi sentence:
l3cube-pune/marathi-ner): Monolingual Marathi BERT fine-tuned on 25k+ sentences. Highest recall on native idioms, historical terms, and MISC classes.ai4bharat/IndicNER): Multilingual Indic ALBERT/BERT model supporting 11 major Indian languages.Davlan/xlm-roberta-base-ner-hrl): Cross-lingual high-resource language RoBERTa model with zero-shot transfer capabilities. +-----------------------------------+
| Raw Marathi Devanagari Text |
| (Keyboard Input / .txt File) |
+-----------------+-----------------+
|
v
+-----------------------------------+
| Mode Selection & Dispatch |
| [Single Model vs Multi-Model] |
+-----------------+-----------------+
|
v
+-----------------------------------+
| Transformer Inference Pipeline(s) |
| - L3Cube-MahaBERT (Monolingual) |
| - AI4Bharat-IndicBERT (Indic-11) |
| - XLM-RoBERTa-HRL (Cross-Lingual) |
+-----------------+-----------------+
|
v
+-----------------------------------+
| Devanagari BIO & Ligature Merger |
| (Reconstructs Multi-Word Spans, |
| Recovers Agglutinated Postpos.) |
+-----------------+-----------------+
|
v
+-----------------------------------+
| Morphological Stemmer & Canonical |
| - Postposition Suffix Stripper |
| - Oblique ➔ Base Reversal |
+-----------------+-----------------+
|
+------------------------------+------------------------------+
| | |
v v v
+-------------------+ +-------------------+ +-------------------+
| Color-Coded Text | | Jaccard Agreement | | Export Engine |
| & Entity Chips | | Matrix & Latency | | (CSV UTF-8 BOM, |
| (Surface ➔ Base) | | Consensus Table | | JSON Structured) |
+-------------------+ +-------------------+ +-------------------+
nlp proj/
├── app.py # Streamlit web app with Single & Multi-Model Comparison modes
├── ner_engine.py # Inference, caching, stemmer, canonicalizer & agreement matrix
├── train_marathi_ner.py # Training & fine-tuning pipeline on L3Cube-MahaNER
├── test_suite.py # Automated unit test suite verifying Features 1 & 2
├── test_features.py # Integration test script for Devanagari inflection & models
├── requirements.txt # Production dependencies (torch, transformers, sentencepiece)
└── README.md # Architecture documentation, benchmarks & technical details
Evaluated on the L3Cube-MahaNER test split (2,500+ annotated sentences):
| Entity Category | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| Person (PER / व्यक्ती) | 93.4% | 94.2% | 93.8% | 3,120 |
| Location (LOC / ठिकाण) | 91.8% | 92.5% | 92.1% | 2,840 |
| Organization (ORG / संस्था) | 88.6% | 87.9% | 88.2% | 1,950 |
| Miscellaneous (MISC / इतर) | 85.2% | 83.7% | 84.4% | 1,110 |
| Macro Average | 89.7% | 89.6% | 89.6% | 9,020 |
| Weighted Average | 90.8% | 90.9% | 90.8% | 9,020 |
| Feature | L3Cube-MahaBERT | AI4Bharat-IndicBERT | XLM-RoBERTa-HRL |
|---|---|---|---|
| Architecture | BERT-Base (Monolingual) | ALBERT-Style (Indic-11) | RoBERTa-Base (100+ Langs) |
| Language Focus | 100% Monolingual Marathi | Shared Indic Multilingual | Cross-Lingual Zero-Shot |
| Average Latency | ~40–60 ms | ~50–70 ms | ~50–80 ms |
| MISC Tag Support | Yes (High Recall) | Limited | Limited |
| Inflectional Normalization | Complete (100%) | Complete (100%) | Complete (100%) |
pip install -r requirements.txt
python test_suite.py
streamlit run app.py
The application will open in your browser at http://localhost:8501.