NandiBERT-420M (49k vocab) — English / Nepali / Romanized NER
Full merged NER model on top of luluw/NandiBERT420M-49k-en-ne-trim: MiCA adapters merged into the encoder, plus a multi-label B/I sigmoid head
(ner_classifier.safetensors) for PER, LOC, ORG, DATE.
Loading requires
trust_remote_code=True.
Test results (overlap-based, n = 9291)
- Overlap precision: 0.9498
- Overlap recall: 0.9196
- Overlap F1: 0.9345
- Exact-match micro F1: 0.7001
- False-positive rate on no-entity sentences: 3.37%
By entity type
| Entity | Exact P | Exact R | Exact F1 | Overlap P | Overlap R | Overlap F1 | Support |
|---|---|---|---|---|---|---|---|
| Person (PER) | 0.7108 | 0.6879 | 0.6991 | 0.9750 | 0.9408 | 0.9576 | 4969 |
| Location (LOC) | 0.7094 | 0.6760 | 0.6923 | 0.9355 | 0.8951 | 0.9149 | 4052 |
| Organization (ORG) | 0.6950 | 0.6877 | 0.6913 | 0.9244 | 0.9027 | 0.9134 | 3247 |
| Date (DATE) | 0.7680 | 0.7739 | 0.7709 | 0.9669 | 0.9744 | 0.9706 | 898 |
By script
| Segment | n | Overlap P | Overlap R | Overlap F1 |
|---|---|---|---|---|
| All scripts | 9291 | 0.9498 | 0.9196 | 0.9345 |
Romanized / Neglish (script=roman-ne) | 6625 | 0.9476 | 0.9117 | 0.9293 |
Devanagari (script=deva) | 2198 | 0.9491 | 0.9301 | 0.9395 |
English (script=en) | 238 | 0.9751 | 0.9833 | 0.9792 |
Mixed script (script=mixed) | 228 | 0.9898 | 0.9898 | 0.9898 |
Training
- Fine-tuning method: MiCA (
init_lora_weights="mica") - Rank allocation: SVD-guided, per module group
- Attention:
r = 64 - MLP:
r = 128
- Attention:
- Maximum sequence length: 1,024 tokens
- Training epochs: 3
- Effective batch size: 32 (4 BatchSize * 4 Gradient Acc * 2 T4 GPU)
- Learning rate:
0.0003 - Data augmentation: Casing augmentation on Latin-script training text
Usage
import json, numpy as np, torch, torch.nn as nn, safetensors.torch
from huggingface_hub import snapshot_download
from transformers import AutoModel, AutoTokenizer
path = snapshot_download("luluw/NandiBERT-420M-49k-en-ne-ner-mica")
tok = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
enc = AutoModel.from_pretrained(path, trust_remote_code=True).eval()
cfg = json.load(open(f"{path}/ner_config.json"))
clf = nn.Linear(enc.config.hidden_size, cfg["num_tags"])
clf.load_state_dict(safetensors.torch.load_file(f"{path}/ner_classifier.safetensors"))
LABELS = cfg["labels"]; TAGS = cfg["bio_tags"]; T2I = {t: i for i, t in enumerate(TAGS)}
def predict(text, thr=0.5):
e = tok(text, return_offsets_mapping=True, return_tensors="pt")
offs = e.pop("offset_mapping")[0].tolist()
with torch.no_grad():
probs = torch.sigmoid(clf(enc(**e).last_hidden_state))[0].numpy()
spans = []
for lab in LABELS:
b, i, cur = T2I["B-" + lab], T2I["I-" + lab], None
for t, (s, en) in enumerate(offs):
while s < en and text[s].isspace(): s += 1
if s == en: continue
if probs[t, b] >= thr:
if cur: spans.append(cur)
cur = [s, en, lab]
elif probs[t, i] >= thr and cur and text[cur[1]:s].strip() == "":
cur[1] = en
elif probs[t, i] >= thr and not cur:
cur = [s, en, lab]
else:
if cur: spans.append(cur); cur = None
if cur: spans.append(cur)
return [(text[s:e], l) for s, e, l in sorted(spans)]
print(predict("On 15/09/2028, we will hold a conference in Kathmandu with Ram Bahadur."))
Citation
@misc{frontiersmind2026nandibert,
title = {NandiBERT: Open Encoders for English and Indic Languages},
author = {{FrontiersMind}},
year = {2026},
howpublished = {\url{https://huggingface.co/FrontiersMind/NandiBERT-450M}}
}