Downloads · 30 days
0
sps1001/b23cs1061_ass_4_best_model.pth
b23cs1061_ass_4_best_model.pth is a machine learning model from sps1001. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Roll Number: B23CS1061 Task: English → Hindi Neural Machine Translation using a from-scratch PyTorch Transformer, optimized via Ray Tune + Optuna hyperparameter search.
Downloads · 30 days
0
Access
Public
Updated Mar 18, 2026
Repo size
202 MB
Likes
0
Public
Click a slice to open those files.
.pth202 MB · 100%
From the Hugging Face model README
Roll Number: B23CS1061 Task: English → Hindi Neural Machine Translation using a from-scratch PyTorch Transformer, optimized via Ray Tune + Optuna hyperparameter search.
| File | Description |
|---|---|
b23cs1061_ass_4_tuned_en_to_hi.ipynb | Main notebook — baseline + Ray Tune + Optuna + final comparison |
b23cs1061_ass_4_best_model.pth | Saved weights of the best-performing model from the tuning sweep |
b23cs1061_ass_4_report.pdf | 1–2 page report with baseline metrics, hyperparameter ranges, best config, and final results |
English-Hindi.tsv | Dataset — 13,186 English-Hindi sentence pairs |
The model was trained as-is for 100 epochs with hardcoded hyperparameters, without any changes to architecture or training logic.
| Metric | Value |
|---|---|
| Total Training Time | 02h 13m 50s (8030.2s) |
| Epochs | 100 |
| Final Training Loss | 0.0988 |
| BLEU Score (NLTK) | 69.39% |
Sample translations (baseline model):
| English | Hindi (Predicted) |
|---|---|
| I love you. | मुझे तुमसे प्यार है। |
| What is your name? | आपका नाम क्या है? |
| How are you? | आप कैसे हो? |
| The weather is nice today. | आज मौसम अच्छा सा है। |
| Hyperparameter | Search Range | API Used |
|---|---|---|
Learning Rate (lr) | 1e-5 to 1e-3 (log scale) | tune.loguniform() |
Batch Size (batch_size) | [16, 32, 64] | tune.choice() |
Attention Heads (num_heads) | [4, 8] | tune.choice() |
Feedforward Dim (d_ff) | [1024, 2048] | tune.choice() |
Dropout Rate (dropout) | 0.1 to 0.4 | tune.uniform() |
Architecture constants (fixed): d_model=512, num_layers=6
OptunaSearch (metric=loss, mode=min)ASHAScheduler (max_t=25, grace_period=5, reduction_factor=2) — early terminates underperforming trials{
'lr': 0.00011477645445159093, # ~1.15e-4
'batch_size': 32,
'num_heads': 4,
'd_ff': 2048,
'dropout': 0.11420284465820767,
'd_model': 512,
'num_layers': 6,
'num_epochs': 25
}
The best configuration from the sweep was retrained for 50 epochs (half the baseline), yielding:
| Metric | Baseline | Best Config (Ray Tune) |
|---|---|---|
| Training Time | 02h 13m 50s | 63.0 min |
| Epochs | 100 | 50 |
| Final Training Loss | 0.0988 | 0.1564 |
| BLEU Score (NLTK) | 69.39% | 73.70% |
73.70% BLEU in 50 epochs (63 min) vs 69.39% BLEU in 100 epochs (2h 13m)
lr≈1.15e-4 with batch=32 and low dropout (0.114) as a significantly better starting point than the hardcoded defaults; the model converges faster without sacrificing qualityThe rubric states: "Matched Baseline OR exceeded BLEU (0.50) score using ≤ X epochs (X < 100)"
A from-scratch PyTorch Transformer with:
nn.CrossEntropyLoss with <pad> ignored)b23cs1061_ass_4_tuned_en_to_hi.ipynb in Google ColabEnglish-Hindi.tsv in My Drive/