Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: ja
|
3 |
+
license: cc-by-sa-4.0
|
4 |
+
library_name: transformers
|
5 |
+
tags:
|
6 |
+
- gpt2
|
7 |
+
datasets:
|
8 |
+
- wikipedia
|
9 |
+
- cc100
|
10 |
+
- oscar
|
11 |
+
widget:
|
12 |
+
- text: "昨日私は京都で"
|
13 |
+
---
|
14 |
+
|
15 |
+
# Model Card for Japanese character-level GPT-2 Small
|
16 |
+
|
17 |
+
## Model description
|
18 |
+
|
19 |
+
This is a Japanese character-level GPT-2 Small language model pre-trained on Japanese Wikipedia, the Japanese portion of CC-100, and the Japanese portion of OSCAR.
|
20 |
+
|
21 |
+
## How to use
|
22 |
+
|
23 |
+
You can use this model directly with a pipeline for text generation.
|
24 |
+
|
25 |
+
```python
|
26 |
+
>>> from transformers import pipeline, set_seed
|
27 |
+
>>> generator = pipeline('text-generation', model='ku-nlp/gpt2-small-japanese-char')
|
28 |
+
>>> set_seed(5)
|
29 |
+
>>> generator("昨日私は京都で", max_length=30, do_sample=True, num_return_sequences=5)
|
30 |
+
|
31 |
+
[{'generated_text': '昨日私は京都で仕事していたんですけど、ある日突然京都にいる私'},
|
32 |
+
{'generated_text': '昨日私は京都で就職し、母と一緒に奈良県の商工会議所に行ってき'},
|
33 |
+
{'generated_text': '昨日私は京都ではありませんが、自分の住んでる事について色々と'},
|
34 |
+
{'generated_text': '昨日私は京都では地図を見ることしかしない、京福電車のホームで'},
|
35 |
+
{'generated_text': '昨日私は京都でこみちに住み始めた時からある不思議な現象で、そ'}]
|
36 |
+
...
|
37 |
+
```
|
38 |
+
|
39 |
+
You can also use this model to get the features of a given text.
|
40 |
+
|
41 |
+
## Vocabulary
|
42 |
+
|
43 |
+
This model has a character-level vocabulary of size 6K. To be precise, rare characters may be split into bytes because we use byte-level byte-pair encoding (BPE). The tokenizer was trained on a small subset of the training data that were converted into a one-character-per-line format so that merge operations never transgressed character boundaries.
|
44 |
+
|
45 |
+
## Training data
|
46 |
+
|
47 |
+
We used the following corpora for pre-training:
|
48 |
+
|
49 |
+
- Japanese Wikipedia (as of 20221020, 3.2GB, 27M sentences, 1.3M documents)
|
50 |
+
- Japanese portion of CC-100 (85GB, 619M sentences, 66M documents)
|
51 |
+
- Japanese portion of OSCAR (54GB, 326M sentences, 25M documents)
|
52 |
+
|
53 |
+
Note that we filtered out documents annotated with "header", "footer", or "noisy" tags in OSCAR.
|
54 |
+
Also note that Japanese Wikipedia was duplicated 10 times to make the total size of the corpus comparable to that of CC-100 and OSCAR. As a result, the total size of the training data is 171GB.
|
55 |
+
|
56 |
+
## Training procedure
|
57 |
+
|
58 |
+
The training took XX weeks using a single NVIDIA A100 80GB GPU.
|
59 |
+
|
60 |
+
The following hyperparameters were used during pre-training:
|
61 |
+
|
62 |
+
- learning_rate: 2e-4
|
63 |
+
- per_device_train_batch_size: 36
|
64 |
+
- gradient_accumulation_steps: 32
|
65 |
+
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-06
|
66 |
+
- weight_decay: 0.01
|
67 |
+
- max_grad_norm: 1.0
|
68 |
+
- max_steps: 500,000
|
69 |
+
- warmup_steps: 10,000
|
70 |
+
|
71 |
+
The eval loss was 1.60 while the eval accuracy was 0.635. The evaluation set consists of 5,000 randomly sampled documents from each of the training corpora.
|