Views
No views yet
| Data set | Sentences | Download |
|---|---|---|
| Training | 133,317 | via GitHub or located in data/train-en-vi.tgz |
| Development | 1,553 | via GitHub or located in data/dev-2012-en-vi.tgz |
| Test | 1,268 | via GitHub or located in data/test-2013-en-vi.tgz |
| Model | BLEU (Beam Search) |
|---|---|
| Luong & Manning (2015) | 23.30 |
| Sequence-to-sequence model with attention | 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 (pretraining, without training data) | 28.46 (cased) / 29.23 (uncased) |
| t5-en-vi-small (fineturning with training data) | 32.38 (cased) / 33.19 (uncased) |
1import torch
2
3from transformers import T5ForConditionalGeneration, T5Tokenizer
4import torch
5if torch.cuda.is_available():
6 device = torch.device("cuda")
7
8 print('There are %d GPU(s) available.' % torch.cuda.device_count())
9
10 print('We will use the GPU:', torch.cuda.get_device_name(0))
11else:
12 print('No GPU available, using the CPU instead.')
13 device = torch.device("cpu")
14
15model = T5ForConditionalGeneration.from_pretrained("NlpHUST/t5-en-vi-small")
16tokenizer = T5Tokenizer.from_pretrained("NlpHUST/t5-en-vi-small")
17model.to(device)
18
19src = "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 ."
20tokenized_text = tokenizer.encode(src, return_tensors="pt").to(device)
21model.eval()
22summary_ids = model.generate(
23 tokenized_text,
24 max_length=128,
25 num_beams=5,
26 repetition_penalty=2.5,
27 length_penalty=1.0,
28 early_stopping=True
29 )
30output = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
31print(output)1
2Ở 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ù.
3