File size: 1,192 Bytes
1465d75
 
 
 
 
 
 
 
 
e55e43b
 
 
 
 
 
8570010
e55e43b
 
 
 
 
 
 
 
 
 
 
 
8570010
e55e43b
 
 
 
 
 
 
 
8570010
e55e43b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
license: apache-2.0
datasets:
- ieuniversity/flirty_or_not
language:
- ko
- en
base_model:
- monologg/koelectra-small-v3-discriminator
---



# Is he flirting?

Fine-tuned model that checks whether someone is flirting with you


## Authors

- [@DoTaeIn](https://www.github.com/DoTaeIn)


## Running Tests

To run tests, run the following command

```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
```

```python
tokenizer = AutoTokenizer.from_pretrained(path)
model = AutoModelForSequenceClassification.from_pretrained(path)


model.eval()
text = "Input Text"

device = next(model.parameters()).device

inputs = tokenizer(
    text,
    return_tensors="pt",
    max_length=128,
    padding="max_length",
    truncation=True,
    return_token_type_ids=False
)
inputs = inputs.to(device)


with torch.no_grad():
  out = model(**inputs)
  logits = out["logits"]
  probs = torch.softmax(logits, dim=-1)
  pred_class = torch.argmax(probs, dim=-1).item()
  prob_class0 = probs[0, 0].item()
  prob_class1 = probs[0, 1].item()

print("pred:", "Flirting" if pred_class else "Not Flirting")
print(f"prob class {pred_class}: {max(prob_class0, prob_class1)}", )```