Views
No views yet
| Metric | Score |
|---|---|
| ROUGE-1 | 45.17% |
| ROUGE-2 | 22.18% |
| ROUGE-L | 27.60% |
| BERT F1 | 69.22% |
| Inference Time | 10.97s/sample (CPU) |
| Compression Ratio | 0.292 |
| Model | ROUGE-1 | ROUGE-2 | ROUGE-L | BERT F1 | Speed |
|---|---|---|---|---|---|
| Abstractive (this) | 45.17% | 22.18% | 27.60% | 69.22% | 10.97s ⚡ |
| Extractive | 50.48% | 22.84% | 30.61% | 71.33% | 20.46s |
pip install transformers torch1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3# Load model and tokenizer
4model_name = "NishiKyen/vit5-vietnamese-news"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
7
8# Input text
9text = """
10Chính phủ Việt Nam đã ban hành quy định mới về thuế thu nhập cá nhân,
11áp dụng từ ngày 1 tháng 1 năm 2026. Theo đó, mức giảm trừ gia cảnh
12sẽ được tăng từ 11 triệu đồng lên 13 triệu đồng mỗi tháng.
13"""
14
15# Tokenize
16inputs = tokenizer(
17 text,
18 max_length=1280,
19 truncation=True,
20 padding="max_length",
21 return_tensors="pt"
22)
23
24# Generate summary
25outputs = model.generate(
26 inputs["input_ids"],
27 max_new_tokens=256,
28 num_beams=5,
29 repetition_penalty=2.5,
30 no_repeat_ngram_size=3,
31 early_stopping=True
32)
33
34# Decode
35summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
36print(summary)Chính phủ tăng mức giảm trừ gia cảnh lên 13 triệu đồng/tháng từ 1/1/2026,
ảnh hưởng đến 15 triệu người nộp thuế TNCN.1def summarize_news(text, max_input_length=1280):
2 """
3 Tóm tắt tin tức với độ dài động
4 """
5 # Estimate output length based on input
6 input_len = len(text.split())
7
8 if input_len <= 500:
9 max_new = 180
10 elif input_len <= 1000:
11 max_new = 250
12 else:
13 max_new = 256
14
15 # Tokenize
16 inputs = tokenizer(
17 text,
18 max_length=max_input_length,
19 truncation=True,
20 return_tensors="pt"
21 )
22
23 # Generate with optimal parameters
24 outputs = model.generate(
25 inputs["input_ids"],
26 max_new_tokens=max_new,
27 min_new_tokens=50,
28 num_beams=5,
29 length_penalty=1.0,
30 repetition_penalty=2.5,
31 no_repeat_ngram_size=3,
32 early_stopping=True
33 )
34
35 summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
36 return summary
37
38# Usage
39long_article = "..." # Your news article
40summary = summarize_news(long_article)1training_args = {
2 "output_dir": "./models/vit5_abstractive",
3 "num_train_epochs": 3,
4 "per_device_train_batch_size": 8,
5 "learning_rate": 5e-5,
6 "warmup_steps": 500,
7 "weight_decay": 0.01,
8 "fp16": True,
9 "evaluation_strategy": "epoch",
10 "save_strategy": "epoch",
11 "load_best_model_at_end": True,
12}ViT5-base (220M parameters)
├── Encoder: 12 layers, 768 hidden, 12 heads
├── Decoder: 12 layers, 768 hidden, 12 heads
└── Vocabulary: 32,000 SentencePiece tokens1@misc{vit5-vietnamese-news,
2 author = {Nguyen Trung Kien},
3 title = {ViT5 Vietnamese News Summarization},
4 year = {2025},
5 publisher = {HuggingFace},
6 howpublished = {\url{https://huggingface.co/NishiKyen/vit5-vietnamese-news}}
7}