File size: 2,648 Bytes
86a5699
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
924e4c5
86a5699
 
 
 
 
 
 
006bf74
7dcaf95
 
86a5699
 
230d3e3
 
7dcaf95
230d3e3
86a5699
 
 
006bf74
86a5699
006bf74
 
 
 
7dcaf95
86a5699
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ce0b0fd
 
 
 
 
 
 
 
 
 
 
a2171f4
ce0b0fd
4cb6da6
ce0b0fd
 
 
 
 
86a5699
 
 
 
 
 
924e4c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
tags:
- generated_from_trainer
datasets:
- jed351/shikoto_zh_hk
metrics:
- accuracy
model-index:
- name: gpt2-shikoto
  results:
  - task:
      name: Causal Language Modeling
      type: text-generation
    dataset:
      name: jed351/shikoto_zh_hk
      type: jed351/shikoto_zh_hk
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.37381769930940056
license: openrail
---

<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->

# gpt2-shikoto

This model was trained on a dataset I obtained from an online novel site. 
**Please be aware that the stories (training data) might contain inappropriate content. This model is intended for research purposes only.**



The base model can be found [here](https://huggingface.co/jed351/gpt2-tiny-zh-hk), which was obtained by 
patching a [GPT2 Chinese model](https://huggingface.co/ckiplab/gpt2-tiny-chinese) and its tokenizer with Cantonese characters.
Refer to the base model for info on the patching process.




## Training procedure

Please refer to the [script](https://github.com/huggingface/transformers/tree/main/examples/pytorch/language-modeling) 
provided by Huggingface. 


The model was trained for 400,000 steps on 2 NVIDIA Quadro RTX6000 for around 15 hours at the Research Computing Services of Imperial College London.


### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 20
- eval_batch_size: 20
- seed: 42
- distributed_type: multi-GPU
- num_devices: 2
- total_train_batch_size: 40
- total_eval_batch_size: 40
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- training_steps: 400000
- mixed_precision_training: Native AMP

### Training results


### How to use it?
```
from transformers import AutoTokenizer
from transformers import TextGenerationPipeline, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("jed351/gpt2-tiny-zh-hk")
model = AutoModelForCausalLM.from_pretrained("jed351/gpt2_tiny_zh-hk-shikoto")

# try messing around with the parameters
generator = TextGenerationPipeline(model, tokenizer, 
                                   max_new_tokens=200, 
                                   no_repeat_ngram_size=3) #, device=0) #if you have a GPU

input_string = "your input" 

output = generator(input_string)
string = output[0]['generated_text'].replace(' ', '')
print(string)
```

### Framework versions

- Transformers 4.26.0.dev0
- Pytorch 1.13.1
- Datasets 2.8.0
- Tokenizers 0.13.2