CoolFace
Modelpublic

orozcohsu/translation_zh_en

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes7downloads
Model Card

中文 ➔ 英文 機器翻譯模型 (Fine-tuned Transformer)

📚 模型簡介

本模型基於 Helsinki-NLP/opus-mt-zh-en 預訓練權重,針對 繁體中文 ➔ 英文翻譯任務進行微調。 使用 Hugging Face transformers 庫完成訓練,並以 BLEU 分數作為主要評估指標。


🔧 訓練資訊

  • —基礎模型:Helsinki-NLP/opus-mt-zh-en
  • —資料來源:自定義資料集,包含繁體中文輸入與英文翻譯目標
  • —Tokenization:自動使用對應 checkpoint 的 tokenizer
  • —最大輸入長度:128
  • —訓練方式:使用 Seq2SeqTrainer 完成微調
  • —訓練週期(epochs):1
  • —學習率(learning rate):2e-5
  • —Batch size:8(訓練與驗證)
  • —保存策略:每500步保存checkpoint,最多保留3個

📝 評估方式

  • —指標:BLEU 分數 (使用 sacrebleu)
  • —其他設定:
  • —predict_with_generate=True(生成翻譯以供評分)
  • —取100筆小型測試集進行快速驗證
  • —使用單束(num_beams=1)生成

📂 輸出結果

  • —訓練過程紀錄於 training_log.csv
  • —完整保存模型及 tokenizer 至 ./results/transformer_v1
  • —支援直接載入推論 (inference)

⚡ 推理示範

python
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

model = AutoModelForSeq2SeqLM.from_pretrained("./results/transformer_v1")
tokenizer = AutoTokenizer.from_pretrained("./results/transformer_v1")

inputs = tokenizer("外出要小心注意安全", return_tensors="pt")
outputs = model.generate(**inputs)
translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(translated_text)