🚀 T5-EN-VI-SMALL:用於英越翻譯的文本到文本轉移變換器預訓練模型
本項目的 T5-EN-VI-SMALL 模型專注於英越翻譯任務,通過預訓練文本到文本轉移變換器,為英越語言之間的翻譯提供了有效的解決方案。
🚀 快速開始
以下是使用該模型進行英越翻譯的示例代碼:
import torch
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-en-vi-small")
tokenizer = T5Tokenizer.from_pretrained("NlpHUST/t5-en-vi-small")
model.to(device)
src = "In school , we spent a lot of time studying the history of Kim Il-Sung , but we never learned much about the outside world , except that America , South Korea , Japan are the enemies ."
tokenized_text = tokenizer.encode(src, return_tensors="pt").to(device)
model.eval()
summary_ids = model.generate(
tokenized_text,
max_length=128,
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)
輸出示例
Ở trường, chúng tôi dành nhiều thời gian để nghiên cứu về lịch sử Kim Il-Sung, nhưng chúng tôi chưa bao giờ học được nhiều về thế giới bên ngoài, ngoại trừ Mỹ, Hàn Quốc, Nhật Bản là kẻ thù.
✨ 主要特性
- 使用預訓練的文本到文本轉移變換器進行英越翻譯。
- 在英越翻譯任務上取得了較好的 BLEU 分數。
📦 數據集
本項目使用了來自 斯坦福 NLP 小組 的 IWSLT'15 英越 數據集。
對於所有實驗,語料庫被劃分為訓練集、開發集和測試集:
數據集 |
句子數量 |
下載地址 |
訓練集 |
133,317 |
通過 GitHub 下載,或位於 data/train-en-vi.tgz |
開發集 |
1,553 |
通過 GitHub 下載,或位於 data/dev-2012-en-vi.tgz |
測試集 |
1,268 |
通過 GitHub 下載,或位於 data/test-2013-en-vi.tgz |
📚 詳細文檔
測試集結果
以下是不同模型在測試集上的 BLEU 分數(束搜索):
聯繫信息
如果您有與本項目相關的個人交流需求,請聯繫 Nha Nguyen Van(nha282@gmail.com)。