animal-metaphor-classifier
Binary sentence classifier: is an animal reference in the sentence used metaphorically
or literally? Fine-tuned from
FacebookAI/roberta-base.
Categories
| Label | Description |
|---|---|
metaphor |
The animal is used figuratively — to characterise a person, action, or situation |
non_metaphor |
The animal is referred to literally, as an actual animal |
Label ids: 0 non_metaphor, 1 metaphor (stored in config.json as id2label).
Usage
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
name = "katrohrb/animal-metaphor-classifier"
tok = AutoTokenizer.from_pretrained(name)
model = AutoModelForSequenceClassification.from_pretrained(name).eval()
sentence = "He is a real snake, you can't trust a word he says."
with torch.no_grad():
probs = model(**tok(sentence, return_tensors="pt")).logits.softmax(-1)[0]
print(model.config.id2label[int(probs.argmax())])
# → metaphor
Or with a pipeline:
from transformers import pipeline
clf = pipeline("text-classification", model="katrohrb/animal-metaphor-classifier")
clf("The dog barked at the mailman every morning.")
# → [{'label': 'non_metaphor', 'score': 0.90}]
Citation
Rohrbacher, K., Wagner, A., Mahlberg, M. (2026). “Letting the Cat out of the Bag”: Towards the Automatic Detection of Animal Metaphors in Literary Texts. Book of Abstracts of the DH 2026, ADHO Annual Conference, South Korea, pp. 685–688. https://doi.org/10.5281/zenodo.21495909
- Downloads last month
- 8
Model tree for katrohrb/animal-metaphor-classifier
Base model
FacebookAI/roberta-base