Spaces:
Sleeping
Sleeping
umsee
commited on
Commit
·
6c5befe
1
Parent(s):
7c087cb
Added the model file and tokenizer as a directory
Browse files- albert/.ipynb_checkpoints/Untitled-checkpoint.ipynb +201 -0
- albert/.ipynb_checkpoints/config-checkpoint.json +62 -0
- albert/Untitled.ipynb +246 -0
- albert/config.json +62 -0
- albert/model.safetensors +3 -0
- albert/special_tokens_map.json +15 -0
- albert/spiece.model +3 -0
- albert/tokenizer.json +0 -0
- albert/tokenizer_config.json +22 -0
- albert/training_args.bin +3 -0
albert/.ipynb_checkpoints/Untitled-checkpoint.ipynb
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "8804bc60-c9e2-4713-9800-1bc2fea11241",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [
|
9 |
+
{
|
10 |
+
"name": "stderr",
|
11 |
+
"output_type": "stream",
|
12 |
+
"text": [
|
13 |
+
"/home/umesh/conda/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
14 |
+
" from .autonotebook import tqdm as notebook_tqdm\n"
|
15 |
+
]
|
16 |
+
}
|
17 |
+
],
|
18 |
+
"source": [
|
19 |
+
"from transformers import pipeline"
|
20 |
+
]
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"cell_type": "code",
|
24 |
+
"execution_count": 4,
|
25 |
+
"id": "322cd68e-9257-4d07-aafc-19e9072f1bba",
|
26 |
+
"metadata": {},
|
27 |
+
"outputs": [],
|
28 |
+
"source": [
|
29 |
+
"from transformers import AutoModelForSequenceClassification, AutoTokenizer\n",
|
30 |
+
"\n",
|
31 |
+
"model = AutoModelForSequenceClassification.from_pretrained('.')\n",
|
32 |
+
"tokenizer = AutoTokenizer.from_pretrained('.')"
|
33 |
+
]
|
34 |
+
},
|
35 |
+
{
|
36 |
+
"cell_type": "code",
|
37 |
+
"execution_count": 5,
|
38 |
+
"id": "fde22c8f-4d57-4544-bc2b-55e4dbbc5fd3",
|
39 |
+
"metadata": {},
|
40 |
+
"outputs": [],
|
41 |
+
"source": [
|
42 |
+
"classifier = pipeline('sentiment-analysis',model = model, tokenizer = tokenizer, top_k =1)\n",
|
43 |
+
"det_classer = pipeline('sentiment-analysis',model = model, tokenizer = tokenizer, top_k =None)"
|
44 |
+
]
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"cell_type": "code",
|
48 |
+
"execution_count": 6,
|
49 |
+
"id": "087c3506-5d27-4dd6-9377-fb34e6926698",
|
50 |
+
"metadata": {},
|
51 |
+
"outputs": [],
|
52 |
+
"source": [
|
53 |
+
"inputs=['This is a rather confusing statement','I do not want to bee seen with you Kusakabe','Rin chan was elegant in dismissing your favours','Damn you! Bonn-kun']"
|
54 |
+
]
|
55 |
+
},
|
56 |
+
{
|
57 |
+
"cell_type": "code",
|
58 |
+
"execution_count": 7,
|
59 |
+
"id": "f5683415-239a-4e68-8f4c-1b9ba8295787",
|
60 |
+
"metadata": {},
|
61 |
+
"outputs": [
|
62 |
+
{
|
63 |
+
"data": {
|
64 |
+
"text/plain": [
|
65 |
+
"[[{'label': 'DISGUST', 'score': 0.2899283468723297}],\n",
|
66 |
+
" [{'label': 'DISGUST', 'score': 0.20709046721458435}],\n",
|
67 |
+
" [{'label': 'OPTIMISM', 'score': 0.1878553181886673}],\n",
|
68 |
+
" [{'label': 'ANGER', 'score': 0.46816307306289673}]]"
|
69 |
+
]
|
70 |
+
},
|
71 |
+
"execution_count": 7,
|
72 |
+
"metadata": {},
|
73 |
+
"output_type": "execute_result"
|
74 |
+
}
|
75 |
+
],
|
76 |
+
"source": [
|
77 |
+
"classifier(inputs)"
|
78 |
+
]
|
79 |
+
},
|
80 |
+
{
|
81 |
+
"cell_type": "code",
|
82 |
+
"execution_count": 8,
|
83 |
+
"id": "9b45cd86-cd63-40b1-81ff-7b510ac94c8d",
|
84 |
+
"metadata": {},
|
85 |
+
"outputs": [],
|
86 |
+
"source": [
|
87 |
+
"statement='Today I did not finish my project and stayed silently away from meetings but my boss found it out and shouted at me in front of a female colleague '"
|
88 |
+
]
|
89 |
+
},
|
90 |
+
{
|
91 |
+
"cell_type": "code",
|
92 |
+
"execution_count": 9,
|
93 |
+
"id": "a7361b72-d959-4993-80cf-5c0d65f3e703",
|
94 |
+
"metadata": {},
|
95 |
+
"outputs": [],
|
96 |
+
"source": [
|
97 |
+
"def classify (statement):\n",
|
98 |
+
" preds = det_classer(statement)\n",
|
99 |
+
" return {label}"
|
100 |
+
]
|
101 |
+
},
|
102 |
+
{
|
103 |
+
"cell_type": "code",
|
104 |
+
"execution_count": 10,
|
105 |
+
"id": "9b6bff6a-3a70-48d8-8b03-1d8327278cad",
|
106 |
+
"metadata": {},
|
107 |
+
"outputs": [],
|
108 |
+
"source": [
|
109 |
+
"import gradio as gr"
|
110 |
+
]
|
111 |
+
},
|
112 |
+
{
|
113 |
+
"cell_type": "code",
|
114 |
+
"execution_count": 11,
|
115 |
+
"id": "d1aa90b3-678f-4ae0-bfa7-6018034c5b3e",
|
116 |
+
"metadata": {},
|
117 |
+
"outputs": [
|
118 |
+
{
|
119 |
+
"name": "stdout",
|
120 |
+
"output_type": "stream",
|
121 |
+
"text": [
|
122 |
+
"Running on local URL: http://127.0.0.1:7860\n",
|
123 |
+
"\n",
|
124 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
125 |
+
]
|
126 |
+
},
|
127 |
+
{
|
128 |
+
"data": {
|
129 |
+
"text/html": [
|
130 |
+
"<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
131 |
+
],
|
132 |
+
"text/plain": [
|
133 |
+
"<IPython.core.display.HTML object>"
|
134 |
+
]
|
135 |
+
},
|
136 |
+
"metadata": {},
|
137 |
+
"output_type": "display_data"
|
138 |
+
},
|
139 |
+
{
|
140 |
+
"data": {
|
141 |
+
"text/plain": []
|
142 |
+
},
|
143 |
+
"execution_count": 11,
|
144 |
+
"metadata": {},
|
145 |
+
"output_type": "execute_result"
|
146 |
+
},
|
147 |
+
{
|
148 |
+
"name": "stderr",
|
149 |
+
"output_type": "stream",
|
150 |
+
"text": [
|
151 |
+
"Traceback (most recent call last):\n",
|
152 |
+
" File \"/home/umesh/conda/lib/python3.10/site-packages/gradio/queueing.py\", line 527, in process_events\n",
|
153 |
+
" response = await route_utils.call_process_api(\n",
|
154 |
+
" File \"/home/umesh/conda/lib/python3.10/site-packages/gradio/route_utils.py\", line 261, in call_process_api\n",
|
155 |
+
" output = await app.get_blocks().process_api(\n",
|
156 |
+
" File \"/home/umesh/conda/lib/python3.10/site-packages/gradio/blocks.py\", line 1795, in process_api\n",
|
157 |
+
" data = await self.postprocess_data(fn_index, result[\"prediction\"], state)\n",
|
158 |
+
" File \"/home/umesh/conda/lib/python3.10/site-packages/gradio/blocks.py\", line 1623, in postprocess_data\n",
|
159 |
+
" prediction_value = block.postprocess(prediction_value)\n",
|
160 |
+
" File \"/home/umesh/conda/lib/python3.10/site-packages/gradio/components/label.py\", line 137, in postprocess\n",
|
161 |
+
" raise ValueError(\n",
|
162 |
+
"ValueError: The `Label` output interface expects one of: a string label, or an int label, a float label, or a dictionary whose keys are labels and values are confidences. Instead, got a <class 'list'>\n"
|
163 |
+
]
|
164 |
+
}
|
165 |
+
],
|
166 |
+
"source": [
|
167 |
+
"demo = gr.Interface(fn=classify, inputs='text',outputs=gr.Label())\n",
|
168 |
+
"demo.launch()"
|
169 |
+
]
|
170 |
+
},
|
171 |
+
{
|
172 |
+
"cell_type": "code",
|
173 |
+
"execution_count": null,
|
174 |
+
"id": "e7852458-9afc-4443-bfc8-ebd16909dc6a",
|
175 |
+
"metadata": {},
|
176 |
+
"outputs": [],
|
177 |
+
"source": []
|
178 |
+
}
|
179 |
+
],
|
180 |
+
"metadata": {
|
181 |
+
"kernelspec": {
|
182 |
+
"display_name": "Python 3 (ipykernel)",
|
183 |
+
"language": "python",
|
184 |
+
"name": "python3"
|
185 |
+
},
|
186 |
+
"language_info": {
|
187 |
+
"codemirror_mode": {
|
188 |
+
"name": "ipython",
|
189 |
+
"version": 3
|
190 |
+
},
|
191 |
+
"file_extension": ".py",
|
192 |
+
"mimetype": "text/x-python",
|
193 |
+
"name": "python",
|
194 |
+
"nbconvert_exporter": "python",
|
195 |
+
"pygments_lexer": "ipython3",
|
196 |
+
"version": "3.10.13"
|
197 |
+
}
|
198 |
+
},
|
199 |
+
"nbformat": 4,
|
200 |
+
"nbformat_minor": 5
|
201 |
+
}
|
albert/.ipynb_checkpoints/config-checkpoint.json
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "albert/albert-base-v2",
|
3 |
+
"architectures": [
|
4 |
+
"AlbertForSequenceClassification"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0,
|
7 |
+
"bos_token_id": 2,
|
8 |
+
"classifier_dropout_prob": 0.1,
|
9 |
+
"down_scale_factor": 1,
|
10 |
+
"embedding_size": 128,
|
11 |
+
"eos_token_id": 3,
|
12 |
+
"gap_size": 0,
|
13 |
+
"hidden_act": "gelu_new",
|
14 |
+
"hidden_dropout_prob": 0,
|
15 |
+
"hidden_size": 768,
|
16 |
+
"id2label": {
|
17 |
+
"0": "LABEL_0",
|
18 |
+
"1": "LABEL_1",
|
19 |
+
"2": "LABEL_2",
|
20 |
+
"3": "LABEL_3",
|
21 |
+
"4": "LABEL_4",
|
22 |
+
"5": "LABEL_5",
|
23 |
+
"6": "LABEL_6",
|
24 |
+
"7": "LABEL_7",
|
25 |
+
"8": "LABEL_8",
|
26 |
+
"9": "LABEL_9",
|
27 |
+
"10": "LABEL_10",
|
28 |
+
"11": "LABEL_11"
|
29 |
+
},
|
30 |
+
"initializer_range": 0.02,
|
31 |
+
"inner_group_num": 1,
|
32 |
+
"intermediate_size": 3072,
|
33 |
+
"label2id": {
|
34 |
+
"LABEL_0": 0,
|
35 |
+
"LABEL_1": 1,
|
36 |
+
"LABEL_10": 10,
|
37 |
+
"LABEL_11": 11,
|
38 |
+
"LABEL_2": 2,
|
39 |
+
"LABEL_3": 3,
|
40 |
+
"LABEL_4": 4,
|
41 |
+
"LABEL_5": 5,
|
42 |
+
"LABEL_6": 6,
|
43 |
+
"LABEL_7": 7,
|
44 |
+
"LABEL_8": 8,
|
45 |
+
"LABEL_9": 9
|
46 |
+
},
|
47 |
+
"layer_norm_eps": 1e-12,
|
48 |
+
"max_position_embeddings": 512,
|
49 |
+
"model_type": "albert",
|
50 |
+
"net_structure_type": 0,
|
51 |
+
"num_attention_heads": 12,
|
52 |
+
"num_hidden_groups": 1,
|
53 |
+
"num_hidden_layers": 12,
|
54 |
+
"num_memory_blocks": 0,
|
55 |
+
"pad_token_id": 0,
|
56 |
+
"position_embedding_type": "absolute",
|
57 |
+
"problem_type": "single_label_classification",
|
58 |
+
"torch_dtype": "float32",
|
59 |
+
"transformers_version": "4.40.1",
|
60 |
+
"type_vocab_size": 2,
|
61 |
+
"vocab_size": 30000
|
62 |
+
}
|
albert/Untitled.ipynb
ADDED
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 2,
|
6 |
+
"id": "8804bc60-c9e2-4713-9800-1bc2fea11241",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [
|
9 |
+
{
|
10 |
+
"name": "stderr",
|
11 |
+
"output_type": "stream",
|
12 |
+
"text": [
|
13 |
+
"/home/umesh/conda/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
14 |
+
" from .autonotebook import tqdm as notebook_tqdm\n"
|
15 |
+
]
|
16 |
+
}
|
17 |
+
],
|
18 |
+
"source": [
|
19 |
+
"from transformers import pipeline"
|
20 |
+
]
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"cell_type": "code",
|
24 |
+
"execution_count": 3,
|
25 |
+
"id": "322cd68e-9257-4d07-aafc-19e9072f1bba",
|
26 |
+
"metadata": {},
|
27 |
+
"outputs": [],
|
28 |
+
"source": [
|
29 |
+
"from transformers import AutoModelForSequenceClassification, AutoTokenizer\n",
|
30 |
+
"\n",
|
31 |
+
"model = AutoModelForSequenceClassification.from_pretrained('.')\n",
|
32 |
+
"tokenizer = AutoTokenizer.from_pretrained('.')"
|
33 |
+
]
|
34 |
+
},
|
35 |
+
{
|
36 |
+
"cell_type": "code",
|
37 |
+
"execution_count": 4,
|
38 |
+
"id": "fde22c8f-4d57-4544-bc2b-55e4dbbc5fd3",
|
39 |
+
"metadata": {},
|
40 |
+
"outputs": [],
|
41 |
+
"source": [
|
42 |
+
"classifier = pipeline('sentiment-analysis',model = model, tokenizer = tokenizer, top_k =1)\n",
|
43 |
+
"det_classer = pipeline('sentiment-analysis',model = model, tokenizer = tokenizer, top_k =None)"
|
44 |
+
]
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"cell_type": "code",
|
48 |
+
"execution_count": 5,
|
49 |
+
"id": "087c3506-5d27-4dd6-9377-fb34e6926698",
|
50 |
+
"metadata": {},
|
51 |
+
"outputs": [],
|
52 |
+
"source": [
|
53 |
+
"inputs=['This is a rather confusing statement','I do not want to bee seen with you Kusakabe','Rin chan was elegant in dismissing your favours','Damn you! Bonn-kun']"
|
54 |
+
]
|
55 |
+
},
|
56 |
+
{
|
57 |
+
"cell_type": "code",
|
58 |
+
"execution_count": 6,
|
59 |
+
"id": "f5683415-239a-4e68-8f4c-1b9ba8295787",
|
60 |
+
"metadata": {},
|
61 |
+
"outputs": [
|
62 |
+
{
|
63 |
+
"data": {
|
64 |
+
"text/plain": [
|
65 |
+
"[[{'label': 'DISGUST', 'score': 0.2899283468723297}],\n",
|
66 |
+
" [{'label': 'DISGUST', 'score': 0.20709046721458435}],\n",
|
67 |
+
" [{'label': 'OPTIMISM', 'score': 0.1878553181886673}],\n",
|
68 |
+
" [{'label': 'ANGER', 'score': 0.46816307306289673}]]"
|
69 |
+
]
|
70 |
+
},
|
71 |
+
"execution_count": 6,
|
72 |
+
"metadata": {},
|
73 |
+
"output_type": "execute_result"
|
74 |
+
}
|
75 |
+
],
|
76 |
+
"source": [
|
77 |
+
"classifier(inputs)"
|
78 |
+
]
|
79 |
+
},
|
80 |
+
{
|
81 |
+
"cell_type": "code",
|
82 |
+
"execution_count": 7,
|
83 |
+
"id": "9b45cd86-cd63-40b1-81ff-7b510ac94c8d",
|
84 |
+
"metadata": {},
|
85 |
+
"outputs": [],
|
86 |
+
"source": [
|
87 |
+
"statement='Today I did not finish my project and stayed silently away from meetings but my boss found it out and shouted at me in front of a female colleague '"
|
88 |
+
]
|
89 |
+
},
|
90 |
+
{
|
91 |
+
"cell_type": "code",
|
92 |
+
"execution_count": 8,
|
93 |
+
"id": "3ae20452-e327-4550-a40d-f28280aad3c8",
|
94 |
+
"metadata": {},
|
95 |
+
"outputs": [],
|
96 |
+
"source": [
|
97 |
+
"x = det_classer(statement)"
|
98 |
+
]
|
99 |
+
},
|
100 |
+
{
|
101 |
+
"cell_type": "code",
|
102 |
+
"execution_count": 9,
|
103 |
+
"id": "ba091f5c-b98c-49ee-a361-f8937c3693c1",
|
104 |
+
"metadata": {},
|
105 |
+
"outputs": [
|
106 |
+
{
|
107 |
+
"data": {
|
108 |
+
"text/plain": [
|
109 |
+
"'DISGUST'"
|
110 |
+
]
|
111 |
+
},
|
112 |
+
"execution_count": 9,
|
113 |
+
"metadata": {},
|
114 |
+
"output_type": "execute_result"
|
115 |
+
}
|
116 |
+
],
|
117 |
+
"source": [
|
118 |
+
"x[0][0]['label']"
|
119 |
+
]
|
120 |
+
},
|
121 |
+
{
|
122 |
+
"cell_type": "code",
|
123 |
+
"execution_count": 14,
|
124 |
+
"id": "003693e3-1aac-4d67-9c54-f17bcda1af34",
|
125 |
+
"metadata": {},
|
126 |
+
"outputs": [
|
127 |
+
{
|
128 |
+
"name": "stdout",
|
129 |
+
"output_type": "stream",
|
130 |
+
"text": [
|
131 |
+
"{'DISGUST': 0.3289419114589691}\n",
|
132 |
+
"{'ANGER': 0.2868015170097351}\n",
|
133 |
+
"{'SADNESS': 0.12498752772808075}\n",
|
134 |
+
"{'FEAR': 0.09882446378469467}\n",
|
135 |
+
"{'ANTICIPATION': 0.051536574959754944}\n",
|
136 |
+
"{'JOY': 0.03244535252451897}\n",
|
137 |
+
"{'SURPRISE': 0.023728473111987114}\n",
|
138 |
+
"{'PESSIMISM': 0.020501434803009033}\n",
|
139 |
+
"{'OPTIMISM': 0.020457664504647255}\n",
|
140 |
+
"{'COMPLICATED': 0.006496347486972809}\n",
|
141 |
+
"{'TRUST': 0.0026527740992605686}\n",
|
142 |
+
"{'LOVE': 0.0026260693557560444}\n"
|
143 |
+
]
|
144 |
+
}
|
145 |
+
],
|
146 |
+
"source": [
|
147 |
+
"for a in x[0]:\n",
|
148 |
+
" print ({a['label']:a['score']})"
|
149 |
+
]
|
150 |
+
},
|
151 |
+
{
|
152 |
+
"cell_type": "code",
|
153 |
+
"execution_count": 23,
|
154 |
+
"id": "a7361b72-d959-4993-80cf-5c0d65f3e703",
|
155 |
+
"metadata": {},
|
156 |
+
"outputs": [],
|
157 |
+
"source": [
|
158 |
+
"def classify (statement):\n",
|
159 |
+
" preds = det_classer(statement)\n",
|
160 |
+
" return {i['label']:float(i['score']) for i in preds[0]}"
|
161 |
+
]
|
162 |
+
},
|
163 |
+
{
|
164 |
+
"cell_type": "code",
|
165 |
+
"execution_count": 16,
|
166 |
+
"id": "9b6bff6a-3a70-48d8-8b03-1d8327278cad",
|
167 |
+
"metadata": {},
|
168 |
+
"outputs": [],
|
169 |
+
"source": [
|
170 |
+
"import gradio as gr"
|
171 |
+
]
|
172 |
+
},
|
173 |
+
{
|
174 |
+
"cell_type": "code",
|
175 |
+
"execution_count": 21,
|
176 |
+
"id": "d1aa90b3-678f-4ae0-bfa7-6018034c5b3e",
|
177 |
+
"metadata": {},
|
178 |
+
"outputs": [
|
179 |
+
{
|
180 |
+
"name": "stdout",
|
181 |
+
"output_type": "stream",
|
182 |
+
"text": [
|
183 |
+
"Running on local URL: http://127.0.0.1:7862\n",
|
184 |
+
"IMPORTANT: You are using gradio version 4.26.0, however version 4.29.0 is available, please upgrade.\n",
|
185 |
+
"--------\n",
|
186 |
+
"\n",
|
187 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
188 |
+
]
|
189 |
+
},
|
190 |
+
{
|
191 |
+
"data": {
|
192 |
+
"text/html": [
|
193 |
+
"<div><iframe src=\"http://127.0.0.1:7862/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
194 |
+
],
|
195 |
+
"text/plain": [
|
196 |
+
"<IPython.core.display.HTML object>"
|
197 |
+
]
|
198 |
+
},
|
199 |
+
"metadata": {},
|
200 |
+
"output_type": "display_data"
|
201 |
+
},
|
202 |
+
{
|
203 |
+
"data": {
|
204 |
+
"text/plain": []
|
205 |
+
},
|
206 |
+
"execution_count": 21,
|
207 |
+
"metadata": {},
|
208 |
+
"output_type": "execute_result"
|
209 |
+
}
|
210 |
+
],
|
211 |
+
"source": [
|
212 |
+
"demo = gr.Interface(fn=classify, inputs='text',outputs=gr.Label())\n",
|
213 |
+
"demo.launch()"
|
214 |
+
]
|
215 |
+
},
|
216 |
+
{
|
217 |
+
"cell_type": "code",
|
218 |
+
"execution_count": null,
|
219 |
+
"id": "e7852458-9afc-4443-bfc8-ebd16909dc6a",
|
220 |
+
"metadata": {},
|
221 |
+
"outputs": [],
|
222 |
+
"source": []
|
223 |
+
}
|
224 |
+
],
|
225 |
+
"metadata": {
|
226 |
+
"kernelspec": {
|
227 |
+
"display_name": "Python 3 (ipykernel)",
|
228 |
+
"language": "python",
|
229 |
+
"name": "python3"
|
230 |
+
},
|
231 |
+
"language_info": {
|
232 |
+
"codemirror_mode": {
|
233 |
+
"name": "ipython",
|
234 |
+
"version": 3
|
235 |
+
},
|
236 |
+
"file_extension": ".py",
|
237 |
+
"mimetype": "text/x-python",
|
238 |
+
"name": "python",
|
239 |
+
"nbconvert_exporter": "python",
|
240 |
+
"pygments_lexer": "ipython3",
|
241 |
+
"version": "3.10.13"
|
242 |
+
}
|
243 |
+
},
|
244 |
+
"nbformat": 4,
|
245 |
+
"nbformat_minor": 5
|
246 |
+
}
|
albert/config.json
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "albert/albert-base-v2",
|
3 |
+
"architectures": [
|
4 |
+
"AlbertForSequenceClassification"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0,
|
7 |
+
"bos_token_id": 2,
|
8 |
+
"classifier_dropout_prob": 0.1,
|
9 |
+
"down_scale_factor": 1,
|
10 |
+
"embedding_size": 128,
|
11 |
+
"eos_token_id": 3,
|
12 |
+
"gap_size": 0,
|
13 |
+
"hidden_act": "gelu_new",
|
14 |
+
"hidden_dropout_prob": 0,
|
15 |
+
"hidden_size": 768,
|
16 |
+
"id2label": {
|
17 |
+
"0": "ANGER",
|
18 |
+
"1": "ANTICIPATION",
|
19 |
+
"2": "DISGUST",
|
20 |
+
"3": "FEAR",
|
21 |
+
"4": "JOY",
|
22 |
+
"5": "LOVE",
|
23 |
+
"6": "OPTIMISM",
|
24 |
+
"7": "PESSIMISM",
|
25 |
+
"8": "SADNESS",
|
26 |
+
"9": "SURPRISE",
|
27 |
+
"10": "TRUST",
|
28 |
+
"11": "COMPLICATED"
|
29 |
+
},
|
30 |
+
"initializer_range": 0.02,
|
31 |
+
"inner_group_num": 1,
|
32 |
+
"intermediate_size": 3072,
|
33 |
+
"label2id": {
|
34 |
+
"ANGER": 0,
|
35 |
+
"ANTICIPATION": 1,
|
36 |
+
"TRUST": 10,
|
37 |
+
"COMPLICATED": 11,
|
38 |
+
"DISGUST": 2,
|
39 |
+
"FEAR": 3,
|
40 |
+
"JOY": 4,
|
41 |
+
"LOVE": 5,
|
42 |
+
"OPTIMISM": 6,
|
43 |
+
"PESSIMISM": 7,
|
44 |
+
"SADNESS": 8,
|
45 |
+
"SURPRISE": 9
|
46 |
+
},
|
47 |
+
"layer_norm_eps": 1e-12,
|
48 |
+
"max_position_embeddings": 512,
|
49 |
+
"model_type": "albert",
|
50 |
+
"net_structure_type": 0,
|
51 |
+
"num_attention_heads": 12,
|
52 |
+
"num_hidden_groups": 1,
|
53 |
+
"num_hidden_layers": 12,
|
54 |
+
"num_memory_blocks": 0,
|
55 |
+
"pad_token_id": 0,
|
56 |
+
"position_embedding_type": "absolute",
|
57 |
+
"problem_type": "single_label_classification",
|
58 |
+
"torch_dtype": "float32",
|
59 |
+
"transformers_version": "4.40.1",
|
60 |
+
"type_vocab_size": 2,
|
61 |
+
"vocab_size": 30000
|
62 |
+
}
|
albert/model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9e43e075ab873a63c42e79634ea3cdf7e4b83220e5dec7bd740491e0d9ade4de
|
3 |
+
size 46774672
|
albert/special_tokens_map.json
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "[CLS]",
|
3 |
+
"cls_token": "[CLS]",
|
4 |
+
"eos_token": "[SEP]",
|
5 |
+
"mask_token": {
|
6 |
+
"content": "[MASK]",
|
7 |
+
"lstrip": true,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false
|
11 |
+
},
|
12 |
+
"pad_token": "<pad>",
|
13 |
+
"sep_token": "[SEP]",
|
14 |
+
"unk_token": "<unk>"
|
15 |
+
}
|
albert/spiece.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fefb02b667a6c5c2fe27602d28e5fb3428f66ab89c7d6f388e7c8d44a02d0336
|
3 |
+
size 760289
|
albert/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
albert/tokenizer_config.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "[CLS]",
|
3 |
+
"clean_up_tokenization_spaces": true,
|
4 |
+
"cls_token": "[CLS]",
|
5 |
+
"do_lower_case": true,
|
6 |
+
"eos_token": "[SEP]",
|
7 |
+
"keep_accents": false,
|
8 |
+
"mask_token": {
|
9 |
+
"__type": "AddedToken",
|
10 |
+
"content": "[MASK]",
|
11 |
+
"lstrip": true,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"model_max_length": 512,
|
17 |
+
"pad_token": "<pad>",
|
18 |
+
"remove_space": true,
|
19 |
+
"sep_token": "[SEP]",
|
20 |
+
"tokenizer_class": "AlbertTokenizer",
|
21 |
+
"unk_token": "<unk>"
|
22 |
+
}
|
albert/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7953cea3ce73edf986db65195dfbaf85c6bd32338ed9940384c4e150b443847a
|
3 |
+
size 4984
|