yohida commited on
Commit
4b50840
1 Parent(s): d820269

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +61 -0
README.md CHANGED
@@ -1,3 +1,64 @@
1
  ---
 
 
 
 
 
 
 
 
 
2
  license: mit
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language: ja
3
+ thumbnail: https://github.com/rinnakk/japanese-pretrained-models/blob/master/rinna.png
4
+ tags:
5
+ - ja
6
+ - japanese
7
+ - gpt
8
+ - text-generation
9
+ - lm
10
+ - nlp
11
  license: mit
12
+ datasets:
13
+ - cc100
14
+ - wikipedia
15
+ widget:
16
+ - text: "西田幾多郎は、"
17
  ---
18
+
19
+ # japanese-gpt-1b
20
+
21
+ ![rinna-icon](./rinna.png)
22
+
23
+ This repository provides a 1.3B-parameter Japanese GPT model. The model was trained by [rinna Co., Ltd.](https://corp.rinna.co.jp/)
24
+
25
+ # How to use the model
26
+
27
+ *NOTE:* Use `T5Tokenizer` to initiate the tokenizer.
28
+
29
+ ~~~~
30
+ import torch
31
+ from transformers import T5Tokenizer, AutoModelForCausalLM
32
+ tokenizer = T5Tokenizer.from_pretrained("rinna/japanese-gpt-1b")
33
+ model = AutoModelForCausalLM.from_pretrained("rinna/japanese-gpt-1b")
34
+ if torch.cuda.is_available():
35
+ model = model.to("cuda")
36
+ text = "西田幾多郎は、"
37
+ token_ids = tokenizer.encode(text, add_special_tokens=False, return_tensors="pt")
38
+ with torch.no_grad():
39
+ output_ids = model.generate(
40
+ token_ids.to(model.device),
41
+ max_length=100,
42
+ min_length=100,
43
+ do_sample=True,
44
+ top_k=500,
45
+ top_p=0.95,
46
+ pad_token_id=tokenizer.pad_token_id,
47
+ bos_token_id=tokenizer.bos_token_id,
48
+ eos_token_id=tokenizer.eos_token_id,
49
+ bad_word_ids=[[tokenizer.unk_token_id]]
50
+ )
51
+ output = tokenizer.decode(output_ids.tolist()[0])
52
+ print(output)
53
+ # sample output: 西田幾多郎は、その主著の「善の研究」などで、人間の内面に自然とその根源があると指摘し、その根源的な性格は、この西田哲学を象徴しているとして、カントの「純粋理性批判」と「判断力批判」を対比して捉えます。それは、「人が理性的存在であるかぎりにおいて、人はその当人に固有な道徳的に自覚された善悪の基準を持っている」とするもので、この理性的な善悪の観念を否定するのがカントの
54
+ ~~~~
55
+
56
+ # Model architecture
57
+ A 24-layer, 2048-hidden-size transformer-based language model.
58
+
59
+ # Training
60
+ The model was trained on [Japanese C4](https://huggingface.co/datasets/allenai/c4), [Japanese CC-100](http://data.statmt.org/cc-100/ja.txt.xz) and [Japanese Wikipedia](https://dumps.wikimedia.org/other/cirrussearch) to optimize a traditional language modelling objective. It reaches around 14 perplexity on a chosen validation set from the same data.
61
+ # Tokenization
62
+ The model uses a [sentencepiece](https://github.com/google/sentencepiece)-based tokenizer. The vocabulary was first trained on a selected subset from the training data using the official sentencepiece training script, and then augmented with emojis and symbols.
63
+ # Licenese
64
+ [The MIT license](https://opensource.org/licenses/MIT)