🚀 越南语机器翻译
本项目提供的模型可用于越南语机器翻译,借助先进的架构实现高效准确的翻译效果,为越南语相关的翻译工作提供有力支持。
🚀 快速开始
模型描述
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.”。