Update README.md
Browse files
README.md
CHANGED
|
@@ -12,9 +12,39 @@ This model identifies common events and patterns within the conversation flow. S
|
|
| 12 |
|
| 13 |
This model should be used *only* for user dialogs.
|
| 14 |
|
| 15 |
-
|
|
|
|
| 16 |
|
| 17 |
## Installation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
```bash
|
| 19 |
pip install tokenizers
|
| 20 |
pip install onnxruntime
|
|
@@ -43,7 +73,9 @@ tokenizer.enable_padding(
|
|
| 43 |
tokenizer.enable_truncation(max_length=256)
|
| 44 |
batch_size = 16
|
| 45 |
|
| 46 |
-
texts = ["
|
|
|
|
|
|
|
| 47 |
outputs = []
|
| 48 |
model = InferenceSession("MiniLMv2-userflow-v2-onnx/model_optimized_quantized.onnx", providers=['CPUExecutionProvider'])
|
| 49 |
|
|
@@ -100,8 +132,8 @@ for result in results:
|
|
| 100 |
res.append(max_score)
|
| 101 |
|
| 102 |
res
|
| 103 |
-
#[('model_wrong_or_try_again', 0.
|
| 104 |
-
# ('user_wants_agent_to_answer', 0.
|
| 105 |
```
|
| 106 |
|
| 107 |
# Categories Explanation
|
|
|
|
| 12 |
|
| 13 |
This model should be used *only* for user dialogs.
|
| 14 |
|
| 15 |
+
|
| 16 |
+
# Optimum
|
| 17 |
|
| 18 |
## Installation
|
| 19 |
+
|
| 20 |
+
Install from source:
|
| 21 |
+
```bash
|
| 22 |
+
python -m pip install optimum[onnxruntime]@git+https://github.com/huggingface/optimum.git
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
## Run the Model
|
| 27 |
+
```py
|
| 28 |
+
from optimum.onnxruntime import ORTModelForSequenceClassification
|
| 29 |
+
from transformers import AutoTokenizer, pipeline
|
| 30 |
+
|
| 31 |
+
model = ORTModelForSequenceClassification.from_pretrained('Ngit/MiniLMv2-userflow-v2-onnx', provider="CPUExecutionProvider")
|
| 32 |
+
tokenizer = AutoTokenizer.from_pretrained('Ngit/MiniLMv2-userflow-v2-onnx', use_fast=True, model_max_length=256, truncation=True, padding='max_length')
|
| 33 |
+
|
| 34 |
+
pipe = pipeline(task='text-classification', model=model, tokenizer=tokenizer, )
|
| 35 |
+
texts = ["that's wrong", "can you please answer me?"]
|
| 36 |
+
pipe(texts)
|
| 37 |
+
# [{'label': 'model_wrong_or_try_again', 'score': 0.9737648367881775},
|
| 38 |
+
# {'label': 'user_wants_agent_to_answer', 'score': 0.9105103015899658}]
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
# ONNX Runtime only
|
| 43 |
+
|
| 44 |
+
A lighter solution for deployment
|
| 45 |
+
|
| 46 |
+
## Installation
|
| 47 |
+
|
| 48 |
```bash
|
| 49 |
pip install tokenizers
|
| 50 |
pip install onnxruntime
|
|
|
|
| 73 |
tokenizer.enable_truncation(max_length=256)
|
| 74 |
batch_size = 16
|
| 75 |
|
| 76 |
+
texts = ["that's wrong", "can you please answer me?"]
|
| 77 |
+
|
| 78 |
+
|
| 79 |
outputs = []
|
| 80 |
model = InferenceSession("MiniLMv2-userflow-v2-onnx/model_optimized_quantized.onnx", providers=['CPUExecutionProvider'])
|
| 81 |
|
|
|
|
| 132 |
res.append(max_score)
|
| 133 |
|
| 134 |
res
|
| 135 |
+
#[('model_wrong_or_try_again', 0.9737648367881775),
|
| 136 |
+
# ('user_wants_agent_to_answer', 0.9105103015899658)]
|
| 137 |
```
|
| 138 |
|
| 139 |
# Categories Explanation
|