KoichiYasuoka commited on
Commit
c98537a
1 Parent(s): a66a53d

model improved for transformers 4.42

Browse files
config.json CHANGED
@@ -2,24 +2,12 @@
2
  "architectures": [
3
  "MistralForTokenClassification"
4
  ],
5
- "attention_bias": false,
6
  "attention_dropout": 0.0,
7
- "auto_map": {
8
- "AutoModelForTokenClassification": "upos.MistralForTokenClassification"
9
- },
10
  "bos_token_id": 1,
11
  "custom_pipelines": {
12
  "upos": {
13
  "impl": "upos.BellmanFordTokenClassificationPipeline",
14
  "pt": "AutoModelForTokenClassification"
15
- },
16
- "token-classification": {
17
- "impl": "upos.RawTokenClassificationPipeline",
18
- "pt": "AutoModelForTokenClassification"
19
- },
20
- "ner": {
21
- "impl": "upos.RawTokenClassificationPipeline",
22
- "pt": "AutoModelForTokenClassification"
23
  }
24
  },
25
  "eos_token_id": 2,
@@ -156,15 +144,13 @@
156
  "num_attention_heads": 32,
157
  "num_hidden_layers": 32,
158
  "num_key_value_heads": 8,
159
- "pretraining_tp": 1,
160
  "rms_norm_eps": 1e-05,
161
- "rope_scaling": null,
162
  "rope_theta": 10000.0,
163
  "sliding_window": 4096,
164
  "tie_word_embeddings": false,
165
  "tokenizer_class": "LlamaTokenizerFast",
166
  "torch_dtype": "float32",
167
- "transformers_version": "4.38.1",
168
  "use_cache": true,
169
  "vocab_size": 43317
170
  }
 
2
  "architectures": [
3
  "MistralForTokenClassification"
4
  ],
 
5
  "attention_dropout": 0.0,
 
 
 
6
  "bos_token_id": 1,
7
  "custom_pipelines": {
8
  "upos": {
9
  "impl": "upos.BellmanFordTokenClassificationPipeline",
10
  "pt": "AutoModelForTokenClassification"
 
 
 
 
 
 
 
 
11
  }
12
  },
13
  "eos_token_id": 2,
 
144
  "num_attention_heads": 32,
145
  "num_hidden_layers": 32,
146
  "num_key_value_heads": 8,
 
147
  "rms_norm_eps": 1e-05,
 
148
  "rope_theta": 10000.0,
149
  "sliding_window": 4096,
150
  "tie_word_embeddings": false,
151
  "tokenizer_class": "LlamaTokenizerFast",
152
  "torch_dtype": "float32",
153
+ "transformers_version": "4.42.4",
154
  "use_cache": true,
155
  "vocab_size": 43317
156
  }
maker.sh CHANGED
@@ -9,7 +9,7 @@ then TMPA=./maker$$a.py
9
  src="tokyotech-llm/Swallow-MS-7b-v0.1"
10
  tgt="exSwallow-MS-7b-v0.1"
11
  import json,torch,unicodedata
12
- from transformers import LlamaTokenizerFast,LlamaForCausalLM
13
  with open("JapaneseCoreKanji.txt","r",encoding="utf-8") as r:
14
  cjk=[chr(int(t,16)) for t in r.read().strip().split("\n") if not t.startswith("#")]
15
  with open("ja_gsd_modern.conllu","r",encoding="utf-8") as r:
@@ -26,7 +26,7 @@ d=json.loads(tkz.backend_tokenizer.to_str())
26
  for i,j in enumerate(c,len(tkz)):
27
  d["model"]["vocab"][j]=i
28
  tkz.backend_tokenizer.from_str(json.dumps(d)).save("tokenizer.json")
29
- mdl=LlamaForCausalLM.from_pretrained(src)
30
  tkz=LlamaTokenizerFast(tokenizer_file="tokenizer.json",model_max_length=mdl.config.max_position_embeddings,cls_token="<s>",sep_token="<s>",mask_token="<unk>",pad_token="</s>")
31
  e=mdl.resize_token_embeddings(len(tkz))
32
  f=mdl.get_output_embeddings()
@@ -48,45 +48,9 @@ cat << 'EOF' > $TMPB
48
  #! /usr/bin/env deepspeed
49
  src="exSwallow-MS-7b-v0.1"
50
  tgt="KoichiYasuoka/Swallow-MS-7b-upos"
51
- from transformers import LlamaTokenizerFast,MistralModel,MistralPreTrainedModel,AutoConfig,DataCollatorForTokenClassification,TrainingArguments,Trainer
52
- from transformers.modeling_outputs import TokenClassifierOutput
53
  from tokenizers.normalizers import Replace
54
 
55
- class MistralForTokenClassification(MistralPreTrainedModel):
56
- def __init__(self,config):
57
- from torch import nn
58
- super().__init__(config)
59
- self.num_labels=config.num_labels
60
- self.model=MistralModel(config)
61
- if hasattr(config,"classifier_dropout") and config.classifier_dropout is not None:
62
- classifier_dropout=config.classifier_dropout
63
- elif hasattr(config,"hidden_dropout") and config.hidden_dropout is not None:
64
- classifier_dropout=config.hidden_dropout
65
- else:
66
- classifier_dropout=0.1
67
- self.dropout=nn.Dropout(classifier_dropout)
68
- self.classifier=nn.Linear(config.hidden_size,config.num_labels)
69
- self.post_init()
70
- def get_input_embeddings(self):
71
- return self.model.embed_tokens
72
- def set_input_embeddings(self,value):
73
- self.model.embed_tokens=value
74
- def forward(self,input_ids=None,past_key_values=None,attention_mask=None,position_ids=None,inputs_embeds=None,labels=None,use_cache=None,output_attentions=None,output_hidden_states=None,return_dict=None):
75
- return_dict=return_dict if return_dict is not None else self.config.use_return_dict
76
- transformer_outputs=self.model(input_ids,past_key_values=past_key_values,attention_mask=attention_mask,position_ids=position_ids,inputs_embeds=inputs_embeds,use_cache=use_cache,output_attentions=output_attentions,output_hidden_states=output_hidden_states,return_dict=return_dict)
77
- hidden_states=transformer_outputs[0]
78
- hidden_states=self.dropout(hidden_states)
79
- logits=self.classifier(hidden_states)
80
- loss=None
81
- if labels is not None:
82
- from torch import nn
83
- loss_fct=nn.CrossEntropyLoss()
84
- loss=loss_fct(logits.view(-1,self.num_labels),labels.view(-1))
85
- if not return_dict:
86
- output=(logits,)+transformer_outputs[2:]
87
- return ((loss,)+output) if loss is not None else output
88
- return TokenClassifierOutput(loss=loss,logits=logits,hidden_states=transformer_outputs.hidden_states,attentions=transformer_outputs.attentions)
89
-
90
  class UPOSFileDataset(object):
