KoichiYasuoka
commited on
Commit
•
5896126
1
Parent(s):
7c2dad0
initial release
Browse files- config.json +163 -0
- maker.sh +177 -0
- pytorch_model-00001-of-00006.bin +3 -0
- pytorch_model-00002-of-00006.bin +3 -0
- pytorch_model-00003-of-00006.bin +3 -0
- pytorch_model-00004-of-00006.bin +3 -0
- pytorch_model-00005-of-00006.bin +3 -0
- pytorch_model-00006-of-00006.bin +3 -0
- pytorch_model.bin.index.json +299 -0
- special_tokens_map.json +51 -0
- tokenizer.json +0 -0
- tokenizer_config.json +41 -0
- upos.py +76 -0
config.json
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"LlamaForTokenClassification"
|
4 |
+
],
|
5 |
+
"attention_bias": false,
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"auto_map": {
|
8 |
+
"AutoModelForTokenClassification": "upos.LlamaForTokenClassification"
|
9 |
+
},
|
10 |
+
"bos_token_id": 1,
|
11 |
+
"custom_pipelines": {
|
12 |
+
"upos": {
|
13 |
+
"impl": "upos.BellmanFordTokenClassificationPipeline",
|
14 |
+
"pt": "AutoModelForTokenClassification"
|
15 |
+
}
|
16 |
+
},
|
17 |
+
"eos_token_id": 2,
|
18 |
+
"hidden_act": "silu",
|
19 |
+
"hidden_size": 4096,
|
20 |
+
"id2label": {
|
21 |
+
"0": "ADJ",
|
22 |
+
"1": "B-ADJ",
|
23 |
+
"2": "I-ADJ",
|
24 |
+
"3": "ADJ|Polarity=Neg",
|
25 |
+
"4": "B-ADJ|Polarity=Neg",
|
26 |
+
"5": "I-ADJ|Polarity=Neg",
|
27 |
+
"6": "ADP",
|
28 |
+
"7": "B-ADP",
|
29 |
+
"8": "I-ADP",
|
30 |
+
"9": "ADV",
|
31 |
+
"10": "B-ADV",
|
32 |
+
"11": "I-ADV",
|
33 |
+
"12": "AUX",
|
34 |
+
"13": "B-AUX",
|
35 |
+
"14": "I-AUX",
|
36 |
+
"15": "AUX|Polarity=Neg",
|
37 |
+
"16": "B-AUX|Polarity=Neg",
|
38 |
+
"17": "I-AUX|Polarity=Neg",
|
39 |
+
"18": "CCONJ",
|
40 |
+
"19": "B-CCONJ",
|
41 |
+
"20": "I-CCONJ",
|
42 |
+
"21": "DET",
|
43 |
+
"22": "B-DET",
|
44 |
+
"23": "I-DET",
|
45 |
+
"24": "INTJ",
|
46 |
+
"25": "B-INTJ",
|
47 |
+
"26": "I-INTJ",
|
48 |
+
"27": "NOUN",
|
49 |
+
"28": "B-NOUN",
|
50 |
+
"29": "I-NOUN",
|
51 |
+
"30": "NOUN|Polarity=Neg",
|
52 |
+
"31": "B-NOUN|Polarity=Neg",
|
53 |
+
"32": "I-NOUN|Polarity=Neg",
|
54 |
+
"33": "NUM",
|
55 |
+
"34": "B-NUM",
|
56 |
+
"35": "I-NUM",
|
57 |
+
"36": "PART",
|
58 |
+
"37": "B-PART",
|
59 |
+
"38": "I-PART",
|
60 |
+
"39": "PRON",
|
61 |
+
"40": "B-PRON",
|
62 |
+
"41": "I-PRON",
|
63 |
+
"42": "PROPN",
|
64 |
+
"43": "B-PROPN",
|
65 |
+
"44": "I-PROPN",
|
66 |
+
"45": "PUNCT",
|
67 |
+
"46": "B-PUNCT",
|
68 |
+
"47": "I-PUNCT",
|
69 |
+
"48": "SCONJ",
|
70 |
+
"49": "B-SCONJ",
|
71 |
+
"50": "I-SCONJ",
|
72 |
+
"51": "SYM",
|
73 |
+
"52": "B-SYM",
|
74 |
+
"53": "I-SYM",
|
75 |
+
"54": "VERB",
|
76 |
+
"55": "B-VERB",
|
77 |
+
"56": "I-VERB",
|
78 |
+
"57": "X",
|
79 |
+
"58": "B-X",
|
80 |
+
"59": "I-X"
|
81 |
+
},
|
82 |
+
"initializer_range": 0.02,
|
83 |
+
"intermediate_size": 11008,
|
84 |
+
"label2id": {
|
85 |
+
"ADJ": 0,
|
86 |
+
"ADJ|Polarity=Neg": 3,
|
87 |
+
"ADP": 6,
|
88 |
+
"ADV": 9,
|
89 |
+
"AUX": 12,
|
90 |
+
"AUX|Polarity=Neg": 15,
|
91 |
+
"B-ADJ": 1,
|
92 |
+
"B-ADJ|Polarity=Neg": 4,
|
93 |
+
"B-ADP": 7,
|
94 |
+
"B-ADV": 10,
|
95 |
+
"B-AUX": 13,
|
96 |
+
"B-AUX|Polarity=Neg": 16,
|
97 |
+
"B-CCONJ": 19,
|
98 |
+
"B-DET": 22,
|
99 |
+
"B-INTJ": 25,
|
100 |
+
"B-NOUN": 28,
|
101 |
+
"B-NOUN|Polarity=Neg": 31,
|
102 |
+
"B-NUM": 34,
|
103 |
+
"B-PART": 37,
|
104 |
+
"B-PRON": 40,
|
105 |
+
"B-PROPN": 43,
|
106 |
+
"B-PUNCT": 46,
|
107 |
+
"B-SCONJ": 49,
|
108 |
+
"B-SYM": 52,
|
109 |
+
"B-VERB": 55,
|
110 |
+
"B-X": 58,
|
111 |
+
"CCONJ": 18,
|
112 |
+
"DET": 21,
|
113 |
+
"I-ADJ": 2,
|
114 |
+
"I-ADJ|Polarity=Neg": 5,
|
115 |
+
"I-ADP": 8,
|
116 |
+
"I-ADV": 11,
|
117 |
+
"I-AUX": 14,
|
118 |
+
"I-AUX|Polarity=Neg": 17,
|
119 |
+
"I-CCONJ": 20,
|
120 |
+
"I-DET": 23,
|
121 |
+
"I-INTJ": 26,
|
122 |
+
"I-NOUN": 29,
|
123 |
+
"I-NOUN|Polarity=Neg": 32,
|
124 |
+
"I-NUM": 35,
|
125 |
+
"I-PART": 38,
|
126 |
+
"I-PRON": 41,
|
127 |
+
"I-PROPN": 44,
|
128 |
+
"I-PUNCT": 47,
|
129 |
+
"I-SCONJ": 50,
|
130 |
+
"I-SYM": 53,
|
131 |
+
"I-VERB": 56,
|
132 |
+
"I-X": 59,
|
133 |
+
"INTJ": 24,
|
134 |
+
"NOUN": 27,
|
135 |
+
"NOUN|Polarity=Neg": 30,
|
136 |
+
"NUM": 33,
|
137 |
+
"PART": 36,
|
138 |
+
"PRON": 39,
|
139 |
+
"PROPN": 42,
|
140 |
+
"PUNCT": 45,
|
141 |
+
"SCONJ": 48,
|
142 |
+
"SYM": 51,
|
143 |
+
"VERB": 54,
|
144 |
+
"X": 57
|
145 |
+
},
|
146 |
+
"max_position_embeddings": 4096,
|
147 |
+
"max_sequence_length": 4096,
|
148 |
+
"model_type": "llama",
|
149 |
+
"num_attention_heads": 32,
|
150 |
+
"num_hidden_layers": 32,
|
151 |
+
"num_key_value_heads": 32,
|
152 |
+
"pad_token_id": 0,
|
153 |
+
"pretraining_tp": 1,
|
154 |
+
"rms_norm_eps": 1e-05,
|
155 |
+
"rope_scaling": null,
|
156 |
+
"rope_theta": 10000.0,
|
157 |
+
"tie_word_embeddings": false,
|
158 |
+
"tokenizer_class": "LlamaTokenizerFast",
|
159 |
+
"torch_dtype": "float32",
|
160 |
+
"transformers_version": "4.38.1",
|
161 |
+
"use_cache": true,
|
162 |
+
"vocab_size": 43744
|
163 |
+
}
|
maker.sh
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#! /bin/sh
|
2 |
+
test -f ja_gsd_modern.conllu || curl -LO https://github.com/KoichiYasuoka/SuPar-UniDic/raw/main/suparunidic/suparmodels/ja_gsd_modern.conllu
|
3 |
+
test -f JapaneseCoreKanji.txt || curl -LO https://www.unicode.org/wg2/iso10646/edition6/data/JapaneseCoreKanji.txt
|
4 |
+
|
5 |
+
if [ ! -d exSwallow-7b-plus-hf ]
|
6 |
+
then TMPA=./maker$$a.py
|
7 |
+
cat << 'EOF' > $TMPA
|
8 |
+
#! /usr/bin/python3
|
9 |
+
src="tokyotech-llm/Swallow-7b-plus-hf"
|
10 |
+
tgt="exSwallow-7b-plus-hf"
|
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:
|
16 |
+
for s in r:
|
17 |
+
t=s.split("\t")
|
18 |
+
if len(t)==10:
|
19 |
+
for c in t[1]:
|
20 |
+
if unicodedata.name(c).startswith("CJK "):
|
21 |
+
cjk.append(c)
|
22 |
+
cjk=list(set(cjk))
|
23 |
+
tkz=LlamaTokenizerFast.from_pretrained(src,cls_token="<s>",sep_token="<s>",mask_token="<unk>",pad_token="</s>")
|
24 |
+
c={i:j[2:] for i,j in zip(cjk,tkz(cjk)["input_ids"]) if len(j)>3}
|
25 |
+
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()
|
33 |
+
with torch.no_grad():
|
34 |
+
for k,v in c.items():
|
35 |
+
e.weight[d["model"]["vocab"][k],:]=e.weight[v,:].sum(0)
|
36 |
+
f.weight[d["model"]["vocab"][k],:]=f.weight[v,:].sum(0)
|
37 |
+
mdl.set_input_embeddings(e)
|
38 |
+
mdl.set_output_embeddings(f)
|
39 |
+
mdl.save_pretrained(tgt)
|
40 |
+
tkz.save_pretrained(tgt)
|
41 |
+
EOF
|
42 |
+
chmod 755 $TMPA
|
43 |
+
$TMPA
|
44 |
+
fi
|
45 |
+
|
46 |
+
TMPB=./maker$$b.py
|
47 |
+
cat << 'EOF' > $TMPB
|
48 |
+
#! /usr/bin/env deepspeed
|
49 |
+
src="exSwallow-7b-plus-hf"
|
50 |
+
tgt="KoichiYasuoka/Swallow-7b-plus-upos"
|
51 |
+
from transformers import LlamaTokenizerFast,LlamaModel,LlamaPreTrainedModel,AutoConfig,DataCollatorForTokenClassification,TrainingArguments,Trainer
|
52 |
+
from transformers.modeling_outputs import TokenClassifierOutput
|
53 |
+
from tokenizers.normalizers import Replace
|
54 |
+
|
55 |
+
class LlamaForTokenClassification(LlamaPreTrainedModel):
|
56 |
+
def __init__(self,config):
|
57 |
+
from torch import nn
|
58 |
+
super().__init__(config)
|
59 |
+
self.num_labels=config.num_labels
|
60 |
+
self.model=LlamaModel(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[1:]
|
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")
|
93 |
+
self.tokenizer=tokenizer
|
94 |
+
self.seeks=[0]
|
95 |
+
self.multiword={}
|
96 |
+
label=set(["SYM"])
|
97 |
+
s=self.conllu.readline()
|
98 |
+
while s!="":
|
99 |
+
if s=="\n":
|
100 |
+
self.seeks.append(self.conllu.tell())
|
101 |
+
else:
|
102 |
+
w=s.split("\t")
|
103 |
+
if len(w)==10:
|
104 |
+
if w[0].isdecimal():
|
105 |
+
label.add(w[3] if w[5]=="_" else w[3]+"|"+w[5])
|
106 |
+
elif w[0].find("-")>0:
|
107 |
+
t=w[0].split("-")
|
108 |
+
f,j,k=w[1],[],[]
|
109 |
+
for i in range(int(t[0]),int(t[1])+1):
|
110 |
+
w=self.conllu.readline().split("\t")
|
111 |
+
j.append(w[3] if w[5]=="_" else w[3]+"|"+w[5])
|
112 |
+
k.append(w[1])
|
113 |
+
p="+".join(j)
|
114 |
+
label.add(p)
|
115 |
+
if p in self.multiword:
|
116 |
+
self.multiword[p][f]=list(k)
|
117 |
+
else:
|
118 |
+
self.multiword[p]={f:list(k)}
|
119 |
+
s=self.conllu.readline()
|
120 |
+
lid={}
|
121 |
+
for i,l in enumerate(sorted(label)):
|
122 |
+
lid[l],lid["B-"+l],lid["I-"+l]=i*3,i*3+1,i*3+2
|
123 |
+
self.label2id=lid
|
124 |
+
def __call__(*args):
|
125 |
+
lid={l:i for i,l in enumerate(sorted(set(sum([list(t.label2id) for t in args],[]))))}
|
126 |
+
for t in args:
|
127 |
+
t.label2id=lid
|
128 |
+
return lid
|
129 |
+
def __del__(self):
|
130 |
+
self.conllu.close()
|
131 |
+
__len__=lambda self:len(self.seeks)-1
|
132 |
+
def __getitem__(self,i):
|
133 |
+
self.conllu.seek(self.seeks[i])
|
134 |
+
form,upos=[],[]
|
135 |
+
while self.conllu.tell()<self.seeks[i+1]:
|
136 |
+
w=self.conllu.readline().split("\t")
|
137 |
+
if len(w)==10:
|
138 |
+
form.append(w[1])
|
139 |
+
if w[0].isdecimal():
|
140 |
+
upos.append(w[3] if w[5]=="_" else w[3]+"|"+w[5])
|
141 |
+
elif w[0].find("-")>0:
|
142 |
+
t=w[0].split("-")
|
143 |
+
u=[]
|
144 |
+
for j in range(int(t[0]),int(t[1])+1):
|
145 |
+
k=self.conllu.readline().split("\t")
|
146 |
+
u.append(k[3] if k[5]=="_" else k[3]+"|"+k[5])
|
147 |
+
upos.append("+".join(u))
|
148 |
+
v=self.tokenizer(form,add_special_tokens=False)
|
149 |
+
i,u=[],[]
|
150 |
+
for j,(x,y) in enumerate(zip(v["input_ids"],upos)):
|
151 |
+
if x!=[]:
|
152 |
+
i+=x
|
153 |
+
u+=[y] if len(x)==1 else ["B-"+y]+["I-"+y]*(len(x)-1)
|
154 |
+
if len(i)<self.tokenizer.model_max_length-3:
|
155 |
+
ids=[self.tokenizer.cls_token_id]+i+[self.tokenizer.sep_token_id]
|
156 |
+
upos=["SYM"]+u+["SYM"]
|
157 |
+
else:
|
158 |
+
ids=i[0:self.tokenizer.model_max_length-2]
|
159 |
+
upos=u[0:self.tokenizer.model_max_length-2]
|
160 |
+
return {"input_ids":ids,"labels":[self.label2id[t] for t in upos]}
|
161 |
+
|
162 |
+
tkz=LlamaTokenizerFast.from_pretrained(src)
|
163 |
+
tkz.backend_tokenizer.normalizer=Replace(" ","\u2581")
|
164 |
+
tkz.backend_tokenizer.model.byte_fallback=False
|
165 |
+
trainDS=UPOSFileDataset("ja_gsd_modern.conllu",tkz)
|
166 |
+
lid=trainDS.label2id
|
167 |
+
cfg=AutoConfig.from_pretrained(src,num_labels=len(lid),label2id=lid,id2label={i:l for l,i in lid.items()},ignore_mismatched_sizes=True)
|
168 |
+
dsp={"fp16":{"enabled":"auto"},"optimizer":{"type":"AdamW"},"scheduler":{"type":"WarmupLR","params":{}},"train_batch_size":"auto","train_micro_batch_size_per_gpu":"auto","zero_optimization":{"stage":3,"offload_optimizer":{"device":"cpu","pin_memory":True},"offload_param":{"device":"cpu","pin_memory":True},"overlap_comm":True,"contiguous_gradients":True,"reduce_bucket_size":"auto","stage3_prefetch_bucket_size":"auto","stage3_param_persistence_threshold":"auto","stage3_gather_16bit_weights_on_model_save":True}}
|
169 |
+
arg=TrainingArguments(num_train_epochs=3,per_device_train_batch_size=8,deepspeed=dsp,output_dir=tgt,overwrite_output_dir=True,save_total_limit=2,learning_rate=5e-05,warmup_ratio=0.1,save_safetensors=False)
|
170 |
+
trn=Trainer(args=arg,data_collator=DataCollatorForTokenClassification(tkz),model=LlamaForTokenClassification.from_pretrained(src,config=cfg,ignore_mismatched_sizes=True),train_dataset=trainDS)
|
171 |
+
trn.train()
|
172 |
+
trn.save_model(tgt)
|
173 |
+
tkz.save_pretrained(tgt)
|
174 |
+
EOF
|
175 |
+
chmod 755 $TMPB
|
176 |
+
$TMPB
|
177 |
+
exit
|
pytorch_model-00001-of-00006.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:febbf717e4d094a9f32b65b84a0dc1e76d671b6c09dd22e1729ea30cc1e72f26
|
3 |
+
size 4965712452
|
pytorch_model-00002-of-00006.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0df6860eb51bbd2ab136351a39f295d4a2853a74a7719e1ea83a296b0af3e9d1
|
3 |
+
size 4924328556
|
pytorch_model-00003-of-00006.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e9680466f58012f08f43e5f12372f3d48769f70e387debe22aaefba6d154682f
|
3 |
+
size 4857219294
|
pytorch_model-00004-of-00006.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:161461dcdc9717b80393bfa008d903aaa92122f584fb287047d4e78b2c68433a
|
3 |
+
size 4857219294
|
pytorch_model-00005-of-00006.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5dbfcec466897e051cbcf40dff7961a632a3836e68ae494edb2ce90e94a920f0
|
3 |
+
size 4857219294
|
pytorch_model-00006-of-00006.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1c75d142cb23ea767435988d9cff5daca87f8f22b2755b4424cfc9aa9a7f78df
|
3 |
+
size 2161173694
|
pytorch_model.bin.index.json
ADDED
@@ -0,0 +1,299 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"metadata": {
|
3 |
+
"total_size": 26622771440
|
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",
|
11 |
+
"model.layers.0.mlp.gate_proj.weight": "pytorch_model-00001-of-00006.bin",
|
12 |
+
"model.layers.0.mlp.up_proj.weight": "pytorch_model-00001-of-00006.bin",
|
13 |
+
"model.layers.0.post_attention_layernorm.weight": "pytorch_model-00001-of-00006.bin",
|
14 |
+
"model.layers.0.self_attn.k_proj.weight": "pytorch_model-00001-of-00006.bin",
|
15 |
+
"model.layers.0.self_attn.o_proj.weight": "pytorch_model-00001-of-00006.bin",
|
16 |
+
"model.layers.0.self_attn.q_proj.weight": "pytorch_model-00001-of-00006.bin",
|
17 |
+
"model.layers.0.self_attn.v_proj.weight": "pytorch_model-00001-of-00006.bin",
|
18 |
+
"model.layers.1.input_layernorm.weight": "pytorch_model-00001-of-00006.bin",
|
19 |
+
"model.layers.1.mlp.down_proj.weight": "pytorch_model-00001-of-00006.bin",
|
20 |
+
"model.layers.1.mlp.gate_proj.weight": "pytorch_model-00001-of-00006.bin",
|
21 |
+
"model.layers.1.mlp.up_proj.weight": "pytorch_model-00001-of-00006.bin",
|
22 |
+
"model.layers.1.post_attention_layernorm.weight": "pytorch_model-00001-of-00006.bin",
|
23 |
+
"model.layers.1.self_attn.k_proj.weight": "pytorch_model-00001-of-00006.bin",
|
24 |
+
"model.layers.1.self_attn.o_proj.weight": "pytorch_model-00001-of-00006.bin",
|
25 |
+
"model.layers.1.self_attn.q_proj.weight": "pytorch_model-00001-of-00006.bin",
|
26 |
+
"model.layers.1.self_attn.v_proj.weight": "pytorch_model-00001-of-00006.bin",
|
27 |
+
"model.layers.10.input_layernorm.weight": "pytorch_model-00002-of-00006.bin",
|
28 |
+
"model.layers.10.mlp.down_proj.weight": "pytorch_model-00002-of-00006.bin",
|
29 |
+
"model.layers.10.mlp.gate_proj.weight": "pytorch_model-00002-of-00006.bin",
|
30 |
+
"model.layers.10.mlp.up_proj.weight": "pytorch_model-00002-of-00006.bin",
|
31 |
+
"model.layers.10.post_attention_layernorm.weight": "pytorch_model-00002-of-00006.bin",
|
32 |
+
"model.layers.10.self_attn.k_proj.weight": "pytorch_model-00002-of-00006.bin",
|
33 |
+
"model.layers.10.self_attn.o_proj.weight": "pytorch_model-00002-of-00006.bin",
|
34 |
+
"model.layers.10.self_attn.q_proj.weight": "pytorch_model-00002-of-00006.bin",
|
35 |
+
"model.layers.10.self_attn.v_proj.weight": "pytorch_model-00002-of-00006.bin",
|
36 |
+
"model.layers.11.input_layernorm.weight": "pytorch_model-00003-of-00006.bin",
|
37 |
+
"model.layers.11.mlp.down_proj.weight": "pytorch_model-00003-of-00006.bin",
|
38 |
+
"model.layers.11.mlp.gate_proj.weight": "pytorch_model-00003-of-00006.bin",
|
39 |
+
"model.layers.11.mlp.up_proj.weight": "pytorch_model-00003-of-00006.bin",
|
40 |
+
"model.layers.11.post_attention_layernorm.weight": "pytorch_model-00003-of-00006.bin",
|
41 |
+
"model.layers.11.self_attn.k_proj.weight": "pytorch_model-00002-of-00006.bin",
|
42 |
+
"model.layers.11.self_attn.o_proj.weight": "pytorch_model-00002-of-00006.bin",
|
43 |
+
"model.layers.11.self_attn.q_proj.weight": "pytorch_model-00002-of-00006.bin",
|
44 |
+
"model.layers.11.self_attn.v_proj.weight": "pytorch_model-00002-of-00006.bin",
|
45 |
+
"model.layers.12.input_layernorm.weight": "pytorch_model-00003-of-00006.bin",
|
46 |
+
"model.layers.12.mlp.down_proj.weight": "pytorch_model-00003-of-00006.bin",
|
47 |
+
"model.layers.12.mlp.gate_proj.weight": "pytorch_model-00003-of-00006.bin",
|
48 |
+
"model.layers.12.mlp.up_proj.weight": "pytorch_model-00003-of-00006.bin",
|
49 |
+
"model.layers.12.post_attention_layernorm.weight": "pytorch_model-00003-of-00006.bin",
|
50 |
+
"model.layers.12.self_attn.k_proj.weight": "pytorch_model-00003-of-00006.bin",
|
51 |
+
"model.layers.12.self_attn.o_proj.weight": "pytorch_model-00003-of-00006.bin",
|
52 |
+
"model.layers.12.self_attn.q_proj.weight": "pytorch_model-00003-of-00006.bin",
|
53 |
+
"model.layers.12.self_attn.v_proj.weight": "pytorch_model-00003-of-00006.bin",
|
54 |
+
"model.layers.13.input_layernorm.weight": "pytorch_model-00003-of-00006.bin",
|
55 |
+
"model.layers.13.mlp.down_proj.weight": "pytorch_model-00003-of-00006.bin",
|
56 |
+
"model.layers.13.mlp.gate_proj.weight": "pytorch_model-00003-of-00006.bin",
|
57 |
+
"model.layers.13.mlp.up_proj.weight": "pytorch_model-00003-of-00006.bin",
|
58 |
+
"model.layers.13.post_attention_layernorm.weight": "pytorch_model-00003-of-00006.bin",
|
59 |
+
"model.layers.13.self_attn.k_proj.weight": "pytorch_model-00003-of-00006.bin",
|
60 |
+
"model.layers.13.self_attn.o_proj.weight": "pytorch_model-00003-of-00006.bin",
|
61 |
+
"model.layers.13.self_attn.q_proj.weight": "pytorch_model-00003-of-00006.bin",
|
62 |
+
"model.layers.13.self_attn.v_proj.weight": "pytorch_model-00003-of-00006.bin",
|
63 |
+
"model.layers.14.input_layernorm.weight": "pytorch_model-00003-of-00006.bin",
|
64 |
+
"model.layers.14.mlp.down_proj.weight": "pytorch_model-00003-of-00006.bin",
|
65 |
+
"model.layers.14.mlp.gate_proj.weight": "pytorch_model-00003-of-00006.bin",
|
66 |
+
"model.layers.14.mlp.up_proj.weight": "pytorch_model-00003-of-00006.bin",
|
67 |
+
"model.layers.14.post_attention_layernorm.weight": "pytorch_model-00003-of-00006.bin",
|
68 |
+
"model.layers.14.self_attn.k_proj.weight": "pytorch_model-00003-of-00006.bin",
|
69 |
+
"model.layers.14.self_attn.o_proj.weight": "pytorch_model-00003-of-00006.bin",
|
70 |
+
"model.layers.14.self_attn.q_proj.weight": "pytorch_model-00003-of-00006.bin",
|
71 |
+
"model.layers.14.self_attn.v_proj.weight": "pytorch_model-00003-of-00006.bin",
|
72 |
+
"model.layers.15.input_layernorm.weight": "pytorch_model-00003-of-00006.bin",
|
73 |
+
"model.layers.15.mlp.down_proj.weight": "pytorch_model-00003-of-00006.bin",
|
74 |
+
"model.layers.15.mlp.gate_proj.weight": "pytorch_model-00003-of-00006.bin",
|
75 |
+
"model.layers.15.mlp.up_proj.weight": "pytorch_model-00003-of-00006.bin",
|
76 |
+
"model.layers.15.post_attention_layernorm.weight": "pytorch_model-00003-of-00006.bin",
|
77 |
+
"model.layers.15.self_attn.k_proj.weight": "pytorch_model-00003-of-00006.bin",
|
78 |
+
"model.layers.15.self_attn.o_proj.weight": "pytorch_model-00003-of-00006.bin",
|
79 |
+
"model.layers.15.self_attn.q_proj.weight": "pytorch_model-00003-of-00006.bin",
|
80 |
+
"model.layers.15.self_attn.v_proj.weight": "pytorch_model-00003-of-00006.bin",
|
81 |
+
"model.layers.16.input_layernorm.weight": "pytorch_model-00003-of-00006.bin",
|
82 |
+
"model.layers.16.mlp.down_proj.weight": "pytorch_model-00003-of-00006.bin",
|
83 |
+
"model.layers.16.mlp.gate_proj.weight": "pytorch_model-00003-of-00006.bin",
|
84 |
+
"model.layers.16.mlp.up_proj.weight": "pytorch_model-00003-of-00006.bin",
|
85 |
+
"model.layers.16.post_attention_layernorm.weight": "pytorch_model-00003-of-00006.bin",
|
86 |
+
"model.layers.16.self_attn.k_proj.weight": "pytorch_model-00003-of-00006.bin",
|
87 |
+
"model.layers.16.self_attn.o_proj.weight": "pytorch_model-00003-of-00006.bin",
|
88 |
+
"model.layers.16.self_attn.q_proj.weight": "pytorch_model-00003-of-00006.bin",
|
89 |
+
"model.layers.16.self_attn.v_proj.weight": "pytorch_model-00003-of-00006.bin",
|
90 |
+
"model.layers.17.input_layernorm.weight": "pytorch_model-00004-of-00006.bin",
|
91 |
+
"model.layers.17.mlp.down_proj.weight": "pytorch_model-00004-of-00006.bin",
|
92 |
+
"model.layers.17.mlp.gate_proj.weight": "pytorch_model-00004-of-00006.bin",
|
93 |
+
"model.layers.17.mlp.up_proj.weight": "pytorch_model-00004-of-00006.bin",
|
94 |
+
"model.layers.17.post_attention_layernorm.weight": "pytorch_model-00004-of-00006.bin",
|
95 |
+
"model.layers.17.self_attn.k_proj.weight": "pytorch_model-00003-of-00006.bin",
|
96 |
+
"model.layers.17.self_attn.o_proj.weight": "pytorch_model-00003-of-00006.bin",
|
97 |
+
"model.layers.17.self_attn.q_proj.weight": "pytorch_model-00003-of-00006.bin",
|
98 |
+
"model.layers.17.self_attn.v_proj.weight": "pytorch_model-00003-of-00006.bin",
|
99 |
+
"model.layers.18.input_layernorm.weight": "pytorch_model-00004-of-00006.bin",
|
100 |
+
"model.layers.18.mlp.down_proj.weight": "pytorch_model-00004-of-00006.bin",
|
101 |
+
"model.layers.18.mlp.gate_proj.weight": "pytorch_model-00004-of-00006.bin",
|
102 |
+
"model.layers.18.mlp.up_proj.weight": "pytorch_model-00004-of-00006.bin",
|
103 |
+
"model.layers.18.post_attention_layernorm.weight": "pytorch_model-00004-of-00006.bin",
|
104 |
+
"model.layers.18.self_attn.k_proj.weight": "pytorch_model-00004-of-00006.bin",
|
105 |
+
"model.layers.18.self_attn.o_proj.weight": "pytorch_model-00004-of-00006.bin",
|
106 |
+
"model.layers.18.self_attn.q_proj.weight": "pytorch_model-00004-of-00006.bin",
|
107 |
+
"model.layers.18.self_attn.v_proj.weight": "pytorch_model-00004-of-00006.bin",
|
108 |
+
"model.layers.19.input_layernorm.weight": "pytorch_model-00004-of-00006.bin",
|
109 |
+
"model.layers.19.mlp.down_proj.weight": "pytorch_model-00004-of-00006.bin",
|
110 |
+
"model.layers.19.mlp.gate_proj.weight": "pytorch_model-00004-of-00006.bin",
|
111 |
+
"model.layers.19.mlp.up_proj.weight": "pytorch_model-00004-of-00006.bin",
|
112 |
+
"model.layers.19.post_attention_layernorm.weight": "pytorch_model-00004-of-00006.bin",
|
113 |
+
"model.layers.19.self_attn.k_proj.weight": "pytorch_model-00004-of-00006.bin",
|
114 |
+
"model.layers.19.self_attn.o_proj.weight": "pytorch_model-00004-of-00006.bin",
|
115 |
+
"model.layers.19.self_attn.q_proj.weight": "pytorch_model-00004-of-00006.bin",
|
116 |
+
"model.layers.19.self_attn.v_proj.weight": "pytorch_model-00004-of-00006.bin",
|
117 |
+
"model.layers.2.input_layernorm.weight": "pytorch_model-00001-of-00006.bin",
|
118 |
+
"model.layers.2.mlp.down_proj.weight": "pytorch_model-00001-of-00006.bin",
|
119 |
+
"model.layers.2.mlp.gate_proj.weight": "pytorch_model-00001-of-00006.bin",
|
120 |
+
"model.layers.2.mlp.up_proj.weight": "pytorch_model-00001-of-00006.bin",
|
121 |
+
"model.layers.2.post_attention_layernorm.weight": "pytorch_model-00001-of-00006.bin",
|
122 |
+
"model.layers.2.self_attn.k_proj.weight": "pytorch_model-00001-of-00006.bin",
|
123 |
+
"model.layers.2.self_attn.o_proj.weight": "pytorch_model-00001-of-00006.bin",
|
124 |
+
"model.layers.2.self_attn.q_proj.weight": "pytorch_model-00001-of-00006.bin",
|
125 |
+
"model.layers.2.self_attn.v_proj.weight": "pytorch_model-00001-of-00006.bin",
|
126 |
+
"model.layers.20.input_layernorm.weight": "pytorch_model-00004-of-00006.bin",
|
127 |
+
"model.layers.20.mlp.down_proj.weight": "pytorch_model-00004-of-00006.bin",
|
128 |
+
"model.layers.20.mlp.gate_proj.weight": "pytorch_model-00004-of-00006.bin",
|
129 |
+
"model.layers.20.mlp.up_proj.weight": "pytorch_model-00004-of-00006.bin",
|
130 |
+
"model.layers.20.post_attention_layernorm.weight": "pytorch_model-00004-of-00006.bin",
|
131 |
+
"model.layers.20.self_attn.k_proj.weight": "pytorch_model-00004-of-00006.bin",
|
132 |
+
"model.layers.20.self_attn.o_proj.weight": "pytorch_model-00004-of-00006.bin",
|
133 |
+
"model.layers.20.self_attn.q_proj.weight": "pytorch_model-00004-of-00006.bin",
|
134 |
+
"model.layers.20.self_attn.v_proj.weight": "pytorch_model-00004-of-00006.bin",
|
135 |
+
"model.layers.21.input_layernorm.weight": "pytorch_model-00004-of-00006.bin",
|
136 |
+
"model.layers.21.mlp.down_proj.weight": "pytorch_model-00004-of-00006.bin",
|
137 |
+
"model.layers.21.mlp.gate_proj.weight": "pytorch_model-00004-of-00006.bin",
|
138 |
+
"model.layers.21.mlp.up_proj.weight": "pytorch_model-00004-of-00006.bin",
|
139 |
+
"model.layers.21.post_attention_layernorm.weight": "pytorch_model-00004-of-00006.bin",
|
140 |
+
"model.layers.21.self_attn.k_proj.weight": "pytorch_model-00004-of-00006.bin",
|
141 |
+
"model.layers.21.self_attn.o_proj.weight": "pytorch_model-00004-of-00006.bin",
|
142 |
+
"model.layers.21.self_attn.q_proj.weight": "pytorch_model-00004-of-00006.bin",
|
143 |
+
"model.layers.21.self_attn.v_proj.weight": "pytorch_model-00004-of-00006.bin",
|
144 |
+
"model.layers.22.input_layernorm.weight": "pytorch_model-00004-of-00006.bin",
|
145 |
+
"model.layers.22.mlp.down_proj.weight": "pytorch_model-00004-of-00006.bin",
|
146 |
+
"model.layers.22.mlp.gate_proj.weight": "pytorch_model-00004-of-00006.bin",
|
147 |
+
"model.layers.22.mlp.up_proj.weight": "pytorch_model-00004-of-00006.bin",
|
148 |
+
"model.layers.22.post_attention_layernorm.weight": "pytorch_model-00004-of-00006.bin",
|
149 |
+
"model.layers.22.self_attn.k_proj.weight": "pytorch_model-00004-of-00006.bin",
|
150 |
+
"model.layers.22.self_attn.o_proj.weight": "pytorch_model-00004-of-00006.bin",
|
151 |
+
"model.layers.22.self_attn.q_proj.weight": "pytorch_model-00004-of-00006.bin",
|
152 |
+
"model.layers.22.self_attn.v_proj.weight": "pytorch_model-00004-of-00006.bin",
|
153 |
+
"model.layers.23.input_layernorm.weight": "pytorch_model-00005-of-00006.bin",
|
154 |
+
"model.layers.23.mlp.down_proj.weight": "pytorch_model-00005-of-00006.bin",
|
155 |
+
"model.layers.23.mlp.gate_proj.weight": "pytorch_model-00005-of-00006.bin",
|
156 |
+
"model.layers.23.mlp.up_proj.weight": "pytorch_model-00005-of-00006.bin",
|
157 |
+
"model.layers.23.post_attention_layernorm.weight": "pytorch_model-00005-of-00006.bin",
|
158 |
+
"model.layers.23.self_attn.k_proj.weight": "pytorch_model-00004-of-00006.bin",
|
159 |
+
"model.layers.23.self_attn.o_proj.weight": "pytorch_model-00004-of-00006.bin",
|
160 |
+
"model.layers.23.self_attn.q_proj.weight": "pytorch_model-00004-of-00006.bin",
|
161 |
+
"model.layers.23.self_attn.v_proj.weight": "pytorch_model-00004-of-00006.bin",
|
162 |
+
"model.layers.24.input_layernorm.weight": "pytorch_model-00005-of-00006.bin",
|
163 |
+
"model.layers.24.mlp.down_proj.weight": "pytorch_model-00005-of-00006.bin",
|
164 |
+
"model.layers.24.mlp.gate_proj.weight": "pytorch_model-00005-of-00006.bin",
|
165 |
+
"model.layers.24.mlp.up_proj.weight": "pytorch_model-00005-of-00006.bin",
|
166 |
+
"model.layers.24.post_attention_layernorm.weight": "pytorch_model-00005-of-00006.bin",
|
167 |
+
"model.layers.24.self_attn.k_proj.weight": "pytorch_model-00005-of-00006.bin",
|
168 |
+
"model.layers.24.self_attn.o_proj.weight": "pytorch_model-00005-of-00006.bin",
|
169 |
+
"model.layers.24.self_attn.q_proj.weight": "pytorch_model-00005-of-00006.bin",
|
170 |
+
"model.layers.24.self_attn.v_proj.weight": "pytorch_model-00005-of-00006.bin",
|
171 |
+
"model.layers.25.input_layernorm.weight": "pytorch_model-00005-of-00006.bin",
|
172 |
+
"model.layers.25.mlp.down_proj.weight": "pytorch_model-00005-of-00006.bin",
|
173 |
+
"model.layers.25.mlp.gate_proj.weight": "pytorch_model-00005-of-00006.bin",
|
174 |
+
"model.layers.25.mlp.up_proj.weight": "pytorch_model-00005-of-00006.bin",
|
175 |
+
"model.layers.25.post_attention_layernorm.weight": "pytorch_model-00005-of-00006.bin",
|
176 |
+
"model.layers.25.self_attn.k_proj.weight": "pytorch_model-00005-of-00006.bin",
|
177 |
+
"model.layers.25.self_attn.o_proj.weight": "pytorch_model-00005-of-00006.bin",
|
178 |
+
"model.layers.25.self_attn.q_proj.weight": "pytorch_model-00005-of-00006.bin",
|
179 |
+
"model.layers.25.self_attn.v_proj.weight": "pytorch_model-00005-of-00006.bin",
|
180 |
+
"model.layers.26.input_layernorm.weight": "pytorch_model-00005-of-00006.bin",
|
181 |
+
"model.layers.26.mlp.down_proj.weight": "pytorch_model-00005-of-00006.bin",
|
182 |
+
"model.layers.26.mlp.gate_proj.weight": "pytorch_model-00005-of-00006.bin",
|
183 |
+
"model.layers.26.mlp.up_proj.weight": "pytorch_model-00005-of-00006.bin",
|
184 |
+
"model.layers.26.post_attention_layernorm.weight": "pytorch_model-00005-of-00006.bin",
|
185 |
+
"model.layers.26.self_attn.k_proj.weight": "pytorch_model-00005-of-00006.bin",
|
186 |
+
"model.layers.26.self_attn.o_proj.weight": "pytorch_model-00005-of-00006.bin",
|
187 |
+
"model.layers.26.self_attn.q_proj.weight": "pytorch_model-00005-of-00006.bin",
|
188 |
+
"model.layers.26.self_attn.v_proj.weight": "pytorch_model-00005-of-00006.bin",
|
189 |
+
"model.layers.27.input_layernorm.weight": "pytorch_model-00005-of-00006.bin",
|
190 |
+
"model.layers.27.mlp.down_proj.weight": "pytorch_model-00005-of-00006.bin",
|
191 |
+
"model.layers.27.mlp.gate_proj.weight": "pytorch_model-00005-of-00006.bin",
|
192 |
+
"model.layers.27.mlp.up_proj.weight": "pytorch_model-00005-of-00006.bin",
|
193 |
+
"model.layers.27.post_attention_layernorm.weight": "pytorch_model-00005-of-00006.bin",
|
194 |
+
"model.layers.27.self_attn.k_proj.weight": "pytorch_model-00005-of-00006.bin",
|
195 |
+
"model.layers.27.self_attn.o_proj.weight": "pytorch_model-00005-of-00006.bin",
|
196 |
+
"model.layers.27.self_attn.q_proj.weight": "pytorch_model-00005-of-00006.bin",
|
197 |
+
"model.layers.27.self_attn.v_proj.weight": "pytorch_model-00005-of-00006.bin",
|
198 |
+
"model.layers.28.input_layernorm.weight": "pytorch_model-00005-of-00006.bin",
|
199 |
+
"model.layers.28.mlp.down_proj.weight": "pytorch_model-00005-of-00006.bin",
|
200 |
+
"model.layers.28.mlp.gate_proj.weight": "pytorch_model-00005-of-00006.bin",
|
201 |
+
"model.layers.28.mlp.up_proj.weight": "pytorch_model-00005-of-00006.bin",
|
202 |
+
"model.layers.28.post_attention_layernorm.weight": "pytorch_model-00005-of-00006.bin",
|
203 |
+
"model.layers.28.self_attn.k_proj.weight": "pytorch_model-00005-of-00006.bin",
|
204 |
+
"model.layers.28.self_attn.o_proj.weight": "pytorch_model-00005-of-00006.bin",
|
205 |
+
"model.layers.28.self_attn.q_proj.weight": "pytorch_model-00005-of-00006.bin",
|
206 |
+
"model.layers.28.self_attn.v_proj.weight": "pytorch_model-00005-of-00006.bin",
|
207 |
+
"model.layers.29.input_layernorm.weight": "pytorch_model-00006-of-00006.bin",
|
208 |
+
"model.layers.29.mlp.down_proj.weight": "pytorch_model-00006-of-00006.bin",
|
209 |
+
"model.layers.29.mlp.gate_proj.weight": "pytorch_model-00006-of-00006.bin",
|
210 |
+
"model.layers.29.mlp.up_proj.weight": "pytorch_model-00006-of-00006.bin",
|
211 |
+
"model.layers.29.post_attention_layernorm.weight": "pytorch_model-00006-of-00006.bin",
|
212 |
+
"model.layers.29.self_attn.k_proj.weight": "pytorch_model-00005-of-00006.bin",
|
213 |
+
"model.layers.29.self_attn.o_proj.weight": "pytorch_model-00005-of-00006.bin",
|
214 |
+
"model.layers.29.self_attn.q_proj.weight": "pytorch_model-00005-of-00006.bin",
|
215 |
+
"model.layers.29.self_attn.v_proj.weight": "pytorch_model-00005-of-00006.bin",
|
216 |
+
"model.layers.3.input_layernorm.weight": "pytorch_model-00001-of-00006.bin",
|
217 |
+
"model.layers.3.mlp.down_proj.weight": "pytorch_model-00001-of-00006.bin",
|
218 |
+
"model.layers.3.mlp.gate_proj.weight": "pytorch_model-00001-of-00006.bin",
|
219 |
+
"model.layers.3.mlp.up_proj.weight": "pytorch_model-00001-of-00006.bin",
|
220 |
+
"model.layers.3.post_attention_layernorm.weight": "pytorch_model-00001-of-00006.bin",
|
221 |
+
"model.layers.3.self_attn.k_proj.weight": "pytorch_model-00001-of-00006.bin",
|
222 |
+
"model.layers.3.self_attn.o_proj.weight": "pytorch_model-00001-of-00006.bin",
|
223 |
+
"model.layers.3.self_attn.q_proj.weight": "pytorch_model-00001-of-00006.bin",
|
224 |
+
"model.layers.3.self_attn.v_proj.weight": "pytorch_model-00001-of-00006.bin",
|
225 |
+
"model.layers.30.input_layernorm.weight": "pytorch_model-00006-of-00006.bin",
|
226 |
+
"model.layers.30.mlp.down_proj.weight": "pytorch_model-00006-of-00006.bin",
|
227 |
+
"model.layers.30.mlp.gate_proj.weight": "pytorch_model-00006-of-00006.bin",
|
228 |
+
"model.layers.30.mlp.up_proj.weight": "pytorch_model-00006-of-00006.bin",
|
229 |
+
"model.layers.30.post_attention_layernorm.weight": "pytorch_model-00006-of-00006.bin",
|
230 |
+
"model.layers.30.self_attn.k_proj.weight": "pytorch_model-00006-of-00006.bin",
|
231 |
+
"model.layers.30.self_attn.o_proj.weight": "pytorch_model-00006-of-00006.bin",
|
232 |
+
"model.layers.30.self_attn.q_proj.weight": "pytorch_model-00006-of-00006.bin",
|
233 |
+
"model.layers.30.self_attn.v_proj.weight": "pytorch_model-00006-of-00006.bin",
|
234 |
+
"model.layers.31.input_layernorm.weight": "pytorch_model-00006-of-00006.bin",
|
235 |
+
"model.layers.31.mlp.down_proj.weight": "pytorch_model-00006-of-00006.bin",
|
236 |
+
"model.layers.31.mlp.gate_proj.weight": "pytorch_model-00006-of-00006.bin",
|
237 |
+
"model.layers.31.mlp.up_proj.weight": "pytorch_model-00006-of-00006.bin",
|
238 |
+
"model.layers.31.post_attention_layernorm.weight": "pytorch_model-00006-of-00006.bin",
|
239 |
+
"model.layers.31.self_attn.k_proj.weight": "pytorch_model-00006-of-00006.bin",
|
240 |
+
"model.layers.31.self_attn.o_proj.weight": "pytorch_model-00006-of-00006.bin",
|
241 |
+
"model.layers.31.self_attn.q_proj.weight": "pytorch_model-00006-of-00006.bin",
|
242 |
+
"model.layers.31.self_attn.v_proj.weight": "pytorch_model-00006-of-00006.bin",
|
243 |
+
"model.layers.4.input_layernorm.weight": "pytorch_model-00001-of-00006.bin",
|
244 |
+
"model.layers.4.mlp.down_proj.weight": "pytorch_model-00001-of-00006.bin",
|
245 |
+
"model.layers.4.mlp.gate_proj.weight": "pytorch_model-00001-of-00006.bin",
|
246 |
+
"model.layers.4.mlp.up_proj.weight": "pytorch_model-00001-of-00006.bin",
|
247 |
+
"model.layers.4.post_attention_layernorm.weight": "pytorch_model-00001-of-00006.bin",
|
248 |
+
"model.layers.4.self_attn.k_proj.weight": "pytorch_model-00001-of-00006.bin",
|
249 |
+
"model.layers.4.self_attn.o_proj.weight": "pytorch_model-00001-of-00006.bin",
|
250 |
+
"model.layers.4.self_attn.q_proj.weight": "pytorch_model-00001-of-00006.bin",
|
251 |
+
"model.layers.4.self_attn.v_proj.weight": "pytorch_model-00001-of-00006.bin",
|
252 |
+
"model.layers.5.input_layernorm.weight": "pytorch_model-00002-of-00006.bin",
|
253 |
+
"model.layers.5.mlp.down_proj.weight": "pytorch_model-00002-of-00006.bin",
|
254 |
+
"model.layers.5.mlp.gate_proj.weight": "pytorch_model-00002-of-00006.bin",
|
255 |
+
"model.layers.5.mlp.up_proj.weight": "pytorch_model-00002-of-00006.bin",
|
256 |
+
"model.layers.5.post_attention_layernorm.weight": "pytorch_model-00002-of-00006.bin",
|
257 |
+
"model.layers.5.self_attn.k_proj.weight": "pytorch_model-00001-of-00006.bin",
|
258 |
+
"model.layers.5.self_attn.o_proj.weight": "pytorch_model-00002-of-00006.bin",
|
259 |
+
"model.layers.5.self_attn.q_proj.weight": "pytorch_model-00001-of-00006.bin",
|
260 |
+
"model.layers.5.self_attn.v_proj.weight": "pytorch_model-00001-of-00006.bin",
|
261 |
+
"model.layers.6.input_layernorm.weight": "pytorch_model-00002-of-00006.bin",
|
262 |
+
"model.layers.6.mlp.down_proj.weight": "pytorch_model-00002-of-00006.bin",
|
263 |
+
"model.layers.6.mlp.gate_proj.weight": "pytorch_model-00002-of-00006.bin",
|
264 |
+
"model.layers.6.mlp.up_proj.weight": "pytorch_model-00002-of-00006.bin",
|
265 |
+
"model.layers.6.post_attention_layernorm.weight": "pytorch_model-00002-of-00006.bin",
|
266 |
+
"model.layers.6.self_attn.k_proj.weight": "pytorch_model-00002-of-00006.bin",
|
267 |
+
"model.layers.6.self_attn.o_proj.weight": "pytorch_model-00002-of-00006.bin",
|
268 |
+
"model.layers.6.self_attn.q_proj.weight": "pytorch_model-00002-of-00006.bin",
|
269 |
+
"model.layers.6.self_attn.v_proj.weight": "pytorch_model-00002-of-00006.bin",
|
270 |
+
"model.layers.7.input_layernorm.weight": "pytorch_model-00002-of-00006.bin",
|
271 |
+
"model.layers.7.mlp.down_proj.weight": "pytorch_model-00002-of-00006.bin",
|
272 |
+
"model.layers.7.mlp.gate_proj.weight": "pytorch_model-00002-of-00006.bin",
|
273 |
+
"model.layers.7.mlp.up_proj.weight": "pytorch_model-00002-of-00006.bin",
|
274 |
+
"model.layers.7.post_attention_layernorm.weight": "pytorch_model-00002-of-00006.bin",
|
275 |
+
"model.layers.7.self_attn.k_proj.weight": "pytorch_model-00002-of-00006.bin",
|
276 |
+
"model.layers.7.self_attn.o_proj.weight": "pytorch_model-00002-of-00006.bin",
|
277 |
+
"model.layers.7.self_attn.q_proj.weight": "pytorch_model-00002-of-00006.bin",
|
278 |
+
"model.layers.7.self_attn.v_proj.weight": "pytorch_model-00002-of-00006.bin",
|
279 |
+
"model.layers.8.input_layernorm.weight": "pytorch_model-00002-of-00006.bin",
|
280 |
+
"model.layers.8.mlp.down_proj.weight": "pytorch_model-00002-of-00006.bin",
|
281 |
+
"model.layers.8.mlp.gate_proj.weight": "pytorch_model-00002-of-00006.bin",
|
282 |
+
"model.layers.8.mlp.up_proj.weight": "pytorch_model-00002-of-00006.bin",
|
283 |
+
"model.layers.8.post_attention_layernorm.weight": "pytorch_model-00002-of-00006.bin",
|
284 |
+
"model.layers.8.self_attn.k_proj.weight": "pytorch_model-00002-of-00006.bin",
|
285 |
+
"model.layers.8.self_attn.o_proj.weight": "pytorch_model-00002-of-00006.bin",
|
286 |
+
"model.layers.8.self_attn.q_proj.weight": "pytorch_model-00002-of-00006.bin",
|
287 |
+
"model.layers.8.self_attn.v_proj.weight": "pytorch_model-00002-of-00006.bin",
|
288 |
+
"model.layers.9.input_layernorm.weight": "pytorch_model-00002-of-00006.bin",
|
289 |
+
"model.layers.9.mlp.down_proj.weight": "pytorch_model-00002-of-00006.bin",
|
290 |
+
"model.layers.9.mlp.gate_proj.weight": "pytorch_model-00002-of-00006.bin",
|
291 |
+
"model.layers.9.mlp.up_proj.weight": "pytorch_model-00002-of-00006.bin",
|
292 |
+
"model.layers.9.post_attention_layernorm.weight": "pytorch_model-00002-of-00006.bin",
|
293 |
+
"model.layers.9.self_attn.k_proj.weight": "pytorch_model-00002-of-00006.bin",
|
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 |
+
}
|
special_tokens_map.json
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": true,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"cls_token": {
|
10 |
+
"content": "<s>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": true,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"eos_token": {
|
17 |
+
"content": "</s>",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": true,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
},
|
23 |
+
"mask_token": {
|
24 |
+
"content": "<unk>",
|
25 |
+
"lstrip": false,
|
26 |
+
"normalized": true,
|
27 |
+
"rstrip": false,
|
28 |
+
"single_word": false
|
29 |
+
},
|
30 |
+
"pad_token": {
|
31 |
+
"content": "</s>",
|
32 |
+
"lstrip": false,
|
33 |
+
"normalized": true,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false
|
36 |
+
},
|
37 |
+
"sep_token": {
|
38 |
+
"content": "<s>",
|
39 |
+
"lstrip": false,
|
40 |
+
"normalized": true,
|
41 |
+
"rstrip": false,
|
42 |
+
"single_word": false
|
43 |
+
},
|
44 |
+
"unk_token": {
|
45 |
+
"content": "<unk>",
|
46 |
+
"lstrip": false,
|
47 |
+
"normalized": true,
|
48 |
+
"rstrip": false,
|
49 |
+
"single_word": false
|
50 |
+
}
|
51 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": true,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"added_tokens_decoder": {
|
5 |
+
"0": {
|
6 |
+
"content": "<unk>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": true,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false,
|
11 |
+
"special": true
|
12 |
+
},
|
13 |
+
"1": {
|
14 |
+
"content": "<s>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": true,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false,
|
19 |
+
"special": true
|
20 |
+
},
|
21 |
+
"2": {
|
22 |
+
"content": "</s>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": true,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false,
|
27 |
+
"special": true
|
28 |
+
}
|
29 |
+
},
|
30 |
+
"bos_token": "<s>",
|
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>",
|
37 |
+
"sep_token": "<s>",
|
38 |
+
"tokenizer_class": "LlamaTokenizerFast",
|
39 |
+
"unk_token": "<unk>",
|
40 |
+
"use_default_system_prompt": false
|
41 |
+
}
|
upos.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import TokenClassificationPipeline,LlamaModel,LlamaPreTrainedModel
|
2 |
+
from transformers.modeling_outputs import TokenClassifierOutput
|
3 |
+
|
4 |
+
class BellmanFordTokenClassificationPipeline(TokenClassificationPipeline):
|
5 |
+
def __init__(self,**kwargs):
|
6 |
+
import numpy
|
7 |
+
super().__init__(**kwargs)
|
8 |
+
x=self.model.config.label2id
|
9 |
+
y=[k for k in x if not k.startswith("I-")]
|
10 |
+
self.transition=numpy.full((len(x),len(x)),numpy.nan)
|
11 |
+
for k,v in x.items():
|
12 |
+
for j in ["I-"+k[2:]] if k.startswith("B-") else [k]+y if k.startswith("I-") else y:
|
13 |
+
self.transition[v,x[j]]=0
|
14 |
+
def check_model_type(self,supported_models):
|
15 |
+
pass
|
16 |
+
def postprocess(self,model_outputs,**kwargs):
|
17 |
+
import numpy
|
18 |
+
if "logits" not in model_outputs:
|
19 |
+
return self.postprocess(model_outputs[0],**kwargs)
|
20 |
+
m=model_outputs["logits"][0].numpy()
|
21 |
+
e=numpy.exp(m-numpy.max(m,axis=-1,keepdims=True))
|
22 |
+
z=e/e.sum(axis=-1,keepdims=True)
|
23 |
+
for i in range(m.shape[0]-1,0,-1):
|
24 |
+
m[i-1]+=numpy.nanmax(m[i]+self.transition,axis=1)
|
25 |
+
k=[numpy.nanargmax(m[0])]
|
26 |
+
for i in range(1,m.shape[0]):
|
27 |
+
k.append(numpy.nanargmax(m[i]+self.transition[k[-1]]))
|
28 |
+
w=[{"entity":self.model.config.id2label[j],"start":s,"end":e,"score":z[i,j]} for i,((s,e),j) in enumerate(zip(model_outputs["offset_mapping"][0].tolist(),k)) if s<e]
|
29 |
+
if "aggregation_strategy" in kwargs and kwargs["aggregation_strategy"]!="none":
|
30 |
+
for i,t in reversed(list(enumerate(w))):
|
31 |
+
p=t.pop("entity")
|
32 |
+
if p.startswith("I-"):
|
33 |
+
w[i-1]["score"]=min(w[i-1]["score"],t["score"])
|
34 |
+
w[i-1]["end"]=w.pop(i)["end"]
|
35 |
+
elif p.startswith("B-"):
|
36 |
+
t["entity_group"]=p[2:]
|
37 |
+
else:
|
38 |
+
t["entity_group"]=p
|
39 |
+
for t in w:
|
40 |
+
t["text"]=model_outputs["sentence"][t["start"]:t["end"]]
|
41 |
+
return w
|
42 |
+
|
43 |
+
class LlamaForTokenClassification(LlamaPreTrainedModel):
|
44 |
+
def __init__(self,config):
|
45 |
+
from torch import nn
|
46 |
+
super().__init__(config)
|
47 |
+
self.num_labels=config.num_labels
|
48 |
+
self.model=LlamaModel(config)
|
49 |
+
if hasattr(config,"classifier_dropout") and config.classifier_dropout is not None:
|
50 |
+
classifier_dropout=config.classifier_dropout
|
51 |
+
elif hasattr(config,"hidden_dropout") and config.hidden_dropout is not None:
|
52 |
+
classifier_dropout=config.hidden_dropout
|
53 |
+
else:
|
54 |
+
classifier_dropout=0.1
|
55 |
+
self.dropout=nn.Dropout(classifier_dropout)
|
56 |
+
self.classifier=nn.Linear(config.hidden_size,config.num_labels)
|
57 |
+
self.post_init()
|
58 |
+
def get_input_embeddings(self):
|
59 |
+
return self.model.embed_tokens
|
60 |
+
def set_input_embeddings(self,value):
|
61 |
+
self.model.embed_tokens=value
|
62 |
+
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):
|
63 |
+
return_dict=return_dict if return_dict is not None else self.config.use_return_dict
|
64 |
+
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)
|
65 |
+
hidden_states=transformer_outputs[0]
|
66 |
+
hidden_states=self.dropout(hidden_states)
|
67 |
+
logits=self.classifier(hidden_states)
|
68 |
+
loss=None
|
69 |
+
if labels is not None:
|
70 |
+
from torch import nn
|
71 |
+
loss_fct=nn.CrossEntropyLoss()
|
72 |
+
loss=loss_fct(logits.view(-1,self.num_labels),labels.view(-1))
|
73 |
+
if not return_dict:
|
74 |
+
output=(logits,)+transformer_outputs[1:]
|
75 |
+
return ((loss,)+output) if loss is not None else output
|
76 |
+
return TokenClassifierOutput(loss=loss,logits=logits,hidden_states=transformer_outputs.hidden_states,attentions=transformer_outputs.attentions)
|