Downloads · 30 days
43
20% of all-time downloads
verisbaby/vinai-translate-en2vi-v2-medev-lora
vinai-translate-en2vi-v2-medev-lora is a translation model from verisbaby. Use it when you need text moved from one language to another. It is set up for peft. The card lists the license as agpl-3.0.
A LoRA adapter that fine-tunes vinai/vinai-translate-en2vi-v2 (mBART, 448M) on the MedEV medical parallel corpus for English→Vietnamese medical translation Dataset.
Downloads · 30 days
43
20% of all-time downloads
All-time downloads
218
Public
Repo size
18.9 MB
Likes
2
Public
Click a slice to open those files.
.safetensors18.9 MB · 82%
From the Hugging Face model README
A LoRA adapter that fine-tunes vinai/vinai-translate-en2vi-v2
(mBART, 448M) on the MedEV medical parallel corpus for English→Vietnamese medical translation Dataset.
🌸🌸🌸
Một bộ chuyển đổi LoRA tinh chỉnh vinai/vinai-translate-en2vi-v2
(mBART, 448M) trên Bộ dữ liệu song ngữ y tế MedEV dành cho dịch thuật y tế tiếng Anh→tiếng Việt.
This is the adapter only (~25 MB). Load it on top of the official base model, the base is not redistributed here.
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 |
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) | 45.40 |
vinai-translate-en2vi-v2 + MedEV LoRA (this adapter) | 46.74 |
| Δ - effect of the adapter (tác dụng của adapter) | +1.34 |
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 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ẻ.)
import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
from peft import PeftModel
BASE = "vinai/vinai-translate-en2vi-v2"
ADAPTER = "verisbaby/vinai-translate-en2vi-v2-medev-lora" # HF repo id, or a local folder path
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.float16 if device == "cuda" else torch.float32
# 1) tokenizer: source English, target Vietnamese
tok = AutoTokenizer.from_pretrained(BASE, src_lang="en_XX")
tok.tgt_lang = "vi_VN"
# 2) base model — clear the forced language ids it ships with BEFORE attaching the adapter
model = AutoModelForSeq2SeqLM.from_pretrained(BASE, torch_dtype=dtype)
for attr in ("decoder_start_token_id", "forced_bos_token_id"):
if getattr(model.config, attr, None) is not None:
setattr(model.config, attr, None)
# 3) attach the LoRA adapter
model = PeftModel.from_pretrained(model, ADAPTER).to(device).eval()
vi_id = tok.convert_tokens_to_ids("vi_VN") # force Vietnamese as the first generated token
@torch.inference_mode()
def translate(text: str) -> str:
enc = tok(text, return_tensors="pt", padding=True, truncation=True, max_length=384).to(device)
out = model.generate(
**enc,
decoder_start_token_id=vi_id, forced_bos_token_id=vi_id,
num_beams=5, no_repeat_ngram_size=3, encoder_no_repeat_ngram_size=3,
repetition_penalty=1.2, max_length=384, early_stopping=True,
)
return tok.batch_decode(out, skip_special_tokens=True)[0].strip()
print(translate("Pleural effusion is observed in the right lung base."))
# 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):
@torch.inference_mode()
def translate_many(texts, batch_size=8):
results = []
for i in range(0, len(texts), batch_size):
chunk = texts[i:i+batch_size]
enc = tok(chunk, return_tensors="pt", padding=True, truncation=True, max_length=384).to(device)
out = model.generate(
**enc, decoder_start_token_id=vi_id, forced_bos_token_id=vi_id,
num_beams=5, no_repeat_ngram_size=3, encoder_no_repeat_ngram_size=3,
repetition_penalty=1.2, max_length=384, early_stopping=True,
)
results.extend(s.strip() for s in tok.batch_decode(out, skip_special_tokens=True))
return 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_idon the base config beforePeftModel.from_pretrained, and thatADAPTERpoints to the folder containingadapter_config.json.
vinai/vinai-translate-en2vi-v2 (mBART-large, 448M; src_lang=en_XX, tgt_lang=vi_VN)num_beams=5, no_repeat_ngram_size=3,
encoder_no_repeat_ngram_size=3, repetition_penalty=1.2LoRA 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"]
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:
@inproceedings{vinaitranslate,
title = {{A Vietnamese-English Neural Machine Translation System}},
author = {Thien Hai Nguyen and Tuan-Duy H. Nguyen and Duy Phung and
Duy Tran-Cong and Hieu Minh Tran and Manh Luong and
Tin Duy Vo and Hung Hai Bui and Dat Quoc Nguyen},
booktitle = {Proceedings of INTERSPEECH},
year = {2022}
}
@misc{vimed_medev_lora,
title = {MedEV LoRA adapter for vinai-translate-en2vi-v2 (English-Vietnamese medical translation)},
author = {Tran Thi The Nhan},
year = {2026},
note = {Part of the ViMed Vietnamese Medical VQA project},
url = {https://huggingface.co/verisbaby/vinai-translate-en2vi-v2-medev-lora}
}