91
  def __init__(self,conllu,tokenizer):
92
  self.conllu=open(conllu,"r",encoding="utf-8")
 
9
  src="tokyotech-llm/Swallow-MS-7b-v0.1"
10
  tgt="exSwallow-MS-7b-v0.1"
11
  import json,torch,unicodedata
12
+ from transformers import LlamaTokenizerFast,MistralForCausalLM
13
  with open("JapaneseCoreKanji.txt","r",encoding="utf-8") as r:
14
  cjk=[chr(int(t,16)) for t in r.read().strip().split("\n") if not t.startswith("#")]
15
  with open("ja_gsd_modern.conllu","r",encoding="utf-8") as r:
 
26
  for i,j in enumerate(c,len(tkz)):
27
  d["model"]["vocab"][j]=i
28
  tkz.backend_tokenizer.from_str(json.dumps(d)).save("tokenizer.json")
29
+ mdl=MistralForCausalLM.from_pretrained(src)
30
  tkz=LlamaTokenizerFast(tokenizer_file="tokenizer.json",model_max_length=mdl.config.max_position_embeddings,cls_token="<s>",sep_token="<s>",mask_token="<unk>",pad_token="</s>")
31
  e=mdl.resize_token_embeddings(len(tkz))
32
  f=mdl.get_output_embeddings()
 
48
  #! /usr/bin/env deepspeed
49
  src="exSwallow-MS-7b-v0.1"
50
  tgt="KoichiYasuoka/Swallow-MS-7b-upos"
51
+ from transformers import LlamaTokenizerFast,MistralForTokenClassification,AutoConfig,DataCollatorForTokenClassification,TrainingArguments,Trainer
 
52
  from tokenizers.normalizers import Replace
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  class UPOSFileDataset(object):
55
  def __init__(self,conllu,tokenizer):
56
  self.conllu=open(conllu,"r",encoding="utf-8")
pytorch_model-00001-of-00006.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e6d84221d64e2e200ded9278ecfde0568bae10c9fb37ce332d0204da2f2bd05c
3
- size 4837046848
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3bc383e2836bfade4a66c8c3c8e5871240d5b1cc86aaf912120c098dc37db88f
3
+ size 2539520
pytorch_model-00002-of-00006.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9dff65e498bee680f1c713066816815201df578e91f946dff3b2916d4a06c710
3
- size 4999825256
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b2a123e02228dbfea708d4ff57dc9ccf7bfd5dbb992567a86d42ab14146b55d2
3
+ size 4390338560
pytorch_model-00003-of-00006.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:09bcc41cb1dc25584295cdd197a59ebeeb28d82742df8e60fc8441ab82c9c8c0
3
  size 4999825316
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70f9676f885d30e08789261553c6ed7a949acef9de9a67dce005cede7ec8fa73
3
  size 4999825316
pytorch_model-00004-of-00006.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:abcd008f22397fe546185c4a3f47601e693e9d2dfc015146f93a546f965e41a0
3
- size 4832018324
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b8a16ad523ebf2fa508012f2b0d0fee6d2c2a4583daff8d4058aaf7240cc020
3
+ size 23379968
pytorch_model-00005-of-00006.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9f5a5f0b7a8bd6b3f2ad8792fef499b63ae99f1cb3209029ff07f20b9d6f4c47
3
  size 4999825320
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ba5e8032cd9a92cfaf0f3d30360285d03a7f32af32b0ad07f0c0b7d241d64f5
3
  size 4999825320
pytorch_model-00006-of-00006.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e39aca1f76ff251d2945a1b8966204baa98480df9ec4edd7da2a115da8314b3f
3
  size 3960601264
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a82d77158930bdf9ffc566bd2be9e7600b4b4831d287679e3086cab45466ac6
3
  size 3960601264
pytorch_model.bin.index.json CHANGED
@@ -3,8 +3,6 @@
3
  "total_size": 28629041392
4
  },
5
  "weight_map": {
6
- "classifier.bias": "pytorch_model-00006-of-00006.bin",
7
- "classifier.weight": "pytorch_model-00006-of-00006.bin",
8
  "model.embed_tokens.weight": "pytorch_model-00001-of-00006.bin",
9
  "model.layers.0.input_layernorm.weight": "pytorch_model-00001-of-00006.bin",
10
  "model.layers.0.mlp.down_proj.weight": "pytorch_model-00001-of-00006.bin",
@@ -294,6 +292,8 @@
294
  "model.layers.9.self_attn.o_proj.weight": "pytorch_model-00002-of-00006.bin",
295
  "model.layers.9.self_attn.q_proj.weight": "pytorch_model-00002-of-00006.bin",
296
  "model.layers.9.self_attn.v_proj.weight": "pytorch_model-00002-of-00006.bin",
297
- "model.norm.weight": "pytorch_model-00006-of-00006.bin"
 
 
298
  }
299
  }
 
3
  "total_size": 28629041392
4
  },
