Update README.md
Browse files
README.md
CHANGED
|
@@ -7,4 +7,56 @@ language:
|
|
| 7 |
- en
|
| 8 |
base_model:
|
| 9 |
- monologg/koelectra-small-v3-discriminator
|
| 10 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
- en
|
| 8 |
base_model:
|
| 9 |
- monologg/koelectra-small-v3-discriminator
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# Is he flirting?
|
| 15 |
+
|
| 16 |
+
Fine-tuned model that check rather someone is flirting with you
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
## Authors
|
| 20 |
+
|
| 21 |
+
- [@DoTaeIn](https://www.github.com/DoTaeIn)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
## Running Tests
|
| 25 |
+
|
| 26 |
+
To run tests, run the following command
|
| 27 |
+
|
| 28 |
+
```python
|
| 29 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
tokenizer = AutoTokenizer.from_pretrained(path)
|
| 34 |
+
model = AutoModelForSequenceClassification.from_pretrained(path)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
model.eval()
|
| 38 |
+
text = "Input Text
|
| 39 |
+
|
| 40 |
+
device = next(model.parameters()).device
|
| 41 |
+
|
| 42 |
+
inputs = tokenizer(
|
| 43 |
+
text,
|
| 44 |
+
return_tensors="pt",
|
| 45 |
+
max_length=128,
|
| 46 |
+
padding="max_length",
|
| 47 |
+
truncation=True,
|
| 48 |
+
return_token_type_ids=False
|
| 49 |
+
)
|
| 50 |
+
inputs = inputs.to(device)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
with torch.no_grad():
|
| 54 |
+
out = model(**inputs)
|
| 55 |
+
logits = out["logits"]
|
| 56 |
+
probs = torch.softmax(logits, dim=-1)
|
| 57 |
+
pred_class = torch.argmax(probs, dim=-1).item()
|
| 58 |
+
prob_class0 = probs[0, 0].item()
|
| 59 |
+
prob_class1 = probs[0, 1].item()
|
| 60 |
+
|
| 61 |
+
print("pred:", "Flirting" if pred_class else "Not Flirting")
|
| 62 |
+
print(f"prob class {pred_class}: {max(prob_class0, prob_class1)}", )```
|