fukugawa commited on
Commit
3721ad6
1 Parent(s): 3471588

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +108 -0
README.md CHANGED
@@ -1,3 +1,111 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ datasets:
4
+ - wiki40b
5
+ language:
6
+ - ja
7
+ tags:
8
+ - ja
9
+ - japanese
10
+ - text-generation
11
+ - lm
12
+ - jax
13
+ - flax
14
+ - lm1b
15
  ---
16
+ # transformer-lm-japanese-0.1b
17
+
18
+ ## Model Description
19
+
20
+ This is a JAX/Flax-based transformer language model trained on a Japanese dataset. It is based on the official Flax example code ([lm1b](https://github.com/google/flax/tree/main/examples/lm1b)).
21
+
22
+ ## Model Sources
23
+
24
+ We've modified Flax's 'lm1b' example to train on Japanese dataset. You can find the code on Github.
25
+
26
+ * [transformer-lm-japanese](https://github.com/FookieMonster/transformer-lm-japanese)
27
+
28
+ ## Model Details
29
+
30
+ | Model | Params | Layers | Dim | Heads | PPL | Dataset | Training time |
31
+ |-|-|-|-|-|-|-|-|
32
+ | lm1b-default | 0.05B | 6 | 512 | 8 | 22.67 | lm1b | 0.5 days |
33
+ | transformer-lm-japanese-0.1b | 0.1B | 12 | 768 | 12 | 35.22 | wiki40b/ja | 1.5 days |
34
+
35
+ ## Usage
36
+
37
+ Please refer to [this](https://cloud.google.com/tpu/docs/run-calculation-jax) document, create a TPU-VM instance, and then execute the following steps while performing shell access to that TPU-VM instance via SSH.
38
+
39
+ * [Run a calculation on a Cloud TPU VM using JAX](https://cloud.google.com/tpu/docs/run-calculation-jax)
40
+
41
+ ```
42
+ (tpu-vm)$ pip install --upgrade huggingface_hub
43
+ ```
44
+
45
+ Run the Python interpreter and download the model files.
46
+
47
+ ```
48
+ (tpu-vm)$ python3
49
+ ```
50
+
51
+ ```python
52
+ >>> from huggingface_hub import hf_hub_download
53
+ >>> hf_hub_download(repo_id="fukugawa/transformer-lm-japanese-0.1b", filename="sentencepiece_model", revision="v1", local_dir="$HOME/logs/japanese_0.1b_v1", local_dir_use_symlinks=False)
54
+ >>> hf_hub_download(repo_id="fukugawa/transformer-lm-japanese-0.1b", filename="checkpoint_499999", revision="v1", local_dir="$HOME/logs/japanese_0.1b_v1", local_dir_use_symlinks=False)
55
+ ```
56
+
57
+ Clone the source code and install the necessary Python packages.
58
+
59
+ ```
60
+ (tpu-vm)$ git clone -b 1.0.0.RC2 https://github.com/FookieMonster/transformer-lm-japanese
61
+ (tpu-vm)$ cd ./transformer-lm-japanese/transformer_lm
62
+ (tpu-vm)$ pip install -r requirements.txt
63
+ (tpu-vm)$ pip install "jax[tpu]==0.3.2" -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
64
+ ```
65
+
66
+ Text generation using downloaded model files.
67
+
68
+ ```
69
+ (tpu-vm)$ python3 generate_text.py --workdir=$HOME/logs/japanese_0.1b_v1 \
70
+ --config=configs/japanese_0.1b_v1.py \
71
+ --config.sampling_temperature=0.6 \
72
+ --config.sampling_top_k=20 \
73
+ --config.seed=0 \
74
+ --config.prompts="夏目漱石は、" \
75
+ --num_generated_texts=10
76
+ ```
77
+
78
+ ```
79
+ Generating text.
80
+ Sample: 夏目漱石は、自分の作品を「文学の本」として出版することを構想していた。
81
+ Generating text.
82
+ Sample: 夏目漱石は、明治の文学運動を「文学の原点に立ち帰る」と位置づけ、漱石が「文学の本質をあらわすのが文学である」との認識を、当時の知識人たちが持っていたことを指摘している。
83
+ Generating text.
84
+ Sample: 夏目漱石は、小説『坊っちゃん』で、この「坊っちゃん」を「坊っちゃん」に置き換えた。「坊っちゃん」は、坊っちゃんの「坊」の字を、「坊」は「坊」の字をもじってつけられた。
85
+ Generating text.
86
+ Sample: 夏目漱石は、漱石の『坊っちゃん』を読んで、「漱石は、私に『坊っちゃん』をおもしろおかしく書かせた。これは、私に『坊っちゃん』を書かせるのを、私に教えてくれたからだ」と述懐している。
87
+ Generating text.
88
+ Sample: 夏目漱石は、自身の著作『漱石全集』の中で「漱石が生涯のほとんどを漱石の文学に捧げた」と評価している。
89
+ Generating text.
90
+ Sample: 夏目漱石は、漱石が「『吾輩は猫』を観るのが嫌だ」と言ったのを、漱石が「あんなに怖いとは思わなかった」と返している。
91
+ Generating text.
92
+ Sample: 夏目漱石は、自身の日記の中で「文学の本質と現実との間には、対立関係があり、また対立関係があっても、それが文学の本質と現実との間には関係がある」と書いている。
93
+ Generating text.
94
+ Sample: 夏目漱石は、夏目が漱石の『吾輩は猫である』を読んでいた時に、漱石の『吾輩は猫である』を読んだという。漱石は「猫は猫である」と書いていたが、漱石は「猫である」と書いた。
95
+ Generating text.
96
+ Sample: 夏目漱石は、小説『坊っちゃん』の中で、主人公が「おばあさん」と「おばあさん」の2人で暮らしていると、その家から「おばあさん」と「おばあさん」が飛び出してくるという話を紹介している。
97
+ Generating text.
98
+ Sample: 夏目漱石は、漱石の「吾輩は猫である」という言葉を、漱石が「猫を飼っている人は猫である」という誤解から誤解したのだろうと、著書『猫の散歩道』で述べている。
99
+ ```
100
+
101
+ ## Dataset
102
+
103
+ * wiki40b/ja
104
+
105
+ ## Tokenization
106
+
107
+ * [sentencepiece](https://github.com/google/sentencepiece)
108
+
109
+ ## Author
110
+
111
+ [Ryoichi Fukugawa](https://huggingface.co/fukugawa)