You need to agree to share your Hugging Face information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

IMD weather-alert translation: English → Hindi / Maithili / Urdu

A 200M-parameter translation model finetuned for India Meteorological Department (IMD) style weather alerts — nowcasts, warnings and advisories for the 38 districts of Bihar — from English into Hindi (hin_Deva), Maithili (mai_Deva) and Urdu (urd_Arab).

Weather alerts carry numbers (hours, km/h, mm, °C, dates) and place names that must come through unchanged. This repository therefore ships imd_translate.py, which checks every translation against the English source and marks any output whose numbers or district names do not match as not verified.

This is not an official IMD product.

How to use

pip install torch transformers IndicTransToolkit==1.1.1
from huggingface_hub import snapshot_download
import sys

path = snapshot_download("coild-repo/IMD")
sys.path.insert(0, path)
from imd_translate import IMDTranslator

t = IMDTranslator(path)
alerts = [
    "Severe thunderstorm with hail and surface wind (60-70 kmph) is very likely to occur "
    "at isolated places over Darbhanga, Supaul and Saharsa districts in next 2-3 hours.",
]
for r in t.translate(alerts, "hin_Deva"):     # or "mai_Deva", "urd_Arab"
    print(r["translation"], r["verified"], r["problems"])
# अगले 2-3 घंटों के दौरान दरभंगा, सुपौल एवं सहरसा जिलों के अलग-अलग स्थानों पर ओलावृष्टि एवं
# 60-70 किमी/घंटा की रफ्तार वाली तेज हवाओं के साथ तीव्र गरज-चमक होने की प्रबल संभावना है। True {}

translate() takes one sentence per item (split longer alerts into sentences; at most 256 tokens each). For each sentence it decodes the model's 5 best candidates (beam 5), re-joins numbers the model split (44. 5 → 44.5, only for numbers present in the source), and returns the first candidate whose numbers and district names match the English exactly. If none does, it returns the best candidate with "verified": False and the mismatches, e.g. {'numbers_missing': ['time 11:00'], 'numbers_extra': ['11']}. A translation with verified: False must be checked by a person before it is sent out.

Text preparation (required)

The model was trained with a specific preparation of the text, which imd_translate.py applies. If you call the model directly, prepare text the same way:

  • IndicTransToolkit's IndicProcessor with inference=False for the source — the default inference=True replaces numbers, ranges and dates with <ID1>… placeholders (wind speed 30-40 kmph … on 31.12.2015 → wind speed <ID2> kmph … on <ID1>), which this model never saw and which can be left in the output;
  • every decimal digit converted to 0-9 before preprocessing;
  • three indic-nlp-library fixes: the nukta written as the literal text ़, a colon→visarga rule that damages numbers (80:40:30 → 8\1ः4\1ः30), and the detokenizer leaving sentence-initial numbers split (2 . 5 → 2. 5).

The model code in this repository includes a fix so that generate() works on transformers ≥ 4.54; generation_config.json sets beam search with 5 beams.

Tested with: transformers 4.57.6, torch 2.5.1, IndicTransToolkit 1.1.1 (indic-nlp-library-itt 0.1.1). The indic-nlp fixes patch internals of these versions.

Results

Baseline = IndicTrans2, as released, with its standard text preparation (IndicProcessor(inference=True)), beam 5. Finetuned = this model with imd_translate.py's text preparation, beam 5, before the candidate check (the check can only improve the number and district figures). BLEU is sacreBLEU with the default 13a tokenizer; chrF++ is sacreBLEU chrF with word order 2.

Number accuracy = of the sentences that contain numbers, the share whose output has exactly the source's numbers (any digit script; a date written 06.10.2026 or 6 अक्टूबर 2026, a time written 08:30, 0830 hrs or 8:30 बजे count as equal; a spelled-out, dropped, changed or split number does not). District accuracy = of the sentences naming Bihar districts, the share whose output names exactly those districts in the IMD spelling. Both are judged against the English source.

IMD alerts, held-out sentence patterns (test-imd)

The training bulletins are template sentences. Test sentences come from templates (hazard wording with districts and numbers masked) that were removed from training.

