uer commited on
Commit
50b5083
1 Parent(s): 758e968

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +24 -19
README.md CHANGED
@@ -12,7 +12,7 @@ widget:
12
 
13
  The model is used to generate Chinese ancient poems. You can download the model either from the [GPT2-Chinese Github page](https://github.com/Morizeyao/GPT2-Chinese), or via HuggingFace from the link [gpt2-chinese-poem][poem].
14
 
15
- Since the parameter skip_special_tokens is used in the pipelines.py, special tokens such as [SEP], [UNK] will be deleted, and the output results may not be neat.
16
 
17
  ## How to use
18
 
@@ -26,7 +26,7 @@ When the parameter skip_special_tokens is True:
26
  >>> model = GPT2LMHeadModel.from_pretrained("uer/gpt2-chinese-poem")
27
  >>> text_generator = TextGenerationPipeline(model, tokenizer)
28
  >>> text_generator("[CLS]梅 山 如 积 翠 ,", max_length=50, do_sample=True)
29
- [{'generated_text': '[CLS]梅 山 如 积 翠 , 丛 竹 隠 疏 花 。 水 影 落 寒 濑 , 竹 声 随 暮 鸦 。 茅 茨 数 间 屋 , 烟 火 两 三 家 。 安 得 携 琴 酒 , 相 逢 烟 雨 赊 。 向 湖 边 过 , 偏 怜 雪 里 看 。 浮 峦 如 画 出 , 远 树 与 天 连 。 月 上 僧 房 静 , 风 回 萤 火 寒 。 幽 情 何 可 写 , 赖 有 子 期 弹 。 棠 真'}]
30
  ```
31
 
32
  When the parameter skip_special_tokens is False:
@@ -37,7 +37,7 @@ When the parameter skip_special_tokens is False:
37
  >>> model = GPT2LMHeadModel.from_pretrained("uer/gpt2-chinese-poem")
38
  >>> text_generator = TextGenerationPipeline(model, tokenizer)
39
  >>> text_generator("[CLS]梅 山 如 积 翠 ,", max_length=100, do_sample=True)
40
- [{'generated_text': '[CLS]梅 山 如 积 翠 , 秀 出 何 其 雄 。 矫 矫 云 间 质 , 映 日 生 玲 珑 。 根 大 乱 石 结 , 枝 高 青 云 蒙 。 常 因 风 露 晚 , 隠 映 瑶 台 中 。 忽 闻 山 石 裂 , 万 里 吹 天 风 。 又 觉 此 身 高 , 迥 出 凡 境 空 。 清 影 落 潭 水 , 暗 香 来 逈 峰 。 却 寻 白 太 白 , 月 影 摇 江 东 。 [SEP] 而 非'}]
41
  ```
42
 
43
  ## Training data
@@ -46,39 +46,44 @@ Training data contains 800,000 Chinese ancient poems which are collected by [chi
46
 
47
  ## Training procedure
48
 
49
- The model is pre-trained by [UER-py](https://github.com/dbiir/UER-py/) on [Tencent Cloud TI-ONE](https://cloud.tencent.com/product/tione/). We pre-train 200,000 steps with a sequence length of 128. We use extended vocabulary to handle out-of-vocabulary words. The Chinese character that occurs greater than or equal to 100 in poem corpus is added to the vocabulary.
50
 
51
  ```
52
  python3 preprocess.py --corpus_path corpora/poem.txt \
53
- --vocab_path models/poem_zh_vocab.txt \
54
- --dataset_path poem_dataset.pt --processes_num 16 \
55
- --seq_length 128 --target lm
56
  ```
57
 
58
  ```
59
  python3 pretrain.py --dataset_path poem_dataset.pt \
60
- --vocab_path models/poem_zh_vocab.txt \
61
- --config_path models/gpt2/config.json \
62
- --output_model_path models/poem_gpt2_model.bin \
63
- --world_size 8 --gpu_ranks 0 1 2 3 4 5 6 7 \
64
- --total_steps 200000 --save_checkpoint_steps 50000 --report_steps 1000 \
65
- --learning_rate 5e-4 --batch_size 64 \
66
- --embedding word_pos --remove_embedding_layernorm \
67
- --encoder transformer --mask causal --layernorm_positioning pre \
68
- --target lm --tie_weight
69
-
70
  ```
71
 
72
  Finally, we convert the pre-trained model into Huggingface's format:
73
  ```
74
  python3 scripts/convert_gpt2_from_uer_to_huggingface.py --input_model_path poem_gpt2_base_model.bin-200000 \
75
- --output_model_path pytorch_model.bin \
76
- --layers_num 12
77
  ```
78
 
79
  ### BibTeX entry and citation info
80
 
81
  ```
 
 
 
 
 
 
82
  @article{zhao2019uer,
83
  title={UER: An Open-Source Toolkit for Pre-training Models},
84
  author={Zhao, Zhe and Chen, Hui and Zhang, Jinbin and Zhao, Xin and Liu, Tao and Lu, Wei and Chen, Xi and Deng, Haotang and Ju, Qi and Du, Xiaoyong},
12
 
13
  The model is used to generate Chinese ancient poems. You can download the model either from the [GPT2-Chinese Github page](https://github.com/Morizeyao/GPT2-Chinese), or via HuggingFace from the link [gpt2-chinese-poem][poem].
14
 
15
+ Since the parameter skip_special_tokens is used in the pipelines.py, special tokens such as [SEP], [UNK] will be deleted, the output results of Hosted inference API (right) may not be properly displayed.
16
 
17
  ## How to use
18
 
26
  >>> model = GPT2LMHeadModel.from_pretrained("uer/gpt2-chinese-poem")
27
  >>> text_generator = TextGenerationPipeline(model, tokenizer)
28
  >>> text_generator("[CLS]梅 山 如 积 翠 ,", max_length=50, do_sample=True)
29
+ [{'generated_text': '[CLS]梅 山 如 积 翠 , 丛 竹 隠 疏 花 。 水 影 落 寒 濑 , 竹 声 随 暮 鸦 。 茅 茨 数 间 屋 , 烟 火 两 三 家 。 安 得 携 琴 酒 , 相 逢 烟 雨 赊 。 向 湖 边 过 , 偏 怜 雪 里 看 。 浮 峦 如 画 出 , 远 树 与 天 连 。 月 上 僧 房 静 , 风 回 萤 火 寒 。 幽 情 何 可 写 , 赖 有 子 期 弹 。 棠 真'}]
30
  ```
31
 
32
  When the parameter skip_special_tokens is False:
37
  >>> model = GPT2LMHeadModel.from_pretrained("uer/gpt2-chinese-poem")
38
  >>> text_generator = TextGenerationPipeline(model, tokenizer)
39
  >>> text_generator("[CLS]梅 山 如 积 翠 ,", max_length=100, do_sample=True)
40
+ [{'generated_text': '[CLS]梅 山 如 积 翠 , 秀 出 何 其 雄 。 矫 矫 云 间 质 , 映 日 生 玲 珑 。 根 大 乱 石 结 , 枝 高 青 云 蒙 。 常 因 风 露 晚 , 隠 映 瑶 台 中 。 忽 闻 山 石 裂 , 万 里 吹 天 风 。 又 觉 此 身 高 , 迥 出 凡 境 空 。 清 影 落 潭 水 , 暗 香 来 逈 峰 。 却 寻 白 太 白 , 月 影 摇 江 东 。 [SEP] 而 非'}]
41
  ```
42
 
43
  ## Training data
46
 
47
  ## Training procedure
48
 
49
+ The model is pre-trained by [UER-py](https://github.com/dbiir/UER-py/) on [Tencent Cloud](https://cloud.tencent.com/). We pre-train 200,000 steps with a sequence length of 128. We use extended vocabulary to handle out-of-vocabulary words. The Chinese character that occurs greater than or equal to 100 in poem corpus is added to the vocabulary.
50
 
51
  ```
52
  python3 preprocess.py --corpus_path corpora/poem.txt \
53
+ --vocab_path models/poem_zh_vocab.txt \
54
+ --dataset_path poem_dataset.pt --processes_num 16 \
55
+ --seq_length 128 --target lm
56
  ```
57
 
58
  ```
59
  python3 pretrain.py --dataset_path poem_dataset.pt \
60
+ --vocab_path models/poem_zh_vocab.txt \
61
+ --config_path models/gpt2/config.json \
62
+ --output_model_path models/poem_gpt2_model.bin \
63
+ --world_size 8 --gpu_ranks 0 1 2 3 4 5 6 7 \
64
+ --total_steps 200000 --save_checkpoint_steps 50000 --report_steps 1000 \
65
+ --learning_rate 5e-4 --batch_size 64 \
66
+ --embedding word_pos --remove_embedding_layernorm \
67
+ --encoder transformer --mask causal --layernorm_positioning pre \
68
+ --target lm --tie_weight
 
69
  ```
70
 
71
  Finally, we convert the pre-trained model into Huggingface's format:
72
  ```
73
  python3 scripts/convert_gpt2_from_uer_to_huggingface.py --input_model_path poem_gpt2_base_model.bin-200000 \
74
+ --output_model_path pytorch_model.bin \
75
+ --layers_num 12
76
  ```
77
 
78
  ### BibTeX entry and citation info
79
 
80
  ```
81
+ @article{radford2019language,
82
+ title={Language Models are Unsupervised Multitask Learners},
83
+ author={Radford, Alec and Wu, Jeff and Child, Rewon and Luan, David and Amodei, Dario and Sutskever, Ilya},
84
+ year={2019}
85
+ }
86
+
87
  @article{zhao2019uer,
88
  title={UER: An Open-Source Toolkit for Pre-training Models},
89
  author={Zhao, Zhe and Chen, Hui and Zhang, Jinbin and Zhao, Xin and Liu, Tao and Lu, Wei and Chen, Xi and Deng, Haotang and Ju, Qi and Du, Xiaoyong},