5
  "weight_map": {
 
 
6
  "model.embed_tokens.weight": "pytorch_model-00001-of-00006.bin",
7
  "model.layers.0.input_layernorm.weight": "pytorch_model-00001-of-00006.bin",
8
  "model.layers.0.mlp.down_proj.weight": "pytorch_model-00001-of-00006.bin",
 
292
  "model.layers.9.self_attn.o_proj.weight": "pytorch_model-00002-of-00006.bin",
293
  "model.layers.9.self_attn.q_proj.weight": "pytorch_model-00002-of-00006.bin",
294
  "model.layers.9.self_attn.v_proj.weight": "pytorch_model-00002-of-00006.bin",
295
+ "model.norm.weight": "pytorch_model-00006-of-00006.bin",
296
+ "score.bias": "pytorch_model-00006-of-00006.bin",
297
+ "score.weight": "pytorch_model-00006-of-00006.bin"
298
  }
299
  }
tokenizer.json CHANGED
@@ -125,6 +125,7 @@
125
  "end_of_word_suffix": null,
126
  "fuse_unk": true,
127
  "byte_fallback": false,
 
128
  "vocab": {
129
  "<unk>": 0,
130
  "<s>": 1,
@@ -42926,523 +42927,523 @@
42926
  "勅": 42797,
42927
  "婿": 42798,
42928
  "魯": 42799,
42929
- "": 42800,
42930
- "": 42801,
42931
- "": 42802,
42932
- "": 42803,
42933
- "": 42804,
42934
- "": 42805,
42935
- "": 42806,
42936
- "": 42807,
42937
- "": 42808,
42938
- "": 42809,
42939
- "": 42810,
42940
- "": 42811,
42941
- "": 42812,
42942
- "": 42813,
42943
- "": 42814,
42944
- "": 42815,
42945
- "": 42816,
42946
- "": 42817,
42947
- "": 42818,
42948
- "": 42819,
42949
- "": 42820,
42950
- "": 42821,
42951
- "": 42822,
42952
- "": 42823,
42953
- "": 42824,
42954
- "": 42825,
42955
- "": 42826,
42956
- "": 42827,
42957
- "": 42828,
42958
- "": 42829,
42959
- "": 42830,
42960
- "": 42831,
42961
- "": 42832,
42962
- "": 42833,
42963
- "": 42834,
42964
- "": 42835,
42965
- "": 42836,
42966
- "": 42837,
42967
- "": 42838,
42968
- "": 42839,
42969
- "": 42840,
42970
- "": 42841,
42971
- "": 42842,
42972
- "": 42843,
42973
- "": 42844,
42974
- "": 42845,
42975
- "": 42846,
42976
- "": 42847,
42977
- "": 42848,
42978
- "": 42849,
42979
- "": 42850,
42980
- "": 42851,
42981
- "": 42852,
42982
- "": 42853,
42983
- "": 42854,
42984
- "": 42855,
42985
- "": 42856,
42986
- "": 42857,
42987
- "": 42858,
42988
- "": 42859,
42989
- "": 42860,
42990
- "": 42861,
42991
- "": 42862,
42992
- "": 42863,
42993
- "": 42864,
42994
- "": 42865,
42995
- "": 42866,
42996
- "": 42867,
42997
- "": 42868,
42998
- "": 42869,
42999
- "": 42870,
43000
- "": 42871,
43001
- "": 42872,
43002
- "": 42873,
43003
- "": 42874,
43004
- "": 42875,
43005
- "": 42876,
43006
- "": 42877,
43007
- "": 42878,
43008
- "": 42879,
43009
- "": 42880,
43010
- "": 42881,
43011
- "": 42882,
43012
- "": 42883,
43013
- "": 42884,
43014
- "": 42885,
43015
- "": 42886,
43016
- "": 42887,
43017
- "": 42888,
43018
- "": 42889,
43019
- "": 42890,
43020
- "": 42891,
43021
- "": 42892,
43022
- "": 42893,
43023
- "": 42894,
43024
- "": 42895,
43025
- "": 42896,
43026
- "": 42897,
43027
- "": 42898,
43028
- "": 42899,
43029
- "": 42900,
43030
- "": 42901,
43031
- "": 42902,
43032
- "": 42903,
43033
- "": 42904,
43034
- "": 42905,
43035
- "": 42906,
43036
- "": 42907,
43037
- "": 42908,
43038
- "": 42909,
43039
- "": 42910,
43040
- "": 42911,
43041
- "": 42912,
43042
- "": 42913,
43043
- "": 42914,
43044
- "": 42915,
43045
- "": 42916,
43046
- "": 42917,
43047
- "": 42918,
43048
- "": 42919,
43049
- "": 42920,
43050
- "": 42921,
43051
- "": 42922,
43052
- "": 42923,
43053
- "": 42924,
43054
- "": 42925,
43055
- "": 42926,
43056
- "": 42927,
43057
- "": 42928,
43058
- "": 42929,
43059
- "": 42930,
43060
- "": 42931,
43061
- "𠮟": 42932,
43062
- "": 42933,
43063
- "": 42934,
43064
- "": 42935,
43065
- "": 42936,
43066
- "": 42937,
43067
- "": 42938,
43068
- "": 42939,
43069
- "": 42940,
43070
- "": 42941,
43071
- "": 42942,
43072
- "": 42943,
43073
- "": 42944,
43074
- "": 42945,
43075
- "": 42946,
43076
- "": 42947,
43077
- "": 42948,
43078
- "": 42949,
43079
- "": 42950,
43080
- "": 42951,
43081
- "": 42952,
43082
- "": 42953,
43083
- "": 42954,
43084
- "": 42955,
43085
- "": 42956,
43086
- "": 42957,
43087
- "": 42958,
43088
- "": 42959,
43089
- "": 42960,
43090
- "": 42961,
43091
- "": 42962,
43092
- "": 42963,
43093
- "": 42964,
43094
- "": 42965,
43095
- "": 42966,
43096
- "": 42967,
43097
- "": 42968,
43098
- "": 42969,
43099
- "": 42970,
43100
- "": 42971,
43101
- "": 42972,
43102
- "": 42973,
43103
- "": 42974,
43104
- "": 42975,
43105
- "": 42976,
43106
- "": 42977,
43107
- "": 42978,
43108
- "": 42979,
43109
- "": 42980,
43110
- "": 42981,
43111
- "": 42982,
43112
- "": 42983,
43113
- "忿": 42984,
43114
- "": 42985,
43115
- "": 42986,
43116
- "": 42987,
43117
- "": 42988,
43118
- "": 42989,
43119
- "": 42990,
43120
- "": 42991,
43121
- "": 42992,
43122
- "": 42993,
43123
- "": 42994,
43124
- "": 42995,
43125
- "": 42996,
43126
- "": 42997,
43127
- "": 42998,
43128
- "": 42999,
43129
- "": 43000,
43130
- "": 43001,
43131
- "": 43002,
43132
- "": 43003,
43133
- "": 43004,
43134
- "": 43005,
43135
- "": 43006,
43136
- "": 43007,
43137
- "": 43008,
43138
- "": 43009,
43139
- "": 43010,
43140
- "": 43011,
43141
- "": 43012,
43142
- "": 43013,
43143
- "": 43014,
43144
- "": 43015,
43145
- "": 43016,
43146
- "": 43017,
43147
- "": 43018,
43148
- "": 43019,
43149
- "": 43020,
43150
- "": 43021,
43151
- "": 43022,
43152
- "": 43023,
43153
- "": 43024,
43154
- "": 43025,
43155
- "": 43026,
43156
- "": 43027,
43157
- "": 43028,
43158
- "": 43029,
43159
- "": 43030,
43160
- "": 43031,
43161
- "": 43032,
43162
- "": 43033,
43163
- "": 43034,
43164
- "": 43035,
43165
- "": 43036,
43166
- "": 43037,
43167
- "": 43038,
43168
- "": 43039,
43169
- "": 43040,
43170
- "": 43041,
43171
- "": 43042,
43172
- "": 43043,
43173
- "": 43044,
43174
- "": 43045,
43175
- "": 43046,
43176
- "": 43047,
43177
- "": 43048,
43178
- "": 43049,
43179
- "": 43050,
43180
- "": 43051,
43181
- "": 43052,
43182
- "": 43053,
43183
- "": 43054,
43184
- "": 43055,
43185
- "": 43056,
43186
- "": 43057,
43187
- "": 43058,
43188
- "": 43059,
43189
- "": 43060,
43190
- "": 43061,
43191
- "": 43062,
43192
- "": 43063,
43193
- "": 43064,
43194
- "": 43065,
43195
- "": 43066,
43196
- "": 43067,
43197
- "": 43068,
43198
- "": 43069,
43199
- "": 43070,
43200
- "": 43071,
43201
- "": 43072,
43202
- "": 43073,
43203
- "": 43074,
43204
- "": 43075,
43205
- "": 43076,
43206
- "": 43077,
43207
- "": 43078,
43208
- "": 43079,
43209
- "": 43080,
43210
- "": 43081,
43211
- "": 43082,
43212
- "": 43083,
43213
- "": 43084,
43214
- "": 43085,
43215
- "": 43086,
43216
- "": 43087,
43217
- "": 43088,
43218
- "": 43089,
43219
- "": 43090,
43220
- "": 43091,
43221
- "": 43092,
43222
- "": 43093,
43223
- "": 43094,
43224
- "": 43095,
43225
- "": 43096,
43226
- "": 43097,
43227
- "": 43098,
43228
- "": 43099,
43229
- "": 43100,
43230
- "": 43101,
43231
- "": 43102,
43232
- "": 43103,
43233
- "": 43104,
43234
- "": 43105,
43235
- "": 43106,
43236
- "": 43107,
43237
- "": 43108,
43238
- "": 43109,
43239
- "": 43110,
43240
- "": 43111,
43241
- "": 43112,
43242
- "": 43113,
43243
- "": 43114,
43244
- "": 43115,
43245
- "": 43116,
43246
- "": 43117,
43247
- "": 43118,
43248
- "": 43119,
43249
- "": 43120,
43250
- "": 43121,
43251
- "": 43122,
43252
- "": 43123,
43253
- "": 43124,
43254
- "": 43125,
43255
- "": 43126,
43256
- "": 43127,
43257
- "": 43128,
43258
- "": 43129,
43259
- "": 43130,
43260
- "": 43131,
43261
- "": 43132,
43262
- "": 43133,
43263
- "": 43134,
43264
- "": 43135,
43265
- "": 43136,
43266
- "": 43137,
43267
- "": 43138,
43268
- "": 43139,
43269
- "": 43140,
43270
- "": 43141,
43271
- "": 43142,
43272
- "": 43143,
43273
- "": 43144,
43274
- "": 43145,
43275
- "": 43146,
43276
- "": 43147,
43277
- "": 43148,
43278
- "": 43149,
43279
- "": 43150,
43280
- "": 43151,
43281
- "": 43152,
43282
- "": 43153,
43283
- "": 43154,
43284
- "": 43155,
43285
- "": 43156,
43286
- "": 43157,
43287
- "": 43158,
43288
- "": 43159,
43289
- "": 43160,
43290
- "": 43161,
43291
- "": 43162,
43292
- "": 43163,
43293
- "": 43164,
43294
- "": 43165,
43295
- "": 43166,
43296
- "": 43167,
43297
- "": 43168,
43298
- "": 43169,
43299
- "": 43170,
43300
- "": 43171,
43301
- "": 43172,
43302
- "": 43173,
43303
- "": 43174,
43304
- "": 43175,
43305
- "": 43176,
43306
- "": 43177,
43307
- "": 43178,
43308
- "": 43179,
43309
- "": 43180,
43310
- "": 43181,
43311
- "": 43182,
43312
- "": 43183,
43313
- "": 43184,
43314
- "": 43185,
43315
- "": 43186,
43316
- "": 43187,
43317
- "": 43188,
43318
- "": 43189,
43319
- "": 43190,
43320
- "": 43191,
43321
- "": 43192,
43322
- "": 43193,
43323
- "": 43194,
43324
- "": 43195,
43325
- "": 43196,
43326
- "": 43197,
43327
- "": 43198,
43328
- "": 43199,
43329
- "": 43200,
43330
- "": 43201,
43331
- "": 43202,
43332
- "": 43203,
43333
- "": 43204,
43334
- "": 43205,
43335
- "": 43206,
43336
- "": 43207,
43337
- "": 43208,
43338
- "": 43209,
43339
- "": 43210,
43340
- "": 43211,
43341
- "": 43212,
43342
- "": 43213,
43343
- "": 43214,
43344
- "": 43215,
43345
- "": 43216,
43346
- "": 43217,
43347
- "": 43218,
43348
- "麿": 43219,
43349
- "": 43220,
43350
- "": 43221,
43351
- "": 43222,
43352
- "": 43223,
43353
- "": 43224,
43354
- "": 43225,
43355
- "": 43226,
43356
- "": 43227,
43357
- "": 43228,
43358
- "": 43229,
43359
- "": 43230,
43360
- "": 43231,
43361
- "": 43232,
43362
- "": 43233,
43363
- "": 43234,
43364
- "": 43235,
43365
  "錮": 43236,
43366
- "": 43237,
43367
- "": 43238,
43368
- "": 43239,
43369
- "": 43240,
43370
- "": 43241,
43371
- "": 43242,
43372
- "": 43243,
43373
- "": 43244,
43374
- "": 43245,
43375
- "": 43246,
43376
- "": 43247,
43377
- "滿": 43248,
43378
- "": 43249,
43379
- "": 43250,
43380
- "": 43251,
43381
- "": 43252,
43382
- "": 43253,
43383
- "": 43254,
43384
- "": 43255,
43385
- "": 43256,
43386
- "": 43257,
43387
- "": 43258,
43388
- "": 43259,
43389
- "": 43260,
43390
- "": 43261,
43391
- "": 43262,
43392
- "": 43263,
43393
- "": 43264,
43394
- "": 43265,
43395
- "": 43266,
43396
- "": 43267,
43397
- "": 43268,
43398
- "": 43269,
43399
- "": 43270,
43400
- "": 43271,
43401
- "": 43272,
43402
- "": 43273,
43403
- "": 43274,
43404
- "": 43275,
43405
- "": 43276,
43406
- "": 43277,
43407
- "": 43278,
43408
- "": 43279,
43409
- "": 43280,
43410
- "": 43281,
43411
- "": 43282,
43412
- "": 43283,
43413
- "": 43284,
43414
- "": 43285,
43415
- "": 43286,
43416
- "": 43287,
43417
- "": 43288,
43418
- "": 43289,
43419
- "": 43290,
43420
- "": 43291,
43421
- "": 43292,
43422
- "": 43293,
43423
- "": 43294,
43424
- "": 43295,
43425
- "": 43296,
43426
- "": 43297,
43427
- "": 43298,
43428
- "": 43299,
43429
- "": 43300,
43430
- "": 43301,
43431
- "": 43302,
43432
- "": 43303,
43433
- "": 43304,
43434
- "": 43305,
43435
- "": 43306,
43436
- "": 43307,
43437
- "": 43308,
43438
- "": 43309,
43439
- "": 43310,
43440
- "": 43311,
43441
- "": 43312,
43442
- "": 43313,
43443
- "": 43314,
43444
- "": 43315,
43445
- "": 43316
43446
  },
