Update README.md
Browse files
README.md
CHANGED
@@ -24,9 +24,26 @@ model-index:
|
|
24 |
|
25 |
# Text Classification GoEmotions
|
26 |
|
27 |
-
This a
|
28 |
|
29 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
```py
|
32 |
import os
|
@@ -37,9 +54,8 @@ from tokenizers import Tokenizer
|
|
37 |
from onnxruntime import InferenceSession
|
38 |
|
39 |
|
40 |
-
|
41 |
|
42 |
-
model_name = "Ngit/MiniLMv2-L6-H384-goemotions-v2-onnx"
|
43 |
tokenizer = Tokenizer.from_pretrained(model_name)
|
44 |
tokenizer.enable_padding(
|
45 |
pad_token="<pad>",
|
@@ -50,9 +66,9 @@ batch_size = 16
|
|
50 |
|
51 |
texts = ["I am angry",]
|
52 |
outputs = []
|
53 |
-
model = InferenceSession("MiniLMv2-
|
54 |
|
55 |
-
with open(os.path.join("MiniLMv2-
|
56 |
config = json.load(f)
|
57 |
|
58 |
output_names = [output.name for output in model.get_outputs()]
|
@@ -62,13 +78,13 @@ for subtexts in np.array_split(np.array(texts), len(texts) // batch_size + 1):
|
|
62 |
encodings = tokenizer.encode_batch(list(subtexts))
|
63 |
inputs = {
|
64 |
"input_ids": np.vstack(
|
65 |
-
[encoding.ids for encoding in encodings],
|
66 |
),
|
67 |
"attention_mask": np.vstack(
|
68 |
-
[encoding.attention_mask for encoding in encodings],
|
69 |
),
|
70 |
"token_type_ids": np.vstack(
|
71 |
-
[encoding.type_ids for encoding in encodings],
|
72 |
),
|
73 |
}
|
74 |
|
|
|
24 |
|
25 |
# Text Classification GoEmotions
|
26 |
|
27 |
+
This a ONNX quantized model and is fined-tuned version of [nreimers/MiniLMv2-L6-H384-distilled-from-RoBERTa-Large](https://huggingface.co/nreimers/MiniLMv2-L6-H384-distilled-from-RoBERTa-Large) on the on the [go_emotions](https://huggingface.co/datasets/go_emotions) dataset using [tasinho/text-classification-goemotions](https://huggingface.co/tasinhoque/text-classification-goemotions) as teacher model.
|
28 |
|
29 |
+
# Usage
|
30 |
+
|
31 |
+
## Transformers
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
## No-transformers
|
38 |
+
|
39 |
+
### Installation
|
40 |
+
```bash
|
41 |
+
pip install tokenizers
|
42 |
+
pip install onnxruntime
|
43 |
+
git clone https://huggingface.co/minuva/MiniLMv2-goemotions-v2-onnx
|
44 |
+
```
|
45 |
+
|
46 |
+
### Load the Model
|
47 |
|
48 |
```py
|
49 |
import os
|
|
|
54 |
from onnxruntime import InferenceSession
|
55 |
|
56 |
|
57 |
+
model_name = "minuva/MiniLMv2-goemotions-v2-onnx"
|
58 |
|
|
|
59 |
tokenizer = Tokenizer.from_pretrained(model_name)
|
60 |
tokenizer.enable_padding(
|
61 |
pad_token="<pad>",
|
|
|
66 |
|
67 |
texts = ["I am angry",]
|
68 |
outputs = []
|
69 |
+
model = InferenceSession("MiniLMv2-goemotions-v2-onnx/model_optimized_quantized.onnx", providers=['CUDAExecutionProvider'])
|
70 |
|
71 |
+
with open(os.path.join("MiniLMv2-goemotions-v2-onnx", "config.json"), "r") as f:
|
72 |
config = json.load(f)
|
73 |
|
74 |
output_names = [output.name for output in model.get_outputs()]
|
|
|
78 |
encodings = tokenizer.encode_batch(list(subtexts))
|
79 |
inputs = {
|
80 |
"input_ids": np.vstack(
|
81 |
+
[encoding.ids for encoding in encodings],
|
82 |
),
|
83 |
"attention_mask": np.vstack(
|
84 |
+
[encoding.attention_mask for encoding in encodings],
|
85 |
),
|
86 |
"token_type_ids": np.vstack(
|
87 |
+
[encoding.type_ids for encoding in encodings],
|
88 |
),
|
89 |
}
|
90 |
|