Downloads · 30 days
0
aashish6969/wmt26-hymt2-finetuned
wmt26-hymt2-finetuned is a translation model from aashish6969. Use it when you need text moved from one language to another. The card lists the license as apache-2.0.
QLoRA fine-tune of tencent/Hy-MT2-1.8B on TVsub for the WMT26 Video Subtitle Translation shared task (Chinese → English).
Downloads · 30 days
0
Access
Public
Updated Sep 11, 2026
Repo size
431 MB
Likes
0
Public
Click a slice to open those files.
.en226 MB · 43%
From the Hugging Face model README
QLoRA fine-tune of tencent/Hy-MT2-1.8B on TVsub for the WMT26 Video Subtitle Translation shared task (Chinese → English).
This repository is the full source of truth: LoRA adapter weights, tokenizer files, chat template, the three working notebooks (scripts/), the scored test outputs (test_results/), and a vendored copy of the TVsub data used (tvsub/).
| Path | Description |
|---|---|
.gitattributes | Git LFS tracking (includes *.safetensors, so adapter_model.safetensors is stored via LFS) |
adapter_config.json | PEFT/LoRA adapter config (verified: r=16, lora_alpha=32, lora_dropout=0.05, targets q/k/v/o/gate/up/down_proj, task_type=CAUSAL_LM, base tencent/Hy-MT2-1.8B) |
adapter_model.safetensors | LoRA adapter weights (Git LFS) |
tokenizer.json / tokenizer_config.json / special_tokens_map.json | Tokenizer (BOS <|hy_begin▁of▁sentence|>, EOS <|hy_place▁holder▁no▁2|>, PAD <|hy_▁pad▁|>) |
chat_template.jinja | Chat template applied via tokenizer.apply_chat_template (<|hy_User|> / <|hy_Assistant|> roles) |
scripts/Hy-MT2-1_8B_train_r16_α32.ipynb | QLoRA training notebook (single code cell; defines CFG, data prep, 4-bit training loop, dev sacreBLEU early stopping) |
scripts/evaluate_hymt2_tvsub.ipynb | Evaluation notebook (single code cell; argparse-driven, defaults below) |
scripts/inference.ipynb | SRT subtitle-translation notebook (single code cell; context-aware prompt with video/album metadata, batch SRT read/write) |
test_results/test_hypotheses.txt | 200 model output lines on the TVsub processed test split |
test_results/test_hypotheses.metrics.json | sacreBLEU, chrF, TER, BLEU for those 200 hypotheses |
tvsub/ | Vendored TVsub checkout used for training/eval |
tvsub/README.md | Upstream TVsub corpus documentation |
tvsub/img/data_details.png | Upstream corpus illustration |
tvsub/data/orignal/{dev,test,train}/ | Upstream original splits (dev.orignal.{en,zh}, test.orignal.{en,zh}, train.{en,zh} plus train/separated/ per-episode files) |
tvsub/data/processed/{dev,test,train}/ | Processed splits consumed by the notebooks (dev_src, dev_trg.sgm, test_src, test_trg.sgm, train.{zh,en,dp.zh,dp.en}, dev_oracle_dp_src, test_{auto,oracle}_dp_src) |
There is no requirements.txt, pyproject.toml, test suite, CI config, or Codespaces/devcontainer config in this repo — the notebooks are the runnable code.
torch.cuda.is_bf16_supported(), otherwise FP16 with GradScaler; CPU-only will work but slowly).adapter_model.safetensors).!pip install lines):
torch>=2.3.0 (CUDA cu121 index)transformers>=4.44.0,<5.0.0, accelerate>=0.33.0, peft>=0.12.0bitsandbytes>=0.43.3, datasets>=2.20.0, sentencepiece>=0.2.0, protobuf>=4.25.0sacrebleu[ja]>=2.4.3, evaluate>=0.4.2, tokenizers>=0.19.1einops>=0.8.0, safetensors>=0.4.3, tqdm>=4.66.0, tabulate>=0.9.0, psutil>=6.0.0git lfs install
git clone https://huggingface.co/aashish6969/wmt26-hymt2-finetuned
cd wmt26-hymt2-finetuned
pip install -q --upgrade pip
pip install -q "transformers>=4.44.0,<5.0.0" "accelerate>=0.33.0" "peft>=0.12.0" \
"bitsandbytes>=0.43.3" "datasets>=2.20.0" "sentencepiece>=0.2.0" "protobuf>=4.25.0" \
"sacrebleu[ja]>=2.4.3" "evaluate>=0.4.2" "tokenizers>=0.19.1" \
"einops>=0.8.0" "safetensors>=0.4.3" "tqdm>=4.66.0" "tabulate>=0.9.0" "psutil>=6.0.0"
pip install -q "torch>=2.3.0" --index-url https://download.pytorch.org/whl/cu121 || true
The training notebook clones https://github.com/longyuewangdcu/tvsub.git into tvsub/ if that directory is missing; this repo already vendors that directory, so no extra download is needed.
Training defaults (CFG in scripts/Hy-MT2-1_8B_train_r16_α32.ipynb):
| Parameter | Value |
|---|---|
| Base model | tencent/Hy-MT2-1.8B |
| Output dir | hymt2_qlora_out |
| Data root | tvsub (expects data/processed/{train.zh,train.en,dev_src,dev_trg.sgm,test_src,test_trg.sgm}) |
| Direction | Chinese → English |
| Length caps | max_src_len=256, max_tgt_len=256, max_total_len=640 |
| Samples | train_samples=60000, val_samples=500, test_samples=200 |
| Batching | batch_size=4 train, eval_batch_size=4, grad_accum=8 |
| Epochs | 3, early stop on dev sacreBLEU (patience=2, min_delta=0.05) |
| Optimizer | bitsandbytes PagedAdamW8bit, fallback to torch AdamW; cosine LR, lr=2e-4, warmup_ratio=0.03, weight_decay=0.0, max_grad_norm=1.0 |
| Quantization | 4-bit NF4 with double quantization (BitsAndBytesConfig) |
| LoRA | r=16, alpha=32, dropout=0.05, targets q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj |
| Generation (eval) | max_new_tokens=160, num_beams=4, repetition_penalty=1.15, no_repeat_ngram_size=3 |
Evaluation defaults (parse_args in scripts/evaluate_hymt2_tvsub.ipynb):
--base_model tencent/Hy-MT2-1.8B, --adapter_dir hymt2_qlora_out/best, --data_root tvsub, --src_lang Chinese, --tgt_lang English, --num_pairs 200, --batch_size 8, --max_new_tokens 160, --num_beams 4, --repetition_penalty 1.15, --no_repeat_ngram_size 3, --out_file test_hypotheses.txt, optional --load_in_4bit.
SRT inference defaults (CFG in scripts/inference.ipynb):
model_name=tencent/Hy-MT2-1.8B, adapter_path=hymt2_qlora_out/best, data_root=wmt26_video_subtitle_translation_testset, output_dir=translated_subtitles, batch_size=16, max_new_tokens=160, num_beams=4. It reads *_zh.srt + *_metadata.json files and writes translated SRTs.
Set by the notebooks (all optional overrides):
TOKENIZERS_PARALLELISM=falsePYTHONWARNINGS=ignorePYTORCH_CUDA_ALLOC_CONF=expandable_segments:True (training)BITSANDBYTES_NOWELCOME=1, HF_HUB_DISABLE_TELEMETRY=1, TRANSFORMERS_VERBOSITY=error, TRANSFORMERS_NO_ADVISORY_WARNINGS=1, DATASETS_VERBOSITY=error (evaluation)MT_EVAL_DEBUG=1 — set to 0 to silence [DEBUG] logging in the evaluation notebookTranslate the following text into {tgt_lang}. Note that you must ONLY output the translated result without any additional explanation:\n\n{src} (labels mask prompt positions with -100, so only target tokens train).Context:\nVideo Title: …\nAlbum Title: …\nDescription: … before the same translation instruction.parse_sgm_multiref parses each <DOC> independently and offsets segment IDs, because dev/test SGM files contain two documents (SUB01, SUB02) that both restart numbering at 1.Load the adapter locally (the notebooks use the same pattern):
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
base_model = AutoModelForCausalLM.from_pretrained(
"tencent/Hy-MT2-1.8B",
torch_dtype=torch.bfloat16,
attn_implementation="sdpa",
trust_remote_code=True,
device_map="auto",
)
model = PeftModel.from_pretrained(base_model, ".") # this repo root holds adapter + tokenizer
model.eval()
tokenizer = AutoTokenizer.from_pretrained(".", trust_remote_code=True)
prompt = (
"Translate the following text into English. Note that you must ONLY "
"output the translated result without any additional explanation:\n\n"
"你好,世界"
)
msgs = [{"role": "user", "content": prompt}]
inputs = tokenizer.apply_chat_template(msgs, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
output = model.generate(inputs, max_new_tokens=160, num_beams=4)
print(tokenizer.decode(output[0][inputs.shape[-1]:], skip_special_tokens=True))
Run a notebook (each is one code cell; convert to a script if preferred):
jupyter nbconvert --to notebook --execute scripts/evaluate_hymt2_tvsub.ipynb --output /tmp/eval_out.ipynb
# or: jupyter nbconvert --to script scripts/evaluate_hymt2_tvsub.ipynb && python evaluate_hymt2_tvsub.py --help
max_new_tokens=160, num_beams=4, do_sample=False, temperature=1.0, repetition_penalty=1.15, no_repeat_ngram_size=3 (per the eval/inference defaults; temperature is listed for completeness since sampling is off).
test_results/test_hypotheses.metrics.json (200 hypotheses in test_hypotheses.txt, scored with sacrebleu tokenize="13a", smooth_method="exp" for sacreBLEU/chrF/TER plus Hugging Face evaluate for BLEU):
| Metric | Value |
|---|---|
| BLEU | 38.55919333186924 |
| sacreBLEU | 37.631053247048335 |
| chrF | 52.758047970086196 |
| TER | 53.933278418451394 |
Apache 2.0 (see base_model front-matter above; upstream TVsub data under tvsub/ follows its own tvsub/README.md).