Downloads · 30 days
57
3% of all-time downloads
thonyyy/pegasus_indonesian_base-finetune
pegasus_indonesian_base-finetune is a summarization model from thonyyy. Use it when you need a shorter version of a longer text. It is set up for transformers. The card lists the license as apache-2.0.
Downloads · 30 days
57
3% of all-time downloads
All-time downloads
2.2K
Public
Repo size
525 MB
Likes
4
Public
Click a slice to open those files.
.h5525 MB · 99%
From the Hugging Face model README
Github : PEGASUS TPU Trainer
This model is a fine-tuned version of pegasus_indonesian_base-pretrain on Indosum, Liputan6 and XLSum.
If you want to try the model quickly, go to this notebook.
This model is uncased, can't read special characters except "," and "." and may not performance well on non-news article text.
| datasets | rouge-1 | rouge-2 | rouge-L | BERTScore |
|---|---|---|---|---|
| Indosum | 52.43 | 41.23 | 48.18 | 80.68 |
| Liputan6 | 38.27 | 20.22 | 31.26 | 76.31 |
| XLSum | 26.97 | 9.99 | 21.70 | 73.62 |
Finetune dataset: 1.Indosum 2.Liputan6 3.XLSum
# Load model and tokenizer
from transformers import TFPegasusForConditionalGeneration, PegasusTokenizerFast
model_name = "thonyyy/pegasus_indonesian_base-finetune"
model = TFPegasusForConditionalGeneration.from_pretrained(model_name)
tokenizer = PegasusTokenizerFast.from_pretrained(model_name)
# Main function to clean text, removes link, bullet point, non ASCII char, parantheses,
# punctuation except "," and ".", numbers with dot (enumerating), extra whitespaces, too short sentences.
import re
import unicodedata
def text_cleaning(input_string):
lowercase = input_string.lower()
remove_link = re.sub(r'(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w\.-]*)', '', lowercase).replace("&","&")
remove_bullet = "\n".join([T for T in remove_link.split('\n') if '•' not in T and "baca juga:" not in T])
remove_accented = unicodedata.normalize('NFKD', remove_bullet).encode('ascii', 'ignore').decode('utf-8', 'ignore')
remove_parentheses = re.sub("([\(\|]).*?([\)\|])", "\g<1>\g<2>", remove_accented)
remove_punc = re.sub(r"[^\w\d.\s]+",' ', remove_parentheses)
remove_num_dot = re.sub(r"(?<=\d)\.|\.(?=\d)|(?<=#)\.","", remove_punc)
remove_extra_whitespace = re.sub(r'^\s*|\s\s*', ' ', remove_num_dot).strip()
return ".".join([s for s in remove_extra_whitespace.strip().split('.') if len(s.strip())>10]).replace("_","")
# Article to summarize
sample_article="""
Dana Moneter Internasional (IMF) menilai Indonesia telah menunjukkan pemulihan ekonomi yang baik pasca pandemi melalui kinerja makroekonomi yang kuat, didukung penerapan kebijakan moneter dan fiskal secara berhati-hati. Kebijakan forward looking dan sinergi telah berhasil membawa Indonesia menghadapi tantangan global pada tahun 2022 dengan pertumbuhan yang sehat, tekanan inflasi yang menurun, dan sistem keuangan yang stabil. Bank Indonesia menyambut baik hasil asesmen IMF atas perekonomian Indonesia dalam laporan Article IV Consultation tahun 2023 yang dirilis hari ini (26/6).
Dewan Direktur IMF menyampaikan apresiasi dan catatan positif terhadap berbagai kebijakan yang ditempuh otoritas Indonesia selama tahun 2022. Pertama, keberhasilan otoritas untuk kembali kepada batas maksimal defisit fiskal 3%, lebih cepat dari yang diperkirakan dan komitmen otoritas untuk menerapkan disiplin fiskal. Kedua, penerapan kebijakan moneter yang memadai untuk menjaga stabilitas harga. Ketiga, ketahanan sektor keuangan yang tetap terjaga. Keempat, penerapan UU Cipta Kerja serta UU Pengembangan dan Penguatan Sektor Keuangan, dengan memastikan implementasi yang tepat dan keberlanjutan momentum reformasi untuk mendorong kemudahan berinvestasi, meningkatkan pendalaman pasar keuangan, dan memitigasi dampak scarring dari pandemi. Kelima, strategi diversifikasi Indonesia yang fokus pada upaya hilirisasi dalam rangka meningkatkan nilai tambah ekspor. Keenam, komitmen otoritas untuk mengurangi emisi gas rumah kaca dan deforestasi.
"""
# Generate summary
x = tokenizer(text_cleaning(sample_article), return_tensors = 'tf')
y = model.generate(**x)
suummary = tokenizer.batch_decode(y, skip_special_tokens=True)
print(summary)
For replication, go to GitHub page
The following hyperparameters were used during training:
| Train Loss | Train Accuracy | Validation Loss | Validation Accuracy | Train Lr | Epoch |
|---|---|---|---|---|---|
| 2.3484 | 0.0859 | 1.6304 | 0.1080 | 0.00013661868 | 1 |
| 1.6196 | 0.1079 | 1.4097 | 0.1153 | 0.00013661868 | 2 |
Research supported with Cloud TPUs from Google’s TPU Research Cloud (TRC)