Upload folder using huggingface_hub
Browse files- config.json +287 -0
- model.onnx +3 -0
- ort_config.json +33 -0
- pipeline.py +103 -0
- special_tokens_map.json +37 -0
- tokenizer.json +0 -0
- tokenizer_config.json +63 -0
- vocab.txt +0 -0
config.json
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_attn_implementation_autoset": true,
|
| 3 |
+
"_name_or_path": "models/bert-onnx-classifier",
|
| 4 |
+
"architectures": [
|
| 5 |
+
"BertForSequenceClassification"
|
| 6 |
+
],
|
| 7 |
+
"attention_probs_dropout_prob": 0.1,
|
| 8 |
+
"classifier_dropout": null,
|
| 9 |
+
"custom_pipelines": {
|
| 10 |
+
"question-classifier": {
|
| 11 |
+
"impl": "pipeline.MultiTaskClassifierPipeline",
|
| 12 |
+
"pt": [
|
| 13 |
+
"AutoModelForSequenceClassification"
|
| 14 |
+
]
|
| 15 |
+
}
|
| 16 |
+
},
|
| 17 |
+
"gradient_checkpointing": false,
|
| 18 |
+
"hidden_act": "gelu",
|
| 19 |
+
"hidden_dropout_prob": 0.1,
|
| 20 |
+
"hidden_size": 1024,
|
| 21 |
+
"id2label": {
|
| 22 |
+
"0": "type_d",
|
| 23 |
+
"1": "type_y",
|
| 24 |
+
"2": "type_c",
|
| 25 |
+
"3": "type_o",
|
| 26 |
+
"4": "category_self",
|
| 27 |
+
"5": "category_health",
|
| 28 |
+
"6": "category_accumulated_wealth",
|
| 29 |
+
"7": "category_family",
|
| 30 |
+
"8": "category_social_media",
|
| 31 |
+
"9": "category_short_travel",
|
| 32 |
+
"10": "category_sports",
|
| 33 |
+
"11": "category_property",
|
| 34 |
+
"12": "category_primary_education",
|
| 35 |
+
"13": "category_love",
|
| 36 |
+
"14": "category_romance",
|
| 37 |
+
"15": "category_children",
|
| 38 |
+
"16": "category_higher_education",
|
| 39 |
+
"17": "category_job",
|
| 40 |
+
"18": "category_diseases",
|
| 41 |
+
"19": "category_hard_times",
|
| 42 |
+
"20": "category_competitive_exam",
|
| 43 |
+
"21": "category_marriage",
|
| 44 |
+
"22": "category_business",
|
| 45 |
+
"23": "category_life_span",
|
| 46 |
+
"24": "category_unearned_wealth",
|
| 47 |
+
"25": "category_spirituality",
|
| 48 |
+
"26": "category_highest_education",
|
| 49 |
+
"27": "category_long_travel",
|
| 50 |
+
"28": "category_career",
|
| 51 |
+
"29": "category_income",
|
| 52 |
+
"30": "category_foreign",
|
| 53 |
+
"31": "category_expense",
|
| 54 |
+
"32": "time_based_y",
|
| 55 |
+
"33": "time_based_n",
|
| 56 |
+
"34": "perception_p",
|
| 57 |
+
"35": "perception_n"
|
| 58 |
+
},
|
| 59 |
+
"initializer_range": 0.02,
|
| 60 |
+
"intermediate_size": 4096,
|
| 61 |
+
"label2id": {
|
| 62 |
+
"category_accumulated_wealth": 6,
|
| 63 |
+
"category_business": 22,
|
| 64 |
+
"category_career": 28,
|
| 65 |
+
"category_children": 15,
|
| 66 |
+
"category_competitive_exam": 20,
|
| 67 |
+
"category_diseases": 18,
|
| 68 |
+
"category_expense": 31,
|
| 69 |
+
"category_family": 7,
|
| 70 |
+
"category_foreign": 30,
|
| 71 |
+
"category_hard_times": 19,
|
| 72 |
+
"category_health": 5,
|
| 73 |
+
"category_higher_education": 16,
|
| 74 |
+
"category_highest_education": 26,
|
| 75 |
+
"category_income": 29,
|
| 76 |
+
"category_job": 17,
|
| 77 |
+
"category_life_span": 23,
|
| 78 |
+
"category_long_travel": 27,
|
| 79 |
+
"category_love": 13,
|
| 80 |
+
"category_marriage": 21,
|
| 81 |
+
"category_primary_education": 12,
|
| 82 |
+
"category_property": 11,
|
| 83 |
+
"category_romance": 14,
|
| 84 |
+
"category_self": 4,
|
| 85 |
+
"category_short_travel": 9,
|
| 86 |
+
"category_social_media": 8,
|
| 87 |
+
"category_spirituality": 25,
|
| 88 |
+
"category_sports": 10,
|
| 89 |
+
"category_unearned_wealth": 24,
|
| 90 |
+
"perception_n": 35,
|
| 91 |
+
"perception_p": 34,
|
| 92 |
+
"time_based_n": 33,
|
| 93 |
+
"time_based_y": 32,
|
| 94 |
+
"type_c": 2,
|
| 95 |
+
"type_d": 0,
|
| 96 |
+
"type_o": 3,
|
| 97 |
+
"type_y": 1
|
| 98 |
+
},
|
| 99 |
+
"label_config": {
|
| 100 |
+
"multi_class": [
|
| 101 |
+
{
|
| 102 |
+
"column": "question type",
|
| 103 |
+
"labels": [
|
| 104 |
+
[
|
| 105 |
+
"d",
|
| 106 |
+
"Descriptive"
|
| 107 |
+
],
|
| 108 |
+
[
|
| 109 |
+
"y",
|
| 110 |
+
"Yes/No"
|
| 111 |
+
],
|
| 112 |
+
[
|
| 113 |
+
"c",
|
| 114 |
+
"Complex"
|
| 115 |
+
],
|
| 116 |
+
[
|
| 117 |
+
"o",
|
| 118 |
+
"Options"
|
| 119 |
+
]
|
| 120 |
+
],
|
| 121 |
+
"loss_weight": 1,
|
| 122 |
+
"name": "type"
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"column": "category",
|
| 126 |
+
"labels": [
|
| 127 |
+
[
|
| 128 |
+
"self",
|
| 129 |
+
"Self"
|
| 130 |
+
],
|
| 131 |
+
[
|
| 132 |
+
"health",
|
| 133 |
+
"Health"
|
| 134 |
+
],
|
| 135 |
+
[
|
| 136 |
+
"accumulated_wealth",
|
| 137 |
+
"Accumulated Wealth"
|
| 138 |
+
],
|
| 139 |
+
[
|
| 140 |
+
"family",
|
| 141 |
+
"Family"
|
| 142 |
+
],
|
| 143 |
+
[
|
| 144 |
+
"social_media",
|
| 145 |
+
"Social media"
|
| 146 |
+
],
|
| 147 |
+
[
|
| 148 |
+
"short_travel",
|
| 149 |
+
"Short Travel"
|
| 150 |
+
],
|
| 151 |
+
[
|
| 152 |
+
"sports",
|
| 153 |
+
"Sports"
|
| 154 |
+
],
|
| 155 |
+
[
|
| 156 |
+
"property",
|
| 157 |
+
"Property"
|
| 158 |
+
],
|
| 159 |
+
[
|
| 160 |
+
"primary_education",
|
| 161 |
+
"Primary Education"
|
| 162 |
+
],
|
| 163 |
+
[
|
| 164 |
+
"love",
|
| 165 |
+
"Love"
|
| 166 |
+
],
|
| 167 |
+
[
|
| 168 |
+
"romance",
|
| 169 |
+
"Romance"
|
| 170 |
+
],
|
| 171 |
+
[
|
| 172 |
+
"children",
|
| 173 |
+
"Children"
|
| 174 |
+
],
|
| 175 |
+
[
|
| 176 |
+
"higher_education",
|
| 177 |
+
"Higher Education"
|
| 178 |
+
],
|
| 179 |
+
[
|
| 180 |
+
"job",
|
| 181 |
+
"Job"
|
| 182 |
+
],
|
| 183 |
+
[
|
| 184 |
+
"diseases",
|
| 185 |
+
"Diseases"
|
| 186 |
+
],
|
| 187 |
+
[
|
| 188 |
+
"hard_times",
|
| 189 |
+
"Hard Times"
|
| 190 |
+
],
|
| 191 |
+
[
|
| 192 |
+
"competitive_exam",
|
| 193 |
+
"Competitive Exam"
|
| 194 |
+
],
|
| 195 |
+
[
|
| 196 |
+
"marriage",
|
| 197 |
+
"Marriage"
|
| 198 |
+
],
|
| 199 |
+
[
|
| 200 |
+
"business",
|
| 201 |
+
"Business"
|
| 202 |
+
],
|
| 203 |
+
[
|
| 204 |
+
"life_span",
|
| 205 |
+
"Life Span"
|
| 206 |
+
],
|
| 207 |
+
[
|
| 208 |
+
"unearned_wealth",
|
| 209 |
+
"Unearned Wealth"
|
| 210 |
+
],
|
| 211 |
+
[
|
| 212 |
+
"spirituality",
|
| 213 |
+
"Spirituality"
|
| 214 |
+
],
|
| 215 |
+
[
|
| 216 |
+
"highest_education",
|
| 217 |
+
"Highest Education"
|
| 218 |
+
],
|
| 219 |
+
[
|
| 220 |
+
"long_travel",
|
| 221 |
+
"Long Travel"
|
| 222 |
+
],
|
| 223 |
+
[
|
| 224 |
+
"career",
|
| 225 |
+
"Career"
|
| 226 |
+
],
|
| 227 |
+
[
|
| 228 |
+
"income",
|
| 229 |
+
"Income"
|
| 230 |
+
],
|
| 231 |
+
[
|
| 232 |
+
"foreign",
|
| 233 |
+
"Foreign"
|
| 234 |
+
],
|
| 235 |
+
[
|
| 236 |
+
"expense",
|
| 237 |
+
"Expense"
|
| 238 |
+
]
|
| 239 |
+
],
|
| 240 |
+
"loss_weight": 1,
|
| 241 |
+
"name": "category"
|
| 242 |
+
},
|
| 243 |
+
{
|
| 244 |
+
"column": "time based",
|
| 245 |
+
"labels": [
|
| 246 |
+
[
|
| 247 |
+
"y",
|
| 248 |
+
"Time Based"
|
| 249 |
+
],
|
| 250 |
+
[
|
| 251 |
+
"n",
|
| 252 |
+
"Non Time Based"
|
| 253 |
+
]
|
| 254 |
+
],
|
| 255 |
+
"loss_weight": 1,
|
| 256 |
+
"name": "time_based"
|
| 257 |
+
},
|
| 258 |
+
{
|
| 259 |
+
"column": "perception",
|
| 260 |
+
"labels": [
|
| 261 |
+
[
|
| 262 |
+
"p",
|
| 263 |
+
"Positive Perception"
|
| 264 |
+
],
|
| 265 |
+
[
|
| 266 |
+
"n",
|
| 267 |
+
"Negative Perception"
|
| 268 |
+
]
|
| 269 |
+
],
|
| 270 |
+
"loss_weight": 1,
|
| 271 |
+
"name": "perception"
|
| 272 |
+
}
|
| 273 |
+
]
|
| 274 |
+
},
|
| 275 |
+
"layer_norm_eps": 1e-12,
|
| 276 |
+
"max_position_embeddings": 512,
|
| 277 |
+
"model_type": "bert",
|
| 278 |
+
"num_attention_heads": 16,
|
| 279 |
+
"num_hidden_layers": 24,
|
| 280 |
+
"pad_token_id": 0,
|
| 281 |
+
"pipeline_tag": "question-classifier",
|
| 282 |
+
"position_embedding_type": "absolute",
|
| 283 |
+
"transformers_version": "4.48.3",
|
| 284 |
+
"type_vocab_size": 2,
|
| 285 |
+
"use_cache": true,
|
| 286 |
+
"vocab_size": 30522
|
| 287 |
+
}
|
model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ae644e537fc6e41fe578fe0a0171f05e6c6daa0d1209ccfa5f7b1496f565795c
|
| 3 |
+
size 337062635
|
ort_config.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"one_external_file": true,
|
| 3 |
+
"opset": null,
|
| 4 |
+
"optimization": {},
|
| 5 |
+
"quantization": {
|
| 6 |
+
"activations_dtype": "QUInt8",
|
| 7 |
+
"activations_symmetric": false,
|
| 8 |
+
"format": "QOperator",
|
| 9 |
+
"is_static": false,
|
| 10 |
+
"mode": "IntegerOps",
|
| 11 |
+
"nodes_to_exclude": [],
|
| 12 |
+
"nodes_to_quantize": [],
|
| 13 |
+
"operators_to_quantize": [
|
| 14 |
+
"Conv",
|
| 15 |
+
"MatMul",
|
| 16 |
+
"Attention",
|
| 17 |
+
"LSTM",
|
| 18 |
+
"Gather",
|
| 19 |
+
"Transpose",
|
| 20 |
+
"EmbedLayerNormalization"
|
| 21 |
+
],
|
| 22 |
+
"per_channel": false,
|
| 23 |
+
"qdq_add_pair_to_weight": false,
|
| 24 |
+
"qdq_dedicated_pair": false,
|
| 25 |
+
"qdq_op_type_per_channel_support_to_axis": {
|
| 26 |
+
"MatMul": 1
|
| 27 |
+
},
|
| 28 |
+
"reduce_range": false,
|
| 29 |
+
"weights_dtype": "QInt8",
|
| 30 |
+
"weights_symmetric": true
|
| 31 |
+
},
|
| 32 |
+
"use_external_data_format": false
|
| 33 |
+
}
|
pipeline.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import numpy as np
|
| 3 |
+
from transformers import AutoModelForSequenceClassification, Pipeline
|
| 4 |
+
from transformers.pipelines import PIPELINE_REGISTRY
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class MultiTaskLabelEncoder:
|
| 8 |
+
def __init__(self, config):
|
| 9 |
+
self.config = config # label_config from model.config
|
| 10 |
+
self.num_tasks = len(config["multi_class"])
|
| 11 |
+
self.label_sets = [task["labels"] for task in config["multi_class"]]
|
| 12 |
+
self.offsets = [0]
|
| 13 |
+
for labels in self.label_sets[:-1]:
|
| 14 |
+
self.offsets.append(self.offsets[-1] + len(labels))
|
| 15 |
+
self.total_labels = sum(len(labels) for labels in self.label_sets)
|
| 16 |
+
|
| 17 |
+
def preds_from_logits(self, logits):
|
| 18 |
+
"""
|
| 19 |
+
Converts model logits into class index predictions for each task.
|
| 20 |
+
Returns shape: (batch_size, num_tasks)
|
| 21 |
+
"""
|
| 22 |
+
preds = []
|
| 23 |
+
offset = 0
|
| 24 |
+
for task in self.config["multi_class"]:
|
| 25 |
+
block_size = len(task['labels'])
|
| 26 |
+
block = logits[:, offset: offset + block_size]
|
| 27 |
+
argmax_indices = np.argmax(block, axis=-1)
|
| 28 |
+
preds.append(argmax_indices)
|
| 29 |
+
offset += block_size
|
| 30 |
+
|
| 31 |
+
preds = np.stack(preds, axis=1) # (batch_size, num_tasks)
|
| 32 |
+
return preds
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class MultiTaskClassifierPipeline(Pipeline):
|
| 36 |
+
def __init__(self, model, tokenizer, device=-1, **kwargs):
|
| 37 |
+
super().__init__(model=model, tokenizer=tokenizer, device=device)
|
| 38 |
+
|
| 39 |
+
if not hasattr(model.config, "label_config"):
|
| 40 |
+
raise ValueError("Your model config must contain 'label_config'.")
|
| 41 |
+
|
| 42 |
+
self.label_config = model.config.label_config
|
| 43 |
+
self.label_encoder = MultiTaskLabelEncoder(self.label_config)
|
| 44 |
+
self.is_onnx = "onnxruntime" in model.__class__.__module__.lower()
|
| 45 |
+
|
| 46 |
+
def _sanitize_parameters(self, **kwargs):
|
| 47 |
+
return {}, {}, {}
|
| 48 |
+
|
| 49 |
+
def preprocess(self, inputs):
|
| 50 |
+
return self.tokenizer(inputs, return_tensors="pt", truncation=True, padding=True)
|
| 51 |
+
|
| 52 |
+
def _forward(self, model_inputs):
|
| 53 |
+
if self.is_onnx:
|
| 54 |
+
# ONNX: send NumPy on CPU
|
| 55 |
+
model_inputs = {k: v.cpu().numpy() for k, v in model_inputs.items()}
|
| 56 |
+
outputs = self.model(**model_inputs)
|
| 57 |
+
logits = outputs.logits if isinstance(outputs, dict) else outputs[0]
|
| 58 |
+
else:
|
| 59 |
+
# PyTorch: send to GPU if available
|
| 60 |
+
model_inputs = {k: v.to(self.model.device) for k, v in model_inputs.items()}
|
| 61 |
+
with torch.no_grad():
|
| 62 |
+
outputs = self.model(**model_inputs)
|
| 63 |
+
logits = outputs.logits
|
| 64 |
+
|
| 65 |
+
return {"logits": logits}
|
| 66 |
+
|
| 67 |
+
def postprocess(self, model_outputs):
|
| 68 |
+
logits = model_outputs["logits"]
|
| 69 |
+
preds = self.label_encoder.preds_from_logits(logits)
|
| 70 |
+
|
| 71 |
+
results = []
|
| 72 |
+
for row in preds:
|
| 73 |
+
result = {
|
| 74 |
+
"type": {},
|
| 75 |
+
"category": {},
|
| 76 |
+
"attributes": []
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
for i, task in enumerate(self.label_config["multi_class"]):
|
| 80 |
+
key, value = task["labels"][row[i]]
|
| 81 |
+
task_name = task["name"]
|
| 82 |
+
|
| 83 |
+
if task_name in ["type", "category"]:
|
| 84 |
+
result[task_name] = {"key": key, "value": value}
|
| 85 |
+
elif task_name in ["time_based", "perception"] and key in ["y", "p"]:
|
| 86 |
+
result["attributes"].append(value)
|
| 87 |
+
|
| 88 |
+
results.append(result)
|
| 89 |
+
|
| 90 |
+
return results
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def register_classifier_pipeline():
|
| 94 |
+
"""
|
| 95 |
+
Register the custom pipeline with Hugging Face's pipeline registry.
|
| 96 |
+
"""
|
| 97 |
+
# Register the custom pipeline
|
| 98 |
+
PIPELINE_REGISTRY.register_pipeline(
|
| 99 |
+
task="question-classifier",
|
| 100 |
+
pipeline_class=MultiTaskClassifierPipeline,
|
| 101 |
+
pt_model=AutoModelForSequenceClassification,
|
| 102 |
+
type="text",
|
| 103 |
+
)
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cls_token": {
|
| 3 |
+
"content": "[CLS]",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"mask_token": {
|
| 10 |
+
"content": "[MASK]",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "[PAD]",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
+
"sep_token": {
|
| 24 |
+
"content": "[SEP]",
|
| 25 |
+
"lstrip": false,
|
| 26 |
+
"normalized": false,
|
| 27 |
+
"rstrip": false,
|
| 28 |
+
"single_word": false
|
| 29 |
+
},
|
| 30 |
+
"unk_token": {
|
| 31 |
+
"content": "[UNK]",
|
| 32 |
+
"lstrip": false,
|
| 33 |
+
"normalized": false,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false
|
| 36 |
+
}
|
| 37 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": false,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_lower_case": true,
|
| 47 |
+
"extra_special_tokens": {},
|
| 48 |
+
"mask_token": "[MASK]",
|
| 49 |
+
"max_length": 512,
|
| 50 |
+
"model_max_length": 512,
|
| 51 |
+
"pad_to_multiple_of": null,
|
| 52 |
+
"pad_token": "[PAD]",
|
| 53 |
+
"pad_token_type_id": 0,
|
| 54 |
+
"padding_side": "right",
|
| 55 |
+
"sep_token": "[SEP]",
|
| 56 |
+
"stride": 0,
|
| 57 |
+
"strip_accents": null,
|
| 58 |
+
"tokenize_chinese_chars": true,
|
| 59 |
+
"tokenizer_class": "BertTokenizer",
|
| 60 |
+
"truncation_side": "right",
|
| 61 |
+
"truncation_strategy": "longest_first",
|
| 62 |
+
"unk_token": "[UNK]"
|
| 63 |
+
}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|