Add examples
Browse files
README.md
CHANGED
|
@@ -22,6 +22,24 @@ It achieves the following results on the evaluation set:
|
|
| 22 |
- Train Binary Accuracy: 0.9915
|
| 23 |
- Epoch: 8
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
## Model description
|
| 26 |
|
| 27 |
Classifies if the user is ending the conversation or wanting to continue it.
|
|
|
|
| 22 |
- Train Binary Accuracy: 0.9915
|
| 23 |
- Epoch: 8
|
| 24 |
|
| 25 |
+
## Example Usage
|
| 26 |
+
```py
|
| 27 |
+
from transformers import AutoTokenizer, TFBertForSequenceClassification, BertTokenizer
|
| 28 |
+
import tensorflow as tf
|
| 29 |
+
|
| 30 |
+
model_name = 'Chakshu/conversation_terminator_classifier'
|
| 31 |
+
|
| 32 |
+
tokenizer = BertTokenizer.from_pretrained(model_name)
|
| 33 |
+
model = TFBertForSequenceClassification.from_pretrained(model_name)
|
| 34 |
+
inputs = tokenizer("I will talk to you later", return_tensors="np", padding=True)
|
| 35 |
+
outputs = model(inputs.input_ids, inputs.attention_mask)
|
| 36 |
+
probabilities = tf.nn.sigmoid(outputs.logits)
|
| 37 |
+
|
| 38 |
+
# Round the probabilities to the nearest integer to get the class prediction
|
| 39 |
+
predicted_class = tf.round(probabilities)
|
| 40 |
+
print("The last message by the user indicates that the conversation has", "'ENDED'" if int(predicted_class.numpy()) == 1 else "'NOT ENDED'")
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
## Model description
|
| 44 |
|
| 45 |
Classifies if the user is ending the conversation or wanting to continue it.
|