This is the adapter only (~25 MB). Load it on top of the official base model, the base is not
redistributed here.
What it improves (Nó cải thiện điều gì?)
The base VinAI model is strong on general Vietnamese↔English text but under-performs on clinical
language (radiology findings, disease names, anatomical terms). Fine-tuning on MedEV adapts it to the
medical domain while keeping the base model's fluency.
BLEU on medical test data
Base vinai-translate-en2vi-v2
48.63
+ MedEV LoRA (this adapter)
51.16
Results of Base vs. Base + MedEV LoRA (Kết quả: Base so với Base + MedEV LoRA)
Both rows use the same base model vinai-translate-en2vi-v2; the only difference is whether the
MedEV LoRA adapter is attached. Same MedEV test set (N = 500), same decoding (beam = 5),
sacreBLEU. Hai dòng dùng cùng một mô hình nền; khác biệt duy nhất là có gắn adapter LoRA hay không.
Configuration (Cấu hình)
BLEU
vinai-translate-en2vi-v2 (base only / chỉ mô hình nền)
The MedEV LoRA adapter improves corpus-level BLEU by +1.34 which is a small but real domain-adaptation
gain, in line with what LoRA fine-tuning typically yields. BLEU correlates with human judgement at the
corpus level, not on single sentences, so the 500-sentence score above (not any individual example)
is the valid comparison.
What is "Reference" (REF)?"Reference" (REF) là bản dịch chuẩn do con người viết sẵn,
đi kèm tập kiểm thử MedEV. BLEU chấm điểm bằng cách đo mức trùng lặp chuỗi từ (n-gram) giữa bản dịch của
mô hình và bản REF này. (The reference is the human translation shipped with the test set;
BLEU measures n-gram overlap between a model's output and this reference. Note that MedEV references are
sometimes loose/non-literal (see Example 2 below), which is normal for human translation)
Example translations (Ví dụ dịch)
Example 1
Text
English
The value of vaporesection for managing benign prostatic hyperplasia using a thulium 2-µm continuous-wave laser
Base
Giá trị của phương pháp tán hơi trong điều trị tăng sinh lành tính tuyến tiền liệt bằng laser sóng liên tục thulium 2 m
+ MedEV LoRA
Giá trị của cắt đốt nội soi điều trị tăng sinh lành tính tuyến tiền liệt bằng laser thulium 2 - m
Reference (human)
Giá trị laser thulium trong điều trị ngoại khoa tăng sinh lành tính tuyến tiền liệt
The adapter renders the procedure as "cắt đốt nội soi" (a surgical resection sense) rather than the
literal "tán hơi", closer to the clinical intent. (Adapter dịch sát ý lâm sàng hơn.)
Example 2
Text
English
The records of all patients, including data on epidemiology, clinical features, laboratory and treatment informations, were obtained and analyzed.
Base
Hồ sơ của tất cả các bệnh nhân, bao gồm dữ liệu về dịch tễ học, lâm sàng, cận lâm sàng và điều trị, được thu thập và phân tích.
+ MedEV LoRA
Tất cả bệnh nhân được thu thập và phân tích các dữ liệu về dịch tễ học, lâm sàng, cận lâm sàng và điều trị.
Reference (human)
Các số liệu của bệnh nhi, bao gồm đặc điểm dịch tễ, lâm sàng, cận lâm sàng, và điều trị, được thu thập và phân tích.
Here the human reference even says "bệnh nhi" (pediatric patients), which is not in the English source,
illustrating why single-sentence BLEU is unreliable and why the corpus score is the metric to trust.
(Bản tham chiếu của con người còn ghi "bệnh nhi" dù tiếng Anh không có, cho thấy vì sao không nên đánh giá
bằng từng câu lẻ.)
Evaluation notes (Ghi chú đánh giá)
BLEU is a corpus-level metric; do not judge model quality from individual sentences.
For a clinical application, consider also reporting COMET (better human-correlation) and a small
human evaluation of clinical-term accuracy. Nên bổ sung COMET và đánh giá thủ công bởi chuyên gia.
Usage
python
1import torch
2from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3from peft import PeftModel
45BASE ="vinai/vinai-translate-en2vi-v2"6ADAPTER ="verisbaby/vinai-translate-en2vi-v2-medev-lora"# HF repo id, or a local folder path78device ="cuda"if torch.cuda.is_available()else"cpu"9dtype = torch.float16 if device =="cuda"else torch.float32
1011# 1) tokenizer: source English, target Vietnamese12tok = AutoTokenizer.from_pretrained(BASE, src_lang="en_XX")13tok.tgt_lang ="vi_VN"1415# 2) base model — clear the forced language ids it ships with BEFORE attaching the adapter16model = AutoModelForSeq2SeqLM.from_pretrained(BASE, torch_dtype=dtype)17for attr in("decoder_start_token_id","forced_bos_token_id"):18ifgetattr(model.config, attr,None)isnotNone:19setattr(model.config, attr,None)2021# 3) attach the LoRA adapter22model = PeftModel.from_pretrained(model, ADAPTER).to(device).eval()2324vi_id = tok.convert_tokens_to_ids("vi_VN")# force Vietnamese as the first generated token2526@torch.inference_mode()27deftranslate(text:str)->str:28 enc = tok(text, return_tensors="pt", padding=True, truncation=True, max_length=384).to(device)29 out = model.generate(30**enc,31 decoder_start_token_id=vi_id, forced_bos_token_id=vi_id,32 num_beams=5, no_repeat_ngram_size=3, encoder_no_repeat_ngram_size=3,33 repetition_penalty=1.2, max_length=384, early_stopping=True,34)35return tok.batch_decode(out, skip_special_tokens=True)[0].strip()3637print(translate("Pleural effusion is observed in the right lung base."))38# expected Vietnamese with diacritics, e.g. "Tràn dịch màng phổi được quan sát thấy ở đáy phổi phải."
Batch translation (faster for many sentences):
python
1@torch.inference_mode()2deftranslate_many(texts, batch_size=8):3 results =[]4for i inrange(0,len(texts), batch_size):5 chunk = texts[i:i+batch_size]6 enc = tok(chunk, return_tensors="pt", padding=True, truncation=True, max_length=384).to(device)7 out = model.generate(8**enc, decoder_start_token_id=vi_id, forced_bos_token_id=vi_id,9 num_beams=5, no_repeat_ngram_size=3, encoder_no_repeat_ngram_size=3,10 repetition_penalty=1.2, max_length=384, early_stopping=True,11)12 results.extend(s.strip()for s in tok.batch_decode(out, skip_special_tokens=True))13return results
Sanity check: the output should contain Vietnamese diacritics. If it comes back as English or
garbled, the adapter did not attach, make sure you cleared decoder_start_token_id / forced_bos_token_id
on the base config beforePeftModel.from_pretrained, and that ADAPTER points to the folder
containing adapter_config.json.
LoRA config (from the training run):
r = 16
lora_alpha = 32
lora_dropout = 0.1
bias = "none"
task_type = SEQ_2_SEQ_LM
target_modules = ["q_proj", "k_proj", "v_proj", "out_proj"]
Intended use & limitations
Use: assisting English→Vietnamese translation of medical text (radiology reports, findings,
disease names) for research and tooling.
Not for: unsupervised clinical decision-making. Machine translation can mistranslate clinical
terms; a qualified human should review medical output. The model can hallucinate on long inputs,
use the decoding settings above and validate outputs.
License & attribution
Released under AGPL-3.0, inherited from the base model vinai/vinai-translate-en2vi-v2.
If you serve this model over a network, AGPL-3.0 §13 requires you to offer users the complete
corresponding source code.
Please cite the VinAI Translate paper when using this model:
bibtex
1@inproceedings{vinaitranslate,
2 title = {{A Vietnamese-English Neural Machine Translation System}},
3 author = {Thien Hai Nguyen and Tuan-Duy H. Nguyen and Duy Phung and
4 Duy Tran-Cong and Hieu Minh Tran and Manh Luong and
5 Tin Duy Vo and Hung Hai Bui and Dat Quoc Nguyen},
6 booktitle = {Proceedings of INTERSPEECH},
7 year = {2022}
8}
Citation for this adapter
bibtex
1@misc{vimed_medev_lora,
2 title = {MedEV LoRA adapter for vinai-translate-en2vi-v2 (English-Vietnamese medical translation)},
3 author = {Tran Thi The Nhan},
4 year = {2026},
5 note = {Part of the ViMed Vietnamese Medical VQA project},
6 url = {https://huggingface.co/verisbaby/vinai-translate-en2vi-v2-medev-lora}
7}