Downloads · 30 days
4
3% of all-time downloads
ayeshasadiq025/nllb-medical-clinical
nllb-medical-clinical is a translation model from ayeshasadiq025. Use it when you need text moved from one language to another. It is set up for peft. The card lists the license as apache-2.0.
This model is a domain-adapted version of facebook/nllb-200-distilled-600M, fine-tuned using LoRA (Low-Rank Adaptation) for medical English-to-Urdu translation. It was developed as part of a student research project a…
Downloads · 30 days
4
3% of all-time downloads
All-time downloads
141
Public
Parameters
615M
2.5 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors2.5 GB · 99%
From the Hugging Face model README
This model is a domain-adapted version of facebook/nllb-200-distilled-600M, fine-tuned using LoRA (Low-Rank Adaptation) for medical English-to-Urdu translation. It was developed as part of a student research project at Sindh Madressatul Islam University (SMIU), Karachi, to address the challenge of safely translating clinical and biomedical text into Urdu for Pakistani patients and healthcare workers.
The LoRA adapters were merged into the base model weights before uploading, so this model loads and runs like a standard AutoModelForSeq2SeqLM — no PEFT library required at inference time.
eng_Latn) → Urdu (urd_Arab)This model is intended for translating English medical and clinical text into Urdu. It is best suited for:
The model can be integrated into healthcare applications, clinical decision-support tools, or patient communication portals where English medical content needs to be made accessible to Urdu speakers.
Users should treat all outputs as a starting point requiring human review, especially in clinical or patient-facing contexts. Medical professionals fluent in both English and Urdu should validate translations before use.
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import torch
model_name = "ayeshasadiq025/nllb-medical-clinical"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name, torch_dtype=torch.float16)
model.eval()
# Move to GPU if available
device = "cuda" if torch.cuda.is_available() else "cpu"
model = model.to(device)
def translate(text: str) -> str:
inputs = tokenizer(
text,
return_tensors="pt",
max_length=128,
truncation=True
).to(device)
# Force Urdu Arabic script as target language
target_lang_id = tokenizer.convert_tokens_to_ids("urd_Arab")
with torch.no_grad():
outputs = model.generate(
**inputs,
forced_bos_token_id=target_lang_id,
max_new_tokens=128,
num_beams=4,
early_stopping=True
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# Example
text = "Patient presented with acute myocardial infarction and elevated troponin levels."
print(translate(text))
# → مریض شدید مایوکارڈیل انفارکشن اور بلند ٹراپونن سطح کے ساتھ پیش ہوا۔
The model was fine-tuned on a custom 12,500-sentence parallel corpus of English–Urdu medical text:
| Split | Sentences |
|---|---|
| Train | 10,000 (80%) |
| Validation | 1,250 (10%) |
| Test | 1,250 (10%) |
Data sources:
medical_parallel_dataset.csv with two columns: english_text and urdu_textBefore tokenization, the following preprocessing pipeline was applied to the English source text:
en_core_web_sm model was used to detect biomedical entities (diseases, drugs, procedures, etc.)[MEDICAL_TERM], [DISEASE], [DRUG_CHEMICAL]) to prevent subword tokenization from fragmenting critical clinical terms — the unmasked variant (this model) was trained on raw expanded text; the masked variant is available as nllb-medical-ablation-masked| Parameter | Value |
|---|---|
| Base model | facebook/nllb-200-distilled-600M |
| Fine-tuning method | LoRA (PEFT) |
| LoRA rank (r) | 8 |
| LoRA alpha | 32 |
| LoRA target modules | q_proj, v_proj |
| LoRA dropout | 0.1 |
| Trainable parameters | ~4.1M (LoRA adapters only) |
| Optimizer | Adafactor |
| Learning rate | 1e-4 |
| Training epochs | 3 |
| Per-device batch size | 1 |
| Gradient accumulation steps | 16 (effective batch size = 16) |
| Mixed precision | FP16 |
| Max sequence length | 128 tokens |
| Gradient checkpointing | Enabled |
| Max gradient norm | 1.0 |
| Weight decay | 0.01 |
| Training hardware | Google Colab T4 GPU |
| Epoch | Training Loss | Validation Loss |
|---|---|---|
| 1 | 10.834 | 0.576 |
| 2 | 9.401 | 0.444 |
| 3 | 9.236 | 0.535 |
Validation loss reached its lowest at Epoch 2 (0.444), with a slight uptick at Epoch 3 — consistent with the model approaching convergence on this domain-specific dataset.
Evaluation was performed on a fixed random sample of 100 sentences from the 1,250-sentence held-out test split (random_state=42 for reproducibility). All three models in the project were evaluated on the same 100 sentences for a fair comparison.
| Metric | Description |
|---|---|
| BLEU | Character-level corpus BLEU via SacreBLEU (tokenize="char") — suitable for Urdu script without word-segmentation assumptions |
| ROUGE-L | Character-level ROUGE Longest Common Subsequence F-measure |
| BERTScore | Contextual embedding similarity using multilingual BERT (lang="ur") — captures semantic similarity beyond surface match |
| Medical Accuracy | Percentage of English medical entities (detected by spaCy NER) that appear in the Urdu output |
| Human Acceptance Rate | Percentage of translations rated ≥ 3/5 by two independent human evaluators |
This model (NLLB + LoRA) achieved the best results across all metrics compared to the other two models in the project (mT5 full fine-tune and BioBERT + custom decoder):
| Model | BLEU ↑ | ROUGE-L ↑ | BERTScore ↑ | Medical Acc (%) | Human Acceptance |
|---|---|---|---|---|---|
| NLLB + LoRA (this model) | 76.02 | 16.82 | 91.56 | 17.5 | 92.0% |
| mT5 Fine-tuned | 64.65 | 14.48 | 89.08 | 17.5 | 84.0% |
| BioBERT + Decoder | 34.59 | 1.00 | 77.84 | 0.0 | — |
Human evaluation (inter-rater agreement):
Two evaluators independently rated 100 translations on a 1–5 scale. Cohen's Kappa for this model was 0.730 (substantial agreement per Landis & Koch 1977). A paired Wilcoxon signed-rank test confirmed the difference between NLLB+LoRA and mT5 was statistically significant.
NLLB-200+LoRA outperformed both fine-tuned mT5 and the custom BioBERT+Decoder architecture on all automatic metrics and human evaluation. The result supports the hypothesis that a multilingual translation-focused base model (NLLB) with lightweight LoRA domain adaptation is more effective for low-resource medical translation than either full fine-tuning of a general multilingual model or a biomedical encoder with a custom decoder.
An ablation study compared this model (trained on raw expanded text) against a variant trained on entity-masked text (where medical terms were replaced with placeholder tokens before translation). See nllb-medical-ablation-masked for the masked variant.
The ablation confirmed that training on raw (non-masked) text produced better BLEU and BERTScore results — masking medical entities before translation caused the model to learn to reproduce placeholder tokens rather than actual Urdu medical terms.
Training was performed on a Google Colab free-tier T4 GPU.
facebook/nllb-200-distilled-600M — a distilled 600M-parameter multilingual seq2seq Transformer supporting 200 languagesq_proj and v_proj attention projection layers in both encoder and decoderAutoModelForSeq2SeqLM API, no PEFT dependency neededtransformers
peft
torch
accelerate
sentencepiece
protobuf
sacrebleu
bert-score
rouge_score
datasets
If you use this model in your work, please cite:
@misc{sadiq2026nllbmedicalurdu,
title = {Domain-Specific Medical English to Urdu Translation Using NLLB-200 and LoRA},
author = {Ayesha Sadiq},
year = {2026},
institution = {Sindh Madressatul Islam University (SMIU), Karachi},
note = {BSE-25S-007. Supervised by Amin Chhajro. Model available at https://huggingface.co/ayeshasadiq025/nllb-medical-clinical}
}
Ayesha Sadiq — Department of Software Engineering, SMIU, Karachi Supervisor: Sir Amin Chhajro
HuggingFace: ayeshasadiq025