๐๏ธ Himachali โ Hindi Multilingual Translator (mT5)
A specialized multilingual NLP model designed to translate local Himachali dialects into standard Hindi.
This is one of the first open-source attempts to build a unified translator for:
- Bilaspuri
- Mandeali
- Kangri
- Kulluvi
Built using google/mt5-small, the model uses a sequence-to-sequence architecture fine-tuned on parallel dialect โ Hindi pairs.
๐ Features
- Translate 4+ Himachali dialects into Hindi
- Unified multilingual translation architecture
- Full ML workflow:
- Dataset preprocessing
- Training
- Evaluation
- Inference
- API + UI
- Gradio demo interface
- FastAPI server endpoint
- Apache 2.0 license (commercial-friendly)
- HuggingFace model card included
- Extensible for future dialects
๐ Project Structure
himachali2hindi-multilingual-mt5/
โ
โโโ data/
โ โโโ raw/
โ โ โโโ parallel.csv
โ โโโ processed/
โ โ โโโ dataset_clean.jsonl
โ โโโ README.md
โ
โโโ src/
โ โโโ __init__.py
โ โโโ config.py
โ โโโ dataset_preprocessing.py
โ โโโ train.py
โ โโโ evaluate.py
โ โโโ inference.py
โ โโโ model_utils.py
โ
โโโ app/
โ โโโ api.py
โ โโโ ui.py
โ
โโโ huggingface/
โ โโโ model_card.md
โ โโโ sample_inputs.txt
โ โโโ sample_outputs.txt
โ
โโโ notebooks/
โ โโโ 01-data-exploration.ipynb
โ โโโ 02-training.ipynb
โ โโโ 03-evaluation.ipynb
โ
โโโ model/
โ โโโ tokenizer/
โ โโโ checkpoints/
โ โโโ best-model/
โ
โโโ tests/
โ โโโ test_preprocessing.py
โ โโโ test_inference.py
โ โโโ test_training.py
โ
โโโ README.md
โโโ LICENSE
โโโ requirements.txt
โจ Supported Dialects
| Dialect | Region |
|---|---|
| Bilaspuri | Bilaspur district |
| Mandeali | Mandi district |
| Kangri | Kangra district |
| Kulluvi | Kullu valley |
You can add more dialects (e.g., Sirmauri, Chambeali) simply by adding datapoints.
๐ก Input Prompt Format
The model expects a standardized prompt:
dialect: <dialect> | translate: <sentence>
Example:
dialect: bilaspuri | translate: mai khet jaa reha
Model Output:
เคฎเฅเค เคเฅเคค เคเคพ เคฐเคนเคพ เคนเฅเค
๐งพ Dataset Format
CSV (raw)
source_dialect,text,target_hindi
bilaspuri,mai khet jaa reha,เคฎเฅเค เคเฅเคค เคเคพ เคฐเคนเคพ เคนเฅเค
mandeali,tus kinne jaande ho?,เคคเฅเคฎ เคเคนเคพเค เคเคพ เคฐเคนเฅ เคนเฅ?
Processed JSONL
{
"input": "dialect: bilaspuri | translate: mai khet jaa reha",
"target": "เคฎเฅเค เคเฅเคค เคเคพ เคฐเคนเคพ เคนเฅเค"
}
Convert CSV โ JSONL:
python -m src.dataset_preprocessing --input data/raw/parallel.csv --output data/processed/dataset_clean.jsonl
๐๏ธ Train the Model
python -m src.train
Outputs saved to:
model/checkpoints/best-model/
๐งช Evaluate
python -m src.evaluate
Metrics: ROUGE-1, ROUGE-L, and optionally BLEU / chrF.
๐ค Inference (Python)
from src.inference import translate
out = translate("mai khet jaa reha", dialect="bilaspuri")
print(out) # Expected: เคฎเฅเค เคเฅเคค เคเคพ เคฐเคนเคพ เคนเฅเค
๐ FastAPI Server
Start server:
uvicorn app.api:app --reload --port 8000
Send request:
POST /translate
{
"text": "mai khet jaa reha",
"dialect": "bilaspuri"
}
๐จ Gradio Demo
python app/ui.py
UI lets users type dialect text + select dialect.
๐ฆ Installation
pip install -r requirements.txt
Or create a virtual environment:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Model tree for hmnshudhmn24/himachali2hindi-multilingual-mt5
Base model
google/mt5-small