43447
  "merges": [
43448
  "▁ t",
 
125
  "end_of_word_suffix": null,
126
  "fuse_unk": true,
127
  "byte_fallback": false,
128
+ "ignore_merges": false,
129
  "vocab": {
130
  "<unk>": 0,
131
  "<s>": 1,
 
42927
  "勅": 42797,
42928
  "婿": 42798,
42929
  "魯": 42799,
42930
+ "": 42800,
42931
+ "": 42801,
42932
+ "": 42802,
42933
+ "": 42803,
42934
+ "": 42804,
42935
+ "": 42805,
42936
+ "𠮟": 42806,
42937
+ "": 42807,
42938
+ "": 42808,
42939
+ "": 42809,
42940
+ "": 42810,
42941
+ "": 42811,
42942
+ "": 42812,
42943
+ "": 42813,
42944
+ "": 42814,
42945
+ "": 42815,
42946
+ "": 42816,
42947
+ "": 42817,
42948
+ "": 42818,
42949
+ "": 42819,
42950
+ "": 42820,
42951
+ "": 42821,
42952
+ "": 42822,
42953
+ "": 42823,
42954
+ "": 42824,
42955
+ "": 42825,
42956
+ "": 42826,
42957
+ "": 42827,
42958
+ "": 42828,
42959
+ "": 42829,
42960
+ "": 42830,
42961
+ "": 42831,
42962
+ "": 42832,
42963
+ "": 42833,
42964
+ "": 42834,
42965
+ "": 42835,
42966
+ "": 42836,
42967
+ "": 42837,
42968
+ "": 42838,
42969
+ "": 42839,
42970
+ "": 42840,
42971
+ "": 42841,
42972
+ "": 42842,
42973
+ "": 42843,
42974
+ "": 42844,
42975
+ "": 42845,
42976
+ "": 42846,
42977
+ "": 42847,
42978
+ "": 42848,
42979
+ "": 42849,
42980
+ "": 42850,
42981
+ "": 42851,
42982
+ "": 42852,
42983
+ "": 42853,
42984
+ "": 42854,
42985
+ "": 42855,
42986
+ "": 42856,
42987
+ "": 42857,
42988
+ "": 42858,
42989
+ "": 42859,
42990
+ "": 42860,
42991
+ "": 42861,
42992
+ "": 42862,
42993
+ "": 42863,
42994
+ "": 42864,
42995
+ "": 42865,
42996
+ "": 42866,
42997
+ "": 42867,
42998
+ "": 42868,
42999
+ "": 42869,
43000
+ "": 42870,
43001
+ "": 42871,
43002
+ "": 42872,
43003
+ "": 42873,
43004
+ "": 42874,
43005
+ "": 42875,
43006
+ "": 42876,
43007
+ "": 42877,
43008
+ "": 42878,
43009
+ "": 42879,
43010
+ "": 42880,
43011
+ "": 42881,
43012
+ "": 42882,
43013
+ "": 42883,
43014
+ "": 42884,
43015
+ "": 42885,
43016
+ "": 42886,
43017
+ "": 42887,
43018
+ "": 42888,
43019
+ "": 42889,
43020
+ "": 42890,
43021
+ "": 42891,
43022
+ "": 42892,
43023
+ "": 42893,
43024
+ "": 42894,
43025
+ "": 42895,
43026
+ "": 42896,
43027
+ "": 42897,
43028
+ "": 42898,
43029
+ "": 42899,
43030
+ "": 42900,
43031
+ "": 42901,
43032
+ "": 42902,
43033
+ "": 42903,
43034
+ "": 42904,
43035
+ "": 42905,
43036
+ "": 42906,
43037
+ "": 42907,
43038
+ "": 42908,
43039
+ "": 42909,
43040
+ "": 42910,
43041
+ "": 42911,
43042
+ "": 42912,
43043
+ "": 42913,
43044
+ "": 42914,
43045
+ "": 42915,
43046
+ "": 42916,
43047
+ "": 42917,
43048
+ "": 42918,
43049
+ "": 42919,
43050
+ "": 42920,
43051
+ "": 42921,
43052
+ "": 42922,
43053
+ "": 42923,
43054
+ "": 42924,
43055
+ "": 42925,
43056
+ "": 42926,
43057
+ "": 42927,
43058
+ "": 42928,
43059
+ "": 42929,
43060
+ "": 42930,
43061
+ "": 42931,
43062
+ "": 42932,
43063
+ "": 42933,
43064
+ "": 42934,
43065
+ "": 42935,
43066
+ "": 42936,
43067
+ "": 42937,
43068
+ "": 42938,
43069
+ "": 42939,
43070
+ "": 42940,
43071
+ "": 42941,
43072
+ "": 42942,
43073
+ "": 42943,
43074
+ "": 42944,
43075
+ "": 42945,
43076
+ "": 42946,
43077
+ "": 42947,
43078
+ "": 42948,
43079
+ "": 42949,
43080
+ "": 42950,
43081
+ "": 42951,
43082
+ "": 42952,
43083
+ "": 42953,
43084
+ "": 42954,
43085
+ "": 42955,
43086
+ "": 42956,
43087
+ "": 42957,
43088
+ "": 42958,
43089
+ "": 42959,
43090
+ "": 42960,
43091
+ "": 42961,
43092
+ "": 42962,
43093
+ "": 42963,
43094
+ "": 42964,
43095
+ "": 42965,
43096
+ "": 42966,
43097
+ "": 42967,
43098
+ "": 42968,
43099
+ "": 42969,
43100
+ "": 42970,
43101
+ "": 42971,
43102
+ "": 42972,
43103
+ "": 42973,
43104
+ "": 42974,
43105
+ "": 42975,
43106
+ "": 42976,
43107
+ "": 42977,
43108
+ "": 42978,
43109
+ "": 42979,
43110
+ "": 42980,
43111
+ "": 42981,
43112
+ "": 42982,
43113
+ "": 42983,
43114
+ "": 42984,
43115
+ "": 42985,
43116
+ "": 42986,
43117
+ "": 42987,
43118
+ "": 42988,
43119
+ "": 42989,
43120
+ "": 42990,
43121
+ "": 42991,
43122
+ "": 42992,
43123
+ "": 42993,
43124
+ "": 42994,
43125
+ "": 42995,
43126
+ "": 42996,
43127
+ "": 42997,
43128
+ "": 42998,
43129
+ "": 42999,
43130
+ "": 43000,
43131
+ "": 43001,
43132
+ "": 43002,
43133
+ "": 43003,
43134
+ "": 43004,
43135
+ "": 43005,
43136
+ "": 43006,
43137
+ "": 43007,
43138
+ "": 43008,
43139
+ "": 43009,
43140
+ "": 43010,
43141
+ "": 43011,
43142
+ "": 43012,
43143
+ "": 43013,
43144
+ "": 43014,
43145
+ "": 43015,
43146
+ "": 43016,
43147
+ "": 43017,
43148
+ "": 43018,
43149
+ "": 43019,
43150
+ "": 43020,
43151
+ "": 43021,
43152
+ "": 43022,
43153
+ "麿": 43023,
43154
+ "": 43024,
43155
+ "": 43025,
43156
+ "": 43026,
43157
+ "": 43027,
43158
+ "": 43028,
43159
+ "": 43029,
43160
+ "": 43030,
43161
+ "": 43031,
43162
+ "": 43032,
43163
+ "": 43033,
43164
+ "": 43034,
43165
+ "": 43035,
43166
+ "": 43036,
43167
+ "": 43037,
43168
+ "": 43038,
43169
+ "": 43039,
43170
+ "": 43040,
43171
+ "": 43041,
43172
+ "": 43042,
43173
+ "": 43043,
43174
+ "": 43044,
43175
+ "": 43045,
43176
+ "": 43046,
43177
+ "": 43047,
43178
+ "": 43048,
43179
+ "": 43049,
43180
+ "": 43050,
43181
+ "": 43051,
43182
+ "": 43052,
43183
+ "": 43053,
43184
+ "": 43054,
43185
+ "": 43055,
43186
+ "": 43056,
43187
+ "": 43057,
43188
+ "": 43058,
43189
+ "": 43059,
43190
+ "": 43060,
43191
+ "": 43061,
43192
+ "": 43062,
43193
+ "": 43063,
43194
+ "": 43064,
43195
+ "": 43065,
43196
+ "": 43066,
43197
+ "": 43067,
43198
+ "": 43068,
43199
+ "": 43069,
43200
+ "": 43070,
43201
+ "": 43071,
43202
+ "": 43072,
43203
+ "": 43073,
43204
+ "": 43074,
43205
+ "": 43075,
43206
+ "": 43076,
43207
+ "": 43077,
43208
+ "": 43078,
43209
+ "": 43079,
43210
+ "": 43080,
43211
+ "": 43081,
43212
+ "": 43082,
43213
+ "": 43083,
43214
+ "": 43084,
43215
+ "": 43085,
43216
+ "": 43086,
43217
+ "": 43087,
43218
+ "": 43088,
43219
+ "": 43089,
43220
+ "": 43090,
43221
+ "": 43091,
43222
+ "": 43092,
43223
+ "": 43093,
43224
+ "": 43094,
43225
+ "": 43095,
43226
+ "": 43096,
43227
+ "": 43097,
43228
+ "": 43098,
43229
+ "": 43099,
43230
+ "": 43100,
43231
+ "": 43101,
43232
+ "": 43102,
43233
+ "": 43103,
43234
+ "": 43104,
43235
+ "": 43105,
43236
+ "": 43106,
43237
+ "": 43107,
43238
+ "": 43108,
43239
+ "": 43109,
43240
+ "": 43110,
43241
+ "": 43111,
43242
+ "": 43112,
43243
+ "": 43113,
43244
+ "": 43114,
43245
+ "": 43115,
43246
+ "": 43116,
43247
+ "": 43117,
43248
+ "": 43118,
43249
+ "": 43119,
43250
+ "": 43120,
43251
+ "": 43121,
43252
+ "": 43122,
43253
+ "": 43123,
43254
+ "": 43124,
43255
+ "": 43125,
43256
+ "": 43126,
43257
+ "": 43127,
43258
+ "": 43128,
43259
+ "": 43129,
43260
+ "": 43130,
43261
+ "": 43131,
43262
+ "": 43132,
43263
+ "": 43133,
43264
+ "": 43134,
43265
+ "": 43135,
43266
+ "": 43136,
43267
+ "忿": 43137,
43268
+ "": 43138,
43269
+ "": 43139,
43270
+ "": 43140,
43271
+ "": 43141,
43272
+ "": 43142,
43273
+ "": 43143,
43274
+ "": 43144,
43275
+ "": 43145,
43276
+ "": 43146,
43277
+ "": 43147,
43278
+ "": 43148,
43279
+ "": 43149,
43280
+ "": 43150,
43281
+ "": 43151,
43282
+ "": 43152,
43283
+ "": 43153,
43284
+ "": 43154,
43285
+ "": 43155,
43286
+ "": 43156,
43287
+ "": 43157,
43288
+ "": 43158,
43289
+ "": 43159,
43290
+ "": 43160,
43291
+ "": 43161,
43292
+ "": 43162,
43293
+ "": 43163,
43294
+ "": 43164,
43295
+ "": 43165,
43296
+ "": 43166,
43297
+ "": 43167,
43298
+ "": 43168,
43299
+ "": 43169,
43300
+ "": 43170,
43301
+ "": 43171,
43302
+ "": 43172,
43303
+ "": 43173,
43304
+ "": 43174,
43305
+ "": 43175,
43306
+ "": 43176,
43307
+ "": 43177,
43308
+ "": 43178,
43309
+ "": 43179,
43310
+ "": 43180,
43311
+ "": 43181,
43312
+ "": 43182,
43313
+ "": 43183,
43314
+ "": 43184,
43315
+ "": 43185,
43316
+ "": 43186,
43317
+ "": 43187,
43318
+ "": 43188,
43319
+ "": 43189,
43320
+ "": 43190,
43321
+ "": 43191,
43322
+ "": 43192,
43323
+ "": 43193,
43324
+ "": 43194,
43325
+ "": 43195,
43326
+ "": 43196,
43327
+ "": 43197,
43328
+ "": 43198,
43329
+ "": 43199,
43330
+ "": 43200,
43331
+ "": 43201,
43332
+ "": 43202,
43333
+ "": 43203,
43334
+ "": 43204,
43335
+ "": 43205,
43336
+ "": 43206,
43337
+ "": 43207,
43338
+ "": 43208,
43339
+ "": 43209,
43340
+ "": 43210,
43341
+ "": 43211,
43342
+ "": 43212,
43343
+ "": 43213,
43344
+ "": 43214,
43345
+ "": 43215,
43346
+ "": 43216,
43347
+ "": 43217,
43348
+ "": 43218,
43349
+ "": 43219,
43350
+ "": 43220,
43351
+ "": 43221,
43352
+ "": 43222,
43353
+ "": 43223,
43354
+ "": 43224,
43355
+ "": 43225,
43356
+ "": 43226,
43357
+ "": 43227,
43358
+ "": 43228,
43359
+ "": 43229,
43360
+ "": 43230,
43361
+ "": 43231,
43362
+ "": 43232,
43363
+ "": 43233,
43364
+ "": 43234,
43365
+ "": 43235,
43366
  "錮": 43236,
43367
+ "": 43237,
43368
+ "": 43238,
43369
+ "": 43239,
43370
+ "": 43240,
43371
+ "": 43241,
43372
+ "": 43242,
43373
+ "": 43243,
43374
+ "": 43244,
43375
+ "": 43245,
43376
+ "": 43246,
43377
+ "": 43247,
43378
+ "": 43248,
43379
+ "": 43249,
43380
+ "": 43250,
43381
+ "": 43251,
43382
+ "": 43252,
43383
+ "滿": 43253,
43384
+ "": 43254,
43385
+ "": 43255,
43386
+ "": 43256,
43387
+ "": 43257,
43388
+ "": 43258,
43389
+ "": 43259,
43390
+ "": 43260,
43391
+ "": 43261,
43392
+ "": 43262,
43393
+ "": 43263,
43394
+ "": 43264,
43395
+ "": 43265,
43396
+ "": 43266,
43397
+ "": 43267,
43398
+ "": 43268,
43399
+ "": 43269,
43400
+ "": 43270,
43401
+ "": 43271,
43402
+ "": 43272,
43403
+ "": 43273,
43404
+ "": 43274,
43405
+ "": 43275,
43406
+ "": 43276,
43407
+ "": 43277,
43408
+ "": 43278,
43409
+ "": 43279,
43410
+ "": 43280,
43411
+ "": 43281,
43412
+ "": 43282,
43413
+ "": 43283,
43414
+ "": 43284,
43415
+ "": 43285,
43416
+ "": 43286,
43417
+ "": 43287,
43418
+ "": 43288,
43419
+ "": 43289,
43420
+ "": 43290,
43421
+ "": 43291,
43422
+ "": 43292,
43423
+ "": 43293,
43424
+ "": 43294,
43425
+ "": 43295,
43426
+ "": 43296,
43427
+ "": 43297,
43428
+ "": 43298,
43429
+ "": 43299,
43430
+ "": 43300,
43431
+ "": 43301,
43432
+ "": 43302,
43433
+ "": 43303,
43434
+ "": 43304,
43435
+ "": 43305,
43436
+ "": 43306,
43437
+ "": 43307,
43438
+ "": 43308,
43439
+ "": 43309,
43440
+ "": 43310,
43441
+ "": 43311,
43442
+ "": 43312,
43443
+ "": 43313,
43444
+ "": 43314,
43445
+ "": 43315,
43446
+ "": 43316
43447
  },
43448
  "merges": [
43449
  "▁ t",
tokenizer_config.json CHANGED
@@ -1,6 +1,7 @@
1
  {
2
  "add_bos_token": true,
3
  "add_eos_token": false,
 
4
  "added_tokens_decoder": {
5
  "0": {
6
  "content": "<unk>",
@@ -31,6 +32,7 @@
31
  "clean_up_tokenization_spaces": false,
32
  "cls_token": "<s>",
33
  "eos_token": "</s>",
 
34
  "mask_token": "<unk>",
35
  "model_max_length": 4096,
36
  "pad_token": "</s>",
 
1
  {
2
  "add_bos_token": true,
3
  "add_eos_token": false,
4
+ "add_prefix_space": null,
5
  "added_tokens_decoder": {
6
  "0": {
7
  "content": "<unk>",
 
32
  "clean_up_tokenization_spaces": false,
33
  "cls_token": "<s>",
34
  "eos_token": "</s>",
35
+ "legacy": true,
36
  "mask_token": "<unk>",
37
  "model_max_length": 4096,
38
  "pad_token": "</s>",
upos.py CHANGED
@@ -1,5 +1,4 @@
1
- from transformers import TokenClassificationPipeline,MistralModel,MistralPreTrainedModel
2
- from transformers.modeling_outputs import TokenClassifierOutput
3
 
4
  class BellmanFordTokenClassificationPipeline(TokenClassificationPipeline):
5
  def __init__(self,**kwargs):
@@ -40,41 +39,3 @@ class BellmanFordTokenClassificationPipeline(TokenClassificationPipeline):
40
  t["text"]=model_outputs["sentence"][t["start"]:t["end"]]
41
  return w
42
 
43
- class RawTokenClassificationPipeline(TokenClassificationPipeline):
44
- def check_model_type(self,supported_models):
45
- pass
46
-
47
- class MistralForTokenClassification(MistralPreTrainedModel):
48
- def __init__(self,config):
49
- from torch import nn
50
- super().__init__(config)
51
- self.num_labels=config.num_labels
52
- self.model=MistralModel(config)
53
- if hasattr(config,"classifier_dropout") and config.classifier_dropout is not None:
54
- classifier_dropout=config.classifier_dropout
55
- elif hasattr(config,"hidden_dropout") and config.hidden_dropout is not None:
56
- classifier_dropout=config.hidden_dropout
57
- else:
58
- classifier_dropout=0.1
59
- self.dropout=nn.Dropout(classifier_dropout)
60
- self.classifier=nn.Linear(config.hidden_size,config.num_labels)
61
- self.post_init()
62
- def get_input_embeddings(self):
63
- return self.model.embed_tokens
64
- def set_input_embeddings(self,value):
65
- self.model.embed_tokens=value
66
- def forward(self,input_ids=None,past_key_values=None,attention_mask=None,position_ids=None,inputs_embeds=None,labels=None,use_cache=None,output_attentions=None,output_hidden_states=None,return_dict=None):
67
- return_dict=return_dict if return_dict is not None else self.config.use_return_dict
68
- transformer_outputs=self.model(input_ids,past_key_values=past_key_values,attention_mask=attention_mask,position_ids=position_ids,inputs_embeds=inputs_embeds,use_cache=use_cache,output_attentions=output_attentions,output_hidden_states=output_hidden_states,return_dict=return_dict)
69
- hidden_states=transformer_outputs[0]
70
- hidden_states=self.dropout(hidden_states)
71
- logits=self.classifier(hidden_states)
72
- loss=None
73
- if labels is not None:
74
- from torch import nn
75
- loss_fct=nn.CrossEntropyLoss()
76
- loss=loss_fct(logits.view(-1,self.num_labels),labels.view(-1))
77
- if not return_dict:
78
- output=(logits,)+transformer_outputs[2:]
79
- return ((loss,)+output) if loss is not None else output
80
- return TokenClassifierOutput(loss=loss,logits=logits,hidden_states=transformer_outputs.hidden_states,attentions=transformer_outputs.attentions)
 
1
+ from transformers import TokenClassificationPipeline
 
2
 
3
  class BellmanFordTokenClassificationPipeline(TokenClassificationPipeline):
4
  def __init__(self,**kwargs):
 
39
  t["text"]=model_outputs["sentence"][t["start"]:t["end"]]
40
  return w
41