Genre is determined by BNC-Baby document ID prefix, following the NAACL FLP 2018 shared-task mapping:
Test document filenames are explicitly excluded from the training file list at load time. No test document appears in the training or development split.
Evaluated on the 27-document NAACL FLP test split (4,080 sentences, 57,811 tokens, 6,697 gold metaphor tokens):
POS tags with zero gold metaphors in the test set are omitted.
1{
2 "0": "non_metaphor",
3 "1": "metaphor"
4}
1from transformers import AutoTokenizer, AutoModelForTokenClassification
2import torch
3
4model_path = "tommyleo2077/deberta-v3-large-metaphor" # or local path
5tokenizer = AutoTokenizer.from_pretrained(model_path)
6model = AutoModelForTokenClassification.from_pretrained(model_path)
7model.eval()
8
9words = ["The", "conference", "threw", "a", "spanner", "in", "the", "works", "."]
10inputs = tokenizer(
11 words,
12 is_split_into_words=True,
13 return_tensors="pt",
14 truncation=True,
15 max_length=192,
16)
17word_ids = inputs.word_ids(batch_index=0)
18
19with torch.no_grad():
20 logits = model(**inputs).logits
21preds = logits.argmax(dim=-1)[0].tolist()
22
23word_preds = {}
24for i, wid in enumerate(word_ids):
25 if wid is not None and wid not in word_preds:
26 word_preds[wid] = preds[i]
27
28for i, w in enumerate(words):
29 label = "metaphor" if word_preds.get(i, 0) == 1 else "non_metaphor"
30 print(f"{w}\t{label}")
1@book{steen2010method,
2 title = {A Method for Linguistic Metaphor Identification: From {MIP} to {MIPVU}},
3 author = {Steen, Gerard and Dorst, Aletta G. and Herrmann, J. Berenike and Kaal, Anna and Krennmayr, Tina and Pasma, Thea},
4 year = {2010},
5 publisher = {John Benjamins}
6}
1@inproceedings{leong2018vua,
2 title = {A Report on the 2018 {VUA} Metaphor Detection Shared Task},
3 author = {Leong, Chee Wee and Beigman Klebanov, Beata and Shutova, Ekaterina},
4 booktitle = {Proceedings of the Workshop on Figurative Language Processing at NAACL-HLT 2018},
5 year = {2018}
6}
1@misc{leo2025debertav3largemetaphor,
2 title = {deberta-v3-large-metaphor: Sentence-Level Fine-Tuning for Metaphor Detection},
3 author = {Leo, Tommy},
4 year = {2026},
5 howpublished = {\url{https://huggingface.co/tommyleo2077/deberta-v3-large-metaphor}},
6 note = {Contact: 1683619168tl@gmail.com}
7}