tanidaiz commited on
Commit
6ce97ad
1 Parent(s): 76b66b3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +63 -0
README.md CHANGED
@@ -1,3 +1,66 @@
1
  ---
2
  license: cc-by-sa-4.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-sa-4.0
3
  ---
4
+ # japanese-gpt2-medium-unidic
5
+ This is a medium-sized Japanese GPT-2 model using BERT-like tokenizer.
6
+
7
+ # How to use
8
+ The model depends on [PyTorch](https://pytorch.org/), [fugashi](https://github.com/polm/fugashi) with [unidic-lite](https://github.com/polm/unidic-lite), and [Hugging Face Transformers](https://github.com/huggingface/transformers).
9
+
10
+ ```sh
11
+ pip install torch torchvision torchaudio
12
+ pip install fugashi[unidic-lite]
13
+ pip install transformers
14
+ ```
15
+
16
+ ```python
17
+ from transformers import AutoTokenizer, AutoModelForCausalLM
18
+ import torch
19
+ tokenizer = AutoTokenizer.from_pretrained('original')
20
+ model = AutoModelForCausalLM.from_pretrained('original')
21
+
22
+ text = '今日はいい天気なので、'
23
+
24
+ bos = tokenizer.convert_tokens_to_ids(['[BOS]']) # [32768]
25
+ input_ids = bos + tokenizer.encode(text)[1:-1] # [CLS] and [SEP] generated by BERT Tokenizer are removed
26
+ input_ids = torch.tensor(input_ids).unsqueeze(0)
27
+ output = model.generate(
28
+ input_ids,
29
+ do_sample=True,
30
+ max_new_tokens=30,
31
+ top_k=50,
32
+ top_p=0.95,
33
+ repetition_penalty=1.0,
34
+ num_return_sequences=1,
35
+ pad_token_id=0,
36
+ eos_token_id=32769,
37
+ )[0]
38
+
39
+ print(tokenizer.decode(output))
40
+ ```
41
+
42
+ # Model architecture
43
+ Transformer-based Language Model
44
+ - Layers: 24
45
+ - Heads: 16
46
+ - Dimensions of hidden states: 1024
47
+
48
+ # Training
49
+ We used a [codebase](https://github.com/rinnakk/japanese-pretrained-models) provided by rinna Co., Ltd. for training.
50
+
51
+ The model was trained on Japanese CC-100 and Japanese Wikipedia (2022/01/31).
52
+ We employed 8 A100 GPUs for 17 days.
53
+ The perplexity on the validation set is 9.80.
54
+
55
+ # Tokenization
56
+ Our tokenizer is based on [the one](https://huggingface.co/cl-tohoku/bert-base-japanese-v2) provided by Tohoku NLP Group.
57
+ The texts are tokenized by MeCab and then WordPiece.
58
+
59
+ The vocabulary size is 32771 (32768 original tokens + 2 special tokens + 1 unused token).
60
+
61
+ # License
62
+ [Creative Commons Attribution-ShareAlike 4.0](https://creativecommons.org/licenses/by-sa/4.0/)
63
+
64
+ Copyright (c) 2021, Tohoku University
65
+
66
+ Copyright (c) 2023, Tokyo Institute of Technology