n BLEU baseline → finetuned chrF++ baseline → finetuned numbers baseline → finetuned districts baseline → finetuned
Hindi 380 26.51 → 99.86 56.95 → 99.63 93.99% → 100% 68.42% → 98.95%
Maithili 455 19.82 → 99.73 51.66 → 99.57 100% → 100% 54.95% → 98.46%
Urdu 455 31.97 → 99.52 59.33 → 99.59 100% → 100% 19.12% → 100%

Same sentences with unseen numbers (test-imd-numstress)

Every number replaced, identically in source and reference, by a value that never occurs in the training data.

n BLEU baseline → finetuned chrF++ baseline → finetuned numbers baseline → finetuned districts baseline → finetuned
Hindi 316 27.94 → 99.90 58.00 → 99.60 92.72% → 100% 68.04% → 99.37%
Maithili 391 19.36 → 99.89 52.10 → 99.62 100% → 99.74% 53.96% → 99.49%
Urdu 391 34.52 → 99.58 60.90 → 99.58 100% → 100% 19.95% → 100%

The baseline's district "errors" in the examples inspected are spellings that differ from the IMD form (सीवान for सिवान, بنکا for بانکا); the finetuned model uses the IMD spellings.

General text, not weather (coild-bm, 2,000 sentences)

Finetuning on alerts costs some quality on unrelated text compared with the baseline:

BLEU baseline → finetuned chrF++ baseline → finetuned
Hindi 36.24 → 33.99 60.07 → 58.52
Maithili 17.40 → 15.51 50.28 → 47.75
Urdu 31.88 → 31.54 56.14 → 55.65

Training

  • Data: English–Hindi, English–Maithili and English–Urdu IMD-style alert sentences for Bihar districts (nowcasts for thunderstorm, lightning, hail, rain, fog, heat and cold waves, plus public advisories): 3,399 / 4,044 / 4,044 training pairs after removing duplicates and every sentence or sentence pattern used for evaluation.
  • Held-out sets: dev 421 / 501 / 501 sentences (checkpoint choice) and test 380 / 455 / 455, split by template so that no test pattern is seen in training.
  • Recipe: lr 2e-5 cosine, warmup 1%, batch 64, AdamW 8-bit, label smoothing 0.1, max length 256, fp32 weights with bf16 autocast, one GPU. Every 100 steps the dev set was translated and scored; the checkpoint with the best dev chrF++ was kept and training stopped after 5 checks without improvement (step 1,100, epoch 6.1). The released weights are step 600 (epoch 3.3), dev chrF++ 100.0, all dev numbers exact.

Limitations

  • Template coverage. The training sentences are template bulletins. Real alerts phrased differently, longer multi-sentence messages, and other states are not measured; the test sets above are template sentences too.
  • Dates, clock times, decimals, temperatures and rainfall amounts do not occur in the training data. The model handles many of them, but not reliably: e.g. in Maithili between 11:00 AM and 4:00 PM came out as "11 hours … 4 hours" (flagged verified: False by the check). Such sentences are where the check matters most.
  • District check covers the 38 Bihar districts only. Other place names are not checked.
  • Numbers spelled out (2.5 → ढाई) or rounded count as errors and are flagged.
  • Output digits are 0-9 in all three languages (Urdu included), as in the training data.
  • General text is slightly worse than the baseline (table above); use a general-purpose translation model for non-weather text.
  • English → Indic only.

Intended use

Drafting Hindi, Maithili and Urdu versions of English weather alerts for Bihar, with a person reviewing every output flagged verified: False before publication. Not intended for publishing translations without review, or for other domains.

Downloads last month
4
Safetensors
Model size
0.3B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Evaluation results

  • BLEU (sacreBLEU 13a) on IMD alert sentences, held-out templates (380 sentences)
    self-reported
    99.860
  • chrF++ on IMD alert sentences, held-out templates (380 sentences)
    self-reported
    99.630
  • BLEU (sacreBLEU 13a) on IMD alert sentences, held-out templates (455 sentences)
    self-reported
    99.730
  • chrF++ on IMD alert sentences, held-out templates (455 sentences)
    self-reported
    99.570
  • BLEU (sacreBLEU 13a) on IMD alert sentences, held-out templates (455 sentences)
    self-reported
    99.520
  • chrF++ on IMD alert sentences, held-out templates (455 sentences)
    self-reported
    99.590