🚀 T5-EN-VI-SMALL: 英語とベトナム語翻訳のためのテキスト-to-テキスト転移トランスフォーマーの事前学習
このプロジェクトは、英語とベトナム語の翻訳タスクに特化した事前学習済みのテキスト-to-テキスト転移トランスフォーマーモデルを提供します。
🚀 クイックスタート
このモデルを使用するには、以下の手順に従ってください。まず、必要なライブラリをインポートし、デバイスを設定します。その後、事前学習済みのモデルとトークナイザーをロードし、翻訳を行います。
📦 データセット
IWSLT'15 English-Vietnamese データは Stanford NLP group から取得しています。すべての実験では、コーパスを学習セット、開発セット、テストセットに分割しています。
データセット |
文数 |
ダウンロード |
学習セット |
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 (ビームサーチ) |
Luong & Manning (2015) |
23.30 |
アテンション付きのシーケンス-to-シーケンスモデル |
26.10 |
Neural Phrase-based Machine Translation Huang et. al. (2017) |
27.69 |
Neural Phrase-based Machine Translation + LM Huang et. al. (2017) |
28.07 |
t5-en-vi-small (事前学習、学習データなし) |
28.46 (大文字小文字区別あり) / 29.23 (大文字小文字区別なし) |
t5-en-vi-small (学習データでファインチューニング) |
32.38 (大文字小文字区別あり) / 33.19 (大文字小文字区別なし) |
💻 使用例
基本的な使用法
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ù.
連絡先
このプロジェクトに関する個人的なコミュニケーションは、Nha Nguyen Van (nha282@gmail.com) までお問い合わせください。