gxy commited on
Commit
a83b3eb
1 Parent(s): 504de16

INIT: add bart model

Browse files
README.md CHANGED
@@ -1,3 +1,44 @@
1
  ---
 
 
2
  license: apache-2.0
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - zh
4
  license: apache-2.0
5
+
6
+ inference: true
7
+
8
+ widget:
9
+ - text: "北京是<mask>的首都"
10
+
11
+
12
  ---
13
+ # Randeng-BART-139M model (Chinese),one model of [Fengshenbang-LM](https://github.com/IDEA-CCNL/Fengshenbang-LM).
14
+ The 139M million parameter Randeng-BART large model, using 180G Chinese data, 8 A100(40G) training for 3 days,which is a standard transformer structure.
15
+
16
+
17
+ ## Usage
18
+ ```python
19
+ from transformers import BartForConditionalGeneration, AutoTokenizer
20
+ import torch
21
+
22
+ tokenizer=AutoTokenizer.from_pretrained('IDEA-CCNL/Randeng-BART-139M', use_fast=false)
23
+ model=BartForConditionalGeneration.from_pretrained('IDEA-CCNL/Randeng-BART-139M')
24
+
25
+ text = '北京是<mask>的首都'
26
+
27
+ logits = model(input_ids).logits
28
+ masked_index = (input_ids[0] == tokenizer.mask_token_id).nonzero().item()
29
+ probs = logits[0, masked_index].softmax(dim=0)
30
+ values, predictions = probs.topk(1)
31
+
32
+ print(tokenizer.decode(predictions))
33
+ ```
34
+
35
+ ## Citation
36
+ If you find the resource is useful, please cite the following website in your paper.
37
+ ```
38
+ @misc{Fengshenbang-LM,
39
+ title={Fengshenbang-LM},
40
+ author={IDEA-CCNL},
41
+ year={2022},
42
+ howpublished={\url{https://github.com/IDEA-CCNL/Fengshenbang-LM}},
43
+ }
44
+ ```
added_tokens.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"<pad>": 40000, "<mask>": 40001}
config.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "bart-base",
3
+ "activation_dropout": 0.1,
4
+ "activation_function": "gelu",
5
+ "add_bias_logits": false,
6
+ "add_final_layer_norm": false,
7
+ "architectures": [
8
+ "BartForConditionalGeneration"
9
+ ],
10
+ "attention_dropout": 0.1,
11
+ "bos_token_id": 0,
12
+ "classif_dropout": 0.1,
13
+ "classifier_dropout": 0.0,
14
+ "d_model": 768,
15
+ "decoder_attention_heads": 12,
16
+ "decoder_ffn_dim": 3072,
17
+ "decoder_layerdrop": 0.0,
18
+ "decoder_layers": 6,
19
+ "decoder_start_token_id": 2,
20
+ "dropout": 0.1,
21
+ "encoder_attention_heads": 12,
22
+ "encoder_ffn_dim": 3072,
23
+ "encoder_layerdrop": 0.0,
24
+ "encoder_layers": 6,
25
+ "eos_token_id": 2,
26
+ "forced_eos_token_id": 2,
27
+ "id2label": {
28
+ "0": "LABEL_0",
29
+ "1": "LABEL_1",
30
+ "2": "LABEL_2"
31
+ },
32
+ "init_std": 0.02,
33
+ "is_encoder_decoder": true,
34
+ "label2id": {
35
+ "LABEL_0": 0,
36
+ "LABEL_1": 1,
37
+ "LABEL_2": 2
38
+ },
39
+ "max_position_embeddings": 1024,
40
+ "model_type": "bart",
41
+ "no_repeat_ngram_size": 3,
42
+ "normalize_before": false,
43
+ "normalize_embedding": true,
44
+ "num_beams": 4,
45
+ "num_hidden_layers": 6,
46
+ "pad_token_id": 1,
47
+ "scale_embedding": false,
48
+ "torch_dtype": "float16",
49
+ "transformers_version": "4.16.0.dev0",
50
+ "use_cache": true,
51
+ "vocab_size": 50265
52
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:feeaeccf52742bf4cd252aa67a3153637983e2334f41971d7c60bc4aad981f84
3
+ size 279034105
save_tokenizer.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import T5Tokenizer
2
+
3
+ tokenizer = T5Tokenizer.from_pretrained(
4
+ '/cognitive_comp/common_data/tokenizers/sentence_piece_bpe/bpe_v40000_s42_cov0.9995_max6_corpus1M.model',
5
+ additional_special_tokens=['<s>', '<mask>'],
6
+ extra_ids=0)
7
+ tokenizer.bos_token = '<s>'
8
+ tokenizer.mask_token = '<mask>'
9
+ tokenizer.save_pretrained('/cognitive_comp/gaoxinyu/pretrained_model/bart-base')
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "pad_token": "<pad>", "mask_token": "<mask>", "additional_special_tokens": ["<s>", "<mask>"]}
spiece.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a1836aa16c5e41fb9bec14c477218b83812919d19dfdde1c49a419cd9935615
3
+ size 858518
tokenizer_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "eos_token": "</s>",
3
+ "unk_token": "<unk>",
4
+ "pad_token": "<pad>",
5
+ "extra_ids": 0,
6
+ "additional_special_tokens": [
7
+ "<s>",
8
+ "<mask>"
9
+ ],
10
+ "sp_model_kwargs": {},
11
+ "name_or_path": "/cognitive_comp/common_data/tokenizers/sentence_piece_bpe/bpe_v40000_s42_cov0.9995_max6_corpus1M.model",
12
+ "tokenizer_class": "T5Tokenizer"
13
+ }