🚀 越南語機器翻譯
本項目提供的模型可用於越南語機器翻譯,藉助先進的架構實現高效準確的翻譯效果,為越南語相關的翻譯工作提供有力支持。
🚀 快速開始
模型描述
T5-vi-en-base 是一個採用 T5 架構設計的用於越南語機器翻譯的 Transformer 模型。
訓練數據
T5-vi-en-base 在 400 萬個句子對(英語 - 越南語)上進行了訓練。
📦 安裝指南
文檔未提及具體安裝步驟,可參考 transformers
庫的官方安裝說明進行安裝。
💻 使用示例
基礎用法
from transformers import T5ForConditionalGeneration, T5Tokenizer
import torch
if torch.cuda.is_available():
device = torch.device("cuda")
print('There are %d GPU(s) available.' % torch.cuda.device_count())
print('We will use the GPU:', torch.cuda.get_device_name(0))
else:
print('No GPU available, using the CPU instead.')
device = torch.device("cpu")
model = T5ForConditionalGeneration.from_pretrained("NlpHUST/t5-vi-en-base")
tokenizer = T5Tokenizer.from_pretrained("NlpHUST/t5-vi-en-base")
model.to(device)
src = "Theo lãnh đạo Sở Y tế, 3 người này không có triệu chứng sốt, ho, khó thở, đã được lấy mẫu xét nghiệm và cách ly tập trung."
tokenized_text = tokenizer.encode(src, return_tensors="pt").to(device)
model.eval()
summary_ids = model.generate(
tokenized_text,
max_length=256,
num_beams=5,
repetition_penalty=2.5,
length_penalty=1.0,
early_stopping=True
)
output = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
print(output)
According to the head of the Department of Health, the three people had no symptoms of fever, cough, shortness of breath, were taken samples for testing and concentrated quarantine.
輸出結果說明
運行上述代碼後,模型會將輸入的越南語句子翻譯成英語並輸出。在這個示例中,輸入的越南語句子 “Theo lãnh đạo Sở Y tế, 3 người này không có triệu chứng sốt, ho, khó thở, đã được lấy mẫu xét nghiệm và cách ly tập trung.” 被翻譯成 “According to the head of the Department of Health, the three people had no symptoms of fever, cough, shortness of breath, were taken samples for testing and concentrated quarantine.”。