TakayoshiMakabe commited on
Commit
85ba499
1 Parent(s): 2018861

[Init] first commit

Browse files
README.md CHANGED
@@ -1,3 +1,108 @@
1
  ---
 
 
 
 
 
 
 
 
2
  license: mit
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language: ja
3
+ tags:
4
+ - ja
5
+ - japanese
6
+ - gpt2
7
+ - text-generation
8
+ - lm
9
+ - nlp
10
  license: mit
11
+ datasets:
12
+ - cc100
13
+ - wikipedia
14
+ - oscar
15
+ widget:
16
+ - text: "人とAIが協調するためには、"
17
  ---
18
+
19
+ # gpt2-large-japanese
20
+
21
+ This repository provides a large sized Japanese GPT-2 model. The model was trained by [ABEJA, Inc](https://abejainc.com/en/)
22
+
23
+ # How to use
24
+
25
+ When using pipeline for text generation.
26
+
27
+ ``` python
28
+ from transformers import pipeline
29
+
30
+
31
+ generator = pipeline("text-generation", model="abeja/gpt2-large-japanese")
32
+ generated = generator(
33
+ "人とAIが協調するためには、",
34
+ max_length=30,
35
+ do_sample=True,
36
+ num_return_sequences=3,
37
+ top_p=0.95,
38
+ top_k=50,
39
+ pad_token_id=3
40
+ )
41
+ print(*generated, sep="\n")
42
+
43
+ """
44
+ [out]
45
+ {'generated_text': '人とAIが協調するためには、社会的なルールをきちんと理解して、人と共存し、協働して生きていくのが重要だという。'}
46
+ {'generated_text': '人とAIが協調するためには、それぞれが人間性を持ち、またその人間性から生まれるインタラクションを調整しなければならないことはいうまで'}
47
+ {'generated_text': '人とAIが協調するためには、AIが判断すべきことを人間が決める必要がある。人工知能の目的は、人間の知性、記憶、理解、'}
48
+ """
49
+ ```
50
+
51
+ When using PyTorch.
52
+
53
+ ``` python
54
+ from transformers import AutoTokenizer, AutoModelForCausalLM
55
+
56
+
57
+ tokenizer = AutoTokenizer.from_pretrained("abeja/gpt2-large-japanese")
58
+ model = AutoModelForCausalLM.from_pretrained("abeja/gpt2-large-japanese")
59
+
60
+ input_text = "人とAIが協調するためには、"
61
+ input_ids = tokenizer.encode(input_text, return_tensors="pt")
62
+
63
+ gen_tokens = model.generate(
64
+ input_ids,
65
+ max_length=100,
66
+ do_sample=True,
67
+ num_return_sequences=3,
68
+ top_p=0.95,
69
+ top_k=50,
70
+ pad_token_id=tokenizer.pad_token_id
71
+ )
72
+ for gen_text in tokenizer.batch_decode(gen_tokens, skip_special_tokens=True):
73
+ print(gen_text)
74
+ ```
75
+
76
+ When using TensorFlow.
77
+
78
+ ```python
79
+ from transformers import AutoTokenizer, TFAutoModelForCausalLM
80
+
81
+
82
+ tokenizer = AutoTokenizer.from_pretrained("abeja/gpt2-large-japanese")
83
+ model = TFAutoModelForCausalLM.from_pretrained("abeja/gpt2-large-japanese", from_pt=True)
84
+
85
+ input_text = "人とAIが協調するためには、"
86
+ input_ids = tokenizer.encode(input_text, return_tensors="tf")
87
+
88
+ gen_tokens = model.generate(
89
+ input_ids,
90
+ max_length=100,
91
+ do_sample=True,
92
+ num_return_sequences=3,
93
+ top_p=0.95,
94
+ top_k=50,
95
+ pad_token_id=tokenizer.pad_token_id
96
+ )
97
+ for gen_text in tokenizer.batch_decode(gen_tokens, skip_special_tokens=True):
98
+ print(gen_text)
99
+ ```
100
+
101
+ # Dataset
102
+ The model was trained on [Japanese CC-100](http://data.statmt.org/cc-100/ja.txt.xz), [Japanese Wikipedia](https://dumps.wikimedia.org/other/cirrussearch), and [Japanese OSCAR](https://huggingface.co/datasets/oscar).
103
+
104
+ # Tokenization
105
+ The model uses a [sentencepiece](https://github.com/google/sentencepiece)-based tokenizer, the vocabulary was trained on the Japanese Wikipedia.
106
+
107
+ # Licenese
108
+ [The MIT license](https://opensource.org/licenses/MIT)
config.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "checkpoint-huggingface/gpt2-large-japanese",
3
+ "activation_function": "gelu_new",
4
+ "architectures": [
5
+ "GPT2LMHeadModel"
6
+ ],
7
+ "attn_pdrop": 0.1,
8
+ "bos_token_id": 1,
9
+ "embd_pdrop": 0.1,
10
+ "eos_token_id": 2,
11
+ "initializer_range": 0.02,
12
+ "layer_norm_epsilon": 1e-05,
13
+ "model_type": "gpt2",
14
+ "n_ctx": 1024,
15
+ "n_embd": 1280,
16
+ "n_head": 20,
17
+ "n_inner": null,
18
+ "n_layer": 36,
19
+ "n_positions": 1024,
20
+ "reorder_and_upcast_attn": false,
21
+ "resid_pdrop": 0.1,
22
+ "scale_attn_by_inverse_layer_idx": false,
23
+ "scale_attn_weights": true,
24
+ "summary_activation": null,
25
+ "summary_first_dropout": 0.1,
26
+ "summary_proj_to_labels": true,
27
+ "summary_type": "cls_index",
28
+ "summary_use_proj": true,
29
+ "task_specific_params": {
30
+ "text-generation": {
31
+ "do_sample": true,
32
+ "max_length": 50
33
+ }
34
+ },
35
+ "tokenizer_class": "T5Tokenizer",
36
+ "torch_dtype": "float32",
37
+ "transformers_version": "4.19.2",
38
+ "use_cache": true,
39
+ "vocab_size": 32000
40
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb5575dce810c32790f2806f28d1813627a7d55d6df6e378ab15b313c0365481
3
+ size 3040548553
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
spiece.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ebbc2b0963521ffc640f69782e4e27c7209b1a6fff8f8d3083f599f8cfe2abb
3
+ size 783792
tf_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:350e954b93459963bc2c0ea333cfa8b1b2bd3e72cb74688561763c654764b26a
3
+ size 3003153768
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"eos_token": "</s>", "unk_token": "<unk>", "pad_token": "[PAD]", "extra_ids": 0, "additional_special_tokens": [], "sp_model_kwargs": {}, "bos_token": "<s>", "cls_token": "[CLS]", "sep_token": "[SEP]", "mask_token": "[MASK]", "do_lower_case": true, "tokenizer_class": "T5Tokenizer"}