Views
No views yet
| 需求 Demand | 任务 Task | 系列 Series | 模型 Model | 参数 Parameter | 额外 Extra |
|---|---|---|---|---|---|
| 特殊 Special | 探索 Exploration | 周文王 Zhouwenwang | 待定 TBD | 1.3B | 中文 Chinese |
| 模型 Model | afqmc | tnews | iflytek | ocnli | cmnli | wsc | csl |
|---|---|---|---|---|---|---|---|
| roberta-wwm-ext-large | 0.7514 | 0.5872 | 0.6152 | 0.7770 | 0.8140 | 0.8914 | 0.8600 |
| Zhouwenwang-Unified-1.3B | 0.7463 | 0.6036 | 0.6288 | 0.7654 | 0.7741 | 0.8849 | 0. 8777 |
git clone https://github.com/IDEA-CCNL/Fengshenbang-LM.git1from fengshen import RoFormerModel
2from fengshen import RoFormerConfig
3from transformers import BertTokenizer
4
5tokenizer = BertTokenizer.from_pretrained("IDEA-CCNL/Zhouwenwang-Unified-1.3B")
6config = RoFormerConfig.from_pretrained("IDEA-CCNL/Zhouwenwang-Unified-1.3B")
7model = RoFormerModel.from_pretrained("IDEA-CCNL/Zhouwenwang-Unified-1.3B")1from fengshen import RoFormerModel
2from transformers import AutoTokenizer
3import torch
4import numpy as np
5
6sentence = '清华大学位于'
7max_length = 32
8
9tokenizer = AutoTokenizer.from_pretrained("IDEA-CCNL/Zhouwenwang-Unified-1.3B")
10model = RoFormerModel.from_pretrained("IDEA-CCNL/Zhouwenwang-Unified-1.3B")
11
12for i in range(max_length):
13 encode = torch.tensor(
14 [[tokenizer.cls_token_id]+tokenizer.encode(sentence, add_special_tokens=False)]).long()
15 logits = model(encode)[0]
16 logits = torch.nn.functional.linear(
17 logits, model.embeddings.word_embeddings.weight)
18 logits = torch.nn.functional.softmax(
19 logits, dim=-1).cpu().detach().numpy()[0]
20 sentence = sentence + \
21 tokenizer.decode(int(np.random.choice(logits.shape[1], p=logits[-1])))
22 if sentence[-1] == '。':
23 break
24print(sentence)1@article{fengshenbang,
2 author = {Jiaxing Zhang and Ruyi Gan and Junjie Wang and Yuxiang Zhang and Lin Zhang and Ping Yang and Xinyu Gao and Ziwei Wu and Xiaoqun Dong and Junqing He and Jianheng Zhuo and Qi Yang and Yongfeng Huang and Xiayu Li and Yanghan Wu and Junyu Lu and Xinyu Zhu and Weifeng Chen and Ting Han and Kunhao Pan and Rui Wang and Hao Wang and Xiaojun Wu and Zhongshen Zeng and Chongpei Chen},
3 title = {Fengshenbang 1.0: Being the Foundation of Chinese Cognitive Intelligence},
4 journal = {CoRR},
5 volume = {abs/2209.02970},
6 year = {2022}
7}1@misc{Fengshenbang-LM,
2 title={Fengshenbang-LM},
3 author={IDEA-CCNL},
4 year={2021},
5 howpublished={\url{https://github.com/IDEA-CCNL/Fengshenbang-LM}},
6}