ardavey commited on
Commit
129f7c9
·
verified ·
1 Parent(s): 17a8717

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +87 -3
README.md CHANGED
@@ -1,3 +1,87 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: id
3
+ tags:
4
+ - pipeline:summarization
5
+ - summarization
6
+ - bert2gpt
7
+ datasets:
8
+ - indosum
9
+ license: mit
10
+ ---
11
+ # Indonesian BERT2BERT Summarization Model
12
+
13
+ Finetuned EncoderDecoder model using BERT-base and GPT2-small for Indonesian text summarization.
14
+
15
+ ## Finetuning Corpus
16
+
17
+ `bert2gpt-indosum` model is based on `cahya/bert2gpt-indonesian-summarization`[cahya](https://huggingface.co/cahya), finetuned using [indosum](https://huggingface.co/datasets/maryantocinn/indosum) dataset.
18
+
19
+ ## How to Load Finetuned Model
20
+
21
+ ```python
22
+ from transformers import BertTokenizer, EncoderDecoderModel
23
+ model_ckpt = 'ardavey/bert2gpt-indosum'
24
+ tokenizer = BertTokenizer.from_pretrained(model_ckpt)
25
+ tokenizer.bos_token = tokenizer.cls_token
26
+ tokenizer.eos_token = tokenizer.sep_token
27
+ model = EncoderDecoderModel.from_pretrained(model_ckpt)
28
+ ```
29
+
30
+ ## Code Example
31
+
32
+ ```python
33
+ model_path = 'ardavey/bert2gpt-indosum'
34
+ tokenizer = BertTokenizer.from_pretrained(model_path)
35
+ tokenizer.bos_token = tokenizer.cls_token
36
+ tokenizer.eos_token = tokenizer.sep_token
37
+ model = EncoderDecoderModel.from_pretrained(model_path)
38
+
39
+ # Source of the article below: [](https://soc.telkomuniversity.ac.id/optiguard-aplikasi-dan-alat-untuk-deteksi-dini-penyakit-kebutaan-ciptaan-mahasiswa-fakultas-informatika-tel-u/)
40
+ custom_text = """
41
+ Bandung, 5 Juli 2024 --- Kebutaan akan membawa dampak negatif bagi penderitanya. Pentingnya menjaga Kesehatan mata untuk mencegah kebutaan membuat sekelompok mahasiswa dari Fakultas Informatika Telkom University menciptakan inovasi untuk mengidentifikasi penyakit mata.
42
+ Inovasi ini diberi nama Optiguard yang dikembangkan melalui Program Kreativitas Mahasiswa Bidang Karsa Cipta (PKM-KC) dan berhasil mendapatkan pendanaan dari Kemendikbudristek. OptiGuard diciptakan sebagai upaya preventif mencegah kebutaan dengan mendeteksi dini penyakit mata, sehingga penyakit mata dapat ditangani sebelum semakin parah dan memperkecil peluang terjadinya kebutaan. Inovasi OptiGuard ini mengedepakan efisiensi, kecepatan, dan ketepatan dalam mendiagnosis penyakit mata.
43
+ OptiGuard merupakan hasil kolaborasi dari sekelompok mahasiswa program studi S1 Sains Data Telkom University yang memiliki peranannya masing-masing. Hendrik Mario Ignatius sebagai Koordinator dan Front End Developer, Izzulhaq Mahardika sebagai Adaptor designer dan Back End Developer, Nida Anggraeni sebagai Reseacher dan Public Relation, Nadia Nurhalija Zuaeni sebagai Content Creator dan Researcher, dan Tiara Sabrina sebagai AI Engineer dan UI/UX Designer. Pengembangan inovasi ini rutin dipantau dan didampingi oleh Dr. Gamma Kosala, S.Si.
44
+ """
45
+
46
+ input_ids = tokenizer.encode(custom_text, return_tensors='pt', padding=True, truncation=True, max_length=512)
47
+ summary_ids = model.generate(input_ids,
48
+ min_length=40,
49
+ max_length=200,
50
+ num_beams=10,
51
+ repetition_penalty=2.0,
52
+ length_penalty=1.0,
53
+ no_repeat_ngram_size=3,
54
+ use_cache=True,
55
+ do_sample = False,
56
+ top_k = 50,
57
+ )
58
+
59
+ summary_text = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
60
+
61
+ ## Apply Post Preprocessing
62
+ You could apply post preprocessing if the model might not have a strong grasp of specific terms, especially for words like "OptiGuard," which may not be common in the pre-trained data.
63
+ ```python
64
+ # capitalize the first letter of the summary and after each period
65
+ def capitalize_sentences(text):
66
+ sentences = text.split('. ')
67
+ capitalized_sentences = [sentence[0].upper() + sentence[1:] if sentence else sentence for sentence in sentences]
68
+ return '. '.join(capitalized_sentences)
69
+
70
+ # correct any wrong terms using the replacement_dict
71
+ replacement_dict = {
72
+ "optiglain": "OptiGuard",
73
+ "telkom university": "Telkom University",
74
+ }
75
+
76
+ for wrong_term, correct_term in replacement_dict.items():
77
+ summary_text = summary_text.replace(wrong_term, correct_term)
78
+
79
+ summary_text = capitalize_sentences(summary_text)
80
+ ```
81
+
82
+
83
+ Output:
84
+ ```
85
+ Summary:
86
+ Kebutaan akan membawa dampak negatif bagi penderitanya. Pentingnya menjaga kesehatan mata untuk mencegah kebutaan membuat sekelompok mahasiswa dari fakultas informatika Telkom University menciptakan inovasi untuk mengidentifikasi penyakit mata. Inovasi ini diberi nama OptiGuard yang dikembangkan melalui program kreativitas mahasiswa bidang karsa cipta ( pkm - kc ) dan berhasil mendapatkan pendanaan dari kemendikbudristek.
87
+ ```