Update README.md
Browse files
README.md
CHANGED
@@ -122,6 +122,37 @@ Using a fixed threshold of 0.5 to convert the scores to binary predictions for e
|
|
122 |
|
123 |
### Use with ONNXRuntime
|
124 |
|
|
|
|
|
125 |
```python
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
### Use with ONNXRuntime
|
124 |
|
125 |
+
The input to the model is called `logits`, and there is one output per label. Each output produces a 2d array, with 1 row per input row, and each row having 2 columns - the first being a proba output for the negative case, and the second being a proba output for the positive case.
|
126 |
+
|
127 |
```python
|
128 |
+
# Assuming you have embeddings from BAAI/bge-small-en-v1.5 for the input sentences
|
129 |
+
# E.g. produced from sentence-transformers E.g. huggingface.co/BAAI/bge-small-en-v1.5
|
130 |
+
# or from an ONNX version E.g. huggingface.co/Xenova/bge-small-en-v1.5
|
131 |
+
|
132 |
+
print(sentences.shape) # E.g. a batch of 1 sentence
|
133 |
+
> (1, 384)
|
134 |
+
|
135 |
+
import onnxruntime as ort
|
136 |
+
|
137 |
+
sess = ort.InferenceSession(
|
138 |
+
"path_to_model_dot_onnx",
|
139 |
+
providers=['CPUExecutionProvider'],
|
140 |
+
)
|
141 |
+
|
142 |
+
outputs = [o.name for o in sess.get_outputs()]
|
143 |
+
preds_onnx = sess.run(_outputs, {'logits': _label_embeddings})
|
144 |
+
# preds_onnx is a list with 28 entries, each with a numpy array of shape (1, 2)
|
145 |
+
|
146 |
+
print(outputs[0])
|
147 |
+
# surprise
|
148 |
+
print(preds_onnx[0])
|
149 |
+
# array([[0.97136074, 0.02863926]], dtype=float32)
|
150 |
```
|
151 |
+
|
152 |
+
### Commentary on the dataset
|
153 |
+
|
154 |
+
Some labels (E.g. gratitude) when considered independently perform very strongly, whilst others (E.g. relief) perform very poorly.
|
155 |
+
|
156 |
+
This is a challenging dataset. Labels such as relief do have much fewer examples in the training data (less than 100 out of the 40k+, and only 11 in the test split).
|
157 |
+
|
158 |
+
But there is also some ambiguity and/or labelling errors visible in the training data of go_emotions that is suspected to constrain the performance. Data cleaning on the dataset to reduce some of the mistakes, ambiguity, conflicts and duplication in the labelling would produce a higher performing model.
|