mymusise commited on
Commit
0263c15
1 Parent(s): 142f513

init project

Browse files

Signed-off-by: mymusise <mymusise1@gmail.com>

Files changed (3) hide show
  1. README.md +51 -0
  2. config.json +36 -0
  3. spiece.model +3 -0
README.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: zh
3
+ widget:
4
+ - text: "今天是下雨天"
5
+ - text: "走向森林"
6
+ ---
7
+
8
+ <h1 align="center">
9
+ CPM
10
+ </h1>
11
+
12
+
13
+ CPM(Chinese Pre-Trained Language Models), which has 2.6B parameters, made by the research team of Beijing Zhiyuan Institute of artificial intelligence and Tsinghua University @TsinghuaAI.
14
+
15
+ [repo: CPM-Generate](https://github.com/TsinghuaAI/CPM-Generate)
16
+
17
+ The One Thing You Need to Know is this model is not uploaded by official, the conver script is [here](https://github.com/mymusise/CPM-TF2Transformer/blob/main/transfor_CMP.ipynb)
18
+
19
+ # Overview
20
+
21
+ - **Language model**: CPM
22
+ - **Model size**: 2.6B parameters
23
+ - **Language**: Chinese
24
+
25
+ # How to use
26
+
27
+ How to use this model directly from the 🤗/transformers library:
28
+
29
+ ```python
30
+ from transformers import XLNetTokenizer, TFGPT2LMHeadModel
31
+
32
+ tokenizer = XLNetTokenizer.from_pretrained('mymusise/CPM-Third-Party')
33
+ model = TFGPT2LMHeadModel.from_pretrained("mymusise/CPM-Third-Party")
34
+ ```
35
+
36
+ How to generate text
37
+
38
+ ```python
39
+ from transformers import TextGenerationPipeline
40
+ text_generater = TextGenerationPipeline(model, tokenizer)
41
+
42
+ display(text_generater('今天天气不错', max_length=20))
43
+ display(text_generater('今天天气不错', max_length=20, do_sample=True, top_k=10, top_p=0.95))
44
+ display(text_generater('今天天气不错', max_length=20, do_sample=True, top_k=10, top_p=0.95, repetition_penalty=2))
45
+
46
+ display(text_generater('天下武功, 唯快不破', max_length=30))
47
+ display(text_generater('天下武功, 唯快不破', max_length=30, do_sample=True, top_k=10))
48
+ ```
49
+
50
+ ![avatar](https://github.com/mymusise/CPM-TF2Transformer/raw/main/example-cpm.png)
51
+
config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_function": "gelu",
3
+ "architectures": [
4
+ "TFGPT2LMHeadModel"
5
+ ],
6
+ "attn_pdrop": 0.0,
7
+ "bos_token_id": 50256,
8
+ "embd_pdrop": 0.0,
9
+ "eos_token_id": 50256,
10
+ "gradient_checkpointing": false,
11
+ "initializer_range": 0.02,
12
+ "layer_norm_epsilon": 1e-05,
13
+ "model_type": "gpt2",
14
+ "n_ctx": 1024,
15
+ "n_embd": 2560,
16
+ "n_head": 32,
17
+ "n_inner": null,
18
+ "n_layer": 32,
19
+ "n_positions": 1024,
20
+ "pad_token_id": 0,
21
+ "resid_pdrop": 0.0,
22
+ "summary_activation": null,
23
+ "summary_first_dropout": 0.0,
24
+ "summary_proj_to_labels": true,
25
+ "summary_type": "cls_index",
26
+ "summary_use_proj": true,
27
+ "task_specific_params": {
28
+ "text-generation": {
29
+ "do_sample": true,
30
+ "max_length": 120
31
+ }
32
+ },
33
+ "tokenizer_class": "XLNetTokenizer",
34
+ "use_cache": true,
35
+ "vocab_size": 30000
36
+ }
spiece.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:25c1d178d54901291c1735cd2ae0788be90df4de01fb445e8a8a998cab35ba43
3
+ size 713229