Downloads · 30 days
7
9% of all-time downloads
ayeshasadiq025/nllb-medical-ablation-masked
nllb-medical-ablation-masked 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 the ablation variant of ayeshasadiq025/nllb-medical-clinical. Both models share the exact same architecture and hyperparameters — the only difference is the training input:
Downloads · 30 days
7
9% of all-time downloads
All-time downloads
74
Public
Repo size
37 MB
Likes
0
Public
Click a slice to open those files.
.json32.2 MB · 87%
From the Hugging Face model README
This model is the ablation variant of ayeshasadiq025/nllb-medical-clinical. Both models share the exact same architecture and hyperparameters — the only difference is the training input:
| Baseline (nllb-medical-clinical) | This model (ablation) | |
|---|---|---|
| Training input | Raw english_text | masked_english_text — medical entities replaced with [MEDICAL_TERM], [DISEASE], [DRUG_CHEMICAL] tags |
| Architecture | NLLB-200-distilled-600M + LoRA | NLLB-200-distilled-600M + LoRA (identical) |
| Hyperparameters | Identical | Identical |
The ablation study was designed to answer: does replacing medical entity names with placeholder tokens before translation help or hurt the model?
Result: the baseline (raw text, no masking) outperformed this masked variant — confirming that entity masking hurt translation quality by preventing the model from learning to produce actual Urdu medical terminology.
eng_Latn) → Urdu (urd_Arab)This model is an ablation/research variant — not the production model.
It was trained on masked input text (medical entities replaced with placeholder tokens). At inference time, you must also mask the input in the same way before passing it to this model — otherwise outputs will be unpredictable.
For standard use, please use ayeshasadiq025/nllb-medical-clinical which was trained on raw text and gives better results.
Research and comparison purposes only. This model demonstrates the effect of entity masking on translation quality for low-resource medical NLP.
masked_english_text. If you pass raw text without applying the entity masking preprocessing step, outputs will be lower quality.⚠️ You must apply entity masking to your input text before passing it to this model.
import re
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import torch
model_name = "ayeshasadiq025/nllb-medical-ablation-masked"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name, torch_dtype=torch.float16)
model.eval()
device = "cuda" if torch.cuda.is_available() else "cpu"
model = model.to(device)
# Required: entity masking preprocessing (same as used during training)
import spacy
nlp = spacy.load("en_core_web_sm")
def mask_medical_entities(text: str) -> str:
"""Replace medical entities with placeholder tokens — must match training preprocessing."""
doc = nlp(text)
masked = text
for ent in reversed(doc.ents):
if ent.label_ in ["DISEASE", "CHEMICAL", "DRUG", "ORG"]:
masked = masked[:ent.start_char] + "[MEDICAL_TERM]" + masked[ent.end_char:]
return masked
def translate(text: str) -> str:
# Step 1: apply entity masking
masked_text = mask_medical_entities(text)
# Step 2: tokenize and translate
inputs = tokenizer(
masked_text,
return_tensors="pt",
max_length=128,
truncation=True
).to(device)
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)
text = "Patient was diagnosed with acute myocardial infarction."
print(translate(text))
Same 12,500-sentence parallel corpus as the baseline model, but using the masked_english_text column (medical entities replaced with placeholder tokens during spaCy NER preprocessing):
| Split | Sentences |
|---|---|
| Train | 10,000 (80%) |
| Validation | 1,250 (10%) |
| Test | 1,250 (10%) |
The key difference from the baseline model:
en_core_web_sm used to detect medical entities (diseases, chemicals, drugs, procedures)[DISEASE][DRUG_CHEMICAL][MEDICAL_TERM]Identical to the baseline model nllb-medical-clinical:
| 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 |
| 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 |
| Weight decay | 0.01 |
| Training hardware | Google Colab T4 GPU |
The ablation study evaluated both variants on the same 100-sentence held-out test sample (random_state=42). Results confirmed that entity masking hurt performance — the baseline without masking was consistently better:
| Variant | BLEU ↑ | ROUGE-L ↑ | Medical Acc (%) ↑ | Finding |
|---|---|---|---|---|
| No masking — baseline (nllb-medical-clinical) | 76.02 | 16.82 | 17.5 | ✅ Better |
| With masking — this model | 26.5 | 3.5 | 2.8 | ❌ Worse |
Why did masking hurt?
The original hypothesis was that masking medical entity names before translation would help preserve them in the Urdu output. In practice, the opposite occurred — when the model was trained on text with placeholder tokens ([MEDICAL_TERM], [DISEASE]), it learned to produce those placeholders in the Urdu output instead of actual Urdu medical terms. This reduced both fluency and faithfulness of translations.
The baseline model, trained on raw text with full medical entity names, learned to directly map English medical terms to their Urdu equivalents — producing more natural and medically accurate output.
The ablation study established that for NLLB-200+LoRA fine-tuning on this dataset, raw (non-masked) input text produces better medical translation quality than entity-masked input. This is an important empirical finding for medical NLP practitioners considering entity masking as a preprocessing strategy for low-resource translation.
Identical to the baseline:
facebook/nllb-200-distilled-600M — 600M parameter multilingual seq2seq Transformerq_proj and v_proj attention layers (encoder + decoder)AutoModelForSeq2SeqLM APItransformers
peft
torch
spacy (en_core_web_sm — for input masking at inference)
sentencepiece
protobuf
sacrebleu
bert-score
rouge_score
datasets
@misc{sadiq2026nllbablation,
title = {Ablation Study: Effect of Medical Entity Masking on NLLB-200+LoRA English-to-Urdu Translation},
author = {Ayesha Sadiq},
year = {2026},
institution = {Sindh Madressatul Islam University (SMIU), Karachi},
note = {BSE-25S-007. Supervised by Amin Chhajro. Ablation variant of https://huggingface.co/ayeshasadiq025/nllb-medical-clinical}
}
Ayesha Sadiq — Department of Software Engineering, SMIU, Karachi Supervisor: Sir Amin Chhajro
HuggingFace: ayeshasadiq025