Views
No views yet
An updated multilingual version is available: hasancanbiyik/euphemism-detector-multilingual — fine-tuned on 7 languages (EN/TR/ZH/ES/YO/PL/UK) with 0.808 macro-F1 and zero-shot transfer to 22 additional languages.
| Class | Precision | Recall | F1 |
|---|---|---|---|
| Literal | 0.81 | 0.83 | 0.82 |
| Euphemistic | 0.88 | 0.86 | 0.87 |
| Macro avg | 0.84 | 0.84 | 0.84 |
[PET_BOUNDARY] tokens marking the target phrase:1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3import torch.nn.functional as F
4
5tokenizer = AutoTokenizer.from_pretrained("hasancanbiyik/euphemism-detector")
6model = AutoModelForSequenceClassification.from_pretrained("hasancanbiyik/euphemism-detector")
7model.eval()
8
9text = "My grandmother [PET_BOUNDARY]passed away[PET_BOUNDARY] last Tuesday."
10inputs = tokenizer(text, return_tensors="pt", max_length=256, truncation=True)
11
12with torch.no_grad():
13 probs = F.softmax(model(**inputs).logits, dim=1).squeeze()
14
15print(f"Euphemistic: {probs[1].item():.1%}")
16print(f"Literal: {probs[0].item():.1%}")