push files
Browse files- deployment/config.json +34 -0
- deployment/model.onnx +3 -0
- deployment/tokenizer.json +0 -0
- deployment/tokenizer_config.json +1 -0
- dev.py +8 -0
- handler.py +24 -0
- requirements.txt +1 -0
deployment/config.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "/home/alexandre/research/distilbert/pruned80_vnni/zoomodels/framework",
|
3 |
+
"activation": "gelu",
|
4 |
+
"architectures": [
|
5 |
+
"DistilBertForSequenceClassification"
|
6 |
+
],
|
7 |
+
"attention_dropout": 0.1,
|
8 |
+
"dim": 768,
|
9 |
+
"dropout": 0.1,
|
10 |
+
"finetuning_task": "sst2",
|
11 |
+
"hidden_dim": 3072,
|
12 |
+
"id2label": {
|
13 |
+
"0": "negative",
|
14 |
+
"1": "positive"
|
15 |
+
},
|
16 |
+
"initializer_range": 0.02,
|
17 |
+
"label2id": {
|
18 |
+
"negative": 0,
|
19 |
+
"positive": 1
|
20 |
+
},
|
21 |
+
"max_position_embeddings": 512,
|
22 |
+
"model_type": "distilbert",
|
23 |
+
"n_heads": 12,
|
24 |
+
"n_layers": 6,
|
25 |
+
"pad_token_id": 0,
|
26 |
+
"problem_type": "single_label_classification",
|
27 |
+
"qa_dropout": 0.1,
|
28 |
+
"seq_classif_dropout": 0.2,
|
29 |
+
"sinusoidal_pos_embds": false,
|
30 |
+
"tie_weights_": true,
|
31 |
+
"torch_dtype": "float32",
|
32 |
+
"transformers_version": "4.18.0.dev0",
|
33 |
+
"vocab_size": 30522
|
34 |
+
}
|
deployment/model.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c8f814a1a6b4f818e07d1183e2204eedd0fb8c8fdd708326e5d97ce4ee44c3e5
|
3 |
+
size 67197076
|
deployment/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
deployment/tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"do_lower_case": true, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "model_max_length": 512, "special_tokens_map_file": null, "name_or_path": "/home/alexandre/research/bert_base/sst2/framework", "tokenizer_class": "BertTokenizer"}
|
dev.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import shutil
|
2 |
+
from sparsezoo import Model
|
3 |
+
|
4 |
+
stub = "zoo:nlp/sentiment_analysis/distilbert-none/pytorch/huggingface/sst2/pruned80_quant-none-vnni"
|
5 |
+
model = Model(stub, download_path=".")
|
6 |
+
|
7 |
+
# Downloads and prints the download path of the model
|
8 |
+
print(model.deployment.path)
|
handler.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Dict, Any
|
2 |
+
from deepsparse import Pipeline
|
3 |
+
from time import perf_counter
|
4 |
+
|
5 |
+
class EndpointHandler:
|
6 |
+
|
7 |
+
def __init__(self, path=""):
|
8 |
+
|
9 |
+
self.pipeline = Pipeline.create(task="text-classification", model_path=path)
|
10 |
+
|
11 |
+
def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:
|
12 |
+
"""
|
13 |
+
Args:
|
14 |
+
data (:obj:):
|
15 |
+
includes the deserialized image file as PIL.Image
|
16 |
+
"""
|
17 |
+
inputs = data.pop("inputs", data)
|
18 |
+
|
19 |
+
start = perf_counter()
|
20 |
+
prediction = self.pipeline(inputs)
|
21 |
+
end = perf_counter()
|
22 |
+
delta = end - start
|
23 |
+
|
24 |
+
return prediction.json(), "latency: " + str(delta) + " secs."
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
deepsparse>=1.2.0
|