Assignment 2 implementation for Sanskrit-to-English neural machine translation.
This repository contains everything required for assignment submission and evaluation:
| File / Folder | Purpose |
|---|---|
Sanskrit_English_NMT_Assignment.ipynb |
Training and inference code (.ipynb only, as required) |
Datasets/ |
Provided Sanskrit-English train/dev/test CSV files |
submission.csv |
Final test-set predictions (Source_id, Sentence_en) |
outputs/metrics.json |
Final BLEU, BERTScore, inference time, and parameter count |
outputs/training_history.csv |
Training loss per epoch |
outputs/training_curve.png |
Training curve plot |
outputs/translation_examples.json |
Example translations with references |
Sanskrit_English_NMT_Report.docx |
Assignment report |
requirements.txt |
Python dependencies with install instructions |
| Component | Pretrained? | Details |
|---|---|---|
| Translation model (encoder-decoder GRU + attention) | No | Trained from scratch on the provided dataset only |
BERTScore evaluation (bert-score) |
Yes | Uses roberta-large downloaded locally for metric computation only |
| External translation APIs | No | Not used |
The translation model does not use any pretrained weights. The only pretrained model is roberta-large, used exclusively by the bert-score library to compute BERTScore F1 during evaluation. It is not part of the translation pipeline.
Use WSL and the local virtual environment:
source .venv/bin/activate
pip install -r requirements.txt
jupyter notebook Sanskrit_English_NMT_Assignment.ipynbRun all cells in order. The notebook will:
- Load and preprocess the provided datasets
- Train the custom seq2seq model with attention
- Evaluate on dev and test sets (BLEU + BERTScore)
- Report inference time and parameter count
- Write
submission.csv
| Metric | Value |
|---|---|
| Dev BLEU | 0.0235 |
| Test BLEU | 0.0253 |
| Test BERTScore F1 | -0.0406 |
| Test inference time | 57.34 seconds |
| Trainable parameters | 6,629,824 |
- Custom PyTorch encoder-decoder with additive attention and beam search
- No external APIs are used
- Only the provided assignment dataset is used for training
- BERTScore uses
rescale_with_baseline=Trueas required