zeroshot commited on
Commit
f3ad8a5
1 Parent(s): 0fd86ae

Upload 6 files

Browse files
Files changed (6) hide show
  1. config.json +34 -0
  2. handler.py +27 -0
  3. model.onnx +3 -0
  4. requirements.txt +1 -0
  5. tokenizer.json +0 -0
  6. tokenizer_config.json +1 -0
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
+ }
handler.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, scheduler="sync")
10
+
11
+ def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:
12
+ """
13
+ Args:
14
+ data (:obj:): prediction input text
15
+ """
16
+ inputs = data.pop("inputs", data)
17
+
18
+ start = perf_counter()
19
+ prediction = self.pipeline(inputs)
20
+ end = perf_counter()
21
+ latency = end - start
22
+
23
+ return {
24
+ "labels": prediction.labels,
25
+ "scores": prediction.scores,
26
+ "latency (secs.)": latency
27
+ }
model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8f814a1a6b4f818e07d1183e2204eedd0fb8c8fdd708326e5d97ce4ee44c3e5
3
+ size 67197076
requirements.txt ADDED
@@ -0,0 +1 @@
 
1
+ deepsparse>=1.2.0
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
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"}