Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: id
|
3 |
+
tags:
|
4 |
+
- gpt2-indo-small-kids-stories
|
5 |
+
license: mit
|
6 |
+
widget:
|
7 |
+
- text: "Archie sedang mengendarai roket ke planet Mars."
|
8 |
+
---
|
9 |
+
|
10 |
+
## GPT-2 Indonesian Small Kids Stories
|
11 |
+
|
12 |
+
GPT-2 Indonesian Small Kids Stories is a causal language model based on the [OpenAI GPT-2](https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf) model. The model was originally the pre-trained [GPT2 Small Indonesian](https://huggingface.co/flax-community/gpt2-small-indonesian) model, which was then fine-tuned on Indonesian kids' stories from [Room To Read](https://literacycloud.org/) and [Let's Read](https://reader.letsreadasia.org/).
|
13 |
+
|
14 |
+
10% of the dataset was kept for evaluation purposes. The pre-trained model was fine-tuned and achieved an evaluation loss of 3.777 and an evaluation perplexity of 43.68.
|
15 |
+
|
16 |
+
Hugging Face's `Trainer` class from the [Transformers](https://huggingface.co/transformers) library was used to train the model. PyTorch was used as the backend framework during training, but the model remains compatible with other frameworks nonetheless.
|
17 |
+
|
18 |
+
## Model
|
19 |
+
|
20 |
+
| Model | #params | Arch. | Training/Validation data (text) |
|
21 |
+
| ------------------------------ | ------- | ---------- | --------------------------------- |
|
22 |
+
| `gpt2-indo-small-kids-stories` | 124M | GPT2 Small | Indonesian Kids' Stories (860 KB) |
|
23 |
+
|
24 |
+
## Evaluation Results
|
25 |
+
|
26 |
+
The model was fine-tuned for 10 epochs.
|
27 |
+
|
28 |
+
| Epoch | Training Loss | Validation Loss |
|
29 |
+
| ----- | ------------- | --------------- |
|
30 |
+
| 1 | 4.259600 | 4.020201 |
|
31 |
+
| 2 | 3.979100 | 3.911295 |
|
32 |
+
| 3 | 3.818300 | 3.849313 |
|
33 |
+
| 4 | 3.691600 | 3.809931 |
|
34 |
+
| 5 | 3.589300 | 3.789201 |
|
35 |
+
| 6 | 3.506200 | 3.778665 |
|
36 |
+
| 7 | 3.439200 | 3.774871 |
|
37 |
+
| 8 | 3.387600 | 3.774859 |
|
38 |
+
| 9 | 3.351300 | 3.776672 |
|
39 |
+
| 10 | 3.330100 | 3.776935 |
|
40 |
+
|
41 |
+
## How to Use (PyTorch)
|
42 |
+
|
43 |
+
### As Causal Language Model
|
44 |
+
|
45 |
+
```python
|
46 |
+
from transformers import pipeline
|
47 |
+
|
48 |
+
pretrained_name = "bookbot/gpt2-indo-small-kids-stories"
|
49 |
+
|
50 |
+
nlp = pipeline(
|
51 |
+
"text-generation",
|
52 |
+
model=pretrained_name,
|
53 |
+
tokenizer=pretrained_name
|
54 |
+
)
|
55 |
+
|
56 |
+
nlp("Archie sedang mengendarai roket ke planet Mars.")
|
57 |
+
```
|
58 |
+
|
59 |
+
### Feature Extraction in PyTorch
|
60 |
+
|
61 |
+
```python
|
62 |
+
from transformers import GPT2LMHeadModel, GPT2TokenizerFast
|
63 |
+
|
64 |
+
pretrained_name = "bookbot/gpt2-indo-small-kids-stories"
|
65 |
+
model = GPT2LMHeadModel.from_pretrained(pretrained_name)
|
66 |
+
tokenizer = GPT2TokenizerFast.from_pretrained(pretrained_name)
|
67 |
+
|
68 |
+
prompt = "Archie sedang mengendarai roket ke planet Mars."
|
69 |
+
encoded_input = tokenizer(prompt, return_tensors='pt')
|
70 |
+
output = model(**encoded_input)
|
71 |
+
```
|
72 |
+
|
73 |
+
## Disclaimer
|
74 |
+
|
75 |
+
Do consider the biases which come from both the pre-trained GPT-2 model and the Indonesian Kids' Stories dataset that may be carried over into the results of this model.
|
76 |
+
|
77 |
+
## Author
|
78 |
+
|
79 |
+
GPT-2 Indonesian Small Kids Stories was trained and evaluated by [Wilson Wongso](https://w11wo.github.io/). All computation and development are done on Google Colaboratory using their free GPU access.
|