cahya commited on
Commit
5edc210
1 Parent(s): 495a4fb

first commit

Browse files
Files changed (6) hide show
  1. README.md +69 -0
  2. config.json +164 -0
  3. pytorch_model.bin +3 -0
  4. special_tokens_map.json +1 -0
  5. tokenizer_config.json +1 -0
  6. vocab.txt +0 -0
README.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: id
3
+ tags:
4
+ - pipeline:summarization
5
+ - summarization
6
+ - bert2gpt
7
+ datasets:
8
+ - id_liputan6
9
+ license: apache-2.0
10
+ ---
11
+
12
+ # Indonesian BERT2BERT Summarization Model
13
+
14
+ Finetuned EncoderDecoder model using BERT-base and GPT2-small for Indonesian text summarization.
15
+
16
+ ## Finetuning Corpus
17
+
18
+ `bert2gpt-indonesian-summarization` model is based on `cahya/bert-base-indonesian-1.5G` and `cahya/gpt2-small-indonesian-522M`by [cahya](https://huggingface.co/cahya), finetuned using [id_liputan6](https://huggingface.co/datasets/id_liputan6) dataset.
19
+
20
+ ## Load Finetuned Model
21
+
22
+ ```python
23
+ from transformers import BertTokenizer, EncoderDecoderModel
24
+
25
+ tokenizer = BertTokenizer.from_pretrained("cahya/bert2gpt-indonesian-summarization")
26
+ tokenizer.bos_token = tokenizer.cls_token
27
+ tokenizer.eos_token = tokenizer.sep_token
28
+ model = EncoderDecoderModel.from_pretrained("cahya/bert2gpt-indonesian-summarization")
29
+ ```
30
+
31
+ ## Code Sample
32
+
33
+ ```python
34
+ from transformers import BertTokenizer, EncoderDecoderModel
35
+
36
+ tokenizer = BertTokenizer.from_pretrained("cahya/bert2gpt-indonesian-summarization")
37
+ tokenizer.bos_token = tokenizer.cls_token
38
+ tokenizer.eos_token = tokenizer.sep_token
39
+ model = EncoderDecoderModel.from_pretrained("cahya/bert2gpt-indonesian-summarization")
40
+
41
+ #
42
+ ARTICLE_TO_SUMMARIZE = ""
43
+
44
+ # generate summary
45
+ input_ids = tokenizer.encode(ARTICLE_TO_SUMMARIZE, return_tensors='pt')
46
+ summary_ids = model.generate(input_ids,
47
+ min_length=20,
48
+ max_length=80,
49
+ num_beams=10,
50
+ repetition_penalty=2.5,
51
+ length_penalty=1.0,
52
+ early_stopping=True,
53
+ no_repeat_ngram_size=2,
54
+ use_cache=True,
55
+ do_sample = True,
56
+ temperature = 0.8,
57
+ top_k = 50,
58
+ top_p = 0.95)
59
+
60
+ summary_text = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
61
+ print(summary_text)
62
+ ```
63
+
64
+ Output:
65
+
66
+ ```
67
+
68
+ ```
69
+
config.json ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "EncoderDecoderModel"
4
+ ],
5
+ "decoder": {
6
+ "_name_or_path": "cahya/gpt2-small-indonesian-522M",
7
+ "activation_function": "gelu_new",
8
+ "add_cross_attention": true,
9
+ "architectures": [
10
+ "GPT2LMHeadModel"
11
+ ],
12
+ "attn_pdrop": 0.1,
13
+ "bad_words_ids": null,
14
+ "bos_token_id": 50256,
15
+ "chunk_size_feed_forward": 0,
16
+ "decoder_start_token_id": null,
17
+ "diversity_penalty": 0.0,
18
+ "do_sample": false,
19
+ "early_stopping": false,
20
+ "embd_pdrop": 0.1,
21
+ "encoder_no_repeat_ngram_size": 0,
22
+ "eos_token_id": 50256,
23
+ "finetuning_task": null,
24
+ "gradient_checkpointing": false,
25
+ "id2label": {
26
+ "0": "LABEL_0",
27
+ "1": "LABEL_1"
28
+ },
29
+ "initializer_range": 0.02,
30
+ "is_decoder": true,
31
+ "is_encoder_decoder": false,
32
+ "label2id": {
33
+ "LABEL_0": 0,
34
+ "LABEL_1": 1
35
+ },
36
+ "layer_norm_epsilon": 1e-05,
37
+ "length_penalty": 1.0,
38
+ "max_length": 20,
39
+ "min_length": 0,
40
+ "model_type": "gpt2",
41
+ "n_ctx": 1024,
42
+ "n_embd": 768,
43
+ "n_head": 12,
44
+ "n_inner": null,
45
+ "n_layer": 12,
46
+ "n_positions": 1024,
47
+ "no_repeat_ngram_size": 0,
48
+ "num_beam_groups": 1,
49
+ "num_beams": 1,
50
+ "num_return_sequences": 1,
51
+ "output_attentions": false,
52
+ "output_hidden_states": false,
53
+ "output_scores": false,
54
+ "pad_token_id": null,
55
+ "prefix": null,
56
+ "pruned_heads": {},
57
+ "repetition_penalty": 1.0,
58
+ "resid_pdrop": 0.1,
59
+ "return_dict": true,
60
+ "return_dict_in_generate": false,
61
+ "sep_token_id": null,
62
+ "summary_activation": null,
63
+ "summary_first_dropout": 0.1,
64
+ "summary_proj_to_labels": true,
65
+ "summary_type": "cls_index",
66
+ "summary_use_proj": true,
67
+ "task_specific_params": null,
68
+ "temperature": 1.0,
69
+ "tie_encoder_decoder": false,
70
+ "tie_word_embeddings": true,
71
+ "tokenizer_class": null,
72
+ "top_k": 50,
73
+ "top_p": 1.0,
74
+ "torchscript": false,
75
+ "transformers_version": "4.4.0.dev0",
76
+ "use_bfloat16": false,
77
+ "use_cache": true,
78
+ "vocab_size": 50257,
79
+ "xla_device": null
80
+ },
81
+ "decoder_start_token_id": 3,
82
+ "early_stopping": true,
83
+ "encoder": {
84
+ "_name_or_path": "cahya/bert-base-indonesian-1.5G",
85
+ "add_cross_attention": false,
86
+ "architectures": [
87
+ "BertForMaskedLM"
88
+ ],
89
+ "attention_probs_dropout_prob": 0.1,
90
+ "bad_words_ids": null,
91
+ "bos_token_id": null,
92
+ "chunk_size_feed_forward": 0,
93
+ "decoder_start_token_id": null,
94
+ "diversity_penalty": 0.0,
95
+ "do_sample": false,
96
+ "early_stopping": false,
97
+ "encoder_no_repeat_ngram_size": 0,
98
+ "eos_token_id": null,
99
+ "finetuning_task": null,
100
+ "gradient_checkpointing": false,
101
+ "hidden_act": "gelu",
102
+ "hidden_dropout_prob": 0.1,
103
+ "hidden_size": 768,
104
+ "id2label": {
105
+ "0": "LABEL_0",
106
+ "1": "LABEL_1"
107
+ },
108
+ "initializer_range": 0.02,
109
+ "intermediate_size": 3072,
110
+ "is_decoder": false,
111
+ "is_encoder_decoder": false,
112
+ "label2id": {
113
+ "LABEL_0": 0,
114
+ "LABEL_1": 1
115
+ },
116
+ "layer_norm_eps": 1e-12,
117
+ "length_penalty": 1.0,
118
+ "max_length": 20,
119
+ "max_position_embeddings": 512,
120
+ "min_length": 0,
121
+ "model_type": "bert",
122
+ "no_repeat_ngram_size": 0,
123
+ "num_attention_heads": 12,
124
+ "num_beam_groups": 1,
125
+ "num_beams": 1,
126
+ "num_hidden_layers": 12,
127
+ "num_return_sequences": 1,
128
+ "output_attentions": false,
129
+ "output_hidden_states": false,
130
+ "output_scores": false,
131
+ "pad_token_id": 0,
132
+ "position_embedding_type": "absolute",
133
+ "prefix": null,
134
+ "pruned_heads": {},
135
+ "repetition_penalty": 1.0,
136
+ "return_dict": true,
137
+ "return_dict_in_generate": false,
138
+ "sep_token_id": null,
139
+ "task_specific_params": null,
140
+ "temperature": 1.0,
141
+ "tie_encoder_decoder": false,
142
+ "tie_word_embeddings": true,
143
+ "tokenizer_class": null,
144
+ "top_k": 50,
145
+ "top_p": 1.0,
146
+ "torchscript": false,
147
+ "transformers_version": "4.4.0.dev0",
148
+ "type_vocab_size": 2,
149
+ "use_bfloat16": false,
150
+ "use_cache": true,
151
+ "vocab_size": 32000,
152
+ "xla_device": null
153
+ },
154
+ "eos_token_id": 1,
155
+ "is_encoder_decoder": true,
156
+ "length_penalty": 2.0,
157
+ "max_length": 40,
158
+ "min_length": 20,
159
+ "model_type": "encoder-decoder",
160
+ "no_repeat_ngram_size": 3,
161
+ "num_beams": 10,
162
+ "pad_token_id": 2,
163
+ "vocab_size": 50257
164
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a8a5e8b8a4539592118c54b98a45e63e47dc9578915f9873dd36ef457922774
3
+ size 1079069947
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
1
+ {"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
1
+ {"special_tokens_map_file": null, "full_tokenizer_file": null}
vocab.txt ADDED
The diff for this file is too large to render. See raw diff